Commit 60680a34 by 崔彦峰

feat(goods): 添加商品上架模型判断逻辑

- 在商品上架审批服务中增加特殊货架和普通货架单店类型的条件判断
- 仅在特殊货架或普通货架单店模式下执行利润率计算完成校验
- 保留原有的利润率缺失检查和异常抛出机制
- 确保不同货架模式下的业务逻辑正确执行
1 parent 3412b478
...@@ -385,23 +385,27 @@ public class GoodsListingApprovalService { ...@@ -385,23 +385,27 @@ public class GoodsListingApprovalService {
if (CollectionUtils.isEmpty(products)) { if (CollectionUtils.isEmpty(products)) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "产品信息为空,businessCode:" + record.getBusinessCode()); throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "产品信息为空,businessCode:" + record.getBusinessCode());
} }
boolean hasNotFinish = products.stream().anyMatch(o -> !Objects.equals(o.getProfitRateCalFinish() ,StatusEnum.YES.getValue())); if (Objects.equals(record.getShelfModel(), ShelfModelEnum.SPECIAL_SHELF.getValue())
if (hasNotFinish) { || (Objects.equals(record.getShelfModel(), ShelfModelEnum.ORDINARY_SHELF.getValue()) && Objects.equals(record.getShelfType(), ShelfTypeEnum.SINGLE_STORE.getValue()))) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "利润率未计算完成"); boolean hasNotFinish = products.stream().anyMatch(o -> !Objects.equals(o.getProfitRateCalFinish() ,StatusEnum.YES.getValue()));
} if (hasNotFinish) {
List<String> nonProfitProducts = products.stream().filter(o -> o.getProfitRate() == null) throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "利润率未计算完成");
.map(o -> { }
if (Objects.equals(o.getProductType(), ProductTypeEnum.PACKAGE.getValue())) { List<String> nonProfitProducts = products.stream().filter(o -> o.getProfitRate() == null)
return "套餐:" + (StringUtils.isNoneBlank(o.getPackageAlias()) ? o.getPackageAlias() :o.getProductName()); .map(o -> {
} else if (Objects.equals(o.getProductType(), ProductTypeEnum.GOODS.getValue())) { if (Objects.equals(o.getProductType(), ProductTypeEnum.PACKAGE.getValue())) {
return "商品:" + o.getProductName(); return "套餐:" + (StringUtils.isNoneBlank(o.getPackageAlias()) ? o.getPackageAlias() :o.getProductName());
} } else if (Objects.equals(o.getProductType(), ProductTypeEnum.GOODS.getValue())) {
return null; return "商品:" + o.getProductName();
}).collect(Collectors.toList()); }
if (CollectionUtils.isNotEmpty(nonProfitProducts)) { return null;
log.warn("存在产品缺少利润率:{}",String.join(",",nonProfitProducts)); }).collect(Collectors.toList());
throw new RpcServiceException(RpcErrorEnum.DATA_INVALID_WITH_SPECIFIC_MSG, "利润率缺失,请检查后重新操作"); if (CollectionUtils.isNotEmpty(nonProfitProducts)) {
log.warn("存在产品缺少利润率:{}",String.join(",",nonProfitProducts));
throw new RpcServiceException(RpcErrorEnum.DATA_INVALID_WITH_SPECIFIC_MSG, "利润率缺失,请检查后重新操作");
}
} }
final Date now = new Date(); final Date now = new Date();
if (Objects.equals(record.getShelfModel(), ShelfModelEnum.SPECIAL_SHELF.getValue())) { if (Objects.equals(record.getShelfModel(), ShelfModelEnum.SPECIAL_SHELF.getValue())) {
goodsListingApprovalMapper.updateByPrimaryKeySelective(GoodsListingApproval.builder() goodsListingApprovalMapper.updateByPrimaryKeySelective(GoodsListingApproval.builder()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!