Merge remote-tracking branch 'origin/hph'

This commit is contained in:
韩鹏辉 2024-07-05 16:01:00 +08:00
commit cbb0276958
4 changed files with 38 additions and 45 deletions

View File

@ -28,9 +28,7 @@ public interface TbProskuConMapper {
List<Integer> selectIdBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId); List<Integer> selectIdBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
List<TbProskuCon> selectByShopIdAndSkuIdAndProductId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);
TbProskuCon selectByShopIdAndSkuIdAndProductId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);

View File

@ -57,53 +57,49 @@ public class ConsService {
List<TbConsInfoFlow> consInfoFlows=new ArrayList<>(); List<TbConsInfoFlow> consInfoFlows=new ArrayList<>();
for (TbOrderDetail orderDetail : orderDetails) { for (TbOrderDetail orderDetail : orderDetails) {
TbProskuCon proskuCon= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId()); List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
if(Objects.isNull(proskuCon)){ if(Objects.isNull(proskuCons)||proskuCons.size()<=0){
log.info("不存在的耗材信息配置:orderId:{},skuId:{},shopId:{},productId:{}",orderDetail.getOrderId(),orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId()); log.info("不存在的耗材信息配置:orderId:{},skuId:{},shopId:{},productId:{}",orderDetail.getOrderId(),orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
continue; continue;
} }
for (TbProskuCon proskuCon : proskuCons) {
TbConsInfo tbConsInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
if(Objects.nonNull(tbConsInfo)&&"1".equals(tbConsInfo.getStatus())){
BigDecimal amount=BigDecimal.ZERO;
TbConsInfoFlow flow=new TbConsInfoFlow();
flow.setConsId(tbConsInfo.getId());
flow.setShopId(tbConsInfo.getShopId());
flow.setConName(tbConsInfo.getConName());
if("create".equals(type)){
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum()));
TbConsInfo tbConsInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); flow.setAmount(amount);
if(Objects.nonNull(tbConsInfo)&&"1".equals(tbConsInfo.getStatus())){ flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
BigDecimal amount=BigDecimal.ZERO; flow.setBizCode("createCart");
TbConsInfoFlow flow=new TbConsInfoFlow(); flow.setBizName("销售扣除");
flow.setConsId(tbConsInfo.getId()); flow.setBizType("-");
flow.setShopId(tbConsInfo.getShopId()); }else if("delete".equals(type)){
flow.setConName(tbConsInfo.getConName()); amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())).negate();
if("create".equals(type)){
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum()));
flow.setAmount(amount); flow.setAmount(amount.abs());
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume())); flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
flow.setBizCode("createCart"); flow.setBizCode("cancelCart");
flow.setBizName("销售扣除"); flow.setBizName("退单返还");
flow.setBizType("-"); flow.setBizType("+");
}else if("delete".equals(type)){ }
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())).negate(); ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),amount);
consInfoPOS.add(consInfoPO);
flow.setCreateTime(new Date());
flow.setUpdateTime(new Date());
consInfoFlows.add(flow);
flow.setAmount(amount.abs());
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
flow.setBizCode("cancelCart");
flow.setBizName("退单返还");
flow.setBizType("+");
} }
ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),amount);
consInfoPOS.add(consInfoPO);
flow.setCreateTime(new Date());
flow.setUpdateTime(new Date());
consInfoFlows.add(flow);
//更新耗材信息
tbConsInfoMapper.batchStock(consInfoPOS);
//记录更新日志
tbConsInfoFlowMapper.insertBatch(consInfoFlows);
} }
//更新耗材信息
tbConsInfoMapper.batchStock(consInfoPOS);
//记录更新日志
tbConsInfoFlowMapper.insertBatch(consInfoFlows);
} }
} }
} }

View File

@ -536,8 +536,6 @@ public class OrderService {
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(orderInfo.getShopId().toString()),object.toString()); redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(orderInfo.getShopId().toString()),object.toString());
//修改耗材数据 //修改耗材数据
JSONObject jsonObject=new JSONObject(); JSONObject jsonObject=new JSONObject();
jsonObject.put("orderId",orderInfo.getId()); jsonObject.put("orderId",orderInfo.getId());

View File

@ -136,6 +136,7 @@
</select> </select>
<select id="selectByShopIdAndSkuIdAndProductId" resultMap="BaseResultMap"> <select id="selectByShopIdAndSkuIdAndProductId" resultMap="BaseResultMap">
select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and product_id=#{productId} and status=1 select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and product_id=#{productId} and status=1
</select> </select>
</mapper> </mapper>