|
@@ -50,21 +50,31 @@ public class SavePayResultService {
|
|
|
this.pushWxMessageService = pushWxMessageService;
|
|
|
}
|
|
|
|
|
|
- public ResultVo<String> saveAppointment(WxPayOrder order) {
|
|
|
+ public int queryAppointmentSaveStatus(String tradeNo, String serialNo, String feeAmount, Date payTime) {
|
|
|
JSONObject obj = new JSONObject();
|
|
|
- obj.put("psOrdNum", order.getTradeNo());
|
|
|
+ obj.put("psOrdNum", tradeNo);
|
|
|
obj.put("payMode", "WX");
|
|
|
- obj.put("payAmt", order.getTotalFee().toPlainString());
|
|
|
- obj.put("agtOrdNum", order.getSerialNo());
|
|
|
- obj.put("payTime", DateUtil.formatDatetime(order.getPayDatetime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ 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;
|
|
|
+ int hasSaved = 0; // 入库状态:0-未查询到,1-入库成功,2-入库失败
|
|
|
if (null != response && response.getResultCode() == 0) {
|
|
|
hasSaved = response.getPayStatus();
|
|
|
}
|
|
|
+ return hasSaved;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> 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) {
|
|
|
log.info("订单号:{} 的挂号信息已保存,无需再次保存。", order.getTradeNo());
|
|
|
return ResultVoUtil.success("保存挂号信息成功。");
|
|
@@ -78,6 +88,7 @@ public class SavePayResultService {
|
|
|
mzyReqrec.setPsordnum(order.getTradeNo());
|
|
|
mzyReqrec.setAgtordnum(order.getSerialNo());
|
|
|
param.setMzyReqrec(mzyReqrec);
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
SaveGhFeeResponse data = template.postForObject(hrgApiUrl + "/payRegistrationFormHaiCi",
|
|
|
param, SaveGhFeeResponse.class);
|
|
|
log.info("保存挂号信息: \n参数:{},\n结果:{}", param, data);
|
|
@@ -85,13 +96,11 @@ public class SavePayResultService {
|
|
|
dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
return ResultVoUtil.success("保存挂号信息成功。");
|
|
|
}
|
|
|
-
|
|
|
- template = new RestTemplate();
|
|
|
- response = template.postForObject(hrgApiUrl + "/getPayStatusForRegistration",
|
|
|
- obj, QueryMzPayStatusResponse.class);
|
|
|
- hasSaved = 0;
|
|
|
- if (null != response && response.getResultCode() == 0) {
|
|
|
- hasSaved = response.getPayStatus();
|
|
|
+ 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) {
|
|
|
return ResultVoUtil.success("保存挂号信息成功。");
|
|
@@ -106,22 +115,32 @@ public class SavePayResultService {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存挂号信息失败,自动退款失败,请联系服务中心进行退款。");
|
|
|
}
|
|
|
|
|
|
- public ResultVo<String> saveMzChargeInfo(WxPayOrder order) {
|
|
|
+ public int queryMzPaySaveStatus(String hisOrdNum, String tradeNo, String serialNo, String feeAmount, Date payTime) {
|
|
|
JSONObject obj = new JSONObject();
|
|
|
- obj.put("hisOrdNum", order.getHisOrdNum());
|
|
|
- obj.put("psOrdNum", order.getTradeNo());
|
|
|
+ obj.put("hisOrdNum", hisOrdNum);
|
|
|
+ obj.put("psOrdNum", tradeNo);
|
|
|
+ obj.put("agtOrdNum", serialNo);
|
|
|
obj.put("payMode", "WX");
|
|
|
- obj.put("payAmt", order.getTotalFee().toPlainString());
|
|
|
- obj.put("agtOrdNum", order.getSerialNo());
|
|
|
- obj.put("payTime", DateUtil.formatDatetime(order.getPayDatetime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ 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;
|
|
|
+ int hasSaved = 0; // 入库状态:0-未查询到,1-入库成功,2-入库失败
|
|
|
if (null != response && response.getResultCode() != -1) {
|
|
|
hasSaved = response.getPayStatus();
|
|
|
}
|
|
|
+ return hasSaved;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> saveMzChargeInfo(WxPayOrder order) {
|
|
|
+ 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) {
|
|
|
log.info("订单号:{} 的门诊缴费信息已保存,无需再次保存。", order.getTradeNo());
|
|
|
return ResultVoUtil.success("保存门诊缴费信息成功。");
|
|
@@ -136,6 +155,7 @@ public class SavePayResultService {
|
|
|
hrgParam.put("payAmt", DecimalTool.moneyYuanToFen(order.getTotalFee()));
|
|
|
hrgParam.put("agtOrdNum", order.getSerialNo());
|
|
|
hrgParam.put("payTime", payTime);
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
SaveMzFeeResponse saveMzFeeResponse = template.postForObject(hrgApiUrl + "/payChargeDetailFormHaiCi",
|
|
|
hrgParam, SaveMzFeeResponse.class);
|
|
|
log.info("保存门诊缴费信息:\n参数:{},\n结果:{}", hrgParam, saveMzFeeResponse);
|
|
@@ -143,13 +163,11 @@ public class SavePayResultService {
|
|
|
dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
return ResultVoUtil.success("保存门诊缴费信息成功。");
|
|
|
}
|
|
|
-
|
|
|
- template = new RestTemplate();
|
|
|
- response = template.postForObject(hrgApiUrl + "/getPayStatus",
|
|
|
- obj, QueryMzPayStatusResponse.class);
|
|
|
- hasSaved = 0;
|
|
|
- if (null != response && response.getResultCode() != -1) {
|
|
|
- hasSaved = response.getPayStatus();
|
|
|
+ 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) {
|
|
|
return ResultVoUtil.success("保存门诊缴费信息成功。");
|