商品库存警戒线
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,6 @@ public class TbProductSku implements Serializable {
|
||||
|
||||
private String coverImg;
|
||||
|
||||
private Integer warnLine;
|
||||
|
||||
private Double weight;
|
||||
|
||||
private Float volume;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user