库存扣减
This commit is contained in:
@@ -78,30 +78,30 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
||||
continue;
|
||||
}
|
||||
// 商品未开启库存
|
||||
if (product.getIsStock() == SystemConstants.OneZero.ZERO) {
|
||||
continue;
|
||||
}
|
||||
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "sub", dto.getNum());
|
||||
// 记录商品库存流水
|
||||
ProductStockFlow flow = new ProductStockFlow();
|
||||
flow.setCreateUserId(1L);
|
||||
flow.setCreateUserName("银收客");
|
||||
flow.setShopId(shopId);
|
||||
flow.setProductId(product.getId());
|
||||
flow.setProductName(product.getName());
|
||||
flow.setBeforeNumber(NumberUtil.toBigDecimal(product.getStockNumber()));
|
||||
flow.setInOutNumber(NumberUtil.sub(BigDecimal.ZERO, NumberUtil.toBigDecimal(dto.getNum())));
|
||||
flow.setAfterNumber(NumberUtil.sub(NumberUtil.toBigDecimal(product.getStockNumber()), NumberUtil.toBigDecimal(dto.getNum())));
|
||||
flow.setInOutType(InOutTypeEnum.OUT.value());
|
||||
flow.setInOutItem(InOutItemEnum.ORDER_OUT.value());
|
||||
flow.setOrderId(orderId);
|
||||
productStockFlowService.saveFlow(flow);
|
||||
cleanCategoryProduct(shopId, product.getCategoryId());
|
||||
refreshRedisProdStock(shopId, product.getId(), flow.getAfterNumber());
|
||||
Integer warnLine = ObjUtil.defaultIfNull(product.getWarnLine(), 10);
|
||||
if (!isLowWarnLine && NumberUtil.isLess(flow.getAfterNumber(), Convert.toBigDecimal(warnLine))) {
|
||||
isLowWarnLine = true;
|
||||
if (product.getIsStock() == SystemConstants.OneZero.ONE) {
|
||||
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "sub", dto.getNum());
|
||||
// 记录商品库存流水
|
||||
ProductStockFlow flow = new ProductStockFlow();
|
||||
flow.setCreateUserId(1L);
|
||||
flow.setCreateUserName("银收客");
|
||||
flow.setShopId(shopId);
|
||||
flow.setProductId(product.getId());
|
||||
flow.setProductName(product.getName());
|
||||
flow.setBeforeNumber(NumberUtil.toBigDecimal(product.getStockNumber()));
|
||||
flow.setInOutNumber(NumberUtil.sub(BigDecimal.ZERO, NumberUtil.toBigDecimal(dto.getNum())));
|
||||
flow.setAfterNumber(NumberUtil.sub(NumberUtil.toBigDecimal(product.getStockNumber()), NumberUtil.toBigDecimal(dto.getNum())));
|
||||
flow.setInOutType(InOutTypeEnum.OUT.value());
|
||||
flow.setInOutItem(InOutItemEnum.ORDER_OUT.value());
|
||||
flow.setOrderId(orderId);
|
||||
productStockFlowService.saveFlow(flow);
|
||||
cleanCategoryProduct(shopId, product.getCategoryId());
|
||||
refreshRedisProdStock(shopId, product.getId(), flow.getAfterNumber());
|
||||
Integer warnLine = ObjUtil.defaultIfNull(product.getWarnLine(), 10);
|
||||
if (!isLowWarnLine && NumberUtil.isLess(flow.getAfterNumber(), Convert.toBigDecimal(warnLine))) {
|
||||
isLowWarnLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询商品绑定耗材信息
|
||||
List<ProdConsRelation> relationList = prodConsRelationMapper.selectListByQuery(QueryWrapper.create().eq(ProdConsRelation::getProductId, dto.getProductId()));
|
||||
if (CollUtil.isEmpty(relationList)) {
|
||||
|
||||
Reference in New Issue
Block a user