公众号通知问题
This commit is contained in:
parent
37b3d0a716
commit
57a211bbce
|
|
@ -275,15 +275,11 @@ public class OrderController extends BaseController {
|
||||||
// 消息组装。
|
// 消息组装。
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
// 订单编号
|
// 订单编号
|
||||||
params.put("character_string1", orderMaster.getCode());
|
params.put("character_string6", orderMaster.getCode());
|
||||||
// 名称
|
// 名称
|
||||||
params.put("thing2", customer.getName());
|
params.put("thing14", customer.getName());
|
||||||
// 预约时间
|
// 预约时间
|
||||||
params.put("data8", com.ghy.common.utils.DateUtils.parseDateToStr("yyyy年MM月dd日 HH:mm", orderMaster.getExpectTimeStart()));
|
params.put("time4", com.ghy.common.utils.DateUtils.parseDateToStr("yyyy年MM月dd日 HH:mm", orderMaster.getExpectTimeStart()));
|
||||||
// 师傅姓名
|
|
||||||
params.put("name3", assignWorker.getName());
|
|
||||||
// 服务区域
|
|
||||||
params.put("thing4", orderMaster.getAddress());
|
|
||||||
// 消息推送
|
// 消息推送
|
||||||
WechatMsgUtils.sendWeChatMsg(WechatMsgUtils.getToken(), assignWorker.getOpenId(), WxMsgEnum.TEXT, params);
|
WechatMsgUtils.sendWeChatMsg(WechatMsgUtils.getToken(), assignWorker.getOpenId(), WxMsgEnum.TEXT, params);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -452,15 +448,11 @@ public class OrderController extends BaseController {
|
||||||
// 消息组装。
|
// 消息组装。
|
||||||
Map<String, Object> paramsNew = new HashMap<>();
|
Map<String, Object> paramsNew = new HashMap<>();
|
||||||
// 订单编号
|
// 订单编号
|
||||||
paramsNew.put("character_string1", om.getCode());
|
paramsNew.put("character_string6", om.getCode());
|
||||||
// 名称
|
// 名称
|
||||||
paramsNew.put("thing2", om.getGoodsName());
|
paramsNew.put("thing14", acceptWorker.getName());
|
||||||
// 预约时间
|
// 预约时间
|
||||||
paramsNew.put("data8", com.ghy.common.utils.DateUtils.parseDateToStr("yyyy年MM月dd日 HH:mm", om.getCreateTime()));
|
paramsNew.put("time4", com.ghy.common.utils.DateUtils.parseDateToStr("yyyy年MM月dd日 HH:mm", om.getExpectTimeStart()));
|
||||||
// 服务区域
|
|
||||||
paramsNew.put("thing4", om.getAddress());
|
|
||||||
// 师傅姓名
|
|
||||||
paramsNew.put("name3", acceptWorker.getName());
|
|
||||||
WechatMsgUtils.sendWeChatMsg(WechatMsgUtils.getToken(), acceptWorker.getOpenId(), WxMsgEnum.TEXT, paramsNew);
|
WechatMsgUtils.sendWeChatMsg(WechatMsgUtils.getToken(), acceptWorker.getOpenId(), WxMsgEnum.TEXT, paramsNew);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
|
@ -559,15 +551,11 @@ public class OrderController extends BaseController {
|
||||||
// 消息组装。
|
// 消息组装。
|
||||||
Map<String, Object> paramsNew = new HashMap<>();
|
Map<String, Object> paramsNew = new HashMap<>();
|
||||||
// 订单编号
|
// 订单编号
|
||||||
paramsNew.put("character_string1", orderMaster.getCode());
|
paramsNew.put("character_string6", orderMaster.getCode());
|
||||||
// 名称
|
// 名称
|
||||||
paramsNew.put("thing2", customer.getName());
|
paramsNew.put("thing14", customer.getName());
|
||||||
// 预约时间
|
// 预约时间
|
||||||
paramsNew.put("data8", com.ghy.common.utils.DateUtils.parseDateToStr("yyyy年MM月dd日 HH:mm", orderMaster.getExpectTimeStart()));
|
paramsNew.put("time4", com.ghy.common.utils.DateUtils.parseDateToStr("yyyy年MM月dd日 HH:mm", orderMaster.getExpectTimeStart()));
|
||||||
// 师傅姓名
|
|
||||||
paramsNew.put("name3", assignWorker.getName());
|
|
||||||
// 服务区域
|
|
||||||
paramsNew.put("thing4", orderMaster.getAddress());
|
|
||||||
// 消息推送
|
// 消息推送
|
||||||
WechatMsgUtils.sendWeChatMsg(WechatMsgUtils.getToken(), assignWorker.getOpenId(), WxMsgEnum.TEXT, paramsNew);
|
WechatMsgUtils.sendWeChatMsg(WechatMsgUtils.getToken(), assignWorker.getOpenId(), WxMsgEnum.TEXT, paramsNew);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ public class WechatMsgUtils {
|
||||||
@Autowired
|
@Autowired
|
||||||
private static WxConfig wxConfig;
|
private static WxConfig wxConfig;
|
||||||
|
|
||||||
static final String appid = "wx105ce607b514ff2a";
|
static final String appid = "wx404f2439a8c24e15";
|
||||||
static final String appsecret = "51df6f2d33bf639fa05891af7a69a56e";
|
static final String appsecret = "49ade04a817067fe2d65ab2f17afce75";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,11 +42,16 @@ public class WechatMsgUtils {
|
||||||
String getTokenApi = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + appsecret;
|
String getTokenApi = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + appsecret;
|
||||||
String tokenJsonStr = doGetPost(getTokenApi, "GET", null);
|
String tokenJsonStr = doGetPost(getTokenApi, "GET", null);
|
||||||
JSONObject tokenJson = JSONObject.parseObject(tokenJsonStr);
|
JSONObject tokenJson = JSONObject.parseObject(tokenJsonStr);
|
||||||
|
log.info("获取到的token返回json内容: {} ", tokenJson);
|
||||||
String token = tokenJson.get("access_token").toString();
|
String token = tokenJson.get("access_token").toString();
|
||||||
log.info("获取到用户token:{}", token);
|
log.info("获取到用户token:{}", token);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setConfig(String token){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送消息
|
* 推送消息
|
||||||
*
|
*
|
||||||
|
|
@ -60,18 +65,25 @@ public class WechatMsgUtils {
|
||||||
String sendMsgApi = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;
|
String sendMsgApi = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;
|
||||||
//整体参数map
|
//整体参数map
|
||||||
Map<String, Object> paramMap = new HashMap<String, Object>();
|
Map<String, Object> paramMap = new HashMap<String, Object>();
|
||||||
paramMap.put("touser", userOpenId);
|
paramMap.put("touser", "oLvgx6KxLrIy7i_O0pd15wUl2tAI");
|
||||||
|
paramMap.put("page", "index");
|
||||||
switch (mesType) {
|
switch (mesType) {
|
||||||
case TEXT:
|
case TEXT:
|
||||||
paramMap.put("template_id", "qfBBrpSq9-JFZFyPo0YRLp3SQTLkIYRFH7A65k6kSVM");
|
paramMap.put("template_id", "dnjTqmqr7OsnOXJR_SikVNNQOPSZLJ6pcDoysOksjNQ");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
paramMap.put("data", dataMap);
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
for (Map.Entry<String, Object> objectEntry : dataMap.entrySet()) {
|
||||||
|
JSONObject model = new JSONObject();
|
||||||
|
model.put("value", objectEntry.getValue());
|
||||||
|
jsonObject.put(objectEntry.getKey(), model);
|
||||||
|
}
|
||||||
|
paramMap.put("data", jsonObject);
|
||||||
String reposont = doGetPost(sendMsgApi, "POST", paramMap);
|
String reposont = doGetPost(sendMsgApi, "POST", paramMap);
|
||||||
log.info("reposont:{}", reposont);
|
log.info("reposont:{}", reposont);
|
||||||
log.info("用户:{}消息:{}推送返回谁:{}", userOpenId, dataMap.toString(),reposont);
|
log.info("用户:{}消息:{}推送返回谁:{}", userOpenId, paramMap.toString(),reposont);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue