Browse Source

创元体检扫码支付

lighter 11 months ago
parent
commit
2fb1f80f8b

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>wxservice-server</artifactId>
-    <version>12.2.1</version>
+    <version>12.2.2</version>
     <name>wxservice-server</name>
     <description>server for wxservice-web</description>
 

+ 7 - 3
src/main/java/thyyxxk/wxservice_server/controller/WxPayNotifyController.java

@@ -2,9 +2,7 @@ package thyyxxk.wxservice_server.controller;
 
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import thyyxxk.wxservice_server.config.auth.PassToken;
 import thyyxxk.wxservice_server.factory.wechatpay.WeChatPayService;
 import thyyxxk.wxservice_server.factory.wechatpay.model.WechatPayGlobalRequest;
@@ -39,4 +37,10 @@ public class WxPayNotifyController {
                 .httpServletRequest(httpServletRequest).build();
         new WeChatPayService().decryptNotify(request);
     }
+
+    @PassToken
+    @GetMapping("/testNotify")
+    public void paymentNotify2(@RequestParam("tradeNo") String tradeNo) {
+        service.testNotify(tradeNo);
+    }
 }

+ 2 - 2
src/main/java/thyyxxk/wxservice_server/dao/WxApiDao.java

@@ -38,12 +38,12 @@ public interface WxApiDao {
             "time_stamp,trade_no,create_order_sign,pay_sign,spbill_create_ip," +
             "create_datetime,trade_state,serial_no,order_type,his_ord_num," +
             "mzy_request_id,yj_req_no,his_status,query_state_times,ap_time," +
-            "fundpay_amt,acctpay_amt,coupon_amt,cashpay_amt,coupon_id) " +
+            "fundpay_amt,acctpay_amt,coupon_amt,cashpay_amt,coupon_id,sgl_check_id) " +
             "values (#{body},#{openid},#{totalFee},#{patientId},#{patientName},#{inpatientNo}," +
             "#{admissTimes},#{appId},#{mchId},#{prepayId},#{timeStamp},#{tradeNo},#{createOrderSign}," +
             "#{paySign},#{spbillCreateIp},#{createDatetime},#{tradeState},#{serialNo},#{orderType}," +
             "#{hisOrdNum},#{mzyRequestId},#{yjReqNo},0,0,#{apTime},#{fundpayAmt}," +
-            "#{acctpayAmt},#{couponAmt},#{cashpayAmt},#{couponId})")
+            "#{acctpayAmt},#{couponAmt},#{cashpayAmt},#{couponId},#{sglCheckId})")
     void insertNewOrder(WxPayOrder param);
 
     @Select("select * from t_si_presetlinfo where pat_no=#{patNo} and times=#{times} ")

+ 1 - 0
src/main/java/thyyxxk/wxservice_server/entity/wxapi/WxPayOrder.java

@@ -67,4 +67,5 @@ public class WxPayOrder {
     private String inpatientNo;
     private Integer admissTimes;
     private String apTime;
+    private String sglCheckId;
 }

+ 5 - 0
src/main/java/thyyxxk/wxservice_server/entity/wxapi/WxPyQrcdPrm.java

@@ -36,4 +36,9 @@ public class WxPyQrcdPrm {
      * */
     private String inpatientNo;
     private Integer admissTimes;
+
+    /**
+     * 体检号,orderType=5时必传
+     * */
+    private String sglcheckid;
 }

+ 31 - 0
src/main/java/thyyxxk/wxservice_server/factory/cytj/CytjService.java

