回滚库存
This commit is contained in:
parent
b66a89b143
commit
2310a0164b
|
|
@ -45,6 +45,8 @@ public class DutyService {
|
|||
@Autowired
|
||||
private TbProductSkuMapper productSkuMapper;
|
||||
@Autowired
|
||||
private TbProductMapper productMapper;
|
||||
@Autowired
|
||||
private CloudPrinterService cloudPrinterService;
|
||||
@Autowired
|
||||
private RedisUtils redisUtil;
|
||||
|
|
@ -372,12 +374,25 @@ public class DutyService {
|
|||
}
|
||||
|
||||
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);
|
||||
if (num > tbProductSku.getStockNumber()) {
|
||||
productSkuMapper.updateStockNum(skuId,num);
|
||||
} else {
|
||||
productSkuMapper.updateByskuIdSub(skuId, num);
|
||||
TbProductWithBLOBs product = productMapper.selectByPrimaryKey(Integer.valueOf(tbProductSku.getProductId()));
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue