|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.jw.care.dao.doorCoach.*;
|
|
import com.yihu.jw.care.dao.doorCoach.*;
|
|
import com.yihu.jw.care.service.consult.ConsultTeamService;
|
|
import com.yihu.jw.care.service.consult.ConsultTeamService;
|
|
import com.yihu.jw.care.service.message.BaseServiceNewsService;
|
|
import com.yihu.jw.care.service.message.BaseServiceNewsService;
|
|
|
|
import com.yihu.jw.care.service.pay.PayService;
|
|
import com.yihu.jw.care.util.MessageUtil;
|
|
import com.yihu.jw.care.util.MessageUtil;
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
@ -13,10 +14,14 @@ import com.yihu.jw.entity.base.im.ConsultTeamDo;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
|
|
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
|
|
import com.yihu.jw.entity.care.doorCoach.*;
|
|
import com.yihu.jw.entity.care.doorCoach.*;
|
|
|
|
import com.yihu.jw.entity.care.lifeCare.LifeCareFeeDetailDO;
|
|
|
|
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
|
|
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
|
|
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
|
|
|
|
import com.yihu.jw.entity.order.BusinessOrderDO;
|
|
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
|
|
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
|
|
import com.yihu.jw.im.dao.ConsultDao;
|
|
import com.yihu.jw.im.dao.ConsultDao;
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
|
import com.yihu.jw.order.dao.BusinessOrderDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
@ -94,6 +99,10 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
private SystemMessageDao systemMessageDao;
|
|
private SystemMessageDao systemMessageDao;
|
|
@Autowired
|
|
@Autowired
|
|
private BaseServiceNewsService serviceNewsService;
|
|
private BaseServiceNewsService serviceNewsService;
|
|
|
|
@Autowired
|
|
|
|
private PayService payService;
|
|
|
|
@Autowired
|
|
|
|
private BusinessOrderDao businessOrderDao;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建上门辅导服务工单
|
|
* 创建上门辅导服务工单
|
|
@ -126,12 +135,16 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
logger.error(failMsg);
|
|
logger.error(failMsg);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
JSONObject dispatcherJson = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
|
|
|
|
String hospital = jsonObjectParam.getJSONObject("hospital").get("code").toString();
|
|
|
|
orderDO.setHospital(hospital);
|
|
orderDO.setNumber(getRandomIntStr());
|
|
orderDO.setNumber(getRandomIntStr());
|
|
orderDO.setCreateTime(new Date());
|
|
orderDO.setCreateTime(new Date());
|
|
orderDO.setCreateUser(orderDO.getProxyPatient());
|
|
orderDO.setCreateUser(orderDO.getProxyPatient());
|
|
orderDO.setCreateUserName(orderDO.getProxyPatientName());
|
|
orderDO.setCreateUserName(orderDO.getProxyPatientName());
|
|
orderDO.setOrderInfo("0");
|
|
orderDO.setOrderInfo("0");
|
|
orderDO.setStatus(1);
|
|
|
|
|
|
orderDO.setStatus(0);//待付款
|
|
|
|
orderDO.setPayStatus(0);//待付款
|
|
// orderDO.setConclusionStatus(1);
|
|
// orderDO.setConclusionStatus(1);
|
|
|
|
|
|
if(StringUtils.isEmpty(orderDO.getPatient())){
|
|
if(StringUtils.isEmpty(orderDO.getPatient())){
|
|
@ -152,7 +165,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
|
|
|
//已取消的订单也可以申请
|
|
//已取消的订单也可以申请
|
|
boolean bool = baseDoorCoachOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
|
|
boolean bool = baseDoorCoachOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
|
|
new Integer[]{BaseDoorCoachOrderDO.Status.waitForSend.getType(),
|
|
|
|
|
|
new Integer[]{
|
|
|
|
BaseDoorCoachOrderDO.Status.waitForPay.getType(),
|
|
|
|
BaseDoorCoachOrderDO.Status.waitForSend.getType(),
|
|
BaseDoorCoachOrderDO.Status.waitForAccept.getType(),
|
|
BaseDoorCoachOrderDO.Status.waitForAccept.getType(),
|
|
BaseDoorCoachOrderDO.Status.waitForServe.getType(),
|
|
BaseDoorCoachOrderDO.Status.waitForServe.getType(),
|
|
BaseDoorCoachOrderDO.Status.accept.getType(),
|
|
BaseDoorCoachOrderDO.Status.accept.getType(),
|
|
@ -177,62 +192,25 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
orderDO.setServiceStatus("1");
|
|
orderDO.setServiceStatus("1");
|
|
this.save(orderDO);
|
|
this.save(orderDO);
|
|
result.put("orderId",orderDO.getId());
|
|
result.put("orderId",orderDO.getId());
|
|
//创建咨询
|
|
|
|
JSONObject successOrNot = null;
|
|
|
|
try {
|
|
|
|
successOrNot = consultTeamService.addDoorCoachServiceConsult(orderDO.getId());
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
String failMsg = "创建咨询时异常: " + e.getMessage();
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
|
logger.error(failMsg);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if (Integer.parseInt(successOrNot.get(ResponseContant.resultFlag).toString()) == ResponseContant.fail) {
|
|
|
|
return JSONObject.parseObject(successOrNot.toString());
|
|
|
|
}
|
|
|
|
ConsultTeamDo consultTeam = (ConsultTeamDo)successOrNot.get(ResponseContant.resultMsg);
|
|
|
|
|
|
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
|
result.put(ResponseContant.resultMsg, orderDO);
|
|
|
|
orderDO.setTotalFee(new BigDecimal(0));
|
|
//新增工单与服务项费用关联关系
|
|
//新增工单与服务项费用关联关系
|
|
if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,null)) {return result;}
|
|
if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,null)) {return result;}
|
|
|
|
|
|
JSONObject dispatcherJson = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
|
|
|
|
if (dispatcherJson.getInteger("resultFlag")==1){
|
|
|
|
List<Map<String,Object>> dispatcherInfoList = (List<Map<String, Object>>) dispatcherJson.get(ResponseContant.resultMsg);
|
|
|
|
for(Map<String,Object> map: dispatcherInfoList){
|
|
|
|
String dispatcher = map.get("code").toString();
|
|
|
|
BaseDoctorDO doctorVO = doctorDao.findById(dispatcher);
|
|
|
|
// 派单消息-首页
|
|
|
|
this.createMessage("新增居民预约服务申请","702","system","system", orderDO.getId(), dispatcher,doctorVO.getName() ,doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
|
|
|
|
// 派单-实时工单消息 430 居民提交工单申请-- 张三提交了服务工单12345678申请
|
|
|
|
this.createMessage("居民提交工单申请","730","system","system", orderDO.getId(), dispatcher,doctorVO.getName() ,doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务工单"+orderDO.getNumber()+"申请");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
|
result.put(ResponseContant.resultMsg, consultTeam);
|
|
|
|
//发送智能助手消息
|
|
|
|
sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
|
|
|
|
|
|
|
|
//发送 预约卡片信息(2201类型)
|
|
|
|
JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
|
|
|
|
orderInfoContent.put("re_msg_type",0);//居民预约
|
|
|
|
this.qucikSendIM(orderDO.getId(), "system", "智能助手", "2201", orderInfoContent.toJSONString());
|
|
|
|
|
|
|
|
if(StringUtils.isNoneBlank(orderDO.getDoctor())){
|
|
|
|
//服务医生修改,直接转派
|
|
|
|
BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
|
|
|
|
sendOrderToDoctor(orderDO.getId(),null,"system","系统",transDoctor.getId(),transDoctor.getName(),transDoctor.getJobTitleName());
|
|
|
|
}
|
|
|
|
|
|
|
|
serviceNewsService.addServiceNews(orderDO.getPatientName(),orderDO.getPatient(),"1",null);
|
|
|
|
|
|
|
|
|
|
//发起支付订单
|
|
|
|
payService.submitOrder(orderDO.getPatient(),"3",orderDO.getId(),orderDO.getTotalFee().doubleValue());
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
public JSONObject proxyCreate(String jsonData,String doctorCode) {
|
|
public JSONObject proxyCreate(String jsonData,String doctorCode) {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
|
|
//医养暂无该功能--屏蔽
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
|
result.put(ResponseContant.resultMsg, "暂无该功能");
|
|
|
|
return result;
|
|
|
|
/*
|
|
JSONObject jsonObjectParam;
|
|
JSONObject jsonObjectParam;
|
|
try {
|
|
try {
|
|
jsonObjectParam = JSONObject.parseObject(jsonData);
|
|
jsonObjectParam = JSONObject.parseObject(jsonData);
|
|
@ -244,8 +222,6 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BaseDoorCoachOrderDO orderDO = null;
|
|
BaseDoorCoachOrderDO orderDO = null;
|
|
try {
|
|
try {
|
|
orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), BaseDoorCoachOrderDO.class);
|
|
orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), BaseDoorCoachOrderDO.class);
|
|
@ -276,7 +252,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
if(StringUtils.isBlank(orderDO.getId())) {
|
|
if(StringUtils.isBlank(orderDO.getId())) {
|
|
//已取消的订单也可以申请
|
|
//已取消的订单也可以申请
|
|
boolean bool = baseDoorCoachOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
|
|
boolean bool = baseDoorCoachOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
|
|
new Integer[]{BaseDoorCoachOrderDO.Status.waitForAccept.getType(),
|
|
|
|
|
|
new Integer[]{BaseDoorCoachOrderDO.Status.waitForPay.getType(),
|
|
|
|
BaseDoorCoachOrderDO.Status.waitForAccept.getType(),
|
|
BaseDoorCoachOrderDO.Status.waitForServe.getType(),
|
|
BaseDoorCoachOrderDO.Status.waitForServe.getType(),
|
|
BaseDoorCoachOrderDO.Status.accept.getType(),
|
|
BaseDoorCoachOrderDO.Status.accept.getType(),
|
|
BaseDoorCoachOrderDO.Status.waitForSend.getType()
|
|
BaseDoorCoachOrderDO.Status.waitForSend.getType()
|
|
@ -311,36 +288,133 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
orderDO.setUpdateUser(orderDO.getProxyPatient());
|
|
orderDO.setUpdateUser(orderDO.getProxyPatient());
|
|
orderDO.setUpdateUserName(orderDO.getProxyPatientName());
|
|
orderDO.setUpdateUserName(orderDO.getProxyPatientName());
|
|
}
|
|
}
|
|
orderDO.setStatus(2);
|
|
|
|
|
|
orderDO.setStatus(0);//待付款
|
|
|
|
orderDO.setPayStatus(0);//待付款
|
|
orderDO.setType(3);
|
|
orderDO.setType(3);
|
|
orderDO.setDispatcherResponseTime(new Date());
|
|
orderDO.setDispatcherResponseTime(new Date());
|
|
this.save(orderDO);
|
|
this.save(orderDO);
|
|
result.put("orderId",orderDO.getId());
|
|
result.put("orderId",orderDO.getId());
|
|
|
|
orderDO.setTotalFee(new BigDecimal(0));
|
|
//新增工单与服务项费用关联关系
|
|
//新增工单与服务项费用关联关系
|
|
if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,doctorCode)) {return result;}
|
|
if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,doctorCode)) {return result;}
|
|
|
|
|
|
if("1".equals(orderDO.getShortcutType())){
|
|
|
|
//快捷的当前医生直接接单
|
|
|
|
try{
|
|
|
|
String sql = "SELECT d.job_title_code,d.job_title_name,o.org_level from base_doctor d,base_doctor_hospital h,base_org o " +
|
|
|
|
"WHERE d.id = h.doctor_code and h.org_code = o.id";
|
|
|
|
sql += " and d.id = '"+orderDO.getDoctor()+"'";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
// 给服务医生发接单消息
|
|
|
|
this.createMessage("服务工单待接单","707",orderDO.getProxyPatient(),orderDO.getProxyPatientName(), orderDO.getId(),orderDO.getDoctor(),orderDO.getDoctorName(), null,"您有新的服务工单,请前往处理");
|
|
|
|
//发送智能助手消息
|
|
|
|
sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
|
|
|
|
|
|
doorOrderService.acceptOrder1(orderDO.getId(), list.get(0).get("job_title_code").toString(),
|
|
|
|
list.get(0).get("job_title_name").toString(), Integer.valueOf(list.get(0).get("org_level").toString()));
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
//发起支付订单
|
|
|
|
BusinessOrderDO businessOrderDO = payService.submitOrder(orderDO.getPatient(),"3",orderDO.getId(),orderDO.getTotalFee().doubleValue());
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
|
return result;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
// 给服务医生发接单消息
|
|
|
|
this.createMessage("服务工单待接单","707",orderDO.getProxyPatient(),orderDO.getProxyPatientName(), orderDO.getId(),orderDO.getDoctor(),orderDO.getDoctorName(), null,"您有新的服务工单,请前往处理");
|
|
|
|
//发送智能助手消息
|
|
|
|
sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
|
|
|
|
|
|
//支付完成后开始上门辅导订单
|
|
|
|
public JSONObject payOrderAfter(String orderId) {
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
try {
|
|
|
|
BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderId);
|
|
|
|
if (businessOrderDO==null){
|
|
|
|
String failMsg = "未查询到该订单";
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
BaseDoorCoachOrderDO orderDO= baseDoorCoachOrderDao.findOne(orderId);
|
|
|
|
if (orderDO!=null){
|
|
|
|
orderDO.setPayStatus(1);
|
|
|
|
orderDO.setPayWay(1);
|
|
|
|
orderDO.setPayTime(new Date());
|
|
|
|
if (orderDO.getType()== 3){//医生代预约
|
|
|
|
orderDO.setStatus(2);//待接单
|
|
|
|
this.save(orderDO);
|
|
|
|
// 给服务医生发接单消息
|
|
|
|
this.createMessage("服务工单待接单","707",orderDO.getProxyPatient(),orderDO.getProxyPatientName(), orderDO.getId(),orderDO.getDoctor(),orderDO.getDoctorName(), null,"您有新的服务工单,请前往处理");
|
|
|
|
//发送智能助手消息
|
|
|
|
sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
|
|
|
|
}else {
|
|
|
|
//创建咨询
|
|
|
|
JSONObject successOrNot = null;
|
|
|
|
try {
|
|
|
|
successOrNot = consultTeamService.addDoorCoachServiceConsult(orderDO.getId());
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
String failMsg = "创建咨询时异常: " + e.getMessage();
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
|
logger.error(failMsg);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if (Integer.parseInt(successOrNot.get(ResponseContant.resultFlag).toString()) == ResponseContant.fail) {
|
|
|
|
return JSONObject.parseObject(successOrNot.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
ConsultTeamDo consultTeam = (ConsultTeamDo)successOrNot.get(ResponseContant.resultMsg);
|
|
|
|
//发送智能助手消息
|
|
|
|
sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
|
|
|
|
|
|
|
|
//发送 预约卡片信息(2201类型)
|
|
|
|
JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
|
|
|
|
orderInfoContent.put("re_msg_type",0);//居民预约
|
|
|
|
this.qucikSendIM(orderDO.getId(), "system", "智能助手", "2201", orderInfoContent.toJSONString());
|
|
|
|
|
|
|
|
if(StringUtils.isNoneBlank(orderDO.getDoctor())){
|
|
|
|
//期望服务医生存在,直接转派
|
|
|
|
BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
|
|
|
|
sendOrderToDoctor(orderDO.getId(),null,"system","系统",transDoctor.getId(),transDoctor.getName(),transDoctor.getJobTitleName());
|
|
|
|
}else {
|
|
|
|
orderDO.setStatus(1);//待派单
|
|
|
|
this.save(orderDO);
|
|
|
|
JSONObject dispatcherJson = queryDispatcherInfoByPatient(orderDO.getHospital());
|
|
|
|
if (dispatcherJson.getInteger("resultFlag")==1){
|
|
|
|
List<Map<String,Object>> dispatcherInfoList = (List<Map<String, Object>>) dispatcherJson.get(ResponseContant.resultMsg);
|
|
|
|
for(Map<String,Object> map: dispatcherInfoList){
|
|
|
|
String dispatcher = map.get("code").toString();
|
|
|
|
BaseDoctorDO doctorVO = doctorDao.findById(dispatcher);
|
|
|
|
// 派单消息-首页
|
|
|
|
this.createMessage("新增居民预约服务申请","702","system","system", orderDO.getId(), dispatcher,doctorVO.getName() ,doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
|
|
|
|
// 派单-实时工单消息 430 居民提交工单申请-- 张三提交了服务工单12345678申请
|
|
|
|
this.createMessage("居民提交工单申请","730","system","system", orderDO.getId(), dispatcher,doctorVO.getName() ,doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务工单"+orderDO.getNumber()+"申请");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
serviceNewsService.addServiceNews(orderDO.getPatientName(),orderDO.getPatient(),"1",null);
|
|
|
|
String failMsg = "success";
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
String failMsg = "工单不存在";
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
|
|
|
//退款后回调
|
|
|
|
public JSONObject refundOrderAfter(String orderId) {
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
try {
|
|
|
|
BaseDoorCoachOrderDO orderDO= baseDoorCoachOrderDao.findOne(orderId);
|
|
|
|
if (orderDO == null){
|
|
|
|
String failMsg = "工单不存在";
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
orderDO.setPayStatus(2);
|
|
|
|
this.save(orderDO);
|
|
|
|
String failMsg = "success";
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@ -783,48 +857,73 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
logger.error(failMsg);
|
|
logger.error(failMsg);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
if(orderDO.getStatus() > BaseDoorCoachOrderDO.Status.waitForServe.getType()){
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
|
String failMsg = "只有医生服务前的工单才可取消:," + orderId;
|
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
|
logger.error(failMsg);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
orderDO.setCancelType(type);
|
|
|
|
orderDO.setCancelTime(new Date());
|
|
|
|
orderDO.setCancelReason(reason);
|
|
|
|
if(!StringUtils.isEmpty(dispatcher)){
|
|
|
|
orderDO.setDoctor(dispatcher);
|
|
|
|
orderDO.setDoctorName(dispatcherName);
|
|
|
|
orderDO.setDispatcher(dispatcher);
|
|
|
|
orderDO.setDispatcherName(dispatcherName);
|
|
|
|
}
|
|
|
|
//如果是调度员取消,推送IM取消工单json消息,
|
|
|
|
if (StringUtils.isNotBlank(dispatcher)){
|
|
|
|
if (!consultTeamService.finishConsult(orderDO.getId(),orderDO.getPatient(),dispatcher,2)){
|
|
|
|
String failMsg = "咨询结束失败 无法取消工单";
|
|
|
|
|
|
if(type==2){//v0.5.1 患者仅未支付的订单能取消此时未正式开始工单,未创建咨询
|
|
|
|
if(orderDO.getStatus() != BaseDoorCoachOrderDO.Status.waitForPay.getType()){
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
|
|
|
String failMsg = "无法取消工单,已支付的工单需要到我的订单中进行申请退款," + orderId;
|
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
|
logger.error(failMsg);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
else {
|
|
|
|
if (!consultTeamService.finishConsult(orderDO.getId(),orderDO.getPatient(),orderDO.getPatient(),1)){
|
|
|
|
String failMsg = "咨询结束失败 无法取消工单";
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
|
|
|
}else{//调度员拒单,此时工单已支付抵达调度员
|
|
|
|
try {
|
|
|
|
if (orderDO.getStatus() > BaseDoorCoachOrderDO.Status.waitForPay.getType()&&1==orderDO.getPayWay()){
|
|
|
|
BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderDO.getId());
|
|
|
|
if (businessOrderDO!=null){
|
|
|
|
if (1 == businessOrderDO.getStatus()){
|
|
|
|
//退款流程
|
|
|
|
payService.orderRefund(businessOrderDO.getOrderNo(),"调度员拒单退款");
|
|
|
|
orderDO.setPayStatus(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//如果是调度员取消,推送IM取消工单json消息,
|
|
|
|
if (StringUtils.isNotBlank(dispatcher)){
|
|
|
|
if (!consultTeamService.finishConsult(orderDO.getId(),orderDO.getPatient(),dispatcher,2)){
|
|
|
|
String failMsg = "咨询结束失败 无法取消工单";
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!StringUtils.isEmpty(dispatcher)){
|
|
|
|
orderDO.setDoctor(dispatcher);
|
|
|
|
orderDO.setDoctorName(dispatcherName);
|
|
|
|
orderDO.setDispatcher(dispatcher);
|
|
|
|
orderDO.setDispatcherName(dispatcherName);
|
|
|
|
}
|
|
|
|
if(type == BaseDoorCoachOrderDO.CancelType.dispatcher.getType()){
|
|
|
|
messageUtil.updateDoorCoachMessage(orderDO,new String[]{"702","703","730"},"732",dispatcher,dispatcher);
|
|
|
|
}
|
|
|
|
else if(type == BaseDoorCoachOrderDO.CancelType.patient.getType()){ //居民取消,消息列表也应该不显示
|
|
|
|
messageUtil.updateDoorCoachMessage(orderDO,new String[]{"702","703","730"},"patientCancel",dispatcher,dispatcher);
|
|
|
|
}
|
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(orderId);
|
|
|
|
// 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
|
|
|
|
String first = "key1您好,您的上门预约订单已退回,点击查看原因";
|
|
|
|
BasePatientDO patient = patientDao.findById(orderDO.getPatient());
|
|
|
|
first = first.replace("key1", null != patient.getName() ? patient.getName() : "");
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
json.put("id", orderDO.getId());
|
|
|
|
List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
|
|
|
|
if (basePatientWechatDos.size()>0){
|
|
|
|
String openId = basePatientWechatDos.get(0).getOpenid();
|
|
|
|
messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",openId,first,null,null,2,json, DateUtil.dateToChineseDate(new Date()),"上门预约已取消","已取消");
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
String failMsg = "退款失败,无法取消工单:," + orderId;
|
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
orderDO.setCancelType(type);
|
|
|
|
orderDO.setCancelTime(new Date());
|
|
|
|
orderDO.setCancelReason(reason);
|
|
|
|
|
|
|
|
|
|
orderDO.setStatus(BaseDoorCoachOrderDO.Status.cancel.getType());
|
|
orderDO.setStatus(BaseDoorCoachOrderDO.Status.cancel.getType());
|
|
this.save(orderDO);
|
|
this.save(orderDO);
|
|
if(type == BaseDoorCoachOrderDO.CancelType.dispatcher.getType()){
|
|
|
|
messageUtil.updateDoorCoachMessage(orderDO,new String[]{"702","703","730"},"732",dispatcher,dispatcher);
|
|
|
|
}
|
|
|
|
else if(type == BaseDoorCoachOrderDO.CancelType.patient.getType()){ //居民取消,消息列表也应该不显示
|
|
|
|
messageUtil.updateDoorCoachMessage(orderDO,new String[]{"702","703","730"},"patientCancel",dispatcher,dispatcher);
|
|
|
|
}
|
|
|
|
|
|
|
|
//保存取消记录
|
|
//保存取消记录
|
|
BaseDoorCoachCancelLogDO cancelLogDO = new BaseDoorCoachCancelLogDO();
|
|
BaseDoorCoachCancelLogDO cancelLogDO = new BaseDoorCoachCancelLogDO();
|
|
@ -845,19 +944,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
JSONObject confirmInfoJson = new JSONObject();
|
|
JSONObject confirmInfoJson = new JSONObject();
|
|
confirmInfoJson.put("confirmInfo",confirmInfo);
|
|
confirmInfoJson.put("confirmInfo",confirmInfo);
|
|
this.orderWithConfirmLogAdd(result,confirmInfo,orderId);
|
|
this.orderWithConfirmLogAdd(result,confirmInfo,orderId);
|
|
ConsultDo consult = consultDao.queryByRelationCode(orderId);
|
|
|
|
// 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
|
|
|
|
String first = "key1您好,您的上门预约订单已退回,点击查看原因";
|
|
|
|
BasePatientDO patient = patientDao.findById(orderDO.getPatient());
|
|
|
|
first = first.replace("key1", null != patient.getName() ? patient.getName() : "");
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
json.put("id", orderDO.getId());
|
|
|
|
List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
|
|
|
|
if (basePatientWechatDos.size()>0){
|
|
|
|
String openId = basePatientWechatDos.get(0).getOpenid();
|
|
|
|
messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",openId,first,null,null,2,json, DateUtil.dateToChineseDate(new Date()),"上门预约已取消","已取消");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 工单状态变更记录
|
|
// 工单状态变更记录
|
|
BaseDoorCoachProcessLogDO processLogDO = new BaseDoorCoachProcessLogDO();
|
|
BaseDoorCoachProcessLogDO processLogDO = new BaseDoorCoachProcessLogDO();
|
|
@ -1039,6 +1126,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
if(null == totalFee){
|
|
if(null == totalFee){
|
|
totalFee = new BigDecimal(0);
|
|
totalFee = new BigDecimal(0);
|
|
}
|
|
}
|
|
|
|
|
|
//新增服务项
|
|
//新增服务项
|
|
int addNum = 0;
|
|
int addNum = 0;
|
|
//服务项费用
|
|
//服务项费用
|
|
@ -1099,7 +1187,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
order.setTotalFee(totalFee);
|
|
|
|
this.save(order);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@ -1154,6 +1243,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
Map<String, Integer> map = new HashMap<>();
|
|
Map<String, Integer> map = new HashMap<>();
|
|
Integer all = 0;
|
|
Integer all = 0;
|
|
|
|
Integer waitForPay = 0;//待付款
|
|
Integer waitForAccept = 0;//待接单
|
|
Integer waitForAccept = 0;//待接单
|
|
Integer waitForServe = 0;//待服务
|
|
Integer waitForServe = 0;//待服务
|
|
Integer served = 0;//已完成
|
|
Integer served = 0;//已完成
|
|
@ -1164,6 +1254,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
case "-1":
|
|
case "-1":
|
|
cancel += Integer.valueOf(tmp.get("num").toString()) ;
|
|
cancel += Integer.valueOf(tmp.get("num").toString()) ;
|
|
break;
|
|
break;
|
|
|
|
case "0":
|
|
|
|
waitForPay += Integer.valueOf(tmp.get("num").toString()) ;
|
|
|
|
break;
|
|
case "1":
|
|
case "1":
|
|
waitForAccept += Integer.valueOf(tmp.get("num").toString()) ;
|
|
waitForAccept += Integer.valueOf(tmp.get("num").toString()) ;
|
|
break;
|
|
break;
|
|
@ -1189,6 +1282,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
}
|
|
}
|
|
all = waitForAccept+waitForServe+served+cancel;
|
|
all = waitForAccept+waitForServe+served+cancel;
|
|
map.put("all",all);
|
|
map.put("all",all);
|
|
|
|
map.put("waitForPay",waitForAccept);
|
|
map.put("waitForAccept",waitForAccept);
|
|
map.put("waitForAccept",waitForAccept);
|
|
map.put("waitForServe",waitForServe);
|
|
map.put("waitForServe",waitForServe);
|
|
map.put("served",served);
|
|
map.put("served",served);
|
|
@ -1273,6 +1367,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
String statusName = "";
|
|
String statusName = "";
|
|
switch (statustemp){
|
|
switch (statustemp){
|
|
case -1:statusName="已取消";break;
|
|
case -1:statusName="已取消";break;
|
|
|
|
case 0:statusName="待付款";break;
|
|
case 1:statusName="待服务";break;
|
|
case 1:statusName="待服务";break;
|
|
case 2:statusName="待服务";break;
|
|
case 2:statusName="待服务";break;
|
|
case 3:statusName="待服务";break;
|
|
case 3:statusName="待服务";break;
|