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