|
@ -6,8 +6,11 @@ import com.yihu.wlyy.wechat.util.WeiXinMessageReplyUtils;
|
|
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
|
|
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
@ -21,6 +24,8 @@ import java.util.*;
|
|
@Component
|
|
@Component
|
|
public class WeiXinEventProcess {
|
|
public class WeiXinEventProcess {
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(WeiXinEventProcess.class);
|
|
|
|
|
|
@Value("${wechat.wechat_base_url}")
|
|
@Value("${wechat.wechat_base_url}")
|
|
private String wechat_base_url;
|
|
private String wechat_base_url;
|
|
@Value("${wechat.appId}")
|
|
@Value("${wechat.appId}")
|
|
@ -29,6 +34,9 @@ public class WeiXinEventProcess {
|
|
private String serverUrl;
|
|
private String serverUrl;
|
|
@Autowired
|
|
@Autowired
|
|
private PushMsgTask pushMsgTask;
|
|
private PushMsgTask pushMsgTask;
|
|
|
|
@Autowired
|
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 微信推送事件处理
|
|
* 微信推送事件处理
|
|
@ -313,7 +321,38 @@ public class WeiXinEventProcess {
|
|
json.put("type", 20);
|
|
json.put("type", 20);
|
|
//模板消息json串
|
|
//模板消息json串
|
|
result = json.toString();
|
|
result = json.toString();
|
|
} else {
|
|
|
|
|
|
}else if (StringUtils.isNotEmpty(eventKey) && (("wechat_ehc").equals(eventKey)) ||
|
|
|
|
eventKey.startsWith("qrscene_wechat_ehc")) {
|
|
|
|
// 配置信息
|
|
|
|
Properties systemConf = SystemConf.getInstance().getSystemProperties();
|
|
|
|
// 图文信息
|
|
|
|
List<Map<String, String>> articles = new ArrayList<>();
|
|
|
|
|
|
|
|
Map<String, String> article = new HashMap<>();
|
|
|
|
// 图文URL
|
|
|
|
String url = systemConf.getProperty("doctor_subscribe_url");
|
|
|
|
// 图文消息图片URL
|
|
|
|
String picUrl = systemConf.getProperty("doctor_qrcode_pic_url");
|
|
|
|
// URL设置服务器URL、AppId
|
|
|
|
url = url.replace("{server}", wechat_base_url)
|
|
|
|
.replace("{appId}", appId);
|
|
|
|
//图片地址
|
|
|
|
picUrl = picUrl.replace("{server}", serverUrl);
|
|
|
|
|
|
|
|
article.put("Url", url);
|
|
|
|
article.put("Title", "欢迎关注厦门i健康,快来签约家庭医生吧~");
|
|
|
|
article.put("Description", "请点击查看家庭签约");
|
|
|
|
article.put("PicUrl", picUrl);
|
|
|
|
|
|
|
|
articles.add(article);
|
|
|
|
|
|
|
|
//设置共有的图文消息
|
|
|
|
setUrlItems(articles, systemConf);
|
|
|
|
|
|
|
|
setWifi(message.get("FromUserName"),articles,systemConf);
|
|
|
|
// 构建回复消息XML
|
|
|
|
result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
|
|
|
|
}else {
|
|
// 配置信息
|
|
// 配置信息
|
|
Properties systemConf = SystemConf.getInstance().getSystemProperties();
|
|
Properties systemConf = SystemConf.getInstance().getSystemProperties();
|
|
// 图文信息
|
|
// 图文信息
|
|
@ -346,6 +385,35 @@ public class WeiXinEventProcess {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void setWifi(String openid,List<Map<String, String>> articles, Properties systemConf){
|
|
|
|
try{
|
|
|
|
String sql = "SELECT t.id FROM wlyy_patient t WHERE t.openid = '"+openid+"'";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
logger.info("setWifi_openid:"+openid+" openid_listSize:"+list.size());
|
|
|
|
if(list!=null&&list.size()>0) {
|
|
|
|
Map<String, String> articleConsult = new HashMap<>();
|
|
|
|
// 图文URL
|
|
|
|
String urlConsult = systemConf.getProperty("patient_wifi_url");
|
|
|
|
// 图文消息图片URL
|
|
|
|
String picUrlConsult = systemConf.getProperty("patient_wifi_pic_url");
|
|
|
|
// URL设置服务器URL、AppId
|
|
|
|
urlConsult = urlConsult.replace("{server}", wechat_base_url)
|
|
|
|
.replace("{appId}", appId);
|
|
|
|
//图片地址
|
|
|
|
picUrlConsult = picUrlConsult.replace("{server}", serverUrl);
|
|
|
|
|
|
|
|
articleConsult.put("Url", urlConsult);
|
|
|
|
articleConsult.put("Title", "共享wifi");
|
|
|
|
articleConsult.put("Description", "共享wifi");
|
|
|
|
articleConsult.put("PicUrl", picUrlConsult);
|
|
|
|
|
|
|
|
articles.add(articleConsult);
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
logger.info(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 设置微信公共的图文消息
|
|
* 设置微信公共的图文消息
|
|
*
|
|
*
|
|
@ -555,6 +623,37 @@ public class WeiXinEventProcess {
|
|
json.put("type", 20);
|
|
json.put("type", 20);
|
|
//模板消息json串
|
|
//模板消息json串
|
|
result = json.toString();
|
|
result = json.toString();
|
|
|
|
}else if (StringUtils.isNotEmpty(eventKey) && (("wechat_hslq").equals(eventKey)) ||
|
|
|
|
eventKey.startsWith("qrscene_wechat_hslq")) {
|
|
|
|
// 配置信息
|
|
|
|
Properties systemConf = SystemConf.getInstance().getSystemProperties();
|
|
|
|
// 图文信息
|
|
|
|
List<Map<String, String>> articles = new ArrayList<>();
|
|
|
|
|
|
|
|
Map<String, String> article = new HashMap<>();
|
|
|
|
// 图文URL
|
|
|
|
String url = systemConf.getProperty("doctor_subscribe_url");
|
|
|
|
// 图文消息图片URL
|
|
|
|
String picUrl = systemConf.getProperty("doctor_qrcode_pic_url");
|
|
|
|
// URL设置服务器URL、AppId
|
|
|
|
url = url.replace("{server}", wechat_base_url)
|
|
|
|
.replace("{appId}", appId);
|
|
|
|
//图片地址
|
|
|
|
picUrl = picUrl.replace("{server}", serverUrl);
|
|
|
|
|
|
|
|
article.put("Url", url);
|
|
|
|
article.put("Title", "欢迎关注厦门i健康,快来签约家庭医生吧~");
|
|
|
|
article.put("Description", "请点击查看家庭签约");
|
|
|
|
article.put("PicUrl", picUrl);
|
|
|
|
|
|
|
|
articles.add(article);
|
|
|
|
|
|
|
|
//设置共有的图文消息
|
|
|
|
setUrlItems(articles, systemConf);
|
|
|
|
|
|
|
|
setWifi(message.get("FromUserName"),articles,systemConf);
|
|
|
|
// 构建回复消息XML
|
|
|
|
result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
|
|
}
|
|
}
|
|
|
|
|
|
return result;
|
|
return result;
|