TRX 1 anno fa
parent
commit
031dc9ee84
15 ha cambiato i file con 238 aggiunte e 13 eliminazioni
  1. 29 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/RescissionParam.java
  2. 23 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/SignInParam.java
  3. 14 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/SignNotifyParam.java
  4. 3 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/SignParam.java
  5. 33 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/SignQueryParam.java
  6. 38 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/SignQueryResponse.java
  7. 1 1
      PaymentClient/src/main/java/com/zhongshu/payment/client/service/OrderPayFeignService.java
  8. 1 1
      PaymentClient/src/main/java/com/zhongshu/payment/client/service/WalletFeignService.java
  9. 21 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/types/unionFrictionlessPayType/ContractState.java
  10. 1 1
      PaymentClient/src/main/java/com/zhongshu/payment/client/types/unionFrictionlessPayType/UnionUserOpenType.java
  11. 2 1
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/unionFrictionlessPay/FrictionlessController.java
  12. 4 3
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/domain/unionFrictionlessPay/UnionUserOpenInfo.java
  13. 50 4
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionFrictionlessPayMainService.java
  14. 1 2
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionNotifyService.java
  15. 17 0
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/config/UnionFrictionlessPayApiConfig.java

+ 29 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/RescissionParam.java

@@ -0,0 +1,29 @@
+package com.zhongshu.payment.client.payModel.unionFrictionlessPay.model;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author TRX
+ * @date 2024/8/27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class RescissionParam extends UnionSuperParam {
+
+    @Schema(description = "报文请求时间, 格式yyyy-MM-dd HH:mm:ss")
+    private String requestTimestamp;
+
+    @Schema(description = "商户代码, 银商商户号")
+    private String mid;
+
+    @Schema(description = "协议模板id, 无感(免密极速)产品模板ID,与接入产品对应。")
+    private String planId;
+
+    @Schema(description = "银商免密支付签约协议号,云闪付侧的签约协议号,由银联生成。即标记化支付信息域的token。BASE64加密。")
+    private String contractId;
+
+}

+ 23 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/SignInParam.java

@@ -0,0 +1,23 @@
+package com.zhongshu.payment.client.payModel.unionFrictionlessPay.model;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * 签约参数 (前台传过来的参数)
+ *
+ * @author TRX
+ * @date 2024/8/27
+ */
+@Data
+public class SignInParam  {
+
+    @Schema(description = "商户ID")
+    private String shopOid;
+
+    @Schema(description = "商户微信小程序id, 交易发起场景03:小程序,必传用于签约完成/失败/取消后跳转")
+    private String mchntWxMpAppId;
+
+    @Schema(description = "商户微信小程序path, 交易发起场景03:小程序,必传用于签约完成/失败/取消后跳转")
+    private String mchntWxMpPath;
+}

+ 14 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/SignNotifyParam.java

@@ -1,5 +1,6 @@
 package com.zhongshu.payment.client.payModel.unionFrictionlessPay.model;
 
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 /**
@@ -11,18 +12,31 @@ import lombok.Data;
 @Data
 public class SignNotifyParam {
 
+    @Schema(description = "报文请求时间")
     private String requestTimestamp;
 
+    @Schema(description = "商户代码")
     private String mid;
 
+    @Schema(description = "商户签约协议号")
     private String contractNo;
 
+    @Schema(description = "银商免密支付签约协议号")
     private String contractId;
 
+    @Schema(description = "签约状态")
     private String contractState;
 
+    @Schema(description = "Token单笔交易限额")
+    private String singleLimitAmt;
+
+    @Schema(description = "可用次数")
+    private String avlNum;
+
+    @Schema(description = "协议签约时间")
     private String contractSignedTime;
 
+    @Schema(description = "协议到期时间")
     private String contractExpiredTime;
 
 }

+ 3 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/SignParam.java

@@ -12,6 +12,9 @@ import lombok.Data;
 @Data
 public class SignParam extends UnionSuperParam {
 
+    @Schema(description = "商户ID")
+    private String shopOid;
+
     @Schema(description = "报文请求时间, 格式yyyy-MM-dd HH:mm:ss")
     private String requestTimestamp;
 

+ 33 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/SignQueryParam.java

@@ -0,0 +1,33 @@
+package com.zhongshu.payment.client.payModel.unionFrictionlessPay.model;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.hibernate.internal.build.AllowPrintStacktrace;
+
+/**
+ * 查询商户签约状态
+ *
+ * @author TRX
+ * @date 2024/8/27
+ */
+@Data
+@AllowPrintStacktrace
+@NoArgsConstructor
+public class SignQueryParam extends UnionSuperParam {
+
+    @Schema(description = "报文请求时间")
+    private String requestTimestamp;
+
+    @Schema(description = "商户代码")
+    private String mid;
+
+    @Schema(description = "协议模板id")
+    private String planId;
+
+    @Schema(description = "商户签约协议号")
+    private String contractNo;
+
+    @Schema(description = "银商免密支付签约协议号")
+    private String contractId;
+}

