|
@@ -16,6 +16,7 @@ import thyyxxk.wxservice_server.entity.bookable.BookedExamination;
|
|
|
import thyyxxk.wxservice_server.entity.bookable.Prescription;
|
|
|
import thyyxxk.wxservice_server.entity.hrgresponse.HrgCommonResponse;
|
|
|
import thyyxxk.wxservice_server.entity.hrgresponse.SaveMzFeeResponse;
|
|
|
+import thyyxxk.wxservice_server.entity.wxapi.WxPayOrder;
|
|
|
import thyyxxk.wxservice_server.utils.CastUtil;
|
|
|
import thyyxxk.wxservice_server.utils.DateUtil;
|
|
|
import thyyxxk.wxservice_server.utils.ResultVoUtil;
|
|
@@ -32,14 +33,16 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Service
|
|
|
public class BookableService {
|
|
|
private final BookableDao dao;
|
|
|
+ private final WxApiService wxApiService;
|
|
|
DelayQueue<BookedExamination> queue = new DelayQueue<>();
|
|
|
|
|
|
@Value("${hrgApiUrl}")
|
|
|
private String hrgApiUrl;
|
|
|
|
|
|
@Autowired
|
|
|
- public BookableService(BookableDao dao) {
|
|
|
+ public BookableService(BookableDao dao, WxApiService wxApiService) {
|
|
|
this.dao = dao;
|
|
|
+ this.wxApiService = wxApiService;
|
|
|
}
|
|
|
|
|
|
public ResultVo<List<ExamItem>> getBookableData(String tableName) {
|
|
@@ -58,6 +61,7 @@ public class BookableService {
|
|
|
if (null != payMark && payMark == 5) {
|
|
|
String url = hrgApiUrl + "/cancelApplyScheduleOfMedical?scheduleId=" + bookedItem.getId();
|
|
|
HrgCommonResponse res = restTemplate.getForObject(url, HrgCommonResponse.class);
|
|
|
+ dao.revokeMzYjReq(bookedItem.getReqNo(), 1);
|
|
|
log.info("自动取消未支付的检验检查预约结果:{},容器剩余:{}", res, queue.size());
|
|
|
}
|
|
|
} catch (InterruptedException e) {
|
|
@@ -103,7 +107,7 @@ public class BookableService {
|
|
|
return ResultVoUtil.success(resultMap);
|
|
|
}
|
|
|
|
|
|
- public ResultVo<String> saveBookPrescription(BookedExamination param) throws InterruptedException {
|
|
|
+ public ResultVo<Integer> saveBookPrescription(BookedExamination param) throws InterruptedException {
|
|
|
int reqNoExist = dao.reqNoExist(param.getPatientId(), param.getCode());
|
|
|
if (reqNoExist > 0) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您有未缴费的相同预约,无法继续预约,敬请谅解。");
|
|
@@ -145,14 +149,28 @@ public class BookableService {
|
|
|
if (0 != hrgCommonResponse.getCode()) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgCommonResponse.getMessage());
|
|
|
}
|
|
|
-
|
|
|
long beginTime = System.currentTimeMillis();
|
|
|
param.setReqNo(reqNo);
|
|
|
param.setCreateTime(new Date());
|
|
|
param.setCancelTime(new Date(beginTime + 30 * 60 * 1000L));
|
|
|
queue.add(param);
|
|
|
log.info("添加新的检验检查预约到待支付列表:{},容器剩余:{}", param.getId(), queue.size());
|
|
|
- return ResultVoUtil.success(hrgCommonResponse.getMessage());
|
|
|
+ return ResultVoUtil.success(reqNo);
|
|
|
}
|
|
|
|
|
|
+ public ResultVo<String> revokeBookPrescription(Integer reqNo) {
|
|
|
+ dao.revokeMzYjReq(reqNo, 2);
|
|
|
+ queue.removeIf(item -> item.getReqNo().equals(reqNo));
|
|
|
+ log.info("【reqNo: {}】驳回检查预约,容器剩余:{}", reqNo, queue.size());
|
|
|
+ WxPayOrder order = dao.selectWxPayOrder(reqNo);
|
|
|
+ if (order.getPayStatus() == 1) {
|
|
|
+ ResultVo<String> refund = wxApiService.autoRefund(order.getTradeNo(), "驳回检查检验预约,自动退款。");
|
|
|
+ log.info("【reqNo: {}】驳回检查预约,自动退款结果:{}", reqNo, refund);
|
|
|
+ if (null != refund && refund.getCode() == 200) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【reqNo: " + reqNo + "】已驳回检查检验预约,自动退款成功。");
|
|
|
+ }
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【reqNo: " + reqNo + "】已驳回检查检验预约,自动退款失败。");
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
}
|