Commit c6899e13 by chenxi

优加门店上架导入改动提交,导入门店商家表格后成功和失败行数错误问题修复

1 parent b39333e4
...@@ -267,6 +267,10 @@ public class StoreImportServiceImpl implements StoreImportService { ...@@ -267,6 +267,10 @@ public class StoreImportServiceImpl implements StoreImportService {
/** /**
* 追加 D+ 侧校验失败原因(V1 商户、V2 场景覆盖)。 * 追加 D+ 侧校验失败原因(V1 商户、V2 场景覆盖)。
*
* <p>V1 / V2 是「文件级」错误(针对商户 / 场景,不是某一行数据的问题),失败原因挂在
* 首行数据行上展示;同时把该行从通过行中扣除,保证
* {@code totalRows = passRows + failRows},不会出现同一行既算通过又算失败。</p>
*/ */
private void appendRemoteFailures(StoreImportCheckResult result, StoreImportExcelListener listener) { private void appendRemoteFailures(StoreImportCheckResult result, StoreImportExcelListener listener) {
// 场景集合(仅取解析成功的场景编码) // 场景集合(仅取解析成功的场景编码)
...@@ -286,11 +290,13 @@ public class StoreImportServiceImpl implements StoreImportService { ...@@ -286,11 +290,13 @@ public class StoreImportServiceImpl implements StoreImportService {
String merchantError = storeImportRemoteValidator.checkMerchant(result.getMerchantNo(), result.getStoreName()); String merchantError = storeImportRemoteValidator.checkMerchant(result.getMerchantNo(), result.getStoreName());
if (merchantError != null) { if (merchantError != null) {
result.addFailure(result.getFirstDataRowIndex(), merchantError); result.addFailure(result.getFirstDataRowIndex(), merchantError);
result.failPassedRow(result.getFirstDataRowIndex());
return; return;
} }
String sceneError = storeImportRemoteValidator.checkSceneCoverage(result.getMerchantNo(), sceneCodes); String sceneError = storeImportRemoteValidator.checkSceneCoverage(result.getMerchantNo(), sceneCodes);
if (sceneError != null) { if (sceneError != null) {
result.addFailure(result.getFirstDataRowIndex(), sceneError); result.addFailure(result.getFirstDataRowIndex(), sceneError);
result.failPassedRow(result.getFirstDataRowIndex());
} }
} }
......
...@@ -38,6 +38,9 @@ public class StoreImportCheckResult { ...@@ -38,6 +38,9 @@ public class StoreImportCheckResult {
/** 通过行(已完成系统转译,可直接落库) */ /** 通过行(已完成系统转译,可直接落库) */
private final List<StoreImportRowDTO> passRows_ = new ArrayList<>(); private final List<StoreImportRowDTO> passRows_ = new ArrayList<>();
/** 通过行的物理行号(与 {@link #passRows_} 一一对应,远程校验失败扣行用) */
private final List<Integer> passRowIndexes = new ArrayList<>();
/** 去重后的产品分类数(按分类 id / 名称) */ /** 去重后的产品分类数(按分类 id / 名称) */
private int distinctProductCategoryCount; private int distinctProductCategoryCount;
...@@ -73,4 +76,26 @@ public class StoreImportCheckResult { ...@@ -73,4 +76,26 @@ public class StoreImportCheckResult {
public int getFailRows() { public int getFailRows() {
return reasonByRow.size(); return reasonByRow.size();
} }
/**
* 远程校验失败时,把指定行从「通过行」中扣除(该行已计入失败行)。
*
* <p>否则同一行会同时出现在 passRows 与 failRows 里,出现
* 「1 行数据 → passRows=1、failRows=1」的重复计数。</p>
*
* @param rowIndex 物理行号
* @return 被移除的通过行;该行本就不在通过行里(如本地校验已失败)返回 null
*/
public StoreImportRowDTO failPassedRow(Integer rowIndex) {
if (rowIndex == null) {
return null;
}
int idx = passRowIndexes.indexOf(rowIndex);
if (idx < 0) {
return null;
}
passRowIndexes.remove(idx);
passRows = Math.max(0, passRows - 1);
return passRows_.remove(idx);
}
} }
...@@ -178,6 +178,7 @@ public class StoreImportValidator { ...@@ -178,6 +178,7 @@ public class StoreImportValidator {
if (l3.isEmpty() && l4.isEmpty()) { if (l3.isEmpty() && l4.isEmpty()) {
passRows++; passRows++;
result.getPassRowIndexes().add(rowIndex);
result.getPassRows_().add(toRowDTO(row, scene, sceneLabel, categoryId, categoryLevel, result.getPassRows_().add(toRowDTO(row, scene, sceneLabel, categoryId, categoryLevel,
marketFee1, marketFee2, sunshine1, sunshine2, point1, point2)); marketFee1, marketFee2, sunshine1, sunshine2, point1, point2));
} else { } else {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!