@@ -0,0 +1,31 @@
+package thyyxxk.wxservice_server.factory.cytj;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.client.RestTemplate;
+import thyyxxk.wxservice_server.entity.wxapi.WxPayOrder;
+import thyyxxk.wxservice_server.factory.cytj.model.NotifyBody;
+import thyyxxk.wxservice_server.utils.DecimalTool;
+
+/**
+ * 创元体检
+ * */
+@Slf4j
+public class CytjService {
+    private final static String URL = "http://172.16.32.100:8088/TaiheWeiXin/TradeStatusNotice";
+
+    public void notifyPaymentSuccess(WxPayOrder params) {
+        NotifyBody body = buildRequestBody(params);
+        String response = new RestTemplate().postForObject(URL, body, String.class);
+        log.info("[创元体检]用户扫码支付成功通知:\n参数:{}\n结果:{}", body, response);
+    }
+
+    private NotifyBody buildRequestBody(WxPayOrder params) {
+        NotifyBody notifyBody = new NotifyBody();
+        notifyBody.setPatientId(params.getPatientId());
+        notifyBody.setTradeNo(params.getTradeNo());
+        notifyBody.setTotalAmt(DecimalTool.moneyYuanToFen(params.getTotalFee()));
+        notifyBody.setSglcheckid(params.getSglCheckId());
+        return notifyBody;
+    }
+
+}

+ 11 - 0
src/main/java/thyyxxk/wxservice_server/factory/cytj/model/NotifyBody.java

@@ -0,0 +1,11 @@
+package thyyxxk.wxservice_server.factory.cytj.model;
+
+import lombok.Data;
+
+@Data
+public class NotifyBody {
+    private String tradeNo;
+    private Integer totalAmt;
+    private String patientId;
+    private String sglcheckid;
+}

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

@@ -251,6 +251,12 @@ public class WxApiService {
             order.setInpatientNo(param.getInpatientNo());
             order.setAdmissTimes(param.getAdmissTimes());
         }
+        if (param.getOrderType() == OrderType.INSPECTIONS.getCode()) {
+            if (StringUtil.isBlank(param.getSglcheckid())) {
+                return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "体检ID不能为空!");
+            }
+            order.setSglCheckId(param.getSglcheckid());
+        }
 
         WechatPayGlobalRequest request = new WechatPayGlobalRequest.Builder()
                 .totalAmount(param.getTotalAmt()).description(param.getDescription()).build();
@@ -271,7 +277,6 @@ 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.setCouponAmt(BigDecimal.ZERO);

+ 9 - 2
src/main/java/thyyxxk/wxservice_server/service/WxPayNotifyService.java

@@ -7,6 +7,7 @@ import org.springframework.stereotype.Service;
 import thyyxxk.wxservice_server.constant.OrderType;
 import thyyxxk.wxservice_server.dao.WxApiDao;
 import thyyxxk.wxservice_server.entity.wxapi.WxPayOrder;
+import thyyxxk.wxservice_server.factory.cytj.CytjService;
 import thyyxxk.wxservice_server.factory.wechatpay.WeChatPayService;
 import thyyxxk.wxservice_server.factory.wechatpay.model.WechatPayGlobalRequest;
 import thyyxxk.wxservice_server.utils.TradeVectorUtil;
@@ -35,8 +36,9 @@ public class WxPayNotifyService {
         String tradeNo = transaction.getOutTradeNo();
         WxPayOrder order = dao.selectOrderByTradeNo(tradeNo);
         Transaction.TradeStateEnum tradeState = order.getTradeState();
-        if (order.getOrderType() == OrderType.INSPECTIONS.getCode()) {
-            // todo 通知体检
+        if (order.getOrderType() == OrderType.INSPECTIONS.getCode()
+                && tradeState == Transaction.TradeStateEnum.SUCCESS) {
+            new CytjService().notifyPaymentSuccess(order);
         }
 
         if (tradeState == Transaction.TradeStateEnum.SUCCESS ||
@@ -68,4 +70,9 @@ public class WxPayNotifyService {
                 break;
         }
     }
+
+    public void testNotify(String tradeNo) {
+        WxPayOrder order = dao.selectOrderByTradeNo(tradeNo);
+        new CytjService().notifyPaymentSuccess(order);
+    }
 }