|
|
@ -320,6 +320,7 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im |
|
|
|
newOrderItemList.add(orderItem); |
|
|
|
} |
|
|
|
|
|
|
|
this.handleCategoryRule(categoryRule,newOrderItemList); |
|
|
|
|
|
|
|
this.updateById(order); |
|
|
|
//移除已有的ITEM
|
|
|
@ -334,6 +335,52 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 拦截规则 |
|
|
|
* @param categoryRule |
|
|
|
* @param orderItems |
|
|
|
*/ |
|
|
|
private void handleCategoryRule(GoodsCategoryRule categoryRule, List<OmsOrderItem> orderItems) { |
|
|
|
if(categoryRule!=null){ |
|
|
|
List<String> cids = Arrays.asList(categoryRule.getBrandIds()); |
|
|
|
List<String> igcids = null; |
|
|
|
if(categoryRule.getIgnoreBrandIds()!=null){ |
|
|
|
igcids = Arrays.asList(categoryRule.getIgnoreBrandIds()); |
|
|
|
} |
|
|
|
Set<Long> spuIds = orderItems.stream().map(OmsOrderItem::getSpuId).collect(Collectors.toSet()); |
|
|
|
List<Long> skuIds = orderItems.stream().map(OmsOrderItem::getSkuId).collect(Collectors.toList()); |
|
|
|
if(CollectionUtil.isNotEmpty(skuIds)){ |
|
|
|
List<GoodsSpu> spuTmpList = goodsSpuService.listByIds(skuIds); |
|
|
|
spuIds.addAll(spuTmpList.stream().map(GoodsSpu::getId).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
|
|
|
|
List<GoodsSpu> spuList = goodsSpuService.listByIds(spuIds); |
|
|
|
for (GoodsSpu goodsSpu : spuList) { |
|
|
|
matchIgnoreCate(igcids,goodsSpu.getCategoryFirst(),goodsSpu); |
|
|
|
matchIgnoreCate(igcids,goodsSpu.getCategorySecond(),goodsSpu); |
|
|
|
matchIgnoreCate(igcids,goodsSpu.getCategoryThird(),goodsSpu); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 拦截忽略的品牌 |
|
|
|
* @param igcids |
|
|
|
* @param spuCateId |
|
|
|
* @param goodsSpu |
|
|
|
*/ |
|
|
|
private void matchIgnoreCate(List<String> igcids, String spuCateId,GoodsSpu goodsSpu) { |
|
|
|
if(igcids==null || spuCateId ==null|| spuCateId.equals("")|| spuCateId.equals("0")){ |
|
|
|
return; |
|
|
|
} |
|
|
|
for (String igcid : igcids) { |
|
|
|
if(spuCateId.equals(igcid)){ |
|
|
|
Assert.throwEx("["+goodsSpu.getSkuCode()+"]"+goodsSpu.getName()+",不符合订单规则"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public OmsOrder createOrder(OmsOrderBo omsOrderBo) { |
|
|
@ -486,7 +533,7 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.handleCategoryRule(categoryRule,orderItems); |
|
|
|
|
|
|
|
omsOrderItemService.saveBatch(orderItems); |
|
|
|
//清空勾选的购物车
|
|
|
@ -557,12 +604,22 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im |
|
|
|
Assert.throwEx("空项目不支持下单"); |
|
|
|
} |
|
|
|
|
|
|
|
//拦截相同的skuItem
|
|
|
|
long countDistinct = orderItemList.stream().map(OmsOrderItem::getSkuId).distinct().count(); |
|
|
|
if(orderItemList.size()!=countDistinct){ |
|
|
|
Assert.throwEx("有重复存货,请检查订单项"); |
|
|
|
} |
|
|
|
|
|
|
|
for (OmsOrderItem orderItem : orderItemList) { |
|
|
|
if(orderItem.getQuantity()==null||orderItem.getQuantity()<1){ |
|
|
|
Assert.throwEx("确认订单商品项数量不能为零"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//下单前规则拦截
|
|
|
|
GoodsCategoryRule categoryRule = goodsCategoryRuleMapper.selectById(omsOrder.getBrandRuleId()); |
|
|
|
this.handleCategoryRule(categoryRule,orderItemList); |
|
|
|
|
|
|
|
//List<Long> spuIds = orderItemList.stream().map(OmsOrderItem::getSpuId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
@ -576,7 +633,6 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im |
|
|
|
|
|
|
|
//加载关联数据
|
|
|
|
BmsSupplierAddress supplierAddress = bmsSupplierAddressService.getById(omsOrder.getSupplierAddrId()); |
|
|
|
GoodsCategoryRule categoryRule = goodsCategoryRuleMapper.selectById(omsOrder.getBrandRuleId()); |
|
|
|
String brands = Arrays.stream(categoryRule.getBrandNames()).collect(Collectors.joining(",")); |
|
|
|
BmsSupplier supplier = bmsSupplierMapper.selectById(omsOrder.getSupplierId()); |
|
|
|
String lastRegionId = supplier.getRegionLast(); |
|
|
|