|
|
@ -18,7 +18,9 @@ import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
@ -70,7 +72,7 @@ public class WechatRest { |
|
|
|
// openId代表一个唯一微信用户,即微信消息的接收人
|
|
|
|
// String openId="otnrM57kui-WCUmRtChhb1HguOgw";
|
|
|
|
//郭
|
|
|
|
String openId="otnrM544hxIgkMOfaDU8VpJhj_6k"; |
|
|
|
// String openId="otnrM544hxIgkMOfaDU8VpJhj_6k";
|
|
|
|
//刘
|
|
|
|
//String openId ="otnrM5ySvUo7ZZc4qafWzM9eyKBk";
|
|
|
|
//聂总
|
|
|
@ -82,22 +84,29 @@ public class WechatRest { |
|
|
|
//微信的基础accessToken
|
|
|
|
String accessToken=getAccessToken(APP_ID,APPSECRET); |
|
|
|
String wxUrl = WX_URL_MESSAGE_SEND.replace("ACCESS_TOKEN", accessToken); |
|
|
|
sendMag.put("thing3", new Template(csmCashReportVo.getCompanyName())); |
|
|
|
sendMag.put("time4", new Template(csmCashReportVo.getReportDate())); |
|
|
|
Map<String, String> miniprogram = new HashMap<>(); |
|
|
|
miniprogram.put("appid","wx11565021714ba796"); |
|
|
|
miniprogram.put("pagepath","pages/index/auditReport?companyName="+csmCashReportVo.getCompanyName()+"&dataDate="+csmCashReportVo.getDataDate()); |
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
//拼接base参数
|
|
|
|
Map<String, Object> sendBody = new HashMap<>(); |
|
|
|
sendBody.put("miniprogram",miniprogram); |
|
|
|
sendBody.put("touser", openId); // openId
|
|
|
|
sendBody.put("url", ""); // 点击模板信息跳转地址
|
|
|
|
sendBody.put("topcolor", "#FF0000"); // 顶色
|
|
|
|
sendBody.put("data", sendMag); // 模板参数
|
|
|
|
sendBody.put("template_id", templateId);// 模板Id
|
|
|
|
ResponseEntity<String> forEntity = restTemplate.postForEntity(wxUrl, sendBody, String.class); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(forEntity.getBody()); |
|
|
|
List<String> openIds=new ArrayList<>(); |
|
|
|
openIds.add("otnrM57kui-WCUmRtChhb1HguOgw"); |
|
|
|
openIds.add("otnrM544hxIgkMOfaDU8VpJhj_6k"); |
|
|
|
openIds.add("otnrM5ySvUo7ZZc4qafWzM9eyKBk"); |
|
|
|
JSONObject jsonObject=new JSONObject(); |
|
|
|
for(String openId:openIds){ |
|
|
|
sendMag.put("thing3", new Template(csmCashReportVo.getCompanyName())); |
|
|
|
sendMag.put("time4", new Template(csmCashReportVo.getReportDate())); |
|
|
|
Map<String, String> miniprogram = new HashMap<>(); |
|
|
|
miniprogram.put("appid","wx11565021714ba796"); |
|
|
|
miniprogram.put("pagepath","pages/index/auditReport?companyName="+csmCashReportVo.getCompanyName()+"&dataDate="+csmCashReportVo.getDataDate()); |
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
//拼接base参数
|
|
|
|
Map<String, Object> sendBody = new HashMap<>(); |
|
|
|
sendBody.put("miniprogram",miniprogram); |
|
|
|
sendBody.put("touser", openId); // openId
|
|
|
|
sendBody.put("url", ""); // 点击模板信息跳转地址
|
|
|
|
sendBody.put("topcolor", "#FF0000"); // 顶色
|
|
|
|
sendBody.put("data", sendMag); // 模板参数
|
|
|
|
sendBody.put("template_id", templateId);// 模板Id
|
|
|
|
ResponseEntity<String> forEntity = restTemplate.postForEntity(wxUrl, sendBody, String.class); |
|
|
|
jsonObject = JSONObject.parseObject(forEntity.getBody()); |
|
|
|
} |
|
|
|
// 0
|
|
|
|
String messageCode = jsonObject.getString("errcode"); |
|
|
|
// 2431260672639467520
|
|
|
|