|
|
|
@ -450,6 +450,83 @@ public class RegService { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Result refundRegister(String hisTransNo) { |
|
|
|
|
log.info("[今日挂号][取消预约]hisTransNo={}", hisTransNo); |
|
|
|
|
|
|
|
|
|
if (hisTransNo == null) { |
|
|
|
|
log.info("[今日挂号][取消预约]参数缺失 hisTransNo=null"); |
|
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Register reg = new RegisterDao().selectRegByHisTransNo(hisTransNo); |
|
|
|
|
if (reg == null) { |
|
|
|
|
log.info("[今日挂号][取消预约]失败, 未查询到挂号支付信息"); |
|
|
|
|
return Result.error(ResultEnum.DATA_NOT_FOUND); |
|
|
|
|
} |
|
|
|
|
String tradeNo = reg.getTradeNo(); |
|
|
|
|
String outTradeNo = reg.getOutTradeNo(); |
|
|
|
|
MerchantEnum merchantEnum = MerchantEnum.getMerchantEnumByOutTradeNo(outTradeNo); |
|
|
|
|
|
|
|
|
|
JsonResult JsonResult = new HisRegisterDao().refundRegister(tradeNo, merchantEnum); |
|
|
|
|
if (!JsonResult.success()) { |
|
|
|
|
String message = JsonResult.getMessage(); |
|
|
|
|
log.info("[今日挂号][取消预约]失败 HIS返回:{}", message); |
|
|
|
|
return Result.error(message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String dbTradeNo = reg.getTradeNo(); |
|
|
|
|
BigDecimal payMoney = reg.getPayMoney(); |
|
|
|
|
if (dbTradeNo == null || outTradeNo == null || payMoney == null) { |
|
|
|
|
log.info("[今日挂号][取消预约]失败, 支付信息的参数为空, tradeNo={}, payMoney={}", tradeNo, payMoney); |
|
|
|
|
return Result.error("今日挂号支付信息的参数为空"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if("OK".equals(reg.getRefundResult())){ |
|
|
|
|
return Result.error("已退费,请不要重复退费"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (merchantEnum == null) { |
|
|
|
|
return Result.error("支付方式未匹配 outTradeNo=" + outTradeNo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("{}[今日挂号][取消预约]开始退款:outTradeNo={}, dbTradeNo={}, payMoney={}", merchantEnum.NAME, outTradeNo, dbTradeNo, payMoney); |
|
|
|
|
|
|
|
|
|
String pushInfo = "取消预约 科室:" + reg.getDeptName(); |
|
|
|
|
|
|
|
|
|
Result result = refundTodayRegister(merchantEnum, JsonResult, reg.getOpenid(), payMoney, outTradeNo, dbTradeNo, "取消预约", pushInfo, reg.getUpdateTime()); |
|
|
|
|
|
|
|
|
|
// 短信通知
|
|
|
|
|
if (HospEnum.isHosp(HospEnum.德宏州中医医院)) { |
|
|
|
|
String tel = reg.getTel(); |
|
|
|
|
if (tel != null && tel.length() == 11) { |
|
|
|
|
String template = "SMS_184121392"; |
|
|
|
|
SmsRegTem sms = new SmsRegTem(); |
|
|
|
|
sms.setTime(reg.getRegDate() + " " + reg.getBegTime() + "-" + reg.getEndTime()); |
|
|
|
|
sms.setDeptName(reg.getDeptName()); |
|
|
|
|
sms.setDoctorName(reg.getDoctName()); |
|
|
|
|
sms.setAddress(reg.getAddress()); |
|
|
|
|
sms.setSeq(reg.getQueueNum()); |
|
|
|
|
|
|
|
|
|
SmsHelper.send(template, tel, sms); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
MessagePushConfig.regCancelPush(merchantEnum, reg); |
|
|
|
|
|
|
|
|
|
if (result.isSuccess()) { |
|
|
|
|
result.setMessage(merchantEnum.NAME + "取消成功,挂号费用将在24小时内退回!"); // 修改返回提示的信息
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MerchantEnum.ALI.equals(merchantEnum)) { |
|
|
|
|
|
|
|
|
|
String link = "pages/center/components/remordList/reserve"; |
|
|
|
|
|
|
|
|
|
String title = "预约挂号取消 " + reg.getDeptName(); |
|
|
|
|
AliMessageHelper.hospitalOrder(reg.getOpenid(), title, AliMsgEnum.MERCHANT_CLOSED, reg.getUpdateTime(), false, reg.getTotalFee(), outTradeNo, reg.getRegDate(), reg.getBegTime(), reg.getDeptCode(), reg.getDeptName(), reg.getDoctName(), |
|
|
|
|
AliHelper.getLink(link, null)); |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 挂号手动退费 |
|
|
|
@ -579,6 +656,17 @@ public class RegService { |
|
|
|
|
* @param hisResult 记录信息 |
|
|
|
|
*/ |
|
|
|
|
public Result regAutoRefund(MerchantEnum merchantEnum, JsonResult JsonResult, String openid, BigDecimal totalFee, String outTradeNo, String tradeNo, String hisResult, String pushInfo, Date tradeDate) { |
|
|
|
|
log.info("[预约挂号/挂号失败自动退费][开始退费]---merchantEnum-{},JsonResult-{},openid-{},totalFee-{},outTradeNo-{},tradeNo-{},hisResult-{},pushInfo-{},tradeDate-{}",merchantEnum,JsonResult,openid,totalFee,outTradeNo,tradeNo,hisResult,pushInfo,tradeDate); |
|
|
|
|
return regRefund(merchantEnum,JsonResult,openid,totalFee,outTradeNo,tradeNo,hisResult,pushInfo,tradeDate,false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Result refundTodayRegister(MerchantEnum merchantEnum, JsonResult JsonResult, String openid, BigDecimal totalFee, String outTradeNo, String tradeNo, String hisResult, String pushInfo, Date tradeDate){ |
|
|
|
|
log.info("[今日挂号][开始退费]---merchantEnum-{},JsonResult-{},openid-{},totalFee-{},outTradeNo-{},tradeNo-{},hisResult-{},pushInfo-{},tradeDate-{}",merchantEnum,JsonResult,openid,totalFee,outTradeNo,tradeNo,hisResult,pushInfo,tradeDate); |
|
|
|
|
return regRefund(merchantEnum,JsonResult,openid,totalFee,outTradeNo,tradeNo,hisResult,pushInfo,tradeDate,true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Result regRefund(MerchantEnum merchantEnum, JsonResult JsonResult, String openid, BigDecimal totalFee, String outTradeNo, String tradeNo, String hisResult, String pushInfo, Date tradeDate,boolean isToday){ |
|
|
|
|
RegisterDao regDao = new RegisterDao(); |
|
|
|
|
|
|
|
|
|
String code = JsonResult.getCode(); |
|
|
|
@ -592,13 +680,15 @@ public class RegService { |
|
|
|
|
return Result.error("[挂号不退费]HIS请求超时"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 如果HIS交过费返回true-->就不向下执行(自动退款)
|
|
|
|
|
String dateShort = DateGenerate.getStringDateShort(); |
|
|
|
|
String paidTip = new HisAccountDao().isPaid(DateGenerate.getNextDay(dateShort, "-7"), DateGenerate.getNextDay(dateShort, "7"), tradeNo); |
|
|
|
|
if (paidTip != null) { |
|
|
|
|
log.info("[挂号][退费错误] paidTip={}, outTradeNo={}, tradeNo={}", paidTip, outTradeNo, tradeNo); |
|
|
|
|
return Result.error(paidTip); |
|
|
|
|
} |
|
|
|
|
if(!isToday){ |
|
|
|
|
// 如果HIS交过费返回true-->就不向下执行(自动退款)
|
|
|
|
|
String dateShort = DateGenerate.getStringDateShort(); |
|
|
|
|
String paidTip = new HisAccountDao().isPaid(DateGenerate.getNextDay(dateShort, "-7"), DateGenerate.getNextDay(dateShort, "7"), tradeNo); |
|
|
|
|
if (paidTip != null) { |
|
|
|
|
log.info("[挂号][退费错误] paidTip={}, outTradeNo={}, tradeNo={}", paidTip, outTradeNo, tradeNo); |
|
|
|
|
return Result.error(paidTip); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String refundResult; |
|
|
|
|
if (totalFee.compareTo(BigDecimal.ZERO) != 0) { // 金为0
|
|
|
|
|