1.耗材推送数量不准确问题

This commit is contained in:
SongZhang 2024-08-09 15:57:52 +08:00
parent 736389aa65
commit 63f5c54284
1 changed files with 10 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.bean.ShopWxMsgTypeEnum;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.util.*;
@ -49,6 +50,8 @@ public class ConsMsgConsumer {
private final WxAccountUtil wxAccountUtil;
private final TbShopOpenIdMapper shopOpenIdMapper;
@Autowired
RedisUtil redisUtil;
@ -64,8 +67,9 @@ public class ConsMsgConsumer {
@Value("${subscribe.message.miniprogramState}")
private String miniprogramState;
public ConsMsgConsumer(WxAccountUtil wxAccountUtil) {
public ConsMsgConsumer(WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper) {
this.wxAccountUtil = wxAccountUtil;
this.shopOpenIdMapper = shopOpenIdMapper;
}
@ -117,10 +121,10 @@ public class ConsMsgConsumer {
}
log.info("耗材名称: {}, conwarning:{},stockNumber:{}",tbConsInfo.getConName(),
tbConsInfo.getConWarning(),tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume().abs()));
if (N.egt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume().abs()))) {
List<TbUserShopMsg> tbUserShopMsgs = tbUserShopMsgMapper.selectAllByShopId(tbConsInfo.getShopId());
tbConsInfo.getConWarning(),tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()));
if (N.egt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()))) {
List<TbShopOpenId> tbUserShopMsgs = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.CONSUMABLES_MSG.getType());
log.info("待推送openId列表: {}", tbUserShopMsgs);
if (Objects.nonNull(tbUserShopMsgs) && tbUserShopMsgs.size()>0) {
tbUserShopMsgs.parallelStream().forEach(tbUserShopMsg->{
String key=RedisCst.ORDER_MESSAGE.concat(tbConsInfo.getShopId().toString()).concat("#").concat(tbConsInfo.getId().toString()).concat("#").concat(tbUserShopMsg.getOpenId());
@ -129,7 +133,7 @@ public class ConsMsgConsumer {
log.info("开始推送耗材模板消息rediskey{}", value);
if (Objects.isNull(value)) {
JSONObject jsonObject = wxAccountUtil.sendStockWarnMsg("耗材库存不足", tbConsInfo.getConName(),
tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume().abs()).toBigInteger().intValue(), tbUserShopMsg.getOpenId());
tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).toBigInteger().intValue(), tbUserShopMsg.getOpenId());
if (jsonObject != null) {
log.info("写入redis:{}",key);
redisUtil.saveMessage(key, "1", 30 * 60);