Commit c6ed804d authored by gaoyingwei's avatar gaoyingwei

修改 订阅消息发送

parent 7fb73698
...@@ -41,6 +41,7 @@ spring.cache.redis.cache-null-values=true ...@@ -41,6 +41,7 @@ spring.cache.redis.cache-null-values=true
# 发送小程序订阅信息url # 发送小程序订阅信息url
wechat.sendMessageUrl=https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token= wechat.sendMessageUrl=https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=
wechat.miniprogramState=developer
wx.app-id=wx16cfb2d12e4ab57c wx.app-id=wx16cfb2d12e4ab57c
wx.app-secret=37556072ad536b8d9d6cf5fb638fec88 wx.app-secret=37556072ad536b8d9d6cf5fb638fec88
......
...@@ -41,6 +41,7 @@ spring.cache.redis.cache-null-values=true ...@@ -41,6 +41,7 @@ spring.cache.redis.cache-null-values=true
# 发送小程序订阅信息url # 发送小程序订阅信息url
wechat.sendMessageUrl=https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token= wechat.sendMessageUrl=https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=
wechat.miniprogramState=developer
wx.app-id=wx16cfb2d12e4ab57c wx.app-id=wx16cfb2d12e4ab57c
wx.app-secret=37556072ad536b8d9d6cf5fb638fec88 wx.app-secret=37556072ad536b8d9d6cf5fb638fec88
......
...@@ -18,6 +18,7 @@ import okhttp3.OkHttpClient; ...@@ -18,6 +18,7 @@ import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
import org.apache.commons.lang3.StringUtils;
import org.nutz.http.Header; import org.nutz.http.Header;
import org.nutz.http.Http; import org.nutz.http.Http;
import org.nutz.json.Json; import org.nutz.json.Json;
...@@ -49,6 +50,8 @@ public class WeixinService { ...@@ -49,6 +50,8 @@ public class WeixinService {
private Logger logger = LoggerFactory.getLogger(WeixinService.class); private Logger logger = LoggerFactory.getLogger(WeixinService.class);
@Value("${wechat.sendMessageUrl}") @Value("${wechat.sendMessageUrl}")
private String sendMessageUrl; private String sendMessageUrl;
@Value("${wechat.miniprogramState}")
private String miniprogramState;
public void updateWeixinToken() { public void updateWeixinToken() {
HttpUtil.trustEveryone(); HttpUtil.trustEveryone();
...@@ -293,6 +296,12 @@ public class WeixinService { ...@@ -293,6 +296,12 @@ public class WeixinService {
else else
result = "审核不通过"; result = "审核不通过";
String finalResult = result; String finalResult = result;
String remarks = "";
if (StringUtils.isNotBlank(receipt.getRemarks())) {
remarks = receipt.getRemarks();
} else
remarks = "审核通过";
String finalRemarks = remarks;
messageContent.put("phrase2", new HashMap<String, Object>() {{ messageContent.put("phrase2", new HashMap<String, Object>() {{
put("value", finalResult); put("value", finalResult);
}}); }});
...@@ -300,7 +309,7 @@ public class WeixinService { ...@@ -300,7 +309,7 @@ public class WeixinService {
put("value", date); put("value", date);
}}); }});
messageContent.put("thing3", new HashMap<String, Object>() {{ messageContent.put("thing3", new HashMap<String, Object>() {{
put("value", receipt.getRemarks()); put("value", finalRemarks);
}}); }});
JSONObject messageContentJson = new JSONObject(messageContent); JSONObject messageContentJson = new JSONObject(messageContent);
//构造订阅消息 //构造订阅消息
...@@ -311,7 +320,8 @@ public class WeixinService { ...@@ -311,7 +320,8 @@ public class WeixinService {
body.put("template_id", "Z1GyWI2Q9m6VZna-AeIGvvKCQzhxHWBbBVe8UY49fbA");//填写你的模板ID body.put("template_id", "Z1GyWI2Q9m6VZna-AeIGvvKCQzhxHWBbBVe8UY49fbA");//填写你的模板ID
body.put("data", messageContentJson); body.put("data", messageContentJson);
body.put("lang", "zh_CN"); body.put("lang", "zh_CN");
// body.put("miniprogram_state", "formal"); body.put("page", "my/myIntegral/receiptRecord/index");
body.put("miniprogram_state", miniprogramState);//跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
org.nutz.http.Response response = Http.post3(url, Json.toJson(body), Header.create(params), 3000); org.nutz.http.Response response = Http.post3(url, Json.toJson(body), Header.create(params), 3000);
if (response.isOK()) { if (response.isOK()) {
......
...@@ -43,3 +43,4 @@ spring.cache.redis.cache-null-values=true ...@@ -43,3 +43,4 @@ spring.cache.redis.cache-null-values=true
# 发送小程序订阅信息url # 发送小程序订阅信息url
wechat.sendMessageUrl=https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token= wechat.sendMessageUrl=https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=
wechat.miniprogramState=developer
...@@ -43,3 +43,4 @@ spring.cache.redis.cache-null-values=true ...@@ -43,3 +43,4 @@ spring.cache.redis.cache-null-values=true
# 发送小程序订阅信息url # 发送小程序订阅信息url
wechat.sendMessageUrl=https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token= wechat.sendMessageUrl=https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=
wechat.miniprogramState=developer
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment