|
@@ -10,6 +10,8 @@ import java.util.UUID;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.jfinal.kit.HashKit;
|
|
import com.jfinal.kit.HashKit;
|
|
import com.jfinal.weixin.sdk.api.ApiConfigKit;
|
|
import com.jfinal.weixin.sdk.api.ApiConfigKit;
|
|
import com.jfinal.weixin.sdk.api.ApiResult;
|
|
import com.jfinal.weixin.sdk.api.ApiResult;
|
|
@@ -31,8 +33,8 @@ public class WeixinService {
|
|
*/
|
|
*/
|
|
public enum PUSH_TYPE {
|
|
public enum PUSH_TYPE {
|
|
|
|
|
|
- //远程诊断患者支付推送
|
|
|
|
- REMOTE_DIAGNOSIS_PATIENT_PAY(1);
|
|
|
|
|
|
+ //远程诊断患者支付推送,远程诊断完成,远程诊断取消,远程诊断退款完成
|
|
|
|
+ REMOTE_DIAGNOSIS_PATIENT_PAY(1),REMOTE_DIAGNOSIS_FINISH(2),REMOTE_DIAGNOSIS_CANCEL(3),REMOTE_DIAGNOSIS_REFUND(4);
|
|
|
|
|
|
private int pushType;
|
|
private int pushType;
|
|
|
|
|
|
@@ -127,17 +129,57 @@ public class WeixinService {
|
|
/*
|
|
/*
|
|
* 发送模板消息
|
|
* 发送模板消息
|
|
*/
|
|
*/
|
|
- public ApiResult sendTemplateMsg(String openid, String url, String userName,Integer pushtype) {
|
|
|
|
- PUSH_TYPE dType2 = null;
|
|
|
|
|
|
+ public ApiResult sendTemplateMsg(String openid, String content, Integer pushtype) {
|
|
|
|
+ PUSH_TYPE type = null;
|
|
ApiResult apiResult = null;
|
|
ApiResult apiResult = null;
|
|
for (PUSH_TYPE xxxEnum : PUSH_TYPE.values()) {
|
|
for (PUSH_TYPE xxxEnum : PUSH_TYPE.values()) {
|
|
if (xxxEnum.getPushType() == pushtype) {
|
|
if (xxxEnum.getPushType() == pushtype) {
|
|
- dType2 = xxxEnum;
|
|
|
|
|
|
+ type = xxxEnum;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- switch (dType2) {
|
|
|
|
|
|
+ switch (type) {
|
|
case REMOTE_DIAGNOSIS_PATIENT_PAY:
|
|
case REMOTE_DIAGNOSIS_PATIENT_PAY:
|
|
- apiResult = sendRemoteDiagnosisPatientPayMsg(openid,url,userName);
|
|
|
|
|
|
+ {
|
|
|
|
+ String urlString = "http://wechat.client.pacsonline.cn/#/pay?openid="+openid;
|
|
|
|
+ JSONObject contentJson = JSON.parseObject(content);
|
|
|
|
+ String out_trade_no = contentJson.getString("out_trade_no");
|
|
|
|
+ String name = contentJson.getString("name");
|
|
|
|
+ String total_fee = contentJson.getString("total_fee");
|
|
|
|
+ apiResult = sendRemoteDiagnosisPatientPayMsg(openid, urlString, out_trade_no, name, total_fee);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case REMOTE_DIAGNOSIS_FINISH:
|
|
|
|
+ {
|
|
|
|
+ String urlString = "http://wechat.client.pacsonline.cn/#/pay?openid="+openid;
|
|
|
|
+ JSONObject contentJson = JSON.parseObject(content);
|
|
|
|
+ String out_trade_no = contentJson.getString("out_trade_no");
|
|
|
|
+ String name = contentJson.getString("name");
|
|
|
|
+ String total_fee = contentJson.getString("total_fee");
|
|
|
|
+ apiResult = sendRemoteDiagnosisFinishMsg(openid, urlString,name);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case REMOTE_DIAGNOSIS_CANCEL:
|
|
|
|
+ {
|
|
|
|
+ String urlString = "http://wechat.client.pacsonline.cn/#/pay?openid="+openid;
|
|
|
|
+ JSONObject contentJson = JSON.parseObject(content);
|
|
|
|
+ String out_trade_no = contentJson.getString("out_trade_no");
|
|
|
|
+ String name = contentJson.getString("name");
|
|
|
|
+ String total_fee = contentJson.getString("total_fee");
|
|
|
|
+ apiResult = sendRemoteDiagnosisCancelMsg(openid, urlString, out_trade_no);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case REMOTE_DIAGNOSIS_REFUND:
|
|
|
|
+ {
|
|
|
|
+ String urlString = "http://wechat.client.pacsonline.cn/#/pay?openid="+openid;
|
|
|
|
+ JSONObject contentJson = JSON.parseObject(content);
|
|
|
|
+ String out_trade_no = contentJson.getString("out_trade_no");
|
|
|
|
+ String name = contentJson.getString("name");
|
|
|
|
+ String total_fee = contentJson.getString("total_fee");
|
|
|
|
+ apiResult = sendRemoteDiagnosisRefundMsg(openid, urlString, out_trade_no, total_fee);
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|
|
@@ -146,7 +188,7 @@ public class WeixinService {
|
|
return apiResult;
|
|
return apiResult;
|
|
}
|
|
}
|
|
|
|
|
|
- public ApiResult sendRemoteDiagnosisPatientPayMsg(String openid, String url, String userName) {
|
|
|
|
|
|
+ public ApiResult sendRemoteDiagnosisPatientPayMsg(String openid, String url, String out_trade_no, String name, String total_fee) {
|
|
String str = " {\n" +
|
|
String str = " {\n" +
|
|
" \"touser\":\""+openid+"\",\n" +
|
|
" \"touser\":\""+openid+"\",\n" +
|
|
" \"template_id\":\"VZ0Y3yj6N6187EggHdtdUZYcdQ-UycrjKCZKjqLn60Y\",\n" +
|
|
" \"template_id\":\"VZ0Y3yj6N6187EggHdtdUZYcdQ-UycrjKCZKjqLn60Y\",\n" +
|
|
@@ -154,27 +196,27 @@ public class WeixinService {
|
|
" \"topcolor\":\"#FF0000\",\n" +
|
|
" \"topcolor\":\"#FF0000\",\n" +
|
|
" \"data\":{\n" +
|
|
" \"data\":{\n" +
|
|
" \"first\": {\n" +
|
|
" \"first\": {\n" +
|
|
- " \"value\":\"您好,你的费用信息情况如下:\",\n" +
|
|
|
|
|
|
+ " \"value\":\"您好,你的远程诊断费用信息情况如下:\",\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" },\n" +
|
|
" },\n" +
|
|
" \"keyword1\":{\n" +
|
|
" \"keyword1\":{\n" +
|
|
- " \"value\":\"订单num\",\n" +
|
|
|
|
|
|
+ " \"value\":\""+out_trade_no+"\",\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" },\n" +
|
|
" },\n" +
|
|
" \"keyword2\":{\n" +
|
|
" \"keyword2\":{\n" +
|
|
- " \"value\":\"张三\",\n" +
|
|
|
|
|
|
+ " \"value\":\""+name+"\",\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" },\n" +
|
|
" },\n" +
|
|
" \"keyword3\":{\n" +
|
|
" \"keyword3\":{\n" +
|
|
- " \"value\":\"日期\",\n" +
|
|
|
|
|
|
+ " \"value\":\""+getNowDateString()+"\",\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" },\n" +
|
|
" },\n" +
|
|
" \"keyword4\":{\n" +
|
|
" \"keyword4\":{\n" +
|
|
- " \"value\":\"1元\",\n" +
|
|
|
|
|
|
+ " \"value\":\""+total_fee+"元"+"\",\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" },\n" +
|
|
" },\n" +
|
|
" \"keyword5\":{\n" +
|
|
" \"keyword5\":{\n" +
|
|
- " \"value\":\"付费\",\n" +
|
|
|
|
|
|
+ " \"value\":\"远程诊断专家咨询费\",\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" \"color\":\"#173177\"\n" +
|
|
" },\n" +
|
|
" },\n" +
|
|
" \"remark\":{\n" +
|
|
" \"remark\":{\n" +
|
|
@@ -186,6 +228,107 @@ public class WeixinService {
|
|
ApiResult apiResult = TemplateMsgApi.send(str);
|
|
ApiResult apiResult = TemplateMsgApi.send(str);
|
|
return apiResult;
|
|
return apiResult;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public ApiResult sendRemoteDiagnosisFinishMsg(String openid, String url, String name) {
|
|
|
|
+ String str = " {\n" +
|
|
|
|
+ " \"touser\":\""+openid+"\",\n" +
|
|
|
|
+ " \"template_id\":\"5wIAbbe28AGQRW7NsPkCla8g_vfiimVOOXJ3Jd-rjBA\",\n" +
|
|
|
|
+ " \"url\":\""+url+"\",\n" +
|
|
|
|
+ " \"topcolor\":\"#FF0000\",\n" +
|
|
|
|
+ " \"data\":{\n" +
|
|
|
|
+ " \"first\": {\n" +
|
|
|
|
+ " \"value\":\"您好,你的远程诊断已完成\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"keyword1\":{\n" +
|
|
|
|
+ " \"value\":\""+name+"\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"keyword2\":{\n" +
|
|
|
|
+ " \"value\":\"远程诊断咨询意见单\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"keyword3\":{\n" +
|
|
|
|
+ " \"value\":\""+getNowDateString()+"\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"remark\":{\n" +
|
|
|
|
+ " \"value\":\"祝您早日康复。\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " }\n" +
|
|
|
|
+ " }\n" +
|
|
|
|
+ " }";
|
|
|
|
+ ApiResult apiResult = TemplateMsgApi.send(str);
|
|
|
|
+ return apiResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public ApiResult sendRemoteDiagnosisCancelMsg(String openid, String url, String out_trade_no) {
|
|
|
|
+ String str = " {\n" +
|
|
|
|
+ " \"touser\":\""+openid+"\",\n" +
|
|
|
|
+ " \"template_id\":\"HuPWL7THvmw0J8svYAWo7_1_AKXwYO46RH2DbgMRGHU\",\n" +
|
|
|
|
+ " \"url\":\""+url+"\",\n" +
|
|
|
|
+ " \"topcolor\":\"#FF0000\",\n" +
|
|
|
|
+ " \"data\":{\n" +
|
|
|
|
+ " \"first\": {\n" +
|
|
|
|
+ " \"value\":\"您好,你的远程诊断申请已取消\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"keyword1\":{\n" +
|
|
|
|
+ " \"value\":\""+out_trade_no+"\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"keyword2\":{\n" +
|
|
|
|
+ " \"value\":\"取消申请\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"remark\":{\n" +
|
|
|
|
+ " \"value\":\"谢谢您的使用。\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " }\n" +
|
|
|
|
+ " }\n" +
|
|
|
|
+ " }";
|
|
|
|
+ ApiResult apiResult = TemplateMsgApi.send(str);
|
|
|
|
+ return apiResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public ApiResult sendRemoteDiagnosisRefundMsg(String openid, String url, String out_trade_no, String total_fee) {
|
|
|
|
+ String str = " {\n" +
|
|
|
|
+ " \"touser\":\""+openid+"\",\n" +
|
|
|
|
+ " \"template_id\":\"VZ0Y3yj6N6187EggHdtdUZYcdQ-UycrjKCZKjqLn60Y\",\n" +
|
|
|
|
+ " \"url\":\""+url+"\",\n" +
|
|
|
|
+ " \"topcolor\":\"#FF0000\",\n" +
|
|
|
|
+ " \"data\":{\n" +
|
|
|
|
+ " \"first\": {\n" +
|
|
|
|
+ " \"value\":\"您好,你的远程诊断已完成退费\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"keyword1\":{\n" +
|
|
|
|
+ " \"value\":\""+out_trade_no+"\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"keyword2\":{\n" +
|
|
|
|
+ " \"value\":\""+total_fee+"元"+"\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"keyword3\":{\n" +
|
|
|
|
+ " \"value\":\""+getNowDateString()+"\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " },\n" +
|
|
|
|
+ " \"remark\":{\n" +
|
|
|
|
+ " \"value\":\"谢谢您的使用。\",\n" +
|
|
|
|
+ " \"color\":\"#173177\"\n" +
|
|
|
|
+ " }\n" +
|
|
|
|
+ " }\n" +
|
|
|
|
+ " }";
|
|
|
|
+ ApiResult apiResult = TemplateMsgApi.send(str);
|
|
|
|
+ return apiResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getNowDateString() {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
|
|
|
|
+ String time = sdf.format(new Date());
|
|
|
|
+ return time;
|
|
|
|
+ }
|
|
public static String getParamByUrl(String url, String name) {
|
|
public static String getParamByUrl(String url, String name) {
|
|
url += "&";
|
|
url += "&";
|
|
String pattern = "(\\?|&){1}#{0,1}" + name + "=[a-zA-Z0-9]*(&{1})";
|
|
String pattern = "(\\?|&){1}#{0,1}" + name + "=[a-zA-Z0-9]*(&{1})";
|