|
@ -23,6 +23,7 @@ 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.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;
|
|
@ -36,6 +37,7 @@ 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.dao.BusinessOrderRefundDao;
|
|
|
import com.yihu.jw.order.pay.ylz.YlzPayService;
|
|
|
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
|
|
|
import com.yihu.jw.restmodel.hospital.archive.ArchiveVO;
|
|
@ -111,6 +113,8 @@ public class EntranceService {
|
|
|
|
|
|
//查询待扣费处方信息
|
|
|
private static String BS15036 = "BS15036";
|
|
|
@Autowired
|
|
|
private YlzPayService ylzPayService;
|
|
|
|
|
|
private String orgCode = "350211A1002";
|
|
|
private String orgName = "350211A1002";
|
|
@ -126,6 +130,8 @@ public class EntranceService {
|
|
|
private String serverUrl;
|
|
|
@Value("${fastDFS.fastdfs_file_url}")
|
|
|
private String fastdfs_file_url;
|
|
|
@Autowired
|
|
|
private BusinessOrderRefundDao orderRefundDao;
|
|
|
|
|
|
@Autowired
|
|
|
private DictHospitalDeptDao dictHospitalDeptDao;
|
|
@ -1449,67 +1455,68 @@ public class EntranceService {
|
|
|
//查询信息拼接
|
|
|
sbs.append("<MsgInfo><endNum>20000</endNum><Msg/>");
|
|
|
if (StringUtils.isNotBlank(userId)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"userId\" splice=\"and\" value=\"'" + userId + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"userId\" splice=\"and\" value=\"" + userId + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(userName)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"userName\" splice=\"and\" value=\"'" + userName + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"userName\" splice=\"and\" value=\"" + userName + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(cardType)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"cardType\" splice=\"and\" value=\"'" + cardType + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"cardType\" splice=\"and\" value=\"" + cardType + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(cardNo)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"cardNo\" splice=\"and\" value=\"'" + cardNo + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"cardNo\" splice=\"and\" value=\"" + cardNo + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(accountType)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"accountType\" splice=\"and\" value=\"'" + accountType + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"accountType\" splice=\"and\" value=\"" + accountType + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(idNo)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"idNo\" splice=\"and\" value=\"'" + idNo + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"idNo\" splice=\"and\" value=\"" + idNo + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(withdrawMode)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"withdrawMode\" splice=\"and\" value=\"'" + withdrawMode + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"withdrawMode\" splice=\"and\" value=\"" + withdrawMode + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(depositType)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"depositType\" splice=\"and\" value=\"'" + depositType + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"depositType\" splice=\"and\" value=\"" + depositType + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(ServiceType)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"ServiceType\" splice=\"and\" value=\"'" + ServiceType + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"ServiceType\" splice=\"and\" value=\"" + ServiceType + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(amount)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"amount\" splice=\"and\" value=\"'" + amount + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"amount\" splice=\"and\" value=\"" + amount + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(outRefundNo)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"outRefundNo\" splice=\"and\" value=\"'" + outRefundNo + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"outRefundNo\" splice=\"and\" value=\"" + outRefundNo + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(outChargeNo)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"outChargeNo\" splice=\"and\" value=\"'" + outChargeNo + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"outChargeNo\" splice=\"and\" value=\"" + outChargeNo + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(origTraceNo)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"origTraceNo\" splice=\"and\" value=\"'" + origTraceNo + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"origTraceNo\" splice=\"and\" value=\"" + origTraceNo + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(traceSerial)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"traceSerial\" splice=\"and\" value=\"'" + traceSerial + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"traceSerial\" splice=\"and\" value=\"" + traceSerial + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(paydate)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"paydate\" splice=\"and\" value=\"'" + paydate + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"paydate\" splice=\"and\" value=\"" + paydate + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(notes)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"notes\" splice=\"and\" value=\"'" + notes + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"notes\" splice=\"and\" value=\"" + notes + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(tradeState)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"tradeState\" splice=\"and\" value=\"'" + tradeState + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"tradeState\" splice=\"and\" value=\"" + tradeState + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(failReason)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"failReason\" splice=\"and\" value=\"'" + failReason + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"failReason\" splice=\"and\" value=\"" + failReason + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(failTime)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"failTime\" splice=\"and\" value=\"'" + failTime + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"failTime\" splice=\"and\" value=\"" + failTime + "\"/>");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(extra)) {
|
|
|
sbs.append("<query compy=\"=\" item=\"extra\" splice=\"and\" value=\"'" + extra + "'\"/>");
|
|
|
sbs.append("<query compy=\"=\" item=\"extra\" splice=\"and\" value=\"" + extra + "\"/>");
|
|
|
}
|
|
|
sbs.append("<startNum>1</startNum></MsgInfo></ESBEntry>");
|
|
|
resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
|
|
|
logger.info("resp:"+resp);
|
|
|
resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
|
|
|
WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
|
|
|
wlyyHttpLogDO.setRequest(sbs.toString());
|
|
@ -1530,21 +1537,28 @@ public class EntranceService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
|
|
|
public String hisRefund(String outPatientId) throws Exception {
|
|
|
public JSONArray hisRefund(String outPatientId,boolean sys) throws Exception {
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findById(outPatientId);
|
|
|
if (outpatientDO == null){
|
|
|
return "门诊信息表为空";
|
|
|
throw new Exception("门诊信息表为空");
|
|
|
}
|
|
|
BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
|
|
|
if (businessOrderDO == null){
|
|
|
return "订单表为空";
|
|
|
throw new Exception("订单表为空");
|
|
|
}
|
|
|
PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByCode(outpatientDO.getCardNo());
|
|
|
if (patientMedicareCardDO == null){
|
|
|
return "患者卡包为空";
|
|
|
throw new Exception("患者卡包为空");
|
|
|
}
|
|
|
String userId = outpatientDO.getPatient();
|
|
|
String userName = outpatientDO.getPatientName();
|
|
|
String userId = "";
|
|
|
String userName = "";
|
|
|
String operatorId = "9690";
|
|
|
String operatorName = "互联网医院";
|
|
|
PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getPatient());
|
|
|
if (patientMappingDO!=null){
|
|
|
userId = patientMappingDO.getMappingCode();
|
|
|
}
|
|
|
userName = outpatientDO.getPatientName();
|
|
|
String idNo = outpatientDO.getIdcard();
|
|
|
String cardType = "03";
|
|
|
if ("A_01".equals(patientMedicareCardDO.getType())){
|
|
@ -1553,13 +1567,11 @@ public class EntranceService {
|
|
|
String cardNo =outpatientDO.getCardNo();
|
|
|
String accountType = "01";
|
|
|
String withdrawMode = "";
|
|
|
String depositType = "";
|
|
|
if (businessOrderDO.getPayType()==3){
|
|
|
depositType = "WX_PUB";
|
|
|
}
|
|
|
String depositType = businessOrderDO.getDepositType();
|
|
|
|
|
|
String ServiceType = "04";
|
|
|
String outChargeNo = "";
|
|
|
String traceSerial = "";
|
|
|
String outChargeNo = businessOrderDO.getOrderNo();
|
|
|
String traceSerial = businessOrderDO.getTraceNo();
|
|
|
String tradeState="";
|
|
|
String paydate ="";
|
|
|
String notes = "";
|
|
@ -1568,15 +1580,27 @@ public class EntranceService {
|
|
|
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 outRefundNo = "HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100;
|
|
|
String origTraceNo = businessOrderDO.getTraceNo();
|
|
|
logger.info("第一次调用his退费接口开始");
|
|
|
//调用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();
|
|
|
|
|
|
BS15051(operatorId, operatorName, cardType, cardNo, accountType, idNo, withdrawMode, depositType, ServiceType, amount, outRefundNo, outChargeNo, origTraceNo, traceSerial, paydate, notes, tradeState, failReason, failTime, extra, demoFlag);
|
|
|
|
|
|
|
|
|
logger.info("第一次调用his退费接口结束");
|
|
|
|
|
|
//调用易联众预缴金退款接口
|
|
|
String refund = ylzPayService.refund(userId, userName, cardType, accountType, cardNo, idNo, amount, outChargeNo, userName, withdrawMode, traceSerial, outRefundNo,cardNo);
|
|
|
String refund = ylzPayService.refund(userId, userName, cardType, accountType, cardNo, idNo, amount, outChargeNo, userName, "0", traceSerial, outRefundNo,cardNo);
|
|
|
BusinessOrderRefundDO businessOrderRefundDO = new BusinessOrderRefundDO();
|
|
|
businessOrderRefundDO.setOrderNo(businessOrderDO.getOrderNo());
|
|
|
businessOrderRefundDO.setOutRefundNo(outRefundNo);
|
|
|
businessOrderRefundDO.setStatus(1);
|
|
|
businessOrderRefundDO.setCreateTime(new Date());
|
|
|
businessOrderRefundDO.setUpdateTime(new Date());
|
|
|
businessOrderRefundDO.setPatient(businessOrderDO.getPatient());
|
|
|
businessOrderRefundDO.setPatientName(businessOrderDO.getPatientName());
|
|
|
orderRefundDao.save(businessOrderRefundDO);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(refund);
|
|
|
//获取调用易联众退费接口交易状态
|
|
|
String respCode = jsonObject.getString("respCode");
|
|
@ -1585,79 +1609,48 @@ public class EntranceService {
|
|
|
}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;
|
|
|
}
|
|
|
logger.info("第二次调用his退费接口开始");
|
|
|
JSONArray resp = new JSONArray();
|
|
|
|
|
|
/**
|
|
|
* 门诊预缴金退费接口(系统自动退费)
|
|
|
*
|
|
|
* @param outPatientId 门诊表id
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
resp = BS15051(operatorId, operatorName, cardType, cardNo, accountType, idNo, withdrawMode, depositType, ServiceType, amount, outRefundNo, outChargeNo, origTraceNo, traceSerial, paydate, notes, tradeState, failReason, failTime, extra, demoFlag);
|
|
|
|
|
|
public String autoRefund(String outPatientId) throws Exception {
|
|
|
logger.info("第二次调用his退费接口结束");
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
public String ylzRefund(String outPatientId,boolean sys) throws Exception {
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findById(outPatientId);
|
|
|
if (outpatientDO == null){
|
|
|
return "门诊信息表为空";
|
|
|
if (outpatientDO == null) {
|
|
|
throw new Exception("门诊信息表为空");
|
|
|
}
|
|
|
BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
|
|
|
if (businessOrderDO == null){
|
|
|
return "订单表为空";
|
|
|
if (businessOrderDO == null) {
|
|
|
throw new Exception("订单表为空");
|
|
|
}
|
|
|
PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByCode(outpatientDO.getCardNo());
|
|
|
if (patientMedicareCardDO == null){
|
|
|
return "患者卡包为空";
|
|
|
if (patientMedicareCardDO == null) {
|
|
|
throw new Exception("患者卡包为空");
|
|
|
}
|
|
|
String operatorId = "9690";
|
|
|
String operatorName = "9690";
|
|
|
String userName = outpatientDO.getPatientName();
|
|
|
String idNo = outpatientDO.getIdcard();
|
|
|
|
|
|
String userId = "";
|
|
|
String userName = "";
|
|
|
String cardType = "03";
|
|
|
String accountType = "01";
|
|
|
String idNo = outpatientDO.getIdcard();
|
|
|
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";
|
|
|
PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getPatient());
|
|
|
if (patientMappingDO!=null){
|
|
|
userId = patientMappingDO.getMappingCode();
|
|
|
}
|
|
|
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;
|
|
|
|
|
|
userName = outpatientDO.getPatientName();
|
|
|
String cardNo =outpatientDO.getCardNo();
|
|
|
String outChargeNo = businessOrderDO.getOrderNo();
|
|
|
String outRefundNo = "HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100;
|
|
|
String traceSerial = businessOrderDO.getTraceNo();
|
|
|
String refund = ylzPayService.refund(userId, userName, cardType, accountType, cardNo, idNo, businessOrderDO.getPayPrice()+"", outChargeNo, userName, "0", traceSerial, outRefundNo,cardNo);
|
|
|
return refund;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -2904,7 +2897,7 @@ public class EntranceService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String BS15036(String cardno,String sfzh00,String isMedicalNewInterface,String fwqd00,String extra,String notes,String ghh000,boolean demoFlag) throws Exception {
|
|
|
public JSONArray BS15036(String cardno,String sfzh00,String isMedicalNewInterface,String fwqd00,String extra,String notes,String ghh000,boolean demoFlag) throws Exception {
|
|
|
int i = 0;
|
|
|
String fid = BS15036;
|
|
|
String resp = "";
|
|
@ -2939,9 +2932,16 @@ public class EntranceService {
|
|
|
sbs.append("<query compy=\"=\" item=\"ghh000\" splice=\"and\" value=\"" + ghh000 + "\"/>");
|
|
|
}
|
|
|
resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
|
|
|
logger.info("resp=" + resp);
|
|
|
resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
|
|
|
WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
|
|
|
wlyyHttpLogDO.setRequest(sbs.toString());
|
|
|
wlyyHttpLogDO.setResponse(resp);
|
|
|
wlyyHttpLogDO.setCode(BS15036);
|
|
|
wlyyHttpLogDO.setName("查询待扣费处方信息");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
wlyyHttpLogDao.save(wlyyHttpLogDO);
|
|
|
}
|
|
|
return MqSdkUtil.xml2jsonArrayRootRowBS10144(resp);
|
|
|
return ConvertUtil.convertListEnvelopInBodyRow(resp);
|
|
|
}
|
|
|
|
|
|
/**
|