|  | @ -12,6 +12,7 @@ import com.yihu.jw.entity.base.wx.WxPayLogDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.wx.WxWechatDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
 | 
	
	
		
			
				|  | @ -21,6 +22,7 @@ import com.yihu.jw.entity.order.BusinessOrderDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.order.BusinessOrderRefundDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
 | 
	
	
		
			
				|  | @ -45,6 +47,7 @@ import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.wechat.WeiXinPayUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.ByteToInputStream;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.StringUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.BasePatientWechatDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WechatDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WxPayLogDao;
 | 
	
	
		
			
				|  | @ -125,6 +128,8 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
 | 
	
		
			
				|  |  |     private PrescriptionService prescriptionService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyChargeDictDao chargeDictDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyHttpLogDao wlyyHttpLogDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -243,7 +248,11 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
 | 
	
		
			
				|  |  |         businessOrderDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         businessOrderDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |         businessOrderDO.setStatus(0);
 | 
	
		
			
				|  |  |         businessOrderDO.setOrderNo("HLWYY"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(businessOrderDO.getDoctor())){
 | 
	
		
			
				|  |  |             businessOrderDO.setOrderNo("HLWYY"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             businessOrderDO.setOrderNo("HLWYYQD"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         businessOrderDO.setUploadStatus(0);
 | 
	
		
			
				|  |  |         businessOrderDO.setPayType(1);
 | 
	
		
			
				|  |  |         if (businessOrderDO.getOrderCategory().equalsIgnoreCase("1")){
 | 
	
	
		
			
				|  | @ -282,7 +291,10 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
 | 
	
		
			
				|  |  |         String orderType =businessOrderDO.getOrderType().toString();
 | 
	
		
			
				|  |  |         String payType="2";
 | 
	
		
			
				|  |  |         String patientTel = basePatientDO.getMobile();
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = null;
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(businessOrderDO.getDoctor())){
 | 
	
		
			
				|  |  |             doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String orderCatagrate = businessOrderDO.getOrderCategory();
 | 
	
		
			
				|  |  |         String pcCallBack=businessOrderDO.getPcCallbackUrl();
 | 
	
		
			
				|  |  |         String appCallBack = businessOrderDO.getAppCallbackUrl();
 | 
	
	
		
			
				|  | @ -299,13 +311,17 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
 | 
	
		
			
				|  |  |                     JSONArray array = jsonObject.getJSONArray("data");
 | 
	
		
			
				|  |  |                     if (array!=null&&array.size()!=0){
 | 
	
		
			
				|  |  |                         yktDoctor=array.getJSONObject(0).getString("DOCTORUSERID");
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         yktDoctor = "hlwyymrys001";
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             /*throw new Exception("医生映射表不存在!");*/
 | 
	
		
			
				|  |  |             yktDoctor="hlwyymrys001";
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                 yktDoctor="hlwyymrys001";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String remark = businessOrderDO.getRematk();
 | 
	
		
			
				|  |  |         if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
 | 
	
	
		
			
				|  | @ -313,6 +329,12 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             String response=ykyyService.addYktOrder(orderNo,patientId,orderAmout,remark,state,orderType,yktDoctor,payType,null,patientTel,orderCatagrate,pcCallBack,appCallBack);
 | 
	
		
			
				|  |  |             JSONObject object = JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |             WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setResponse(response);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setRequest("orderNo;"+orderNo+";"+"yktDoctor:"+yktDoctor);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setName("同步眼科通订单接口");
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             wlyyHttpLogDao.save(wlyyHttpLogDO);
 | 
	
		
			
				|  |  |             if (object.getInteger("code")==200){
 | 
	
		
			
				|  |  |                 businessOrderDO.setUploadStatus(1);
 | 
	
		
			
				|  |  |                 businessOrderDao.save(businessOrderDO);
 | 
	
	
		
			
				|  | @ -354,7 +376,10 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
 | 
	
		
			
				|  |  |         String orderType =businessOrderDO.getOrderType().toString();
 | 
	
		
			
				|  |  |         String payType="2";
 | 
	
		
			
				|  |  |         String patientTel = basePatientDO.getMobile();
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = null;
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(businessOrderDO.getDoctor())){
 | 
	
		
			
				|  |  |             doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String orderCatagrate = businessOrderDO.getOrderCategory();
 | 
	
		
			
				|  |  |         String pcCallBack=businessOrderDO.getPcCallbackUrl();
 | 
	
		
			
				|  |  |         String appCallBack = businessOrderDO.getAppCallbackUrl();
 | 
	
	
		
			
				|  | @ -364,6 +389,10 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
 | 
	
		
			
				|  |  |         String doctorId = "";
 | 
	
		
			
				|  |  |         if (doctorMappingDO!=null){
 | 
	
		
			
				|  |  |             doctorId = doctorMappingDO.getMappingCode();
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                 doctorId="hlwyymrys001";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("YKTCONTROL");
 | 
	
		
			
				|  |  |         if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
 | 
	
	
		
			
				|  | @ -881,19 +910,33 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
 | 
	
		
			
				|  |  |         String orderType =businessOrderDO.getOrderType().toString();
 | 
	
		
			
				|  |  |         String payType="2";
 | 
	
		
			
				|  |  |         String patientTel = basePatientDO.getMobile();
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = null;
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(businessOrderDO.getDoctor())){
 | 
	
		
			
				|  |  |             doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String orderCatagrate = businessOrderDO.getOrderCategory();
 | 
	
		
			
				|  |  |         String pcCallBack=businessOrderDO.getPcCallbackUrl();
 | 
	
		
			
				|  |  |         String appCallBack = businessOrderDO.getAppCallbackUrl();
 | 
	
		
			
				|  |  |         String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |         String yktDoctor ="";
 | 
	
		
			
				|  |  |         JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
 | 
	
		
			
				|  |  |         if (jsonObject.getInteger("code")==200){
 | 
	
		
			
				|  |  |             JSONArray array = jsonObject.getJSONArray("data");
 | 
	
		
			
				|  |  |             if (array!=null&&array.size()!=0){
 | 
	
		
			
				|  |  |                 yktDoctor=array.getJSONObject(0).getString("DOCTORUSERID");
 | 
	
		
			
				|  |  |         if (null!=doctorMappingDO){
 | 
	
		
			
				|  |  |             String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |             JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
 | 
	
		
			
				|  |  |             if (jsonObject.getInteger("code")==200){
 | 
	
		
			
				|  |  |                 JSONArray array = jsonObject.getJSONArray("data");
 | 
	
		
			
				|  |  |                 if (array!=null&&array.size()!=0){
 | 
	
		
			
				|  |  |                     yktDoctor=array.getJSONObject(0).getString("DOCTORUSERID");
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                         yktDoctor="hlwyymrys001";
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                 yktDoctor="hlwyymrys001";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = ykyyService.addYktOrder(orderNo,patientId,orderAmout,description,state,orderType,yktDoctor,payType,null,patientTel,orderCatagrate,pcCallBack,appCallBack);
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 |