|  | @ -13,13 +13,16 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.patient.BasePatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.doctor.BaseDoctorZsInfoDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.order.BusinessOrderDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
 | 
	
	
		
			
				|  | @ -32,12 +35,17 @@ import com.yihu.jw.hospital.prescription.dao.PrescriptionEmrDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.util.ConvertUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.util.MqSdkUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.util.WebserviceUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.order.dao.BusinessOrderDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.order.pay.ylz.YlzPayService;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.hospital.archive.ArchiveVO;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.hospital.prescription.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.PwdUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.http.HttpClientUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.idcard.IdCardUtil;
 | 
	
		
			
				|  |  | import com.ylzinfo.onepay.sdk.domain.ResponseParams;
 | 
	
		
			
				|  |  | import com.ylzinfo.onepay.sdk.domain.ext.RefundResult;
 | 
	
		
			
				|  |  | import net.sf.json.JSON;
 | 
	
		
			
				|  |  | import net.sf.json.JSONArray;
 | 
	
		
			
				|  |  | import net.sf.json.xml.XMLSerializer;
 | 
	
	
		
			
				|  | @ -99,7 +107,7 @@ public class EntranceService {
 | 
	
		
			
				|  |  |     private static String BS16018 = "BS16018";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //his退费接口
 | 
	
		
			
				|  |  |     private static String BS15021 = "BS15021";
 | 
	
		
			
				|  |  |     private static String BS15051 = "BS15051";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private String orgCode = "350211A1002";
 | 
	
		
			
				|  |  |     private String orgName = "350211A1002";
 | 
	
	
		
			
				|  | @ -144,6 +152,10 @@ public class EntranceService {
 | 
	
		
			
				|  |  |     private WlyyHttpLogDao wlyyHttpLogDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorRoleDao baseDoctorRoleDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BusinessOrderDao businessOrderDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientMedicareCardDao basePatientMedicareCardDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private static String entranceUrl="http://172.16.100.240:10023/mqsdk/";
 | 
	
		
			
				|  |  | //    private static String entranceUrl="http://localhost:10023/mqsdk/";
 | 
	
	
		
			
				|  | @ -1417,11 +1429,11 @@ public class EntranceService {
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray BS15021(String userId, String userName, String cardType, String cardNo, String accountType,String idNo,
 | 
	
		
			
				|  |  |     public JSONArray BS15051(String userId, String userName, String cardType, String cardNo, String accountType,String idNo,
 | 
	
		
			
				|  |  |                              String withdrawMode,String depositType,String ServiceType,String amount,String outRefundNo,
 | 
	
		
			
				|  |  |                              String outChargeNo,String origTraceNo,String traceSerial,String paydate,String notes,String tradeState,
 | 
	
		
			
				|  |  |                              String failReason,String failTime,String extra, boolean demoFlag) throws Exception {
 | 
	
		
			
				|  |  |         String fid = BS15021;
 | 
	
		
			
				|  |  |         String fid = BS15051;
 | 
	
		
			
				|  |  |         String resp = "";
 | 
	
		
			
				|  |  |         if (demoFlag) {
 | 
	
		
			
				|  |  |             resp = getJosnFileResullt(fid);
 | 
	
	
		
			
				|  | @ -1499,7 +1511,7 @@ public class EntranceService {
 | 
	
		
			
				|  |  |             WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setRequest(sbs.toString());
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setResponse(resp);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCode(BS15021);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCode(BS15051);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setName("预交金退款");
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             wlyyHttpLogDao.save(wlyyHttpLogDO);
 | 
	
	
		
			
				|  | @ -1507,6 +1519,144 @@ public class EntranceService {
 | 
	
		
			
				|  |  |         return ConvertUtil.convertListEnvelopInBodyRow(resp);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 门诊预缴金退费接口
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param outPatientId 门诊表id
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String hisRefund(String outPatientId) throws Exception {
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findById(outPatientId);
 | 
	
		
			
				|  |  |         if (outpatientDO == null){
 | 
	
		
			
				|  |  |             return "门诊信息表为空";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
 | 
	
		
			
				|  |  |         if (businessOrderDO == null){
 | 
	
		
			
				|  |  |             return "订单表为空";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByCode(outpatientDO.getCardNo());
 | 
	
		
			
				|  |  |         if (patientMedicareCardDO == null){
 | 
	
		
			
				|  |  |             return "患者卡包为空";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String userId = outpatientDO.getPatient();
 | 
	
		
			
				|  |  |         String userName = outpatientDO.getPatientName();
 | 
	
		
			
				|  |  |         String idNo = outpatientDO.getIdcard();
 | 
	
		
			
				|  |  |         String cardType = "03";
 | 
	
		
			
				|  |  |         if ("A_01".equals(patientMedicareCardDO.getType())){
 | 
	
		
			
				|  |  |             cardType = "01";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String cardNo =outpatientDO.getCardNo();
 | 
	
		
			
				|  |  |         String accountType = "01";
 | 
	
		
			
				|  |  |         String withdrawMode = "";
 | 
	
		
			
				|  |  |         String depositType = "";
 | 
	
		
			
				|  |  |         if (businessOrderDO.getPayType()==3){
 | 
	
		
			
				|  |  |             depositType = "WX_PUB";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String ServiceType = "04";
 | 
	
		
			
				|  |  |         String outChargeNo = "";
 | 
	
		
			
				|  |  |         String traceSerial = "";
 | 
	
		
			
				|  |  |         String tradeState="";
 | 
	
		
			
				|  |  |         String paydate ="";
 | 
	
		
			
				|  |  |         String notes = "";
 | 
	
		
			
				|  |  |         String failReason = "";
 | 
	
		
			
				|  |  |         String failTime = "";
 | 
	
		
			
				|  |  |         String extra = "";
 | 
	
		
			
				|  |  |         boolean demoFlag = false;
 | 
	
		
			
				|  |  |         String amount = businessOrderDO.getPayPrice().toString();
 | 
	
		
			
				|  |  |         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 | 
	
		
			
				|  |  |         String uuid = sdf.format(new Date()) + UUID.randomUUID().toString().replaceAll("-", "").substring(0, 4);
 | 
	
		
			
				|  |  |         String outRefundNo = uuid;
 | 
	
		
			
				|  |  |         String origTraceNo = businessOrderDO.getTraceNo();
 | 
	
		
			
				|  |  |         //调用his退费接口
 | 
	
		
			
				|  |  |         JSONArray jsonArray = BS15051(userId, userName, cardType, cardNo, accountType, idNo, withdrawMode, depositType, ServiceType, amount, outRefundNo, outChargeNo, origTraceNo, traceSerial, paydate, notes, tradeState, failReason, failTime, extra, demoFlag);
 | 
	
		
			
				|  |  |         YlzPayService ylzPayService = new YlzPayService();
 | 
	
		
			
				|  |  |         //调用易联众预缴金退款接口
 | 
	
		
			
				|  |  |         String refund = ylzPayService.refund(userId, userName, cardType, accountType, cardNo, idNo, amount, outChargeNo, userName, withdrawMode, traceSerial, outRefundNo,cardNo);
 | 
	
		
			
				|  |  |         JSONObject jsonObject = JSONObject.parseObject(refund);
 | 
	
		
			
				|  |  |         //获取调用易联众退费接口交易状态
 | 
	
		
			
				|  |  |         String respCode = jsonObject.getString("respCode");
 | 
	
		
			
				|  |  |         if (respCode.equals("000000")){
 | 
	
		
			
				|  |  |             tradeState = "succ";
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             tradeState = "fail";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         JSONArray resp = BS15051(userId, userName, cardType, cardNo, accountType, idNo, withdrawMode, depositType, ServiceType, amount, outRefundNo, outChargeNo, origTraceNo, traceSerial, paydate, notes, tradeState, failReason, failTime, extra, demoFlag);
 | 
	
		
			
				|  |  |         String result = resp.toString();
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 门诊预缴金退费接口(系统自动退费)
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param outPatientId 门诊表id
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String autoRefund(String outPatientId) throws Exception {
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findById(outPatientId);
 | 
	
		
			
				|  |  |         if (outpatientDO == null){
 | 
	
		
			
				|  |  |             return "门诊信息表为空";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
 | 
	
		
			
				|  |  |         if (businessOrderDO == null){
 | 
	
		
			
				|  |  |             return "订单表为空";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByCode(outpatientDO.getCardNo());
 | 
	
		
			
				|  |  |         if (patientMedicareCardDO == null){
 | 
	
		
			
				|  |  |             return "患者卡包为空";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String operatorId = "9690";
 | 
	
		
			
				|  |  |         String operatorName = "9690";
 | 
	
		
			
				|  |  |         String userName = outpatientDO.getPatientName();
 | 
	
		
			
				|  |  |         String idNo = outpatientDO.getIdcard();
 | 
	
		
			
				|  |  |         String cardType = "03";
 | 
	
		
			
				|  |  |         if ("A_01".equals(patientMedicareCardDO.getType())){
 | 
	
		
			
				|  |  |             cardType = "01";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String cardNo = patientMedicareCardDO.getMedicareNumber();
 | 
	
		
			
				|  |  |         String accountType = "01";
 | 
	
		
			
				|  |  |         String withdrawMode = "1";
 | 
	
		
			
				|  |  |         String depositType = "";
 | 
	
		
			
				|  |  |         if (businessOrderDO.getPayType()==3){
 | 
	
		
			
				|  |  |             depositType = "WX_PUB";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String ServiceType = "04";
 | 
	
		
			
				|  |  |         String outChargeNo = "";
 | 
	
		
			
				|  |  |         String traceSerial = "";
 | 
	
		
			
				|  |  |         String tradeState="";
 | 
	
		
			
				|  |  |         String paydate ="";
 | 
	
		
			
				|  |  |         String notes = "";
 | 
	
		
			
				|  |  |         String failReason = "";
 | 
	
		
			
				|  |  |         String failTime = "";
 | 
	
		
			
				|  |  |         String extra = "";
 | 
	
		
			
				|  |  |         boolean demoFlag = false;
 | 
	
		
			
				|  |  |         String amount = businessOrderDO.getPayPrice().toString();
 | 
	
		
			
				|  |  |         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 | 
	
		
			
				|  |  |         String uuid = sdf.format(new Date()) + UUID.randomUUID().toString().replaceAll("-", "").substring(0, 4);
 | 
	
		
			
				|  |  |         String outRefundNo = uuid;
 | 
	
		
			
				|  |  |         String origTraceNo = businessOrderDO.getTraceNo();
 | 
	
		
			
				|  |  |         //调用his退费接口
 | 
	
		
			
				|  |  |         JSONArray jsonArray = BS15051(operatorId, operatorName, cardType, cardNo, accountType, idNo, withdrawMode, depositType, ServiceType, amount, outRefundNo, outChargeNo, origTraceNo, traceSerial, paydate, notes, tradeState, failReason, failTime, extra, demoFlag);
 | 
	
		
			
				|  |  |         YlzPayService ylzPayService = new YlzPayService();
 | 
	
		
			
				|  |  |         //调用易联众预缴金退款接口
 | 
	
		
			
				|  |  |         String refund = ylzPayService.refund(operatorId, operatorName, cardType, accountType, cardNo, idNo, amount, outChargeNo, userName, withdrawMode, traceSerial, outRefundNo,cardNo);
 | 
	
		
			
				|  |  |         JSONObject jsonObject = JSONObject.parseObject(refund);
 | 
	
		
			
				|  |  |         //获取调用易联众退费接口交易状态
 | 
	
		
			
				|  |  |         String respCode = jsonObject.getString("respCode");
 | 
	
		
			
				|  |  |         if (respCode.equals("000000")){
 | 
	
		
			
				|  |  |             tradeState = "succ";
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             tradeState = "fail";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         JSONArray resp = BS15051(operatorId, operatorName, cardType, cardNo, accountType, idNo, withdrawMode, depositType, ServiceType, amount, outRefundNo, outChargeNo, origTraceNo, traceSerial, paydate, notes, tradeState, failReason, failTime, extra, demoFlag);
 | 
	
		
			
				|  |  |         String result = resp.toString();
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 检查检验
 | 
	
		
			
				|  |  |      *
 |