+ 38 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/unionFrictionlessPay/model/SignQueryResponse.java

@@ -0,0 +1,38 @@
+package com.zhongshu.payment.client.payModel.unionFrictionlessPay.model;
+
+import com.github.microservice.models.requestModel.SuperResponseModel;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 查询签约状态 返回
+ *
+ * @author TRX
+ * @date 2024/8/27
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class SignQueryResponse extends SuperResponseModel {
+
+    @Schema(description = "商户代码")
+    private String mid;
+
+    @Schema(description = "银商免密支付签约协议号")
+    private String contractId;
+
+    @Schema(description = "协议模板id")
+    private String planId;
+
+    @Schema(description = "协议状态")
+    private String contractState;
+
+    @Schema(description = "协议签约时间")
+    private String contractSignedTime;
+
+    @Schema(description = "协议到期时间")
+    private String contractExpiredTime;
+
+}

+ 1 - 1
PaymentClient/src/main/java/com/zhongshu/payment/client/service/OrderPayFeignService.java

@@ -17,7 +17,7 @@ import javax.validation.Valid;
 /**
  * @author
  */
-@FeignClient("paymentserver-trx/manager/orderPay")
+@FeignClient("paymentserver/manager/orderPay")
 public interface OrderPayFeignService {
 
     /**

+ 1 - 1
PaymentClient/src/main/java/com/zhongshu/payment/client/service/WalletFeignService.java

@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam;
  * @author wjf
  * @date 2024/7/26
  */
-@FeignClient("paymentserver-trx/manager/wallet")
+@FeignClient("paymentserver/manager/wallet")
 public interface WalletFeignService {
 
     /** 获取钱包信息 */

+ 21 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/types/unionFrictionlessPayType/ContractState.java

@@ -0,0 +1,21 @@
+package com.zhongshu.payment.client.types.unionFrictionlessPayType;
+
+/**
+ * 无感支付签约状态
+ */
+public enum ContractState {
+
+    UNSIGNED("未签约"),
+    SIGNED("已签约"),
+    RESCISSION("已解约"),
+    DELETING_CONTRACT("解约中"),
+    UNKNOWN("未知"),
+    ;
+
+    // 名称
+    private String name;
+
+    ContractState(String name) {
+        this.name = name;
+    }
+}

+ 1 - 1
PaymentClient/src/main/java/com/zhongshu/payment/client/types/unionFrictionlessPayType/UnionUserOpenType.java

@@ -6,7 +6,7 @@ package com.zhongshu.payment.client.types.unionFrictionlessPayType;
 public enum UnionUserOpenType {
 
     Shop("商户"),//
-    User("银联无感支付"),//
+    User("用户"),//
     ;
 
     // 名称

+ 2 - 1
PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/unionFrictionlessPay/FrictionlessController.java

@@ -1,6 +1,7 @@
 package com.zhongshu.payment.server.core.controller.unionFrictionlessPay;
 
 import com.github.microservice.net.ResultContent;
+import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.SignInParam;
 import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.SignParam;
 import com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay.UnionFrictionlessPayMainService;
 import com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay.UnionNotifyService;
@@ -32,7 +33,7 @@ public class FrictionlessController {
     //---------------------------通知 start-----------------------------
     @Operation(summary = "无感支付开始签约")
     @PostMapping(value = "sign", consumes = MediaType.APPLICATION_JSON_VALUE)
-    public ResultContent payNotify(@RequestBody @Valid SignParam param) {
+    public ResultContent payNotify(@RequestBody @Valid SignInParam param) {
         return unionFrictionlessPayMainService.sign(param);
     }
 

+ 4 - 3
PaymentServer/src/main/java/com/zhongshu/payment/server/core/domain/unionFrictionlessPay/UnionUserOpenInfo.java

@@ -1,5 +1,6 @@
 package com.zhongshu.payment.server.core.domain.unionFrictionlessPay;
 
+import com.zhongshu.payment.client.types.unionFrictionlessPayType.ContractState;
 import com.zhongshu.payment.client.types.unionFrictionlessPayType.UnionUserOpenType;
 import com.zhongshu.payment.server.core.domain.base.SuperMain;
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -19,6 +20,9 @@ public class UnionUserOpenInfo extends SuperMain {
     @Schema(description = "签约类型")
     private UnionUserOpenType unionUserOpenType;
 
+    @Schema(description = "签约状态")
+    private ContractState contractState;
+
     @Schema(description = "用户ID")
     private String userId;
 
@@ -34,9 +38,6 @@ public class UnionUserOpenInfo extends SuperMain {
     @Schema(description = "银商免密支付签约协议号")
     private String contractId;
 
-    @Schema(description = "签约状态,通知商户,必传。UNSIGNED-未签约 SIGNED-已签约 RESCISSION-已解约 ELETING_CONTRACT-解约中 UNKNOWN-未知")
-    private String contractState;
-
     @Schema(description = "签约时间")
     private Long signedTime;
 

+ 50 - 4
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionFrictionlessPayMainService.java

@@ -5,6 +5,7 @@ import cn.hutool.json.JSONObject;
 import com.github.microservice.models.requestModel.SuperResponseModel;
 import com.github.microservice.models.type.PaymentType;
 import com.github.microservice.net.ResultContent;
+import com.zhongshu.card.client.service.feign.OrganizationFeignService;
 import com.zhongshu.card.client.utils.DateUtils;
 import com.zhongshu.payment.client.annotation.PayAnnotationService;
 import com.zhongshu.payment.client.model.WalletModel;
@@ -14,7 +15,8 @@ import com.zhongshu.payment.client.payModel.commn.ClosePayOrderParam;
 import com.zhongshu.payment.client.payModel.commn.CreateOrderParam;
 import com.zhongshu.payment.client.payModel.commn.PayNotifyParam;
 import com.zhongshu.payment.client.payModel.commn.PayOrderParam;
-import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.SignParam;
+import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.*;
+import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.UnionUserOpenInfoDao;
 import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.UnionUserOpenInfo;
 import com.zhongshu.payment.server.core.service.pay.SuperPayService;
 import com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay.config.UnionFrictionlessPayApiConfig;
@@ -42,18 +44,31 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
     @Autowired
     UnionFrictionlessPayApiConfig payApiConfig;
 
+    @Autowired
+    UnionUserOpenInfoDao unionUserOpenInfoDao;
+
+    @Autowired
+    OrganizationFeignService organizationFeignService;
+
     /**
      * 发起签约
      *
      * @param param
      * @return
      */
-    public ResultContent sign(SignParam param) {
+    public ResultContent sign(SignInParam param) {
 //        String sign = unionRequestService.signParam(param);
 //        log.info("sign: {}", sign);
-        param.setRequestTimestamp(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
+        String shopOid = param.getShopOid();
+        // 验证学校信息
+        UnionUserOpenInfo unionUserOpenInfo = new UnionUserOpenInfo();
+        unionUserOpenInfo.setShopOid(shopOid);
+
+
+        SignParam signParam = new SignParam();
+        signParam.setRequestTimestamp(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
         String url = payApiConfig.getUlr(UnionFrictionlessPayApiConfig.sign);
-        SuperResponseModel requestAPI = unionRequestService.requestAPI(url, param, SuperResponseModel.class);
+        SuperResponseModel requestAPI = unionRequestService.requestAPI(url, signParam, SuperResponseModel.class);
         if (requestAPI.isFailed()) {
             return ResultContent.buildFail(requestAPI.getMsg());
         }
@@ -89,6 +104,37 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
         return ResultContent.buildSuccess();
     }
 
+    /**
+     * 商户解约
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent rescission(SignInParam param) {
+        RescissionParam rescissionParam = new RescissionParam();
+        rescissionParam.setRequestTimestamp(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
+        String url = payApiConfig.getUlr(UnionFrictionlessPayApiConfig.sign);
+        SuperResponseModel requestAPI = unionRequestService.requestAPI(url, rescissionParam, SuperResponseModel.class);
+        if (requestAPI.isFailed()) {
+            return ResultContent.buildFail(requestAPI.getMsg());
+        }
+
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent signQuery(SignInParam param) {
+//        SignQueryParam signQueryParam = new SignQueryParam();
+//        signQueryParam.setRequestTimestamp(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
+//        String url = payApiConfig.getUlr(UnionFrictionlessPayApiConfig.sign);
+//        SignQueryResponse requestAPI = unionRequestService.requestAPI(url, signQueryParam, SignQueryResponse.class);
+//        if (requestAPI.isFailed()) {
+//            return ResultContent.buildFail(requestAPI.getMsg());
+//        }
+
+        return ResultContent.buildSuccess();
+    }
+
+
     /**
      * 创建支付渠道订单
      *

+ 1 - 2
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionNotifyService.java

@@ -25,7 +25,7 @@ public class UnionNotifyService {
     JsonHelper jsonHelper;
 
     /**
-     * 无感支付签约回调
+     * 无感支付签约回调 (解约也调用该接口)
      *
      * @param request
      * @return
@@ -43,7 +43,6 @@ public class UnionNotifyService {
         String body = stringBuffer.toString();
         SignNotifyParam signNotifyParam = jsonHelper.toObject(body, SignNotifyParam.class);
 
-
         return ResultContent.buildSuccess();
     }
 

+ 17 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/config/UnionFrictionlessPayApiConfig.java

@@ -40,6 +40,12 @@ public class UnionFrictionlessPayApiConfig {
     // 商户签约
     public static String sign = "sign";
 
+    // 商户解约
+    public static String rescission = "rescission";
+
+    // 签约状态查询
+    public static String signQuery = "signQuery";
+
     private static List<UnionPayApi> apis = new ArrayList<>();
 
     static {
@@ -79,6 +85,17 @@ public class UnionFrictionlessPayApiConfig {
                 .prodUrl("https://api-mop.chinaums.com/v1/inip/sign/uac/entrust-pay/sign")
                 .build());
 
+        apis.add(UnionPayApi.builder().apiKey(rescission)
+                .devUrl("https://test-api-open.chinaums.com/v1/inip/sign/uac/entrust-pay/rescission")
+                .prodUrl("https://api-mop.chinaums.com/v1/inip/sign/uac/entrust-pay/rescission")
+                .build());
+
+        apis.add(UnionPayApi.builder().apiKey(signQuery)
+                .devUrl("https://test-api-open.chinaums.com/v1/inip/sign/uac/entrust-pay/sign-query")
+                .prodUrl("https://api-mop.chinaums.com/v1/inip/sign/uac/entrust-pay/sign-query")
+                .build());
+
+
     }
 
     public String getUlr(String key) {