回滚库存
This commit is contained in:
@@ -45,6 +45,8 @@ public class DutyService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TbProductSkuMapper productSkuMapper;
|
private TbProductSkuMapper productSkuMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private TbProductMapper productMapper;
|
||||||
|
@Autowired
|
||||||
private CloudPrinterService cloudPrinterService;
|
private CloudPrinterService cloudPrinterService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisUtils redisUtil;
|
private RedisUtils redisUtil;
|
||||||
@@ -372,12 +374,25 @@ public class DutyService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void subInventory(Integer shopId, Integer skuId, Integer num) {
|
private void subInventory(Integer shopId, Integer skuId, Integer num) {
|
||||||
String result = redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":" + skuId.toString(), num.toString());
|
|
||||||
TbProductSku tbProductSku = productSkuMapper.selectByPrimaryKey(skuId);
|
TbProductSku tbProductSku = productSkuMapper.selectByPrimaryKey(skuId);
|
||||||
if (num > tbProductSku.getStockNumber()) {
|
TbProductWithBLOBs product = productMapper.selectByPrimaryKey(Integer.valueOf(tbProductSku.getProductId()));
|
||||||
productSkuMapper.updateStockNum(skuId,num);
|
|
||||||
} else {
|
|
||||||
productSkuMapper.updateByskuIdSub(skuId, num);
|
if (ObjectUtil.isNotEmpty(product)) {
|
||||||
|
if (product.getIsDistribute() == 1) {
|
||||||
|
redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":product" + product.getId().toString(), num.toString());
|
||||||
|
productMapper.updateStockById(skuId, num);
|
||||||
|
} else {
|
||||||
|
redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":" + skuId.toString(), num.toString());
|
||||||
|
if (ObjectUtil.isNotEmpty(tbProductSku)) {
|
||||||
|
if (num > tbProductSku.getStockNumber()) {
|
||||||
|
productSkuMapper.updateStockNum(skuId,num);
|
||||||
|
} else {
|
||||||
|
productSkuMapper.updateByskuIdSub(skuId, num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user