lighter 5 hónapja
szülő
commit
38b7990b79

+ 0 - 9
src/main/java/thyyxxk/wxservice_server/Test.java

@@ -2,21 +2,12 @@ package thyyxxk.wxservice_server;
 
 import thyyxxk.wxservice_server.utils.TokenUtil;
 
-import java.time.LocalDate;
-import java.time.temporal.ChronoUnit;
-
 public class Test {
     public static void main(String[] args) {
         String t = TokenUtil.getInstance().createToken("oao6f0y4oF7jd60QhzPzMD9C3bBU");
 //        String t = TokenUtil.getInstance().createToken("oao6f03RmgVNqQujHHdDjH5qbDzo");
         System.out.println(t);
 
-        LocalDate date1 = LocalDate.of(2025, 4, 3);
-        LocalDate date2 = LocalDate.now();
-
-        long daysBetween = ChronoUnit.DAYS.between(date1, date2);
-        System.out.println("天数差: " + daysBetween);
-
     }
 
 }

+ 4 - 0
src/main/java/thyyxxk/wxservice_server/constant/OrderType.java

@@ -23,6 +23,10 @@ public enum OrderType {
 
     WXMALL_PACKAGE(10, "服务号商城套餐"),
 
+    SELF_MACHINE_REG(11, "自助机挂号"),
+
+    SELF_MACHINE_PAY(12, "自助机缴费"),
+
     UNDEFINED(99, "未说明的费用类型");
 
     private final int code;

+ 3 - 2
src/main/java/thyyxxk/wxservice_server/controller/AppointmentController.java

@@ -91,8 +91,9 @@ public class AppointmentController {
     }
 
     @GetMapping("/checkAppointmentRequirements")
-    public ResultVo<String> checkAppointmentRequirements(@RequestParam("patientId") String patientId,
-                                                    @RequestParam("deptCode") String deptCode) {
+    public ResultVo<String> checkAppointmentRequirements(
+            @RequestParam("patientId") String patientId,
+            @RequestParam("deptCode") String deptCode) {
         String response = service.checkAppointmentRequirements(patientId, deptCode);
         if (response.startsWith("ERROR:")) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, response);

+ 47 - 0
src/main/java/thyyxxk/wxservice_server/controller/selfmachine/MzjfController.java

@@ -0,0 +1,47 @@
+package thyyxxk.wxservice_server.controller.selfmachine;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.wxservice_server.config.auth.PassToken;
+import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.paymzfee.MedinsSettle;
+import thyyxxk.wxservice_server.service.PayMzFeeService;
+import thyyxxk.wxservice_server.utils.ResultVoUtil;
+
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/selfMachine/mzjf")
+public class MzjfController {
+    private final PayMzFeeService service;
+
+    @Autowired
+    public MzjfController(PayMzFeeService service) {
+        this.service = service;
+    }
+
+    @PassToken
+    @GetMapping("/getUnPaidFee")
+    public ResultVo<List<Map<String, Object>>> getUnPaidFee(@RequestParam("patientId") String patientId) {
+        return service.getUnPaidFee(patientId);
+    }
+
+    @PassToken
+    @GetMapping("/getUnPaidDetail")
+    public ResultVo<List<Map<String, Object>>> getUnPaidDetail(
+            @RequestParam("patientId") String patientId,
+            @RequestParam("hisOrdNum") String hisOrdNum) {
+        return service.getUnPaidDetail(patientId, hisOrdNum);
+    }
+
+    @PassToken
+    @GetMapping("/getFundPayAmt")
+    public ResultVo<MedinsSettle> getFundPayAmt(@RequestParam("hisOrdNum") String hisOrdNum) {
+        MedinsSettle setlinfo = service.getFundPayAmt(hisOrdNum);
+        return ResultVoUtil.success(setlinfo);
+    }
+}

+ 35 - 0
src/main/java/thyyxxk/wxservice_server/controller/selfmachine/WxPayController.java

@@ -0,0 +1,35 @@
+package thyyxxk.wxservice_server.controller.selfmachine;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.wxservice_server.config.auth.PassToken;
+import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.wxapi.WxPyQrcdPrm;
+import thyyxxk.wxservice_server.service.WxApiService;
+import thyyxxk.wxservice_server.utils.ResultVoUtil;
+
+import java.util.Map;
+
+@RestController
+@RequestMapping("/selfMachine/wxPay")
+public class WxPayController {
+    private final WxApiService service;
+
+    @Autowired
+    public WxPayController(WxApiService service) {
+        this.service = service;
+    }
+
+    @PassToken
+    @PostMapping("/getWxPayQrcode")
+    public ResultVo<Map<String, String>> getWxPayQrcode(@RequestBody WxPyQrcdPrm prm) {
+        return service.getWxPayQrcode(prm);
+    }
+
+    @PassToken
+    @GetMapping("/queryOrderState")
+    public ResultVo<String> queryOrderState(@RequestParam("tradeNo") String tradeNo) {
+        String payTime = service.queryOrderState(tradeNo);
+        return ResultVoUtil.success(payTime);
+    }
+}

+ 96 - 0
src/main/java/thyyxxk/wxservice_server/controller/selfmachine/YyghController.java

@@ -0,0 +1,96 @@
+package thyyxxk.wxservice_server.controller.selfmachine;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.wxservice_server.config.auth.PassToken;
+import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
+import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.appointment.GetDoctorSourcesParam;
+import thyyxxk.wxservice_server.entity.appointment.GetGhFeeParam;
+import thyyxxk.wxservice_server.entity.appointment.MzClass;
+import thyyxxk.wxservice_server.entity.selfmachine.Yyghinfo;
+import thyyxxk.wxservice_server.factory.thmz.ThmzService;
+import thyyxxk.wxservice_server.factory.thmz.model.SaveAppointmentRequest;
+import thyyxxk.wxservice_server.service.AppointmentService;
+import thyyxxk.wxservice_server.utils.ResultVoUtil;
+import thyyxxk.wxservice_server.utils.SnowFlakeId;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/selfMachine/yygh")
+public class YyghController {
+    private final AppointmentService service;
+    private final ThmzService thmzService;
+
+    @Autowired
+    public YyghController(AppointmentService service, ThmzService thmzService) {
+        this.service = service;
+        this.thmzService = thmzService;
+    }
+
+    @PassToken
+    @GetMapping("/getAllDepartments")
+    public ResultVo<List<MzClass>> getAllDepartments() {
+        List<MzClass> list = service.getAllDepartments();
+        if (list.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "获取科室分类失败,请联系服务中心。");
+        }
+        return ResultVoUtil.success(list);
+    }
+
+    @PassToken
+    @PostMapping("/getDoctorSources")
+    public ResultVo<List<Map<String, Object>>> getDoctorSources(@RequestBody GetDoctorSourcesParam param) {
+        return ResultVoUtil.success(service.getDoctorSources(param));
+    }
+
+    @PassToken
+    @PostMapping("/getDoctorArrangement")
+    public ResultVo<List<Map<String, Object>>> getDoctorArrangement(@RequestBody GetDoctorSourcesParam param) {
+        return ResultVoUtil.success(service.getDoctorArrangement(param));
+    }
+
+    @PassToken
+    @PostMapping("/getGhFee")
+    public ResultVo<Map<String, Object>> getGhFee(@RequestBody @Validated GetGhFeeParam param) {
+        Map<String, Object> response = service.getGhFee(param);
+        if (null == response) {
+            return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "获取挂号费用失败,请稍后重试。");
+        }
+        return ResultVoUtil.success(response);
+    }
+
+    @PassToken
+    @GetMapping("/checkAppointmentRequirements")
+    public ResultVo<String> checkAppointmentRequirements(
+            @RequestParam("patientId") String patientId,
+            @RequestParam("deptCode") String deptCode) {
+        String response = service.checkAppointmentRequirements(patientId, deptCode);
+        if (response.startsWith("ERROR:")) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, response);
+        }
+        return ResultVoUtil.success();
+    }
+
+    @PassToken
+    @PostMapping("/saveRegWithoutCharge")
+    public ResultVo<String> saveRegWithoutCharge(@RequestBody Yyghinfo info) {
+        String sfid = SnowFlakeId.instance().nextId();
+        String psordnum = "PS" + sfid;
+        SaveAppointmentRequest request = new SaveAppointmentRequest.Builder()
+                .mzyRequestId(info.getMzyRequestId()).patientId(info.getPatientId())
+                .totalFee(BigDecimal.ZERO).fundpayAmt(BigDecimal.ZERO)
+                .acctpayAmt(BigDecimal.ZERO).couponAmt(BigDecimal.ZERO)
+                .cashpayAmt(BigDecimal.ZERO).psordnum(psordnum)
+                .agtordnum(sfid).apTime(info.getApTime()).build();
+        String res = thmzService.saveAppointment(request);
+        if (res.startsWith("ERROR:")) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, res);
+        }
+        return ResultVoUtil.success(res);
+    }
+}

