商品库存警戒线

This commit is contained in:
2024-10-08 11:36:46 +08:00
parent 657596f619
commit d4cc9deed0
5 changed files with 103 additions and 101 deletions

View File

@@ -131,6 +131,8 @@ public class TbProduct implements Serializable {
private Integer stockNumber;
private Integer warnLine = 0;
@Transient
private int orderCount;
@@ -655,4 +657,12 @@ public class TbProduct implements Serializable {
public void setStockNumber(Integer stockNumber) {
this.stockNumber = stockNumber;
}
public Integer getWarnLine() {
return warnLine;
}
public void setWarnLine(Integer warnLine) {
this.warnLine = warnLine;
}
}

View File

@@ -35,8 +35,6 @@ public class TbProductSku implements Serializable {
private String coverImg;
private Integer warnLine;
private Double weight;
private Float volume;

View File

@@ -426,7 +426,7 @@ public class OrderService {
private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer shopId, Integer num) {
log.info("下单,开始校验库存预警,商品信息:{}, {}, {}", product, productSku, num);
if (productSku.getWarnLine() == null) {
if (product.getWarnLine() == null) {
return;
}
@@ -434,21 +434,15 @@ public class OrderService {
return;
}
if (productSku.getStockNumber() == null) {
productSku.setStockNumber((double) 0);
}
if (product.getStockNumber() == null) {
product.setStockNumber(0);
}
if (
(product.getIsDistribute() == 1 && product.getStockNumber() - num <= productSku.getWarnLine())
|| (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine()
) {
if (product.getStockNumber() - num <= product.getWarnLine()) {
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType());
shopOpenIds.forEach(item -> {
wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(),
product.getIsDistribute() == 1 ? product.getStockNumber()-num : (int) (productSku.getStockNumber() - num), item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopId);
product.getStockNumber() - num , item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopId);
});
}
}