|
@@ -16,6 +16,7 @@ import thyyxxk.wxservice_server.entity.PureCodeName;
|
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
|
import thyyxxk.wxservice_server.entity.electronichealthcard.HisRegister;
|
|
|
import thyyxxk.wxservice_server.entity.inpatient.GetZyFeeParam;
|
|
|
+import thyyxxk.wxservice_server.entity.paymzfee.MedinsPresettle;
|
|
|
import thyyxxk.wxservice_server.entity.wxapi.PushMessageParam;
|
|
|
import thyyxxk.wxservice_server.entity.wxapi.WxPayOrder;
|
|
|
import thyyxxk.wxservice_server.factory.thmz.ThmzService;
|
|
@@ -24,6 +25,7 @@ import thyyxxk.wxservice_server.factory.thmz.model.SaveClinicRegisterRequest;
|
|
|
import thyyxxk.wxservice_server.factory.thmz.model.SaveMzPayRequest;
|
|
|
import thyyxxk.wxservice_server.utils.*;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -119,7 +121,7 @@ public class SavePayResultService {
|
|
|
}
|
|
|
if (dao.alreadyPayed(tradeNo) > 0) {
|
|
|
log.info("订单号:{} 的门诊缴费信息已保存,无需再次保存。", tradeNo);
|
|
|
- updateAppletHisChargeplStatus(hisOrdNum, tradeNo, order.getCouponId());
|
|
|
+ updateAppletHisChargeplStatus(hisOrdNum, tradeNo, order.getCouponId(), order.getCashpayAmt());
|
|
|
return payTime;
|
|
|
}
|
|
|
PureCodeName status = dao.selectPayStatus(tradeNo);
|
|
@@ -145,14 +147,14 @@ public class SavePayResultService {
|
|
|
.psOrdNum(tradeNo).build();
|
|
|
ResultVo<String> saveMzPayResponse = thmzService.saveMzPay(request);
|
|
|
if (saveMzPayResponse.getCode() == ExceptionEnum.SUCCESS.getCode()) {
|
|
|
- updateAppletHisChargeplStatus(hisOrdNum, tradeNo, order.getCouponId());
|
|
|
+ updateAppletHisChargeplStatus(hisOrdNum, tradeNo, order.getCouponId(), order.getCashpayAmt());
|
|
|
int fundpayCount = dao.selectFundPayCount(tradeNo);
|
|
|
String cardCostTypes = fundpayCount > 0 ? CardCostTypes.MED_INS : CardCostTypes.SELF_PAY;
|
|
|
healthCardService.reportHisData(order.getPatientId(), "0101051", null, cardCostTypes);
|
|
|
return payTime;
|
|
|
}
|
|
|
if (dao.alreadyPayed(tradeNo) > 0) {
|
|
|
- updateAppletHisChargeplStatus(hisOrdNum, tradeNo, order.getCouponId());
|
|
|
+ updateAppletHisChargeplStatus(hisOrdNum, tradeNo, order.getCouponId(), order.getCashpayAmt());
|
|
|
return payTime;
|
|
|
}
|
|
|
String refund = refundService.autoRefund(tradeNo, saveMzPayResponse.getMessage());
|
|
@@ -163,25 +165,36 @@ public class SavePayResultService {
|
|
|
return "ERROR:【" + saveMzPayResponse.getMessage() + "】自动退款失败,请联系服务中心进行退款。";
|
|
|
}
|
|
|
|
|
|
- private void updateAppletHisChargeplStatus(String hisOrdNum, String tradeNo, String couponId) {
|
|
|
+ private void updateAppletHisChargeplStatus(String hisOrdNum, String tradeNo, String couponId, BigDecimal cashpayAmt) {
|
|
|
String[] patinfo = hisOrdNum.split("_");
|
|
|
- medinsSettle(hisOrdNum);
|
|
|
+ medinsSettle(hisOrdNum, cashpayAmt);
|
|
|
dao.updateMzSavedFlag(patinfo[0], patinfo[1]);
|
|
|
dao.updateSuccessHisStatus(tradeNo);
|
|
|
dao.couponUsed(couponId);
|
|
|
}
|
|
|
|
|
|
- public void medinsSettle(String hisOrdNum) {
|
|
|
+ private void medinsSettle(String hisOrdNum, BigDecimal cashpayAmt) {
|
|
|
String[] arr = hisOrdNum.split("_");
|
|
|
- Double acctPay = dao.selectPreSetlinfo(arr[0], arr[1]);
|
|
|
- if (null != acctPay) {
|
|
|
+ MedinsPresettle presettle = dao.selectPreSetlinfo(arr[0], arr[1]);
|
|
|
+ if (null != presettle) {
|
|
|
+ BigDecimal medinsPayAmt = presettle.getFundPaySumamt().add(presettle.getAcctPay());
|
|
|
+
|
|
|
JSONObject params = new JSONObject();
|
|
|
params.put("patNo", arr[0]);
|
|
|
params.put("times", arr[1]);
|
|
|
params.put("staffId", "99999");
|
|
|
- if (acctPay > 0) {
|
|
|
+ if (presettle.getAcctPay().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
params.put("acctUsedFlag", "1");
|
|
|
}
|
|
|
+
|
|
|
+ if (medinsPayAmt.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (presettle.getMedfeeSumamt().compareTo(cashpayAmt) <= 0) {
|
|
|
+ String url = siMzApiUrl + "/revokeOutpatientSettlement";
|
|
|
+ String response = new RestTemplate().postForObject(url, params, String.class);
|
|
|
+ log.info("患者全自费缴费,自动撤销医保业务:\n参数:{}\n:结果:{}", params, JSON.toJSON(response));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
String url = siMzApiUrl + "/outpatientSettlement";
|
|
|
String response = new RestTemplate().postForObject(url, params, String.class);
|
|
|
log.info("患者自助医保结算:\n参数:{}\n结果:{}", params, JSON.toJSON(response));
|