+ 10 - 0
src/main/java/thyyxxk/wxservice_server/entity/selfmachine/Yyghinfo.java

@@ -0,0 +1,10 @@
+package thyyxxk.wxservice_server.entity.selfmachine;
+
+import lombok.Data;
+
+@Data
+public class Yyghinfo {
+    private Integer mzyRequestId;
+    private String patientId;
+    private String apTime;
+}

+ 23 - 1
src/main/java/thyyxxk/wxservice_server/entity/wxapi/WxPyQrcdPrm.java

@@ -5,6 +5,7 @@ import lombok.Data;
 import javax.validation.constraints.Min;
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
 
 /**
  * @description: 自助机获取微信支付二维码参数
@@ -31,6 +32,11 @@ public class WxPyQrcdPrm {
      * */
     private String payMode;
 
+    /**
+     * 门诊排班主键,orderType=11时不能为空
+     * */
+    private Integer mzyRequestId;
+
     /**
      * orderType=3(住院预交金) 时,住院号和住院次数不能为空。
      * */
@@ -43,7 +49,7 @@ public class WxPyQrcdPrm {
     private String sglcheckid;
 
     /**
-     * HIS单号,orderType=8时必传
+     * HIS单号,orderType=8|12时必传
      * */
     private String hisOrdNum;
 
@@ -51,4 +57,20 @@ public class WxPyQrcdPrm {
      * 患者姓名,orderType=8时必传
      * */
     private String patName;
+
+    private BigDecimal fundpayAmt;
+    private BigDecimal acctpayAmt;
+    private BigDecimal cashpayAmt;
+
+    public BigDecimal getFundpayAmt() {
+        return null == fundpayAmt ? BigDecimal.ZERO : fundpayAmt;
+    }
+
+    public BigDecimal getAcctpayAmt() {
+        return null == acctpayAmt ? BigDecimal.ZERO : acctpayAmt;
+    }
+
+    public BigDecimal getCashpayAmt() {
+        return null == cashpayAmt ? new BigDecimal(totalAmt / 100) : cashpayAmt;
+    }
 }

+ 4 - 2
src/main/java/thyyxxk/wxservice_server/service/SavePayResultService.java

@@ -7,6 +7,7 @@ import com.wechat.pay.java.service.payments.model.Transaction;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import thyyxxk.wxservice_server.config.exception.BizException;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.constant.CardCostTypes;
 import thyyxxk.wxservice_server.constant.OrderType;
@@ -124,7 +125,7 @@ public class SavePayResultService {
             dao.refundOrder(order.getTradeNo(), response);
             return response;
         }
-        return "ERROR:保存挂号信息失败,自动退款失败,请联系服务中心进行退款。";
+        throw new BizException(ExceptionEnum.LOGICAL_ERROR, "保存挂号信息失败,自动退款失败,请联系服务中心进行退款。");
     }
 
     public String saveMzChargeInfo(WxPayOrder order, String payTime) throws Exception {
@@ -153,7 +154,8 @@ public class SavePayResultService {
             return "ERROR:因系统原因,订单已退款。请稍后重新缴费或前往一楼收费窗口缴费。";
         }
 
-        boolean isNormalClinic = order.getOrderType() == OrderType.OUTPATIENT.getCode();
+        OrderType orderType = OrderType.get(order.getOrderType());
+        boolean isNormalClinic = orderType == OrderType.OUTPATIENT || orderType == OrderType.SELF_MACHINE_PAY;
         SaveMzPayRequest request = new SaveMzPayRequest.Builder().payTime(payTime)
                 .patCardNo(order.getPatientId()).agtOrdNum(order.getSerialNo())
                 .payAmt(order.getTotalFee()).fundpayAmt(order.getFundpayAmt())

+ 14 - 6
src/main/java/thyyxxk/wxservice_server/service/WxApiService.java

@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
+import thyyxxk.wxservice_server.config.exception.BizException;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.constant.OrderType;
 import thyyxxk.wxservice_server.dao.WxApiDao;
@@ -155,7 +156,7 @@ public class WxApiService {
             TradeVectorUtil.addBeingQuery(tradeNo);
             WxPayOrder order = dao.selectOrderByTradeNo(tradeNo);
             if (null == order) {
-                return "ERROR:订单不存在。【订单号:" + tradeNo + "】";
+                throw new BizException(ExceptionEnum.LOGICAL_ERROR, "订单不存在。【订单号:" + tradeNo + "】");
             }
             OrderType orderType = OrderType.get(order.getOrderType());
             int hasSaved = 0;
@@ -193,9 +194,11 @@ public class WxApiService {
                     case CLINIC_REGISTER:
                         return savePayResultService.saveClinicRegister(order, successTime);
                     case REGISTRATION:
+                    case SELF_MACHINE_REG:
                         return savePayResultService.saveAppointment(order, successTime);
                     case OUTPATIENT:
                     case AESTHETIC_MEDICINE:
+                    case SELF_MACHINE_PAY:
                         return savePayResultService.saveMzChargeInfo(order, successTime);
                     case INPATIENT_PRE_PAY:
                         return savePayResultService.saveZyYjjInfo(order, successTime);
@@ -211,14 +214,15 @@ public class WxApiService {
                     case WXMALL_PACKAGE:
                         return savePayResultService.saveWxMallPackage(order, successTime);
                     default:
-                        return "ERROR:未识别到的订单类型,请联系服务中心。";
+                        throw new BizException(ExceptionEnum.LOGICAL_ERROR, "未识别到的订单类型,请联系服务中心。");
                 }
             }
             dao.updatePayStatusAndQueryTimes(tradeNo, tradeState);
             return "ERROR:" + transaction.getTradeStateDesc();
         } catch (Exception e) {
             log.error("查询订单状态出错:", e);
-            return "ERROR:服务器错误,请联系管理员处理。【订单号:" + tradeNo + "】";
+            throw new BizException(ExceptionEnum.INTERNAL_SERVER_ERROR,
+                    "服务器错误,请联系管理员处理。【订单号:" + tradeNo + "】");
         } finally {
             TradeVectorUtil.removeBeingQuery(tradeNo);
         }
@@ -269,6 +273,9 @@ public class WxApiService {
             order.setPatientName(patName);
         }
         switch (orderType) {
+            case SELF_MACHINE_REG:
+                order.setMzyRequestId(param.getMzyRequestId());
+                break;
             case INPATIENT_PRE_PAY:
                 if (StringUtil.isBlank(param.getInpatientNo())) {
                     return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "费用类型为住院预交金时,住院号不能为空!");
@@ -287,6 +294,7 @@ public class WxApiService {
                 order.setSglCheckNotified(Boolean.FALSE);
                 break;
             case AESTHETIC_MEDICINE:
+            case SELF_MACHINE_PAY:
                 if (StringUtil.isBlank(param.getHisOrdNum())) {
                     return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "HIS单号不能为空!");
                 }
@@ -315,10 +323,10 @@ public class WxApiService {
         order.setTradeState(Transaction.TradeStateEnum.NOTPAY);
         order.setSerialNo(SnowFlakeId.instance().nextId());
         order.setOrderType(param.getOrderType());
-        order.setFundpayAmt(BigDecimal.ZERO);
-        order.setAcctpayAmt(BigDecimal.ZERO);
+        order.setFundpayAmt(param.getFundpayAmt());
+        order.setAcctpayAmt(param.getAcctpayAmt());
         order.setCouponAmt(BigDecimal.ZERO);
-        order.setCashpayAmt(order.getTotalFee());
+        order.setCashpayAmt(param.getCashpayAmt());
         dao.insertNewOrder(order);
 
         Map<String, String> map = new HashMap<>();

+ 1 - 1
src/main/resources/application.yml

@@ -1,3 +1,3 @@
 spring:
   profiles:
-    active: prod
+    active: dev