修改耗材库存
This commit is contained in:
@@ -11,6 +11,7 @@ import com.chaozhanggui.system.cashierservice.util.HttpClientUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.N;
|
||||
import com.chaozhanggui.system.cashierservice.util.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
@@ -19,10 +20,8 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -192,44 +191,88 @@ public class ConsMsgConsumer {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JSONObject getAccessToken1() {
|
||||
String requestUrl = "https://api.weixin.qq.com/cgi-bin/token";
|
||||
Map<String, String> requestUrlParam = new HashMap<>();
|
||||
|
||||
|
||||
requestUrlParam.put("appid", "wxcf0fe8cdba153fd6");
|
||||
//小程序secret
|
||||
requestUrlParam.put("secret", "c33e06467c6879a62af633d50ed6b720");
|
||||
//默认参数
|
||||
requestUrlParam.put("grant_type", "client_credential");
|
||||
JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl, requestUrlParam));
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class MsgInfo{
|
||||
private String openId;
|
||||
private String shopName;
|
||||
|
||||
private String productName;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
public MsgInfo(String openId, String shopName, String productName, BigDecimal amount) {
|
||||
this.openId = openId;
|
||||
this.shopName = shopName;
|
||||
this.productName = productName;
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
JSONObject access_token = new ConsMsgConsumer().getAccessToken();
|
||||
String accessToken = String.valueOf(access_token.get("access_token"));
|
||||
|
||||
JSONObject object1 = new JSONObject();
|
||||
List<MsgInfo> list=new ArrayList<>();
|
||||
|
||||
object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
|
||||
object1.put("touser", "oeQYq5CAuSpdeX9uZz52DJiSUO9M");
|
||||
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 data = new JSONObject();
|
||||
|
||||
JSONObject thing1 = new JSONObject();
|
||||
thing1.put("value", "水");
|
||||
JSONObject thing1 = new JSONObject();
|
||||
thing1.put("value", msgInfo.getShopName());
|
||||
|
||||
JSONObject thing5 = new JSONObject();
|
||||
thing5.put("value", "耗材库存不足,请及时补充。");
|
||||
JSONObject thing5 = new JSONObject();
|
||||
thing5.put("value", "耗材库存不足,请及时补充。");
|
||||
|
||||
JSONObject thing6 = new JSONObject();
|
||||
thing6.put("value", "咖啡");
|
||||
JSONObject thing6 = new JSONObject();
|
||||
thing6.put("value", msgInfo.getProductName());
|
||||
|
||||
|
||||
JSONObject thing7 = new JSONObject();
|
||||
thing7.put("value", "3.2");
|
||||
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);
|
||||
data.put("thing1", thing1);
|
||||
data.put("thing6", thing6);
|
||||
data.put("number7", thing7);
|
||||
data.put("thing5", thing5);
|
||||
|
||||
object1.put("data", data);
|
||||
object1.put("data", data);
|
||||
|
||||
object1.put("miniprogram_state", "trial");
|
||||
object1.put("lang", "zh_CN");
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class RabbitConfig {
|
||||
|
||||
@Bean
|
||||
public Binding bindingcons_Register() {
|
||||
return BindingBuilder.bind(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT);
|
||||
return BindingBuilder.bind(queuecons_Register()).to(consExchange_Register()).with(RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,12 +120,11 @@ public class RabbitConfig {
|
||||
|
||||
@Bean
|
||||
public Binding bindingcons_msg_Register() {
|
||||
return BindingBuilder.bind(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT);
|
||||
return BindingBuilder.bind(queuecons_msg_Register()).to(cons_msg_Exchange_Register()).with(RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -45,9 +45,6 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void con_msg(String content){
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_MSG_COLLECT_PUT, RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT, content, correlationId);
|
||||
|
||||
Reference in New Issue
Block a user