Commit de637cf7 by 崔彦峰

fix(goods): 修复商品上架服务中的验证逻辑

- 添加了对merchantInfo中serviceProviderId和parentMerchantId的空值检查
- 优化了太阳膜商品部位验证逻辑,移除了不必要的upgradeGoodsDTO参数验证
- 新增了validatePartner2MerchantInfoWhenSelected方法来验证服务商2的商户信息
- 实现了hasPartner2SettleTarget方法来检测是否存在服务商2分账目标
- 简化了isValidSolarFilmPosition方法,移除了复杂的部位匹配逻辑只保留基础枚举验证
1 parent bbe01152
...@@ -353,7 +353,9 @@ public class GoodsListingSubmitService { ...@@ -353,7 +353,9 @@ public class GoodsListingSubmitService {
|| merchantInfo.getSigningEntityId() == null || merchantInfo.getSigningEntityId() == null
|| StringUtils.isBlank(merchantInfo.getAccountTypes()) || StringUtils.isBlank(merchantInfo.getAccountTypes())
|| merchantInfo.getTrafficPartyId() == null || merchantInfo.getTrafficPartyId() == null
|| merchantInfo.getParkingStoreId() == null) { || merchantInfo.getParkingStoreId() == null
|| merchantInfo.getServiceProviderId() == null
|| merchantInfo.getParentMerchantId() == null) {
return false; return false;
} }
return true; return true;
...@@ -698,9 +700,7 @@ public class GoodsListingSubmitService { ...@@ -698,9 +700,7 @@ public class GoodsListingSubmitService {
if (solarFilmGoods && StringUtils.isBlank(row.getPosition())) { if (solarFilmGoods && StringUtils.isBlank(row.getPosition())) {
setLineError(errorList, "太阳膜商品部位不能为空", i); setLineError(errorList, "太阳膜商品部位不能为空", i);
} }
if (solarFilmGoods else if (solarFilmGoods && !isValidSolarFilmPosition(row.getPosition())) {
&& StringUtils.isNotBlank(upgradeGoodsDTO.getPosition())
&& !isValidSolarFilmPosition(upgradeGoodsDTO, row.getPosition())) {
setLineError(errorList, "上架部位不合法", i); setLineError(errorList, "上架部位不合法", i);
} }
if (parseAmountWithRange(row.getUpgradeProductCost(), BigDecimal.ZERO, CommonConstants.DECIMAL_VALUE_ALMOST_MILLION) == null) { if (parseAmountWithRange(row.getUpgradeProductCost(), BigDecimal.ZERO, CommonConstants.DECIMAL_VALUE_ALMOST_MILLION) == null) {
...@@ -1107,6 +1107,7 @@ public class GoodsListingSubmitService { ...@@ -1107,6 +1107,7 @@ public class GoodsListingSubmitService {
validateRuleMergeRanges(submitDTO.getGlobalContext(), submitDTO.getGlobalContext().getErrorList(), (byte) 1); validateRuleMergeRanges(submitDTO.getGlobalContext(), submitDTO.getGlobalContext().getErrorList(), (byte) 1);
validateSettleRuleFields(submitDTO, list); validateSettleRuleFields(submitDTO, list);
validatePartner2MerchantInfoWhenSelected(submitDTO, list);
if (hasError(submitDTO.getGlobalContext().getErrorList())) { if (hasError(submitDTO.getGlobalContext().getErrorList())) {
return null; return null;
} }
...@@ -1208,6 +1209,62 @@ public class GoodsListingSubmitService { ...@@ -1208,6 +1209,62 @@ public class GoodsListingSubmitService {
} }
} }
private void validatePartner2MerchantInfoWhenSelected(GoodsListingSubmitDTO submitDTO,
List<CreateBusinessApproveAllImportVo> list) {
if (CollectionUtils.isEmpty(list) || !hasPartner2SettleTarget(submitDTO, list)) {
return;
}
Map<Integer, CreateBusinessApproveMerchantDTO> merchantRowIndexMap = buildMerchantRowIndexMap(submitDTO, list);
if (MapUtil.isEmpty(merchantRowIndexMap)) {
return;
}
List<StringBuilder> errorList = submitDTO.getGlobalContext().getErrorList();
for (Map.Entry<Integer, CreateBusinessApproveMerchantDTO> entry : merchantRowIndexMap.entrySet()) {
CreateBusinessApproveMerchantDTO merchant = entry.getValue();
if (merchant == null || merchant.getMerchantId() == null) {
continue;
}
// Excel选择服务商2作为分配对象时,必须依赖商户详情返回服务商2信息,错误要落到具体门店行。
if (merchant.getPartnerMerchantId2() == null || StringUtils.isBlank(merchant.getPartnerMerchantName2())) {
setLineError(errorList, "门店未配置服务商2,无法选择服务商2作为分账对象", entry.getKey());
}
}
}
private boolean hasPartner2SettleTarget(GoodsListingSubmitDTO submitDTO,
List<CreateBusinessApproveAllImportVo> list) {
Map<Integer, Integer> baseLeaderIndexMap = buildBaseLeaderIndexMap(list,
submitDTO.getGlobalContext() == null ? null : submitDTO.getGlobalContext().getPackageGoodsIndexList());
for (int i = 0; i < list.size(); i++) {
CreateBusinessApproveAllImportVo row = list.get(i);
if (!hasGoodsData(row, submitDTO.getBaseSceneCode())) {
continue;
}
if (i != 0 && !hasAnySettleRuleField(row)) {
continue;
}
if (isPartner2Target(resolveFirstLineMergedText(list, i, CreateBusinessApproveAllImportVo::getShopMerchantDivideTarget))
|| isPartner2Target(resolveFirstLineMergedText(list, i, CreateBusinessApproveAllImportVo::getPartnerMerchantDivideTarget))
|| isPartner2Target(resolveFirstLineMergedText(list, i, CreateBusinessApproveAllImportVo::getPartnerMerchant2DivideTarget))
|| isPartner2Target(resolveFirstLineMergedText(list, i, CreateBusinessApproveAllImportVo::getOtherFeeTarget))) {
return true;
}
if (isSceneEquity(submitDTO.getBaseSceneCode())) {
String thirdPartyCostTarget = resolveBaseMergedText(list, i, baseLeaderIndexMap, CreateBusinessApproveAllImportVo::getThirdPartyCostTarget);
if (isPartner2Target(thirdPartyCostTarget)) {
return true;
}
} else if (isSceneBoutique(submitDTO.getBaseSceneCode())) {
String upgradeProductCostTarget = resolveBaseMergedText(list, i, baseLeaderIndexMap, CreateBusinessApproveAllImportVo::getUpgradeProductCostTarget);
String recoveryCostTarget = resolveBaseMergedText(list, i, baseLeaderIndexMap, CreateBusinessApproveAllImportVo::getRecoveryCostTarget);
if (isPartner2Target(upgradeProductCostTarget) || isPartner2Target(recoveryCostTarget)) {
return true;
}
}
}
return false;
}
private void validateRuleMergeRanges(CreateBusinessApproveImportExcelContext globalContext, private void validateRuleMergeRanges(CreateBusinessApproveImportExcelContext globalContext,
List<StringBuilder> errorList, List<StringBuilder> errorList,
Byte ruleType) { Byte ruleType) {
...@@ -2615,20 +2672,11 @@ public class GoodsListingSubmitService { ...@@ -2615,20 +2672,11 @@ public class GoodsListingSubmitService {
return solarFilmGoodsTypeList.contains(goodsType); return solarFilmGoodsTypeList.contains(goodsType);
} }
private boolean isValidSolarFilmPosition(UpgradeGoodsDTO upgradeGoodsDTO, String positionText) { private boolean isValidSolarFilmPosition(String positionText) {
if (StringUtils.isBlank(positionText) || upgradeGoodsDTO == null || StringUtils.isBlank(upgradeGoodsDTO.getPosition())) {
return false;
}
PositionEnum positionEnum = PositionEnum.getByName(positionText); PositionEnum positionEnum = PositionEnum.getByName(positionText);
if (positionEnum == null) { if (positionEnum == null) {
return false; return false;
} }
/*String[] supportedPositions = upgradeGoodsDTO.getPosition().split(",");
for (String supportedPosition : supportedPositions) {
if (StringUtils.equals(String.valueOf(positionEnum.getValue()), supportedPosition)) {
return true;
}
}*/
return true; return true;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!