修改耗材提醒
This commit is contained in:
@@ -109,19 +109,25 @@ public class ConsMsgConsumer {
|
||||
tbProskuCons.parallelStream().forEach(it -> {
|
||||
TbConsInfo tbConsInfo = tbConsInfoMapper.selectByPrimaryKey(it.getConInfoId());
|
||||
if (Objects.isNull(tbConsInfo)) {
|
||||
log.info("耗材信息不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Objects.nonNull(tbConsInfo)) {
|
||||
log.info("conwarning:{},stockNumber:{}",tbConsInfo.getConWarning(),tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).abs());
|
||||
if (N.gt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).abs())) {
|
||||
|
||||
if (N.gt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).abs())) {
|
||||
String key = redisUtil.getMessage(RedisCst.ORDER_MESSAGE.concat(tbConsInfo.getShopId().toString()).concat("#").concat(tbConsInfo.getId().toString()));
|
||||
|
||||
if (Objects.isNull(key)) {
|
||||
List<TbUserShopMsg> tbUserShopMsgs = tbUserShopMsgMapper.selectAllByShopId(tbConsInfo.getShopId());
|
||||
if (Objects.nonNull(tbUserShopMsgs) && tbUserShopMsgs.size()>0) {
|
||||
List<TbUserShopMsg> tbUserShopMsgs = tbUserShopMsgMapper.selectAllByShopId(tbConsInfo.getShopId());
|
||||
if (Objects.nonNull(tbUserShopMsgs) && tbUserShopMsgs.size()>0) {
|
||||
|
||||
for (TbUserShopMsg tbUserShopMsg : tbUserShopMsgs) {
|
||||
|
||||
|
||||
|
||||
tbUserShopMsgs.parallelStream().forEach(tbUserShopMsg->{
|
||||
String key=RedisCst.ORDER_MESSAGE.concat(tbConsInfo.getShopId().toString()).concat("#").concat(tbConsInfo.getId().toString()).concat("#").concat(tbUserShopMsg.getOpenId());
|
||||
String value = redisUtil.getMessage(key);
|
||||
log.info("redis_key:{}",value);
|
||||
if (Objects.isNull(value)) {
|
||||
JSONObject access_token = getAccessToken();
|
||||
String accessToken = String.valueOf(access_token.get("access_token"));
|
||||
|
||||
@@ -140,11 +146,11 @@ public class ConsMsgConsumer {
|
||||
thing5.put("value", "耗材库存不足,请及时补充。");
|
||||
|
||||
JSONObject thing6 = new JSONObject();
|
||||
thing6.put("value", product.getName());
|
||||
thing6.put("value", tbConsInfo.getConName());
|
||||
|
||||
|
||||
JSONObject thing7 = new JSONObject();
|
||||
thing7.put("value", tbConsInfo.getStockNumber().toPlainString());
|
||||
thing7.put("value", tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).toPlainString());
|
||||
|
||||
data.put("thing1", thing1);
|
||||
data.put("thing6", thing6);
|
||||
@@ -157,21 +163,17 @@ public class ConsMsgConsumer {
|
||||
object1.put("lang", "zh_CN");
|
||||
|
||||
String response = HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
log.info("openId:{},返回结果:{}",tbUserShopMsg.getOpenId(), response);
|
||||
JSONObject resObj = JSONObject.parseObject(response);
|
||||
if (ObjectUtil.isNotEmpty(resObj) && ObjectUtil.isNotNull(resObj) && "0".equals(String.valueOf(resObj.get("errcode")))) {
|
||||
redisUtil.saveMessage(key, object1.toString(),10*60*1000);
|
||||
log.info("写入redis:{}",key);
|
||||
redisUtil.saveMessage(key, object1.toString(), 10 * 60 * 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -233,51 +235,51 @@ public class ConsMsgConsumer {
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
List<MsgInfo> list=new ArrayList<>();
|
||||
|
||||
list.add(new MsgInfo("oeQYq5KEjN1-laurB3oRbqEllVzs","双屿Pisces","茄汁肉酱意面",new BigDecimal(24)));
|
||||
list.add(new MsgInfo("oeQYq5KEjN1-laurB3oRbqEllVzs","森食界创意轻食(未央店)","番茄鸳鸯锅",new BigDecimal(36)));
|
||||
|
||||
for (MsgInfo msgInfo : list) {
|
||||
JSONObject access_token = new ConsMsgConsumer().getAccessToken1();
|
||||
String accessToken = String.valueOf(access_token.get("access_token"));
|
||||
|
||||
JSONObject object1 = new JSONObject();
|
||||
|
||||
object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
|
||||
object1.put("touser", msgInfo.getOpenId());
|
||||
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
JSONObject thing1 = new JSONObject();
|
||||
thing1.put("value", msgInfo.getShopName());
|
||||
|
||||
JSONObject thing5 = new JSONObject();
|
||||
thing5.put("value", "耗材库存不足,请及时补充。");
|
||||
|
||||
JSONObject thing6 = new JSONObject();
|
||||
thing6.put("value", msgInfo.getProductName());
|
||||
|
||||
|
||||
JSONObject thing7 = new JSONObject();
|
||||
thing7.put("value", msgInfo.getAmount().toPlainString());
|
||||
|
||||
data.put("thing1", thing1);
|
||||
data.put("thing6", thing6);
|
||||
data.put("number7", thing7);
|
||||
data.put("thing5", thing5);
|
||||
|
||||
object1.put("data", data);
|
||||
|
||||
object1.put("miniprogram_state", "formal");
|
||||
object1.put("lang", "zh_CN");
|
||||
|
||||
String response = HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
JSONObject resObj = JSONObject.parseObject(response);
|
||||
}
|
||||
//
|
||||
// List<MsgInfo> list=new ArrayList<>();
|
||||
//
|
||||
// list.add(new MsgInfo("oeQYq5KEjN1-laurB3oRbqEllVzs","双屿Pisces","茄汁肉酱意面",new BigDecimal(24)));
|
||||
// list.add(new MsgInfo("oeQYq5KEjN1-laurB3oRbqEllVzs","森食界创意轻食(未央店)","番茄鸳鸯锅",new BigDecimal(36)));
|
||||
//
|
||||
// for (MsgInfo msgInfo : list) {
|
||||
// JSONObject access_token = new ConsMsgConsumer().getAccessToken1();
|
||||
// String accessToken = String.valueOf(access_token.get("access_token"));
|
||||
//
|
||||
// JSONObject object1 = new JSONObject();
|
||||
//
|
||||
// object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
|
||||
// object1.put("touser", msgInfo.getOpenId());
|
||||
//
|
||||
//
|
||||
// JSONObject data = new JSONObject();
|
||||
//
|
||||
// JSONObject thing1 = new JSONObject();
|
||||
// thing1.put("value", msgInfo.getShopName());
|
||||
//
|
||||
// JSONObject thing5 = new JSONObject();
|
||||
// thing5.put("value", "耗材库存不足,请及时补充。");
|
||||
//
|
||||
// JSONObject thing6 = new JSONObject();
|
||||
// thing6.put("value", msgInfo.getProductName());
|
||||
//
|
||||
//
|
||||
// JSONObject thing7 = new JSONObject();
|
||||
// thing7.put("value", msgInfo.getAmount().toPlainString());
|
||||
//
|
||||
// data.put("thing1", thing1);
|
||||
// data.put("thing6", thing6);
|
||||
// data.put("number7", thing7);
|
||||
// data.put("thing5", thing5);
|
||||
//
|
||||
// object1.put("data", data);
|
||||
//
|
||||
// object1.put("miniprogram_state", "formal");
|
||||
// object1.put("lang", "zh_CN");
|
||||
//
|
||||
// String response = HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||
// log.info("返回结果:{}", response);
|
||||
// JSONObject resObj = JSONObject.parseObject(response);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user