src/main/java/cc/mrbird/febs/mall/mapper/MallGoodsMapper.java
@@ -50,4 +50,6 @@ MallGoodsCommentVo findMallGoodsCommentLevelByGoodsId(@Param("id")Long id); Integer upDateStockAndVolumeByGoodsId(@Param("id")Long id,@Param("cnt")Integer cnt); Integer updateStockAndVolumeByGoodsId(@Param("id")Long id,@Param("cnt")Integer cnt); } src/main/java/cc/mrbird/febs/mall/mapper/MallGoodsSkuMapper.java
@@ -21,4 +21,6 @@ int delSkuByIds(@Param("list") List<Long> ids); Integer upDateStockAndVolumeBySkuId(@Param("id")Long id, @Param("cnt")Integer cnt); Integer updateStockAndVolumeBySkuId(@Param("id")Long id, @Param("cnt")Integer cnt); } src/main/java/cc/mrbird/febs/mall/quartz/OrderOvertimeJob.java
@@ -65,12 +65,12 @@ } MallGoods mallGoods = mallGoodsMapper.selectById(sku.getGoodsId()); Integer goodsResult = mallGoodsMapper.upDateStockAndVolumeByGoodsId(mallGoods.getId(), mallOrderItem.getCnt()); Integer goodsResult = mallGoodsMapper.updateStockAndVolumeByGoodsId(mallGoods.getId(), mallOrderItem.getCnt()); if(1 != goodsResult){ throw new FebsException(mallGoods.getGoodsName() + "库存不足"); } Integer skuResult = mallGoodsSkuMapper.upDateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); Integer skuResult = mallGoodsSkuMapper.updateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); if(1 != skuResult){ throw new FebsException(sku.getSkuName() + "库存不足"); } src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -261,6 +261,8 @@ orderInfo.setCancelType(MallOrderInfo.CANCEL_BY_SELF); this.baseMapper.updateById(orderInfo); List<MallOrderItem> mallOrderItemList = mallOrderItemMapper.selectListByOrderId(orderInfo.getId()); if(CollUtil.isNotEmpty(mallOrderItemList)){ for(MallOrderItem mallOrderItem : mallOrderItemList){ @@ -274,12 +276,12 @@ } MallGoods mallGoods = mallGoodsMapper.selectById(sku.getGoodsId()); Integer goodsResult = mallGoodsMapper.upDateStockAndVolumeByGoodsId(mallGoods.getId(), mallOrderItem.getCnt()); Integer goodsResult = mallGoodsMapper.updateStockAndVolumeByGoodsId(mallGoods.getId(), mallOrderItem.getCnt()); if(1 != goodsResult){ throw new FebsException(mallGoods.getGoodsName() + "库存不足"); } Integer skuResult = mallGoodsSkuMapper.upDateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); Integer skuResult = mallGoodsSkuMapper.updateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); if(1 != skuResult){ throw new FebsException(sku.getSkuName() + "库存不足"); } @@ -711,12 +713,12 @@ } MallGoods mallGoods = mallGoodsMapper.selectById(sku.getGoodsId()); Integer goodsResult = mallGoodsMapper.upDateStockAndVolumeByGoodsId(mallGoods.getId(), mallOrderItem.getCnt()); Integer goodsResult = mallGoodsMapper.updateStockAndVolumeByGoodsId(mallGoods.getId(), mallOrderItem.getCnt()); if(1 != goodsResult){ throw new FebsException(mallGoods.getGoodsName() + "库存不足"); } Integer skuResult = mallGoodsSkuMapper.upDateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); Integer skuResult = mallGoodsSkuMapper.updateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); if(1 != skuResult){ throw new FebsException(sku.getSkuName() + "库存不足"); } src/main/resources/mapper/modules/MallGoodsMapper.xml
@@ -271,4 +271,11 @@ where id=#{id} and stock - #{cnt} <![CDATA[ >= ]]> 0 </update> <update id="updateStockAndVolumeByGoodsId"> update mall_goods set stock = stock + #{cnt}, volume = volume - #{cnt} where id=#{id} and volume - #{cnt} <![CDATA[ >= ]]> 0 </update> </mapper> src/main/resources/mapper/modules/MallGoodsSkuMapper.xml
@@ -45,4 +45,11 @@ sku_volume = sku_volume + #{cnt} where id=#{id} and stock - #{cnt} <![CDATA[ >= ]]> 0 </update> <update id="updateStockAndVolumeBySkuId"> update mall_goods_sku set stock = stock + #{cnt}, sku_volume = sku_volume - #{cnt} where id=#{id} and sku_volume - #{cnt} <![CDATA[ >= ]]> 0 </update> </mapper>