排队叫号添加微信模板消息提醒
This commit is contained in:
@@ -25,6 +25,10 @@ public class WxMiniUtils {
|
||||
|
||||
@Value("${wx.mini.user.msgId.currentCall}")
|
||||
private String currentCallTempId;
|
||||
@Value("${wx.mini.user.msgId.nearCall}")
|
||||
private String nearCallTempId;
|
||||
@Value("${wx.mini.user.msgId.passCall}")
|
||||
private String passCallTempId;
|
||||
|
||||
|
||||
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
||||
@@ -61,8 +65,8 @@ public class WxMiniUtils {
|
||||
}
|
||||
|
||||
|
||||
public JSONObject sendTempMsg(String tempId, String toUserOpenId, Map<String, Object> data) {
|
||||
log.info("开始发送微信模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
|
||||
public JSONObject sendTempMsg(String tempId, String toUserOpenId, Map<String, Object> data, String note) {
|
||||
log.info("开始发送" + note + "模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
|
||||
JSONObject object= getAccessToken();
|
||||
String accessToken=object.get("access_token")+"";
|
||||
|
||||
@@ -85,7 +89,7 @@ public class WxMiniUtils {
|
||||
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
||||
}
|
||||
|
||||
public void sendNearCallMsg(String shopName, String state, String callNum, String currentNum, String note, String openId) {
|
||||
public void sendCurrentOrNearCallMsg(String shopName, String state, String callNum, String currentNum, String note, String openId, boolean isNear) {
|
||||
Map<String, Object> data = new HashMap<String, Object>() {{
|
||||
put("thing1", new HashMap<String, Object>() {{
|
||||
put("value", shopName);
|
||||
@@ -103,9 +107,33 @@ public class WxMiniUtils {
|
||||
put("value", note);
|
||||
}});
|
||||
}};
|
||||
log.info("开始发送排号到号消息, 接收用户openId: {}, 消息数据: {}", openId, data);
|
||||
try {
|
||||
sendTempMsg(currentCallTempId, openId, data);
|
||||
sendTempMsg(isNear ? nearCallTempId : currentCallTempId, openId, data, "排队到号");
|
||||
} catch (Exception e) {
|
||||
log.error("发送失败, openId:{}, msg: {}", openId, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPassCallMsg(String shopName, String state, String callNum, String currentNum, String note, String openId) {
|
||||
Map<String, Object> data = new HashMap<String, Object>() {{
|
||||
put("thing1", new HashMap<String, Object>() {{
|
||||
put("value", shopName);
|
||||
}});
|
||||
put("character_string2", new HashMap<String, Object>() {{
|
||||
put("value", callNum);
|
||||
}});
|
||||
put("character_string3", new HashMap<String, Object>() {{
|
||||
put("value", currentNum);
|
||||
}});
|
||||
put("phrase4", new HashMap<String, Object>() {{
|
||||
put("value", state);
|
||||
}});
|
||||
put("thing5", new HashMap<String, Object>() {{
|
||||
put("value", note);
|
||||
}});
|
||||
}};
|
||||
try {
|
||||
sendTempMsg(currentCallTempId, openId, data, "过号");
|
||||
} catch (Exception e) {
|
||||
log.error("发送失败, openId:{}, msg: {}", openId, e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user