|  | @ -126,6 +126,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
 | 
	
		
			
				|  |  |             logger.error(failMsg);
 | 
	
		
			
				|  |  |             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.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         orderDO.setCreateUser(orderDO.getProxyPatient());
 | 
	
	
		
			
				|  | @ -177,56 +180,12 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
 | 
	
		
			
				|  |  |         orderDO.setServiceStatus("1");
 | 
	
		
			
				|  |  |         this.save(orderDO);
 | 
	
		
			
				|  |  |         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);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //新增工单与服务项费用关联关系
 | 
	
		
			
				|  |  |         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);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -244,8 +203,6 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         BaseDoorCoachOrderDO orderDO = null;
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), BaseDoorCoachOrderDO.class);
 | 
	
	
		
			
				|  | @ -319,28 +276,81 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
 | 
	
		
			
				|  |  |         //新增工单与服务项费用关联关系
 | 
	
		
			
				|  |  |         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);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 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();
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         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();
 | 
	
		
			
				|  |  |         BaseDoorCoachOrderDO orderDO= baseDoorCoachOrderDao.findOne(orderId);
 | 
	
		
			
				|  |  |         if (orderDO!=null){
 | 
	
		
			
				|  |  |             if (orderDO.getPayWay()!=null){
 | 
	
		
			
				|  |  |                 if (orderDO.getType()==3){//医生代预约
 | 
	
		
			
				|  |  |                     // 给服务医生发接单消息
 | 
	
		
			
				|  |  |                     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 {
 | 
	
		
			
				|  |  |                         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);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             String failMsg = "工单不存在";
 | 
	
		
			
				|  |  |             result.put(ResponseContant.resultFlag, ResponseContant.fail);
 | 
	
		
			
				|  |  |             result.put(ResponseContant.resultMsg, failMsg);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         result.put(ResponseContant.resultFlag, ResponseContant.success);
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -790,6 +800,15 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
 | 
	
		
			
				|  |  |             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);
 |