|
@@ -88,12 +88,14 @@ public class WxController {
|
|
|
|
|
|
|
|
HttpEntity<Map<String, String>> requestM = new HttpEntity<>(paramCardNumber, headers);
|
|
HttpEntity<Map<String, String>> requestM = new HttpEntity<>(paramCardNumber, headers);
|
|
|
|
|
|
|
|
|
|
+ System.out.println("获取电话号码的access_token为:" + access_token);
|
|
|
|
|
+
|
|
|
String userInfoUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + access_token;
|
|
String userInfoUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + access_token;
|
|
|
ResponseEntity<String> responsem = restTemplate.postForEntity(userInfoUrl, requestM, String.class);
|
|
ResponseEntity<String> responsem = restTemplate.postForEntity(userInfoUrl, requestM, String.class);
|
|
|
|
|
|
|
|
JSONObject resPhoneInfo = JSON.parseObject(responsem.getBody());
|
|
JSONObject resPhoneInfo = JSON.parseObject(responsem.getBody());
|
|
|
|
|
|
|
|
- System.out.println(resPhoneInfo);
|
|
|
|
|
|
|
+ System.out.println("调用获取电话号码接口的返回值:" + resPhoneInfo);
|
|
|
|
|
|
|
|
JSONObject phoneInfo = resPhoneInfo.getJSONObject("phone_info");
|
|
JSONObject phoneInfo = resPhoneInfo.getJSONObject("phone_info");
|
|
|
String phoneNumber = phoneInfo.get("phoneNumber").toString();
|
|
String phoneNumber = phoneInfo.get("phoneNumber").toString();
|
|
@@ -106,7 +108,8 @@ public class WxController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 获取access_token
|
|
// 获取access_token
|
|
|
- @Scheduled(cron = "0 59 0/1 * * ?") // 每1小时59分,执行一次刷新access_token
|
|
|
|
|
|
|
+// @Scheduled(cron = "0 59 0/1 * * ?") // 每1小时59分,执行一次刷新access_token
|
|
|
|
|
+ @Scheduled(cron = "0 0/30 * * * ?")
|
|
|
public void getAccessToken() {
|
|
public void getAccessToken() {
|
|
|
// Map<String, String> token = new HashMap<>();
|
|
// Map<String, String> token = new HashMap<>();
|
|
|
// token.put("appid", appID);
|
|
// token.put("appid", appID);
|
|
@@ -124,7 +127,7 @@ public class WxController {
|
|
|
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
|
|
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
|
|
|
JSONObject objParam = JSON.parseObject(responseEntity.getBody());
|
|
JSONObject objParam = JSON.parseObject(responseEntity.getBody());
|
|
|
|
|
|
|
|
- System.out.println(objParam);
|
|
|
|
|
|
|
+ System.out.println("刷新access_token的返回值:" + objParam);
|
|
|
|
|
|
|
|
for (Map.Entry<String, Object> entry : objParam.entrySet()) {
|
|
for (Map.Entry<String, Object> entry : objParam.entrySet()) {
|
|
|
Object o = entry.getValue();
|
|
Object o = entry.getValue();
|
|
@@ -237,7 +240,20 @@ public class WxController {
|
|
|
|
|
|
|
|
// 申请项目
|
|
// 申请项目
|
|
|
JSONObject thing6 = new JSONObject();
|
|
JSONObject thing6 = new JSONObject();
|
|
|
- thing6.put("value", itemName);
|
|
|
|
|
|
|
+ if(itemName.length()>20){
|
|
|
|
|
+ // 截取前17位
|
|
|
|
|
+ int numChars = 17;
|
|
|
|
|
+ String cutitemName = itemName.substring(0,numChars);
|
|
|
|
|
+ // 前17位 + ... 共20字符,符合微信thing字段的要求
|
|
|
|
|
+ String enditemName = cutitemName + "...";
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("项目名称大于20字符,已切割,现为【" + enditemName + "】");
|
|
|
|
|
+
|
|
|
|
|
+ thing6.put("value", enditemName);
|
|
|
|
|
+
|
|
|
|
|
+ }else {
|
|
|
|
|
+ thing6.put("value", itemName);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 审核结果
|
|
// 审核结果
|
|
|
data.put("thing1", thing1);
|
|
data.put("thing1", thing1);
|