|  | @ -12,12 +12,14 @@ import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.order.BusinessOrderDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.order.BusinessOrderRefundDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.ykyy.service.YkyyService;
 | 
	
		
			
				|  |  | import com.yihu.jw.order.dao.BusinessOrderDao;
 | 
	
	
		
			
				|  | @ -79,9 +81,97 @@ public class BusinessOrderService {
 | 
	
		
			
				|  |  |     private PrescriptionDao prescriptionDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private YkyyEntranceService ykyyEntranceService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionInfoDao prescriptionInfoDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * 处方下单
 | 
	
		
			
				|  |  |      * drugType	String	药品类型【1,到院 2、到商城】
 | 
	
		
			
				|  |  |      orderId	String	订单Id
 | 
	
		
			
				|  |  |      userId	String	用户Id
 | 
	
		
			
				|  |  |      Shopping	String	药品列表
 | 
	
		
			
				|  |  |      commodityName	String	药品名称
 | 
	
		
			
				|  |  |      commodityPrice	String	价格
 | 
	
		
			
				|  |  |      purchaseQuantity	String	数量
 | 
	
		
			
				|  |  |      DrugUnit	String	单位
 | 
	
		
			
				|  |  |      MedicineDoctor	String	医生Id
 | 
	
		
			
				|  |  |      [{"commodityName":"","commodityPrice":"","DrugUnit":"","MedicineDoctor":""}]
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<BusinessOrderDO> savePrescriptionOrder(String code) throws Exception {
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findById(code);
 | 
	
		
			
				|  |  |         List<BusinessOrderDO> businessOrderDOS = new ArrayList<>();
 | 
	
		
			
				|  |  |         if (wlyyPrescriptionDOS!=null&&wlyyPrescriptionDOS.size()!=0){
 | 
	
		
			
				|  |  |             WlyyPrescriptionDO wlyyPrescriptionDO = wlyyPrescriptionDOS.get(0);
 | 
	
		
			
				|  |  |             BusinessOrderDO businessOrderDO = new BusinessOrderDO();
 | 
	
		
			
				|  |  |             businessOrderDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             businessOrderDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |             businessOrderDO.setStatus(0);
 | 
	
		
			
				|  |  |             businessOrderDO.setOrderNo("VAS"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
 | 
	
		
			
				|  |  |             businessOrderDO.setUploadStatus(0);
 | 
	
		
			
				|  |  |             businessOrderDO.setPayType(1);
 | 
	
		
			
				|  |  |             businessOrderDO.setRelationCode(code);
 | 
	
		
			
				|  |  |             businessOrderDO.setRelationName("处方结算");
 | 
	
		
			
				|  |  |             businessOrderDO.setOrderCategory("4");
 | 
	
		
			
				|  |  |             businessOrderDO.setOrderType(4);
 | 
	
		
			
				|  |  |             businessOrderDO.setDoctor(wlyyPrescriptionDO.getDoctor());
 | 
	
		
			
				|  |  |             businessOrderDO.setPatient(wlyyPrescriptionDO.getPatientCode());
 | 
	
		
			
				|  |  |             businessOrderDO.setPatientName(wlyyPrescriptionDO.getPatientName());
 | 
	
		
			
				|  |  |             businessOrderDO.setPayPrice(wlyyPrescriptionDO.getDrugFee()*100);
 | 
	
		
			
				|  |  |             businessOrderDO.setDescription("处方结算");
 | 
	
		
			
				|  |  |             businessOrderDO = businessOrderDao.save(businessOrderDO);
 | 
	
		
			
				|  |  |             businessOrderDOS.add(businessOrderDO);
 | 
	
		
			
				|  |  |             wlyyPrescriptionDO.setOrderNo(businessOrderDO.getOrderNo());
 | 
	
		
			
				|  |  |             prescriptionDao.save(wlyyPrescriptionDO);
 | 
	
		
			
				|  |  |             JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(code);
 | 
	
		
			
				|  |  |             for (WlyyPrescriptionInfoDO prescriptionInfoDO:wlyyPrescriptionInfoDOS){
 | 
	
		
			
				|  |  |                 JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |                 //{"commodityName":"","commodityPrice":"","DrugUnit":"","MedicineDoctor":""}
 | 
	
		
			
				|  |  |                 object.put("commodityName",prescriptionInfoDO.getDrugName());
 | 
	
		
			
				|  |  |                 object.put("commodityPrice",prescriptionInfoDO.getPackRetprice());
 | 
	
		
			
				|  |  |                 object.put("DrugUnit",prescriptionInfoDO.getPackUnitName());
 | 
	
		
			
				|  |  |                 DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
 | 
	
		
			
				|  |  |                 String yktDoctor ="";
 | 
	
		
			
				|  |  |                 if (doctorMappingDO!=null&&StringUtils.isNoneBlank(doctorMappingDO.getMappingCode())){
 | 
	
		
			
				|  |  |                     String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |                     JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
 | 
	
		
			
				|  |  |                     if (jsonObject.getInteger("code")==200){
 | 
	
		
			
				|  |  |                         JSONArray array1 = jsonObject.getJSONArray("data");
 | 
	
		
			
				|  |  |                         if (array1!=null&&array1.size()!=0){
 | 
	
		
			
				|  |  |                             yktDoctor=array.getJSONObject(0).getString("DOCTORUSERID");
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     throw new Exception("医生映射表不存在!");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 object.put("MedicineDoctor",yktDoctor);
 | 
	
		
			
				|  |  |                 array.add(object);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
 | 
	
		
			
				|  |  |             String userId =null;
 | 
	
		
			
				|  |  |             if (patientDO!=null){
 | 
	
		
			
				|  |  |                 userId = patientDO.getUserId();
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String response = ykyyService.addOrder4Jkzl("1","",userId,array);
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(response)){
 | 
	
		
			
				|  |  |                 JSONObject jsonObject = JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |                 if (jsonObject.getString("code").equalsIgnoreCase("10000")){
 | 
	
		
			
				|  |  |                     String orderId = jsonObject.getString("orderId");
 | 
	
		
			
				|  |  |                     String orderNo = jsonObject.getString("orderNo");
 | 
	
		
			
				|  |  |                     businessOrderDO.setYkOrderId(orderId);
 | 
	
		
			
				|  |  |                     businessOrderDO.setYkOrderNo(orderNo);
 | 
	
		
			
				|  |  |                     businessOrderDao.save(businessOrderDO);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return businessOrderDOS;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * @param businessOrderDO
 |