|
@@ -13,7 +13,6 @@ 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;
|
|
@@ -42,7 +41,8 @@ public class SavePayResultService {
|
|
|
private String hrgApiUrl;
|
|
|
|
|
|
@Autowired
|
|
|
- public SavePayResultService(WxApiDao dao, InpatientDao yjjDao, AutoRefundService refundService, PushWxMessageService pushWxMessageService) {
|
|
|
+ public SavePayResultService(WxApiDao dao, InpatientDao yjjDao, AutoRefundService refundService,
|
|
|
+ PushWxMessageService pushWxMessageService) {
|
|
|
this.dao = dao;
|
|
|
this.yjjDao = yjjDao;
|
|
|
this.refundService = refundService;
|
|
@@ -50,42 +50,22 @@ 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"));
|
|
|
- try {
|
|
|
- RestTemplate template = new RestTemplate();
|
|
|
- QueryMzPayStatusResponse response = template.postForObject(hrgApiUrl + "/ getPayStatusForRegistration",
|
|
|
- obj, QueryMzPayStatusResponse.class);
|
|
|
- log.info("门诊挂号订单支付状态查询:参数:{},结果:{}", 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());
|
|
|
- MzyReqrec mzyReqrec = new MzyReqrec();
|
|
|
- mzyReqrec.setPatientId(order.getPatientId());
|
|
|
- mzyReqrec.setPaymode("WX");
|
|
|
- mzyReqrec.setPsordnum(order.getTradeNo());
|
|
|
- mzyReqrec.setAgtordnum(order.getSerialNo());
|
|
|
- param.setMzyReqrec(mzyReqrec);
|
|
|
- SaveGhFeeResponse data = template.postForObject(hrgApiUrl + "/payRegistrationFormHaiCi",
|
|
|
- param, SaveGhFeeResponse.class);
|
|
|
- log.info("保存挂号信息: 参数:{},结果:{}", param, data);
|
|
|
- if (null != data && (data.getResultCode() == 0 || data.getMessage().contains("挂号成功"))) {
|
|
|
- return ResultVoUtil.success("保存挂号信息成功。");
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ SaveAppointmentParam param = new SaveAppointmentParam();
|
|
|
+ param.setMzyRequestId(order.getMzyRequestId());
|
|
|
+ param.setTotalFee(order.getTotalFee().doubleValue());
|
|
|
+ MzyReqrec mzyReqrec = new MzyReqrec();
|
|
|
+ mzyReqrec.setPatientId(order.getPatientId());
|
|
|
+ mzyReqrec.setPaymode("WX");
|
|
|
+ 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);
|
|
|
+ if (null != data && (data.getResultCode() == 0 || data.getMessage().contains("挂号成功"))) {
|
|
|
+ dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
+ return ResultVoUtil.success("保存挂号信息成功。");
|
|
|
}
|
|
|
ResultVo<String> refund = refundService.autoRefund(order.getTradeNo(), "保存挂号信息失败,自动退款。");
|
|
|
log.info("【订单号:{}】保存挂号信息失败,自动退款结果:{}", order.getTradeNo(), refund);
|
|
@@ -97,44 +77,23 @@ 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"));
|
|
|
- try {
|
|
|
- RestTemplate template = new RestTemplate();
|
|
|
- QueryMzPayStatusResponse response = template.postForObject(hrgApiUrl + "/getPayStatus",
|
|
|
- obj, QueryMzPayStatusResponse.class);
|
|
|
- log.info("门诊缴费订单支付状态查询:参数:{},结果:{}", 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);
|
|
|
- hrgParam.put("patCardNo", order.getPatientId());
|
|
|
- hrgParam.put("hisOrdNum", order.getHisOrdNum());
|
|
|
- hrgParam.put("psOrdNum", order.getTradeNo());
|
|
|
- hrgParam.put("payMode", "WX");
|
|
|
- hrgParam.put("payAmt", DecimalTool.moneyYuanToFen(order.getTotalFee()));
|
|
|
- hrgParam.put("agtOrdNum", order.getSerialNo());
|
|
|
- hrgParam.put("payTime", payTime);
|
|
|
- SaveMzFeeResponse saveMzFeeResponse = template.postForObject(hrgApiUrl + "/payChargeDetailFormHaiCi",
|
|
|
- hrgParam, SaveMzFeeResponse.class);
|
|
|
- log.info("保存门诊缴费信息:参数:{},结果:{}", hrgParam, saveMzFeeResponse);
|
|
|
- if (saveMzFeeResponse != null && saveMzFeeResponse.getResultCode() == 0) {
|
|
|
- return ResultVoUtil.success("保存门诊缴费信息成功。");
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ String payTime = DateUtil.formatDatetime(new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ JSONObject hrgParam = new JSONObject();
|
|
|
+ hrgParam.put("patCardType", 1);
|
|
|
+ hrgParam.put("patCardNo", order.getPatientId());
|
|
|
+ hrgParam.put("hisOrdNum", order.getHisOrdNum());
|
|
|
+ hrgParam.put("psOrdNum", order.getTradeNo());
|
|
|
+ hrgParam.put("payMode", "WX");
|
|
|
+ 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);
|
|
|
+ if (saveMzFeeResponse != null && saveMzFeeResponse.getResultCode() == 0) {
|
|
|
+ dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
+ return ResultVoUtil.success("保存门诊缴费信息成功。");
|
|
|
}
|
|
|
ResultVo<String> refund = refundService.autoRefund(order.getTradeNo(), "保存门诊缴费信息失败,自动退款。");
|
|
|
log.info("【订单号:{}】保存门诊缴费信息失败,自动退款结果:{}", order.getTradeNo(), refund);
|
|
@@ -145,35 +104,36 @@ public class SavePayResultService {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存门诊缴费信息失败,自动退款失败,请联系服务中心进行退款。");
|
|
|
}
|
|
|
|
|
|
- public ResultVo<String> saveZyYjjInfo(WxPayOrder param) {
|
|
|
- int savedCount = yjjDao.selectSavedCount(param.getTradeNo(), param.getSerialNo());
|
|
|
+ public ResultVo<String> saveZyYjjInfo(WxPayOrder order) {
|
|
|
+ int savedCount = yjjDao.selectSavedCount(order.getTradeNo(), order.getSerialNo());
|
|
|
if (savedCount > 0) {
|
|
|
- log.info("订单号:{} 的住院预交金信息已保存,无需再次保存。", param.getTradeNo());
|
|
|
+ log.info("订单号:{} 的住院预交金信息已保存,无需再次保存。", order.getTradeNo());
|
|
|
return ResultVoUtil.success("保存住院预交金信息成功。");
|
|
|
}
|
|
|
String datetime = DateUtil.formatDatetime(new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
|
- yjjDao.payZyYjjSuccessful(param.getInpatientNo(), param.getAdmissTimes(), param.getTotalFee(),
|
|
|
- datetime, param.getTradeNo(), param.getSerialNo(), "");
|
|
|
+ yjjDao.payZyYjjSuccessful(order.getInpatientNo(), order.getAdmissTimes(), order.getTotalFee(),
|
|
|
+ datetime, order.getTradeNo(), order.getSerialNo(), "");
|
|
|
GetZyFeeParam getZyFeeParam = new GetZyFeeParam();
|
|
|
String date = DateUtil.formatDatetime(new Date(), "yyyy-MM-dd");
|
|
|
- getZyFeeParam.setInpatientNo(param.getInpatientNo());
|
|
|
- getZyFeeParam.setAdmissTimes(param.getAdmissTimes());
|
|
|
+ getZyFeeParam.setInpatientNo(order.getInpatientNo());
|
|
|
+ getZyFeeParam.setAdmissTimes(order.getAdmissTimes());
|
|
|
getZyFeeParam.setStart(date);
|
|
|
getZyFeeParam.setEnd(date);
|
|
|
yjjDao.selectZyFees(getZyFeeParam);
|
|
|
- log.info("缴纳住院预交金成功:{}", JSON.toJSONStringWithDateFormat(param, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ log.info("缴纳住院预交金成功:{}", JSON.toJSONStringWithDateFormat(order, "yyyy-MM-dd HH:mm:ss"));
|
|
|
String msgContent = "{\"touser\":\"\",\"data\":" +
|
|
|
- "{\"keyword3\":{\"color\":\"#173177\",\"value\":\"" + param.getTotalFee() + "\"}," +
|
|
|
- "\"keyword1\":{\"color\":\"#173177\",\"value\":\"" + param.getPatientName() + "\"}," +
|
|
|
- "\"keyword2\":{\"color\":\"#173177\",\"value\":\"" + param.getInpatientNo() + "\"}," +
|
|
|
+ "{\"keyword3\":{\"color\":\"#173177\",\"value\":\"" + order.getTotalFee() + "\"}," +
|
|
|
+ "\"keyword1\":{\"color\":\"#173177\",\"value\":\"" + order.getPatientName() + "\"}," +
|
|
|
+ "\"keyword2\":{\"color\":\"#173177\",\"value\":\"" + order.getInpatientNo() + "\"}," +
|
|
|
"\"remark\":{\"color\":\"#FF0000\",\"value\":\"感谢您的使用,祝您健康!\"}," +
|
|
|
"\"first\":{\"color\":\"#FF0000\",\"value\":\"您好,您已成功支付住院预交金,详情如下:\"}}," +
|
|
|
"\"template_id\":\"6qWVpQopIe4a_fYYnZg_yaInPoMFduDDJ4hotv3Mtxo\"," +
|
|
|
"\"url\":\"\"}";
|
|
|
PushMessageParam pojo = new PushMessageParam();
|
|
|
- pojo.setCardNo(yjjDao.selectCardNoByPatientId(param.getPatientId()));
|
|
|
+ pojo.setCardNo(yjjDao.selectCardNoByPatientId(order.getPatientId()));
|
|
|
pojo.setMsgContext(JSONObject.parseObject(msgContent));
|
|
|
pushWxMessageService.pushMessage(pojo);
|
|
|
+ dao.updateSuccessHisStatus(order.getTradeNo());
|
|
|
return ResultVoUtil.success("保存住院预交金信息成功。");
|
|
|
}
|
|
|
|