|
@@ -52,32 +52,9 @@ public class SavePayResultService {
|
|
|
this.pushWxMessageService = pushWxMessageService;
|
|
|
}
|
|
|
|
|
|
- public int queryAppointmentSaveStatus(String tradeNo, String serialNo, String feeAmount, Date payTime) {
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
- obj.put("psOrdNum", tradeNo);
|
|
|
- obj.put("payMode", "WX");
|
|
|
- obj.put("payAmt", feeAmount);
|
|
|
- obj.put("agtOrdNum", serialNo);
|
|
|
- obj.put("payTime", DateUtil.formatDatetime(payTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
- RestTemplate template = new RestTemplate();
|
|
|
- QueryMzPayStatusResponse response = template.postForObject(hrgApiUrl + "/getPayStatusForRegistration",
|
|
|
- obj, QueryMzPayStatusResponse.class);
|
|
|
- log.info("门诊挂号订单HIS入库状态查询:\n参数:{},\n结果:{}", obj, response);
|
|
|
- int hasSaved = 0; // 入库状态:0-未查询到,1-入库成功,2-入库失败
|
|
|
- if (null != response && response.getResultCode() == 0) {
|
|
|
- hasSaved = response.getPayStatus();
|
|
|
- }
|
|
|
- return hasSaved;
|
|
|
- }
|
|
|
-
|
|
|
public ResultVo<Object> saveAppointment(WxPayOrder order) {
|
|
|
- int hasSaved = queryAppointmentSaveStatus(order.getTradeNo(), order.getSerialNo(),
|
|
|
- order.getTotalFee().toPlainString(), order.getPayDatetime());
|
|
|
- if (hasSaved == 0) {
|
|
|
- log.info("订单号:{} 的挂号信息查询失败,接口未调用成功。", order.getTradeNo());
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "挂号信息查询失败,将于3分钟后重新发起查询。");
|
|
|
- }
|
|
|
- if (hasSaved == 1) {
|
|
|
+ if (dao.alreadyPaidRegisterFee(order.getTradeNo()) == 1) {
|
|
|
+ dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
log.info("订单号:{} 的挂号信息已保存,无需再次保存。", order.getTradeNo());
|
|
|
return ResultVoUtil.success("保存挂号信息成功。");
|
|
|
}
|
|
@@ -98,13 +75,8 @@ public class SavePayResultService {
|
|
|
dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
return ResultVoUtil.success("保存挂号信息成功。");
|
|
|
}
|
|
|
- hasSaved = queryAppointmentSaveStatus(order.getTradeNo(), order.getSerialNo(),
|
|
|
- order.getTotalFee().toPlainString(), order.getPayDatetime());
|
|
|
- if (hasSaved == 0) {
|
|
|
- log.info("订单号:{} 的挂号信息查询失败,接口未调用成功。", order.getTradeNo());
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "挂号信息查询失败,将于3分钟后重新发起查询。");
|
|
|
- }
|
|
|
- if (hasSaved == 1) {
|
|
|
+ if (dao.alreadyPaidRegisterFee(order.getTradeNo()) == 1) {
|
|
|
+ dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
return ResultVoUtil.success("保存挂号信息成功。");
|
|
|
}
|
|
|
ResultVo<String> refund = refundService.autoRefund(order.getTradeNo(), "保存挂号信息失败,自动退款。");
|
|
@@ -117,34 +89,10 @@ public class SavePayResultService {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存挂号信息失败,自动退款失败,请联系服务中心进行退款。");
|
|
|
}
|
|
|
|
|
|
- public int queryMzPaySaveStatus(String hisOrdNum, String tradeNo, String serialNo, String feeAmount, Date payTime) {
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
- obj.put("hisOrdNum", hisOrdNum);
|
|
|
- obj.put("psOrdNum", tradeNo);
|
|
|
- obj.put("agtOrdNum", serialNo);
|
|
|
- obj.put("payMode", "WX");
|
|
|
- obj.put("payAmt", feeAmount);
|
|
|
- obj.put("payTime", DateUtil.formatDatetime(payTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
- RestTemplate template = new RestTemplate();
|
|
|
- QueryMzPayStatusResponse response = template.postForObject(hrgApiUrl + "/getPayStatus",
|
|
|
- obj, QueryMzPayStatusResponse.class);
|
|
|
- log.info("门诊缴费订单HIS入库状态查询:\n参数:{},\n结果:{}", obj, response);
|
|
|
- int hasSaved = 0; // 入库状态:0-未查询到,1-入库成功,2-入库失败
|
|
|
- if (null != response && response.getResultCode() != -1) {
|
|
|
- hasSaved = response.getPayStatus();
|
|
|
- }
|
|
|
- return hasSaved;
|
|
|
- }
|
|
|
-
|
|
|
public ResultVo<Object> saveMzChargeInfo(WxPayOrder order, QuerySource source, String successTime) {
|
|
|
- int hasSaved = queryMzPaySaveStatus(order.getHisOrdNum(), order.getTradeNo(),
|
|
|
- order.getSerialNo(), order.getTotalFee().toPlainString(), order.getPayDatetime());
|
|
|
- if (hasSaved == 0) {
|
|
|
- log.info("订单号:{} 的门诊缴费信息查询失败,接口未调用成功。", order.getTradeNo());
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "门诊缴费信息查询失败,将于3分钟后重新发起查询。");
|
|
|
- }
|
|
|
- if (hasSaved == 1) {
|
|
|
+ if (dao.alreadyPayed(order.getTradeNo()) == 1) {
|
|
|
log.info("订单号:{} 的门诊缴费信息已保存,无需再次保存。", order.getTradeNo());
|
|
|
+ dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
return ResultVoUtil.success("保存门诊缴费信息成功。");
|
|
|
}
|
|
|
JSONObject hrgParam = new JSONObject();
|
|
@@ -160,7 +108,8 @@ public class SavePayResultService {
|
|
|
SaveMzFeeResponse saveMzFeeResponse = template.postForObject(hrgApiUrl + "/payChargeDetailFormHaiCi",
|
|
|
hrgParam, SaveMzFeeResponse.class);
|
|
|
log.info("保存门诊缴费信息:\n参数:{},\n结果:{}", hrgParam, saveMzFeeResponse);
|
|
|
- if (null != saveMzFeeResponse && null != saveMzFeeResponse.getResultCode() && saveMzFeeResponse.getResultCode() == 0) {
|
|
|
+ if (null != saveMzFeeResponse && null != saveMzFeeResponse.getResultCode() &&
|
|
|
+ saveMzFeeResponse.getResultCode() == 0) {
|
|
|
dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
updateSiMzSavedFlag(order.getHisOrdNum());
|
|
|
if (source == QuerySource.INTERFACE) {
|
|
@@ -175,13 +124,8 @@ public class SavePayResultService {
|
|
|
}
|
|
|
return ResultVoUtil.success("保存门诊缴费信息成功。");
|
|
|
}
|
|
|
- hasSaved = queryMzPaySaveStatus(order.getHisOrdNum(), order.getTradeNo(),
|
|
|
- order.getSerialNo(), order.getTotalFee().toPlainString(), order.getPayDatetime());
|
|
|
- if (hasSaved == 0) {
|
|
|
- log.info("订单号:{} 的门诊缴费信息查询失败,接口未调用成功。", order.getTradeNo());
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "门诊缴费信息查询失败,将于3分钟后重新发起查询。");
|
|
|
- }
|
|
|
- if (hasSaved == 1) {
|
|
|
+ if (dao.alreadyPayed(order.getTradeNo()) == 1) {
|
|
|
+ dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
if (source == QuerySource.INTERFACE) {
|
|
|
String hisOrdNum = order.getHisOrdNum();
|
|
|
String[] hsrdnms = hisOrdNum.split("_");
|