|
@@ -13,6 +13,7 @@ import thyyxxk.wxservice_server.dao.WxApiDao;
|
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
|
import thyyxxk.wxservice_server.entity.appointment.MzyReqrec;
|
|
|
import thyyxxk.wxservice_server.entity.appointment.SaveAppointmentParam;
|
|
|
+import thyyxxk.wxservice_server.entity.hrgresponse.QueryMzPayStatusResponse;
|
|
|
import thyyxxk.wxservice_server.entity.hrgresponse.SaveGhFeeResponse;
|
|
|
import thyyxxk.wxservice_server.entity.hrgresponse.SaveMzFeeResponse;
|
|
|
import thyyxxk.wxservice_server.entity.inpatient.GetZyFeeParam;
|
|
@@ -50,6 +51,24 @@ public class SavePayResultService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<String> saveAppointment(WxPayOrder order) {
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("psOrdNum", order.getTradeNo());
|
|
|
+ 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"));
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
+ QueryMzPayStatusResponse response = template.postForObject(hrgApiUrl + "/getPayStatusForRegistration",
|
|
|
+ obj, QueryMzPayStatusResponse.class);
|
|
|
+ log.info("门诊挂号订单HIS入库状态查询:\n参数:{},\n结果:{}", obj, response);
|
|
|
+ int hasSaved = 0;
|
|
|
+ if (null != response && response.getResultCode() == 0) {
|
|
|
+ hasSaved = response.getPayStatus();
|
|
|
+ }
|
|
|
+ if (hasSaved == 1) {
|
|
|
+ log.info("订单号:{} 的挂号信息已保存,无需再次保存。", order.getTradeNo());
|
|
|
+ return ResultVoUtil.success("保存挂号信息成功。");
|
|
|
+ }
|
|
|
SaveAppointmentParam param = new SaveAppointmentParam();
|
|
|
param.setMzyRequestId(order.getMzyRequestId());
|
|
|
param.setTotalFee(order.getTotalFee().doubleValue());
|
|
@@ -59,7 +78,6 @@ 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("保存挂号信息: 参数:{},结果:{}", param, data);
|
|
@@ -70,6 +88,7 @@ public class SavePayResultService {
|
|
|
ResultVo<String> refund = refundService.autoRefund(order.getTradeNo(), "保存挂号信息失败,自动退款。");
|
|
|
log.info("【订单号:{}】保存挂号信息失败,自动退款结果:{}", order.getTradeNo(), refund);
|
|
|
if (null != refund && refund.getCode() == ExceptionEnum.SUCCESS.getCode()) {
|
|
|
+ dao.refundOrder(order.getTradeNo(), "保存挂号信息失败,自动退款。");
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存挂号信息失败,已为您自动退款,请留意到账信息。");
|
|
|
}
|
|
|
dao.updatePayStatusOnly(order.getTradeNo(), 7);
|
|
@@ -77,6 +96,25 @@ public class SavePayResultService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<String> saveMzChargeInfo(WxPayOrder order) {
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("hisOrdNum", order.getHisOrdNum());
|
|
|
+ obj.put("psOrdNum", order.getTradeNo());
|
|
|
+ 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"));
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
+ QueryMzPayStatusResponse response = template.postForObject(hrgApiUrl + "/getPayStatus",
|
|
|
+ obj, QueryMzPayStatusResponse.class);
|
|
|
+ log.info("门诊缴费订单HIS入库状态查询:\n参数:{},\n结果:{}", obj, response);
|
|
|
+ int hasSaved = 0;
|
|
|
+ if (null != response && response.getResultCode() != -1) {
|
|
|
+ hasSaved = response.getPayStatus();
|
|
|
+ }
|
|
|
+ if (hasSaved == 1) {
|
|
|
+ log.info("订单号:{} 的门诊缴费信息已保存,无需再次保存。", order.getTradeNo());
|
|
|
+ return ResultVoUtil.success("保存门诊缴费信息成功。");
|
|
|
+ }
|
|
|
String payTime = DateUtil.formatDatetime(new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
|
JSONObject hrgParam = new JSONObject();
|
|
|
hrgParam.put("patCardType", 1);
|
|
@@ -87,7 +125,6 @@ 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("保存门诊缴费信息:参数:{},结果:{}", hrgParam, saveMzFeeResponse);
|
|
@@ -98,6 +135,7 @@ public class SavePayResultService {
|
|
|
ResultVo<String> refund = refundService.autoRefund(order.getTradeNo(), "保存门诊缴费信息失败,自动退款。");
|
|
|
log.info("【订单号:{}】保存门诊缴费信息失败,自动退款结果:{}", order.getTradeNo(), refund);
|
|
|
if (refund.getCode() == ExceptionEnum.SUCCESS.getCode()) {
|
|
|
+ dao.refundOrder(order.getTradeNo(), "保存门诊缴费信息失败,自动退款。");
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存门诊缴费信息失败,已为您自动退款,请留意到账信息。");
|
|
|
}
|
|
|
dao.updatePayStatusOnly(order.getTradeNo(), 7);
|