|
|
@@ -3,6 +3,7 @@ package com.usoftchina.smartschool.wechat.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.github.kevinsawicki.http.HttpRequest;
|
|
|
import com.usoftchina.smartschool.base.Result;
|
|
|
+import com.usoftchina.smartschool.utils.StringUtils;
|
|
|
import com.usoftchina.smartschool.wechat.po.MessageInfo;
|
|
|
import com.usoftchina.smartschool.wechat.service.WxPushService;
|
|
|
import com.usoftchina.smartschool.wechat.wxUtils.ObjectUtils;
|
|
|
@@ -29,7 +30,7 @@ public class WxPushServiceImpl implements WxPushService{
|
|
|
if (ObjectUtils.isNotEmpty(openid)){
|
|
|
String json="{\"touser\":\""+openid+"\","
|
|
|
+ "\"template_id\":\""+templateId+"\","
|
|
|
- + "\"url\":\""+""+url+""+"\","
|
|
|
+ + "\"url\":\""+""+ (StringUtils.isEmpty(url) ? "" : url) +""+"\","
|
|
|
+ "\"data\":{"
|
|
|
+ "\"first\":{\"value\":\""+title+"\",\"color\":\"#173177\"},"
|
|
|
+ "\"keyword1\":{\"value\":\""+keyword1+"\",\"color\":\"#173177\"},"
|
|
|
@@ -37,6 +38,7 @@ public class WxPushServiceImpl implements WxPushService{
|
|
|
+ "\"keyword3\":{\"value\":\""+keyword3+"\",\"color\":\"#173177\"},"
|
|
|
+ "\"keyword4\":{\"value\":\""+keyword4+"\",\"color\":\"#173177\"},"
|
|
|
+ "\"remark\":{\"value\":\""+remark+"\",\"color\":\"#173177\"}}}";
|
|
|
+ logger.info("send to wechat, data={}", json);
|
|
|
HashMap<String, Object> params=new HashMap<>();
|
|
|
params.put("appid", appId);
|
|
|
params.put("secret", secret);
|
|
|
@@ -77,7 +79,7 @@ public class WxPushServiceImpl implements WxPushService{
|
|
|
if (ObjectUtils.isNotEmpty(info.getTouser())){
|
|
|
String json="{\"touser\":\"" + info.getTouser() + "\","
|
|
|
+ "\"template_id\":\"" + info.getTemplateId() + "\","
|
|
|
- + "\"url\":\"" + "" + info.getUrl() + "" + "\","
|
|
|
+ + "\"url\":\"" + "" + (StringUtils.isEmpty(info.getUrl()) ? "" : info.getUrl()) + "" + "\","
|
|
|
+ "\"data\":{"
|
|
|
+ "\"first\":{\"value\":\"" + info.getTitle() + "\","
|
|
|
+"\"color\":\"#173177\"},"
|
|
|
@@ -87,7 +89,7 @@ public class WxPushServiceImpl implements WxPushService{
|
|
|
+ "\"keyword4\":{\"value\":\"" + info.getKeyword4() + "\",\"color\":\"#173177\"},"
|
|
|
+ "\"keyword5\":{\"value\":\"" + info.getKeyword5() + "\",\"color\":\"#173177\"},"
|
|
|
+ "\"remark\":{\"value\":\"" + info.getRemark() + "\",\"color\":\"#173177\"}}}";
|
|
|
-
|
|
|
+ logger.info("send to wechat, data={}", json);
|
|
|
HashMap<String, Object> params=new HashMap<>();
|
|
|
params.put("appid", info.getAppId());
|
|
|
params.put("secret", info.getSecret());
|