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