From 63f5c54284f0eaa9655ead7fc087211c83002bd3 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Fri, 9 Aug 2024 15:57:52 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=80=97=E6=9D=90=E6=8E=A8=E9=80=81=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E4=B8=8D=E5=87=86=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/rabbit/ConsMsgConsumer.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/ConsMsgConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/ConsMsgConsumer.java index 46b35fe..670d978 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/ConsMsgConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/ConsMsgConsumer.java @@ -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 tbUserShopMsgs = tbUserShopMsgMapper.selectAllByShopId(tbConsInfo.getShopId()); + tbConsInfo.getConWarning(),tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume())); + if (N.egt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()))) { + List 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);