Merge remote-tracking branch 'origin/hph' into dev
This commit is contained in:
commit
2818f8afff
|
|
@ -69,6 +69,8 @@ public class ConsMsgConsumer {
|
|||
@RabbitHandler
|
||||
public void listener(String message) {
|
||||
|
||||
log.info("耗材即将售罄提醒:{}",message);
|
||||
|
||||
JSONObject object = JSONObject.parseObject(message);
|
||||
if (Objects.isNull(object) || !object.containsKey("skuId") || !object.containsKey("shopId") || Objects.isNull(object.getInteger("skuId")) || Objects.isNull(object.getInteger("shopId"))) {
|
||||
log.info("接收的信息为空");
|
||||
|
|
@ -107,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"));
|
||||
|
||||
|
|
@ -138,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);
|
||||
|
|
@ -155,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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -231,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);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -862,10 +862,20 @@ public class PayService {
|
|||
|
||||
}else if("deposit".equals(payType)){
|
||||
TbShopUser user= tbShopUserMapper.selectByUserIdAndShopId(orderInfo.getUserId(),orderInfo.getShopId());
|
||||
if(ObjectUtil.isNull(user)||ObjectUtil.isEmpty(user)){
|
||||
user=tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
|
||||
}
|
||||
|
||||
|
||||
if(ObjectUtil.isNull(user)||ObjectUtil.isEmpty(user)){
|
||||
return Result.fail(ACCOUNTEIXST);
|
||||
}
|
||||
|
||||
if(!user.getShopId().equals(orderInfo.getShopId())){
|
||||
return Result.fail(ACCOUNTEIXST);
|
||||
}
|
||||
|
||||
|
||||
newOrderInfo.setMemberId(orderInfo.getMemberId());
|
||||
newOrderInfo.setUserId(orderInfo.getUserId());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue