|
@ -10,7 +10,9 @@ import com.yihu.wlyy.repository.prescription.PrescriptionDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
|
|
|
import com.ylzinfo.onepay.sdk.utils.StringUtil;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@ -26,26 +28,31 @@ public class PrescriptionNoticesService extends BaseService {
|
|
|
@Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
@Autowired
|
|
|
private DoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
|
|
|
@Autowired
|
|
|
private WeiXinOpenIdUtils weiXinOpenIdUtils;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 发送续方相关模板消息
|
|
|
* 发送续方相关模板消息(增加代理模式)
|
|
|
*
|
|
|
* @param openId 要发送对象居民的微信openID
|
|
|
* @param name 要发送对象居民姓名
|
|
|
* @param doctName 相关医生姓名(type=1审核医生、type=2 null、type=3配送健管师、type=4审核医生)
|
|
|
* @param ordenTime 订单完成时间(type=1 null、type=2 null、type=3 null、type=4 订单完成时间)
|
|
|
* @param type 1:续方审核通知 2:取药代办通知 3:配送中信息变更 4:已完成服务结果
|
|
|
* @param status 续方通知状态 0不通过 1通过 2调整处方 其余状态均为0
|
|
|
* @param url 带参数的模板跳转链接
|
|
|
* @param patient 要发送对象居民code
|
|
|
* @param doctName 相关医生姓名(type=1审核医生、type=2 null、type=3配送健管师、type=4审核医生)
|
|
|
* @param ordenTime 订单完成时间(type=1 null、type=2 null、type=3 null、type=4 订单完成时间)
|
|
|
* @param type 1:续方审核通知 2:取药代办通知 3:配送中信息变更 4:已完成服务结果
|
|
|
* @param status 续方通知状态 0不通过 1通过 2调整处方 其余状态均为0
|
|
|
* @param url 带参数的模板跳转链接
|
|
|
*/
|
|
|
public void sendMessages( String openId, String name, String doctName, String ordenTime, int type, int status, String url) throws Exception {
|
|
|
public void sendMessages(String patient, String doctName, String ordenTime, int type, int status, String url) throws Exception {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
JSONArray jsonArray = null;
|
|
|
|
|
|
Patient people = patientDao.findByCode(patient);
|
|
|
String openId = people.getOpenid();
|
|
|
String name = people.getName();
|
|
|
|
|
|
|
|
|
JSONObject sendJson = new JSONObject();
|
|
|
String first = "";
|
|
@ -62,6 +69,22 @@ public class PrescriptionNoticesService extends BaseService {
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, openId, name, sendJson);
|
|
|
//发送代理人
|
|
|
jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
|
|
|
if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
JSONObject j = jsonArray.getJSONObject(i);
|
|
|
Patient member = (Patient) j.get("member");
|
|
|
int start = url.indexOf("&toUser=");
|
|
|
int end = url.indexOf("&", start + 1);
|
|
|
String touser = url.substring(start, end);
|
|
|
url = url.replace(touser, "&toUser=" + member.getCode());
|
|
|
//name患者姓名
|
|
|
sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
|
|
|
sendJson.put("url", url);
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case 1:
|
|
|
first = name + "您好,你的续方申请医生已审核。";
|
|
@ -72,6 +95,22 @@ public class PrescriptionNoticesService extends BaseService {
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, openId, name, sendJson);
|
|
|
//发送代理人
|
|
|
jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
|
|
|
if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
JSONObject j = jsonArray.getJSONObject(i);
|
|
|
Patient member = (Patient) j.get("member");
|
|
|
int start = url.indexOf("&toUser=");
|
|
|
int end = url.indexOf("&", start + 1);
|
|
|
String touser = url.substring(start, end);
|
|
|
url = url.replace(touser, "&toUser=" + member.getCode());
|
|
|
//name患者姓名
|
|
|
sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
|
|
|
sendJson.put("url", url);
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case 2:
|
|
|
first = name + "您好,您的续方申请医生已修改处方清单并审核。";
|
|
@ -82,6 +121,22 @@ public class PrescriptionNoticesService extends BaseService {
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, openId, name, sendJson);
|
|
|
//发送代理人
|
|
|
jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
|
|
|
if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
JSONObject j = jsonArray.getJSONObject(i);
|
|
|
Patient member = (Patient) j.get("member");
|
|
|
int start = url.indexOf("&toUser=");
|
|
|
int end = url.indexOf("&", start + 1);
|
|
|
String touser = url.substring(start, end);
|
|
|
url = url.replace(touser, "&toUser=" + member.getCode());
|
|
|
//name患者姓名
|
|
|
sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
|
|
|
sendJson.put("url", url);
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
} else if (type == 2) {
|
|
@ -93,6 +148,22 @@ public class PrescriptionNoticesService extends BaseService {
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, openId, name, sendJson);
|
|
|
//发送代理人
|
|
|
jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
|
|
|
if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
JSONObject j = jsonArray.getJSONObject(i);
|
|
|
Patient member = (Patient) j.get("member");
|
|
|
int start = url.indexOf("&toUser=");
|
|
|
int end = url.indexOf("&", start + 1);
|
|
|
String touser = url.substring(start, end);
|
|
|
url = url.replace(touser, "&toUser=" + member.getCode());
|
|
|
//name患者姓名
|
|
|
sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
|
|
|
sendJson.put("url", url);
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, member.getOpenid(), name, sendJson);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (type == 3) {
|
|
|
first = name + "您好,您的续方订单配送员" + doctName + "已顺利取药,续方状态变更为配送中。";
|
|
@ -104,6 +175,22 @@ public class PrescriptionNoticesService extends BaseService {
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 10, openId, name, sendJson);
|
|
|
//发送代理人
|
|
|
jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
|
|
|
if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
JSONObject j = jsonArray.getJSONObject(i);
|
|
|
Patient member = (Patient) j.get("member");
|
|
|
int start = url.indexOf("&toUser=");
|
|
|
int end = url.indexOf("&", start + 1);
|
|
|
String touser = url.substring(start, end);
|
|
|
url = url.replace(touser, "&toUser=" + member.getCode());
|
|
|
//name患者姓名
|
|
|
sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
|
|
|
sendJson.put("url", url);
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 10, member.getOpenid(), name, sendJson);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (type == 4) {
|
|
|
first = name + ",您好!您的续方订单已成功配送。";
|
|
@ -115,6 +202,22 @@ public class PrescriptionNoticesService extends BaseService {
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", url);//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 20, openId, name, sendJson);
|
|
|
//发送代理人
|
|
|
jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
|
|
|
if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
JSONObject j = jsonArray.getJSONObject(i);
|
|
|
Patient member = (Patient) j.get("member");
|
|
|
int start = url.indexOf("&toUser=");
|
|
|
int end = url.indexOf("&", start + 1);
|
|
|
String touser = url.substring(start, end);
|
|
|
url = url.replace(touser, "&toUser=" + member.getCode());
|
|
|
//name患者姓名
|
|
|
sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
|
|
|
sendJson.put("url", url);
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 20, member.getOpenid(), name, sendJson);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|