|
@ -0,0 +1,119 @@
|
|
|
package com.yihu.wlyy.service.app.prescription;
|
|
|
|
|
|
import antlr.StringUtils;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.Prescription;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.ylzinfo.onepay.sdk.utils.StringUtil;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* Created by Reece on 2017/8/3.
|
|
|
*/
|
|
|
@Service
|
|
|
public class PrescriptionNoticesService extends BaseService {
|
|
|
@Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
@Autowired
|
|
|
private DoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 发送续方相关模板消息
|
|
|
*
|
|
|
* @param accessToken
|
|
|
* @param doctor 医生code
|
|
|
* @param patient 居民code
|
|
|
* @param type 1:续方审核通知 2:取药代办通知 3:配送中信息变更 4:已完成服务结果
|
|
|
* @param status 续方通知状态 0不通过 1通过 2调整处方 其余状态均为0
|
|
|
*/
|
|
|
public void sendMessages(String accessToken, String doctor, String patient, String checkDoctor,String ordenTime,int type, int status) throws Exception{
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
Doctor doct = doctorDao.findByCode(doctor);
|
|
|
Patient people = patientDao.findByCode(patient);
|
|
|
|
|
|
if (StringUtil.isEmpty(people.getOpenid())){
|
|
|
return;
|
|
|
}
|
|
|
String doctName = doct.getName();
|
|
|
String name = people.getName();
|
|
|
String openId = people.getOpenid();
|
|
|
JSONObject sendJson = new JSONObject();
|
|
|
String first = "";
|
|
|
String remark = "";
|
|
|
|
|
|
if (type == 1) {
|
|
|
switch (status) {
|
|
|
case 0:
|
|
|
first = name+ "您好,你的续方申请医生已审核。";
|
|
|
remark = "您可点击消息查看详情,修改续方信息后重新提交。";
|
|
|
sendJson.put("keyword1", "审核不通过");
|
|
|
sendJson.put("keyword2", doctName);
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
pushMsgTask.putWxMsg(accessToken, 19, openId, name, sendJson);
|
|
|
break;
|
|
|
case 1:
|
|
|
first = name + "您好,你的续方申请医生已审核。";
|
|
|
remark = "您可点击消息查看详情并完成支付。";
|
|
|
sendJson.put("keyword1", "审核通过");
|
|
|
sendJson.put("keyword2", doctName);
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
pushMsgTask.putWxMsg(accessToken, 19, openId, name, sendJson);
|
|
|
break;
|
|
|
case 2:
|
|
|
first = name + "您好,您的续方申请医生已修改处方清单并审核。";
|
|
|
remark = "您可点击消息查看详情并完成支付。";
|
|
|
sendJson.put("keyword1", "审核通过");
|
|
|
sendJson.put("keyword2", doctName);
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
pushMsgTask.putWxMsg(accessToken, 19, openId, name, sendJson);
|
|
|
break;
|
|
|
}
|
|
|
} else if (type == 2) {
|
|
|
first = name+ "您好,您的续方订单已完成配药,请尽快致社区医院取药。";
|
|
|
remark = "";
|
|
|
sendJson.put("keyword1", "续方订单取药");
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
pushMsgTask.putWxMsg(accessToken, 11, openId, name, sendJson);
|
|
|
}
|
|
|
if (type == 3) {
|
|
|
first = name+ "您好,您的续方订单配送员"+doctName+"已顺利取药,续方状态变更为配送中。";
|
|
|
remark = "您可点击消息查看详情。";
|
|
|
sendJson.put("keyword1", doctName);
|
|
|
sendJson.put("keyword2", dateFormat.format(new Date()));
|
|
|
sendJson.put("keyword3", "续方状态");
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
pushMsgTask.putWxMsg(accessToken, 10, openId, name, sendJson);
|
|
|
}
|
|
|
if (type == 4) {
|
|
|
first = name+ ",您好!您的续方订单已成功配送。";
|
|
|
remark = "感谢您的使用。";
|
|
|
sendJson.put("keyword1", "续方申请");
|
|
|
sendJson.put("keyword2", checkDoctor);//审核医生姓名
|
|
|
sendJson.put("keyword3", ordenTime);//订单完成时间
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
pushMsgTask.putWxMsg(accessToken, 20, openId, name, sendJson);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|