|
@ -14,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.wx.BasePatientWechatDo;
|
|
|
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.order.BusinessOrderDO;
|
|
|
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
|
|
|
import com.yihu.jw.im.dao.ConsultDao;
|
|
|
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.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
@ -97,6 +101,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
private BaseServiceNewsService serviceNewsService;
|
|
|
@Autowired
|
|
|
private PayService payService;
|
|
|
@Autowired
|
|
|
private BusinessOrderDao businessOrderDao;
|
|
|
|
|
|
/**
|
|
|
* 创建上门辅导服务工单
|
|
@ -137,7 +143,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
orderDO.setCreateUser(orderDO.getProxyPatient());
|
|
|
orderDO.setCreateUserName(orderDO.getProxyPatientName());
|
|
|
orderDO.setOrderInfo("0");
|
|
|
orderDO.setStatus(1);
|
|
|
orderDO.setStatus(0);//待付款
|
|
|
orderDO.setPayStatus(0);//待付款
|
|
|
// orderDO.setConclusionStatus(1);
|
|
|
|
|
|
if(StringUtils.isEmpty(orderDO.getPatient())){
|
|
@ -158,7 +165,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
|
|
|
//已取消的订单也可以申请
|
|
|
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.waitForServe.getType(),
|
|
|
BaseDoorCoachOrderDO.Status.accept.getType(),
|
|
@ -197,6 +206,11 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
@Transactional
|
|
|
public JSONObject proxyCreate(String jsonData,String doctorCode) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
//医养暂无该功能--屏蔽
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg, "暂无该功能");
|
|
|
return result;
|
|
|
/*
|
|
|
JSONObject jsonObjectParam;
|
|
|
try {
|
|
|
jsonObjectParam = JSONObject.parseObject(jsonData);
|
|
@ -238,7 +252,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
if(StringUtils.isBlank(orderDO.getId())) {
|
|
|
//已取消的订单也可以申请
|
|
|
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.accept.getType(),
|
|
|
BaseDoorCoachOrderDO.Status.waitForSend.getType()
|
|
@ -273,7 +288,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
orderDO.setUpdateUser(orderDO.getProxyPatient());
|
|
|
orderDO.setUpdateUserName(orderDO.getProxyPatientName());
|
|
|
}
|
|
|
orderDO.setStatus(2);
|
|
|
orderDO.setStatus(0);//待付款
|
|
|
orderDO.setPayStatus(0);//待付款
|
|
|
orderDO.setType(3);
|
|
|
orderDO.setDispatcherResponseTime(new Date());
|
|
|
this.save(orderDO);
|
|
@ -288,19 +304,31 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
|
|
|
|
|
|
//发起支付订单
|
|
|
payService.submitOrder(orderDO.getPatient(),"3",orderDO.getId(),orderDO.getTotalFee().doubleValue());
|
|
|
BusinessOrderDO businessOrderDO = payService.submitOrder(orderDO.getPatient(),"3",orderDO.getId(),orderDO.getTotalFee().doubleValue());
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
return result;
|
|
|
*/
|
|
|
}
|
|
|
|
|
|
//支付完成后开始上门辅导订单
|
|
|
public JSONObject payOrderAfter(String orderId) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
BaseDoorCoachOrderDO orderDO= baseDoorCoachOrderDao.findOne(orderId);
|
|
|
if (orderDO!=null){
|
|
|
serviceNewsService.addServiceNews(orderDO.getPatientName(),orderDO.getPatient(),"1",null);
|
|
|
if (orderDO.getPayWay()!=null){
|
|
|
if (orderDO.getType()==3){//医生代预约
|
|
|
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,"您有新的服务工单,请前往处理");
|
|
|
//发送智能助手消息
|
|
@ -336,6 +364,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
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);
|
|
@ -354,16 +384,36 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
}
|
|
|
}else {
|
|
|
String failMsg = "订单未支付";
|
|
|
}
|
|
|
else {
|
|
|
String failMsg = "工单不存在";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
else {
|
|
|
String failMsg = "工单不存在";
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//退款后回调
|
|
|
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;
|
|
|
}
|
|
@ -807,57 +857,73 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
logger.error(failMsg);
|
|
|
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;
|
|
|
}
|
|
|
//触发退款流程,退款失败时无法取消工单
|
|
|
try {
|
|
|
|
|
|
}catch (Exception e){
|
|
|
String failMsg = "退款失败,无法取消工单:," + orderId;
|
|
|
result.put(ResponseContant.resultMsg, 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.resultMsg,failMsg);
|
|
|
String failMsg = "无法取消工单,已支付的工单需要到我的订单中进行申请退款," + orderId;
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
logger.error(failMsg);
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
orderDO.setCancelType(type);
|
|
|
orderDO.setCancelTime(new Date());
|
|
|
orderDO.setCancelReason(reason);
|
|
|
|
|
|
|
|
|
orderDO.setStatus(BaseDoorCoachOrderDO.Status.cancel.getType());
|
|
|
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();
|
|
@ -878,19 +944,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
JSONObject confirmInfoJson = new JSONObject();
|
|
|
confirmInfoJson.put("confirmInfo",confirmInfo);
|
|
|
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();
|
|
@ -1133,7 +1187,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
order.setTotalFee(totalFee);
|
|
|
this.save(order);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@ -1188,6 +1243,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
Map<String, Integer> map = new HashMap<>();
|
|
|
Integer all = 0;
|
|
|
Integer waitForPay = 0;//待付款
|
|
|
Integer waitForAccept = 0;//待接单
|
|
|
Integer waitForServe = 0;//待服务
|
|
|
Integer served = 0;//已完成
|
|
@ -1198,6 +1254,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
case "-1":
|
|
|
cancel += Integer.valueOf(tmp.get("num").toString()) ;
|
|
|
break;
|
|
|
case "0":
|
|
|
waitForPay += Integer.valueOf(tmp.get("num").toString()) ;
|
|
|
break;
|
|
|
case "1":
|
|
|
waitForAccept += Integer.valueOf(tmp.get("num").toString()) ;
|
|
|
break;
|
|
@ -1223,6 +1282,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
}
|
|
|
all = waitForAccept+waitForServe+served+cancel;
|
|
|
map.put("all",all);
|
|
|
map.put("waitForPay",waitForAccept);
|
|
|
map.put("waitForAccept",waitForAccept);
|
|
|
map.put("waitForServe",waitForServe);
|
|
|
map.put("served",served);
|
|
@ -1307,6 +1367,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
|
|
|
String statusName = "";
|
|
|
switch (statustemp){
|
|
|
case -1:statusName="已取消";break;
|
|
|
case 0:statusName="待付款";break;
|
|
|
case 1:statusName="待服务";break;
|
|
|
case 2:statusName="待服务";break;
|
|
|
case 3:statusName="待服务";break;
|