下单处理活动库存调整
This commit is contained in:
@ -1492,20 +1492,21 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
|
||||
* @param cartInfo 购物车
|
||||
*/
|
||||
public void deStockIncSale(List<YxStoreCartQueryVo> 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,"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public interface YxStoreProductAttrService extends BaseService<YxStoreProductAt
|
||||
* @param productId 商品id
|
||||
* @param unique sku唯一值
|
||||
*/
|
||||
void decProductAttrStock(int num, Long productId, String unique);
|
||||
void decProductAttrStock(int num, Long productId, String unique,String type);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ public interface YxStoreProductService extends BaseService<YxStoreProduct>{
|
||||
* @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);
|
||||
|
||||
|
@ -171,8 +171,15 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductA
|
||||
* @param unique sku唯一值
|
||||
*/
|
||||
@Override
|
||||
public void decProductAttrStock(int num, Long productId, String unique) {
|
||||
int res = yxStoreProductAttrValueMapper.decStockIncSales(num,productId,unique);
|
||||
public void decProductAttrStock(int num, Long productId, String unique,String type) {
|
||||
int res = 0;
|
||||
if("combination".equals(type)){
|
||||
res = yxStoreProductAttrValueMapper.decCombinationStockIncSales(num,productId,unique);
|
||||
}else if("seckill".equals(type)){
|
||||
res = yxStoreProductAttrValueMapper.decSeckillStockIncSales(num,productId,unique);
|
||||
}else {
|
||||
res = yxStoreProductAttrValueMapper.decStockIncSales(num,productId,unique);
|
||||
}
|
||||
if(res == 0) throw new YshopException("商品库存不足");
|
||||
}
|
||||
|
||||
|
@ -138,11 +138,19 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
||||
* @param unique sku
|
||||
*/
|
||||
@Override
|
||||
public void decProductStock(int num, Long productId, String unique) {
|
||||
public void decProductStock(int num, Long productId, String unique,Long activityId,String type) {
|
||||
if(StrUtil.isNotEmpty(unique)){
|
||||
yxStoreProductAttrService.decProductAttrStock(num,productId,unique);
|
||||
yxStoreProductAttrService.decProductAttrStock(num,productId,unique, type);
|
||||
}
|
||||
int res = storeProductMapper.decStockIncSales(num,productId);
|
||||
int res = 0;
|
||||
if("combination".equals(type)){
|
||||
res = storeProductMapper.decCombinationStockIncSales(num,productId,activityId);
|
||||
}else if("seckill".equals(type)){
|
||||
res = storeProductMapper.decSeckillStockIncSales(num,productId,activityId);
|
||||
}else {
|
||||
res = storeProductMapper.decStockIncSales(num,productId);
|
||||
}
|
||||
|
||||
if(res == 0) throw new YshopException("商品库存不足");
|
||||
}
|
||||
|
||||
|
@ -35,4 +35,12 @@ public interface StoreProductAttrValueMapper extends CoreMapper<YxStoreProductAt
|
||||
" where product_id=#{productId} and `unique`=#{unique}")
|
||||
int incStockDecSales(@Param("num") int num,@Param("productId") Long productId,
|
||||
@Param("unique") String unique);
|
||||
|
||||
@Update("update yx_store_product_attr_value set stock=stock-#{num}, pink_stock=pink_stock-#{num} sales=sales+#{num}" +
|
||||
" where product_id=#{productId} and `unique`=#{unique} and stock >= #{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);
|
||||
}
|
||||
|
@ -43,4 +43,13 @@ public interface StoreProductMapper extends CoreMapper<YxStoreProduct> {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user