From 966e153f886b368673575fc39741e7b280e06050 Mon Sep 17 00:00:00 2001 From: xuwenbo <717567226@qq.com> Date: Thu, 27 Aug 2020 16:35:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E5=8D=95=E5=A4=84=E7=90=86=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E5=BA=93=E5=AD=98=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/YxStoreOrderServiceImpl.java | 9 +++++---- .../product/service/YxStoreProductAttrService.java | 2 +- .../product/service/YxStoreProductService.java | 2 +- .../impl/YxStoreProductAttrServiceImpl.java | 11 +++++++++-- .../service/impl/YxStoreProductServiceImpl.java | 14 +++++++++++--- .../mapper/StoreProductAttrValueMapper.java | 8 ++++++++ .../product/service/mapper/StoreProductMapper.java | 9 +++++++++ 7 files changed, 44 insertions(+), 11 deletions(-) diff --git a/yshop-mall/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java b/yshop-mall/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java index 49c65e55..875ed0cb 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java @@ -1492,20 +1492,21 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl cartInfo) { - //todo 活动商品库存待处理 for (YxStoreCartQueryVo storeCartVO : cartInfo) { Long combinationId = storeCartVO.getCombinationId(); Long seckillId = storeCartVO.getSeckillId(); Long bargainId = storeCartVO.getBargainId(); if(combinationId != null && combinationId > 0){ - combinationService.decStockIncSales(storeCartVO.getCartNum(),combinationId); + productService.decProductStock(storeCartVO.getCartNum(),storeCartVO.getProductId(), + storeCartVO.getProductAttrUnique(),combinationId,"combination"); }else if(seckillId != null && seckillId > 0){ - storeSeckillService.decStockIncSales(storeCartVO.getCartNum(),seckillId); + productService.decProductStock(storeCartVO.getCartNum(),storeCartVO.getProductId(), + storeCartVO.getProductAttrUnique(),combinationId,"seckill"); }else if(bargainId != null && bargainId > 0){ storeBargainService.decStockIncSales(storeCartVO.getCartNum(),bargainId); } else { productService.decProductStock(storeCartVO.getCartNum(),storeCartVO.getProductId(), - storeCartVO.getProductAttrUnique()); + storeCartVO.getProductAttrUnique(),0l,""); } } } diff --git a/yshop-mall/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrService.java b/yshop-mall/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrService.java index b8a846fe..18364384 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrService.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrService.java @@ -37,7 +37,7 @@ public interface YxStoreProductAttrService extends BaseService{ * @param productId 商品id * @param unique sku */ - void decProductStock(int num, Long productId, String unique); + void decProductStock(int num, Long productId, String unique,Long activityId,String type); YxStoreProduct getProductInfo(int id); diff --git a/yshop-mall/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrServiceImpl.java b/yshop-mall/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrServiceImpl.java index 19aa533b..c5a5bb8d 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrServiceImpl.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrServiceImpl.java @@ -171,8 +171,15 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl= #{num} and pink_stock>=#{num}") + int decCombinationStockIncSales(int num, Long productId, String unique); + + @Update("update yx_store_product_attr_value set stock=stock-#{num}, seckill_stock=seckill_stock-#{num} sales=sales+#{num}" + + " where product_id=#{productId} and `unique`=#{unique} and stock >= #{num} and seckill_stock>=#{num}") + int decSeckillStockIncSales(int num, Long productId, String unique); } diff --git a/yshop-mall/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductMapper.java b/yshop-mall/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductMapper.java index c64023ef..36ec166e 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductMapper.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductMapper.java @@ -43,4 +43,13 @@ public interface StoreProductMapper extends CoreMapper { @Update("update yx_store_product set is_show = #{status} where id = #{id}") void updateOnsale(@Param("status") Integer status, @Param("id") Long id); + + //todo 拼团商品库存+— + @Update("update yx_store_combination set stock=stock-#{num}, sales=sales+#{num}" + + " where id=#{activityId} and stock >= #{num}") + int decCombinationStockIncSales(int num, Long productId,Long activityId); + //todo 拼团商品库存+— + @Update("update yx_store_seckill set stock=stock-#{num}, sales=sales+#{num}" + + " where id=#{activityId} and stock >= #{num}") + int decSeckillStockIncSales(int num, Long productId,Long activityId); }