Commit f17b2003 by zhoulm

fix: 修复商品列表查询和验证逻辑

在GoodsListingProductBaseMapper.xml中添加id查询条件
修改GoodsListingProductDetailService中的比较逻辑,使用merchantGoodsCode替代upgradeCommodityCode
注释掉GoodsListingApprovalService中不必要的下架操作
重构GoodsListingProductBaseService中的验证逻辑,将验证移到循环内部并移除重复检查
1 parent 77865ca6
......@@ -350,7 +350,7 @@ public class GoodsListingApprovalService {
publishApprovedSettleRules(context);
publishApprovedReconciliationRules(context);
updateMerchantRuleIds(context);
goodsListingRemote.offShelfSomeMerchantPackage(businessCode);
//goodsListingRemote.offShelfSomeMerchantPackage(businessCode);
if(CollectionUtils.isNotEmpty(context.details)){
taskExecutor.execute(() -> {
context.details.forEach(item ->{
......
......@@ -201,11 +201,20 @@ public class GoodsListingProductBaseService {
List<Integer> equityTypeIdList = CommonUtil.convert2Integer(OrePropertyConfigurer.getString("smartcarlife.goodsType.equity", "126").split(","));
//延保类、权益类
extendedInsuranceTypeIdList.addAll(equityTypeIdList);
Set<String> upgradeGoodsKeyStrSet = new HashSet<>();
productBaseList.forEach(record ->{
Set<String> upgradeGoodsKeySet = new HashSet<>();
record.getDetailList().forEach(o->{
RpcAssert.assertNotNull(o.getUpgradeGoodsId(), DefaultErrorEnum.DATA_NULL, "升级商品ID is null");
RpcAssert.assertNotNull(o.getSellPrice(), DefaultErrorEnum.DATA_NULL, "销售价格 is null");
RpcAssert.assertIsTrue(o.getSellPrice().compareTo(BigDecimal.ZERO) > 0, DefaultErrorEnum.SERVER_ERROR,"售价需大于0");
RpcAssert.assertNotNull(o.getMinSellPrice(), DefaultErrorEnum.DATA_NULL, "最低销售价格 is null");
RpcAssert.assertIsTrue(o.getSellPrice().compareTo(o.getMinSellPrice()) >= 0, DefaultErrorEnum.SERVER_ERROR,"最低售价不得大于售价");
RpcAssert.assertNotNull(o.getInventoryType(), DefaultErrorEnum.DATA_NULL, "库存模式 is null");
if(isScene0) {
RpcAssert.assertNotNull(o.getThirdPartyCost(), DefaultErrorEnum.DATA_NULL, "第三方成本 is null");
}else {
RpcAssert.assertNotNull(o.getUpgradeProductCost(), DefaultErrorEnum.DATA_NULL, "升级成本 is null");
}
UpgradeGoodsDTO upgradeGoods = goodsListingProductDetailService.getUpgradeGoodsByUpgradeGoodsId(o.getUpgradeGoodsId());
RpcAssert.assertNotNull(upgradeGoods, DefaultErrorEnum.SERVER_ERROR, "升级商品不存在");
if(isScene0) {
......@@ -235,11 +244,6 @@ public class GoodsListingProductBaseService {
}
o.setUpgradeGoods(upgradeGoods);
});
if(Objects.equals(record.getProductType(), ProductTypeEnum.PACKAGE.getValue())) {
String upgradeGoodsIdStr = StringUtils.join(upgradeGoodsKeySet,",");
RpcAssert.assertIsTrue(!upgradeGoodsKeyStrSet.contains(upgradeGoodsIdStr), DefaultErrorEnum.SERVER_ERROR,"存在重复套餐");
upgradeGoodsKeyStrSet.add(upgradeGoodsIdStr);
}
});
} catch (RpcServiceException rpcServiceException) {
throw rpcServiceException;
......@@ -279,16 +283,6 @@ public class GoodsListingProductBaseService {
validProductDetailAndSetUpgradeGoods(goodsListingApproval, Arrays.asList(record));
record.getDetailList().forEach(o->{
o.setGoodsAlias(StringUtils.isNotBlank(o.getGoodsAlias()) ? o.getGoodsAlias():null);
RpcAssert.assertNotNull(o.getUpgradeGoodsId(), DefaultErrorEnum.DATA_NULL, "升级商品ID is null");
RpcAssert.assertNotNull(o.getSellPrice(), DefaultErrorEnum.DATA_NULL, "销售价格 is null");
RpcAssert.assertNotNull(o.getMinSellPrice(), DefaultErrorEnum.DATA_NULL, "最低销售价格 is null");
RpcAssert.assertIsTrue(o.getSellPrice().compareTo(o.getMinSellPrice()) >= 0, DefaultErrorEnum.SERVER_ERROR,"最低售价不得大于售价");
RpcAssert.assertNotNull(o.getInventoryType(), DefaultErrorEnum.DATA_NULL, "库存模式 is null");
if(isScene0) {
RpcAssert.assertNotNull(o.getThirdPartyCost(), DefaultErrorEnum.DATA_NULL, "第三方成本 is null");
}else {
RpcAssert.assertNotNull(o.getUpgradeProductCost(), DefaultErrorEnum.DATA_NULL, "升级成本 is null");
}
UpgradeGoodsDTO upgradeGoods = o.getUpgradeGoods();
o.setBusinessCode(record.getBusinessCode());
o.setUpgradeCommodityCode(upgradeGoods.getCommodityCode());
......
......@@ -139,7 +139,7 @@ public class GoodsListingProductDetailService {
new CompareResultHandler<GoodsListingProductDetailDTO>() {
@Override
public boolean equals(GoodsListingProductDetailDTO v,GoodsListingProductDetailDTO item) {
return Objects.equals(v.getUpgradeCommodityCode(), item.getUpgradeCommodityCode());
return Objects.equals(v.getMerchantGoodsCode(), item.getMerchantGoodsCode());
}
@Override
......
......@@ -110,6 +110,9 @@
and if(glpb.package_alias is not null and glpb.package_alias!='',glpb.package_alias,glpb.product_name)
like CONCAT('%', #{productName},'%')
</if>
<if test="id != null">
and glpb.id = #{id}
</if>
</where>
</sql>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!