|
@@ -11,15 +11,17 @@ import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.wxservice_server.constant.Constants;
|
|
|
import thyyxxk.wxservice_server.dao.BookableDao;
|
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
|
-import thyyxxk.wxservice_server.entity.bookable.ExamItem;
|
|
|
-import thyyxxk.wxservice_server.entity.bookable.BookedExamination;
|
|
|
+import thyyxxk.wxservice_server.entity.bookable.YjReqItem;
|
|
|
+import thyyxxk.wxservice_server.entity.bookable.BookedYjReq;
|
|
|
import thyyxxk.wxservice_server.entity.bookable.Prescription;
|
|
|
+import thyyxxk.wxservice_server.entity.bookable.RejectedYjReq;
|
|
|
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;
|
|
|
+import thyyxxk.wxservice_server.utils.StringUtil;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.DelayQueue;
|
|
@@ -34,7 +36,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
public class BookableService {
|
|
|
private final BookableDao dao;
|
|
|
private final WxApiService wxApiService;
|
|
|
- DelayQueue<BookedExamination> queue = new DelayQueue<>();
|
|
|
+ DelayQueue<BookedYjReq> queue = new DelayQueue<>();
|
|
|
|
|
|
@Value("${hrgApiUrl}")
|
|
|
private String hrgApiUrl;
|
|
@@ -45,7 +47,7 @@ public class BookableService {
|
|
|
this.wxApiService = wxApiService;
|
|
|
}
|
|
|
|
|
|
- public ResultVo<List<ExamItem>> getBookableData(String tableName) {
|
|
|
+ public ResultVo<List<YjReqItem>> getBookableData(String tableName) {
|
|
|
return ResultVoUtil.success(dao.getBookableData(tableName));
|
|
|
}
|
|
|
|
|
@@ -56,7 +58,7 @@ public class BookableService {
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
while (true) {
|
|
|
try {
|
|
|
- BookedExamination bookedItem = queue.take();
|
|
|
+ BookedYjReq bookedItem = queue.take();
|
|
|
Integer payMark = dao.selectPayMarkByReqNo(bookedItem.getReqNo());
|
|
|
if (null != payMark && payMark == 5) {
|
|
|
String url = hrgApiUrl + "/cancelApplyScheduleOfMedical?scheduleId=" + bookedItem.getId();
|
|
@@ -70,12 +72,12 @@ public class BookableService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public ResultVo<Map<String, Object>> getFullScheduleOfMedicalForPlatform(BookedExamination exam) {
|
|
|
+ public ResultVo<Map<String, Object>> getFullScheduleOfMedicalForPlatform(String execUnit) {
|
|
|
String[] dateRange = DateUtil.getDatesInOneWeek();
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
HrgCommonResponse hrgResponse = restTemplate
|
|
|
.getForObject(String.format(hrgApiUrl + "/getFullScheduleOfMedicalForPlatform?depNo=%s&beginTime=%s&endTime=%s",
|
|
|
- exam.getExecUnit(), dateRange[0], dateRange[6]), HrgCommonResponse.class);
|
|
|
+ execUnit, dateRange[0], dateRange[6]), HrgCommonResponse.class);
|
|
|
if (null == hrgResponse) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "网络服务错误!");
|
|
|
}
|
|
@@ -107,7 +109,33 @@ public class BookableService {
|
|
|
return ResultVoUtil.success(resultMap);
|
|
|
}
|
|
|
|
|
|
- public ResultVo<Integer> saveBookPrescription(BookedExamination param) throws InterruptedException {
|
|
|
+ public ResultVo<List<Map<String, Object>>> getOtherTimeForRejectedReq(String execUnit) {
|
|
|
+ String[] dateRange = DateUtil.getDatesInOneWeek();
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ HrgCommonResponse hrgResponse = restTemplate
|
|
|
+ .getForObject(String.format(hrgApiUrl + "/getFullScheduleOfMedicalForPlatform?depNo=%s&beginTime=%s&endTime=%s",
|
|
|
+ execUnit, dateRange[0], dateRange[6]), HrgCommonResponse.class);
|
|
|
+ if (null == hrgResponse) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "网络服务错误!");
|
|
|
+ }
|
|
|
+ if (-1 == hrgResponse.getCode()) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgResponse.getMessage());
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> data = CastUtil.cast(hrgResponse.getData());
|
|
|
+ data.removeIf(item -> (int) item.get("status") != 0);
|
|
|
+ return ResultVoUtil.success(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String[]> getBookTip(String tableName, String code) {
|
|
|
+ String tip = dao.selectBookTip(tableName, code);
|
|
|
+ if (StringUtil.isBlank(tip)) {
|
|
|
+ return ResultVoUtil.success(null);
|
|
|
+ }
|
|
|
+ String[] tips = tip.split("\n");
|
|
|
+ return ResultVoUtil.success(tips);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<Integer> saveBookPrescription(BookedYjReq param) throws InterruptedException {
|
|
|
int reqNoExist = dao.reqNoExist(param.getPatientId(), param.getCode());
|
|
|
if (reqNoExist > 0) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您有未缴费的相同预约,无法继续预约,敬请谅解。");
|
|
@@ -151,6 +179,7 @@ public class BookableService {
|
|
|
}
|
|
|
long beginTime = System.currentTimeMillis();
|
|
|
param.setReqNo(reqNo);
|
|
|
+ dao.updateReqInfo(param);
|
|
|
param.setCreateTime(new Date());
|
|
|
param.setCancelTime(new Date(beginTime + 30 * 60 * 1000L));
|
|
|
queue.add(param);
|
|
@@ -158,19 +187,42 @@ public class BookableService {
|
|
|
return ResultVoUtil.success(reqNo);
|
|
|
}
|
|
|
|
|
|
+ public ResultVo<String> changeYjReqTime(BookedYjReq param) {
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("scheduleId", param.getId());
|
|
|
+ obj.put("xdtjcjg", 0);
|
|
|
+ obj.put("actOrderNo", param.getReqNo());
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ HrgCommonResponse hrgCommonResponse = restTemplate.postForObject(hrgApiUrl + "/applyScheduleOfMedicalForPlatform",
|
|
|
+ obj, HrgCommonResponse.class);
|
|
|
+ if (null == hrgCommonResponse) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
|
|
|
+ }
|
|
|
+ if (0 != hrgCommonResponse.getCode()) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgCommonResponse.getMessage());
|
|
|
+ }
|
|
|
+ dao.updateReqInfo(param);
|
|
|
+ return ResultVoUtil.success("修改预约时间成功。");
|
|
|
+ }
|
|
|
+
|
|
|
public ResultVo<String> revokeBookPrescription(Integer reqNo) {
|
|
|
dao.revokeMzYjReq(reqNo, 2);
|
|
|
queue.removeIf(item -> item.getReqNo().equals(reqNo));
|
|
|
log.info("【reqNo: {}】驳回检查预约,容器剩余:{}", reqNo, queue.size());
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<RejectedYjReq> getRejectedYjReq(Integer reqNo) {
|
|
|
+ return ResultVoUtil.success(dao.getRejectedYjReq(reqNo));
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> applyRefund(Integer reqNo) {
|
|
|
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 + "】已驳回检查检验预约,自动退款失败。");
|
|
|
+ ResultVo<String> refundResult = wxApiService.autoRefund(order.getTradeNo(), "驳回的医技预约,患者选择退款。");
|
|
|
+ log.info("【reqNo: {}】驳回的检查预约,患者选择退款,退款结果:{}", reqNo, refundResult);
|
|
|
+ if (null != refundResult && refundResult.getCode() == 200) {
|
|
|
+ return ResultVoUtil.success("退款成功,资金已原路返还,请您留意退款到账信息(可能有1到3分钟延迟)。");
|
|
|
}
|
|
|
- return ResultVoUtil.success();
|
|
|
+ return refundResult;
|
|
|
}
|
|
|
}
|