TRX 1 年之前
父節點
當前提交
eaddaf6a96
共有 14 個文件被更改,包括 326 次插入58 次删除
  1. 10 1
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/CooperatorParam.java
  2. 16 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/ShopIdParam.java
  3. 32 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/ShopProcessWithdrawParam.java
  4. 18 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/WithDrawOpenParam.java
  5. 20 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/WithQueryParam.java
  6. 24 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/platmatModel/ShopBalanceModel.java
  7. 16 0
      PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/platmatModel/ShopOpenWithDrawModel.java
  8. 21 27
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/unionFrictionlessPay/CooperatorController.java
  9. 8 1
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/domain/unionFrictionlessPay/ShopOpenWithDraw.java
  10. 3 0
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/domain/unionFrictionlessPay/ShopWithDrawRecord.java
  11. 1 1
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/org/CollectionIdService.java
  12. 0 11
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/CooperatorService.java
  13. 154 14
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionFrictionlessPayMainService.java
  14. 3 3
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionRequestService.java

+ 10 - 1
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/CooperatorParam.java

@@ -2,6 +2,9 @@ package com.zhongshu.payment.client.payModel.cooperator;
 
 import com.github.microservice.models.type.PaymentType;
 import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.Min;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.Size;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import org.hibernate.internal.build.AllowPrintStacktrace;
@@ -32,12 +35,18 @@ public class CooperatorParam {
     private String schoolId;
 
     @Schema(description = "商户oid")
+    @NotEmpty(message = "商户oid不能为空")
     private String shopId;
 
     @Schema(description = "提现金额,单位分")
-    private BigDecimal withdrawAmt;
+    @Min(value = 1, message = "提现金额必须大于等于1")
+    private Integer withdrawAmt;
 
     @Schema(description = "提现类型 0 - D0 1 - D1(对公对私是TN内部维护)")
     private String withdrawType = "0";
 
+    @Schema(description = "提现备注")
+    @Size(max = 50)
+    private String remark;
+
 }

+ 16 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/ShopIdParam.java

@@ -0,0 +1,16 @@
+package com.zhongshu.payment.client.payModel.cooperator;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author TRX
+ * @date 2024/9/6
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ShopIdParam {
+    private String shopId;
+}

+ 32 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/ShopProcessWithdrawParam.java

@@ -0,0 +1,32 @@
+package com.zhongshu.payment.client.payModel.cooperator;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.Min;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.Size;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 提现
+ *
+ * @author TRX
+ * @date 2024/9/6
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ShopProcessWithdrawParam {
+    @Schema(description = "商户oid")
+    @NotEmpty(message = "商户oid不能为空")
+    private String shopId;
+
+    @Schema(description = "提现金额,单位分")
+    @Min(value = 1, message = "提现金额必须大于等于1")
+    private Integer withdrawAmt;
+
+    @Schema(description = "提现备注")
+    @Size(max = 50)
+    private String remark;
+}

+ 18 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/WithDrawOpenParam.java

@@ -0,0 +1,18 @@
+package com.zhongshu.payment.client.payModel.cooperator;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author TRX
+ * @date 2024/9/6
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class WithDrawOpenParam {
+    @Schema(description = "商户oid")
+    private String shopOid;
+}

+ 20 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/WithQueryParam.java

@@ -0,0 +1,20 @@
+package com.zhongshu.payment.client.payModel.cooperator;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author TRX
+ * @date 2024/9/6
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class WithQueryParam {
+    @Schema(description = "提现订单号")
+    @NotEmpty(message = "订单号不能为空")
+    private String sysOrderId;
+}

+ 24 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/platmatModel/ShopBalanceModel.java

@@ -0,0 +1,24 @@
+package com.zhongshu.payment.client.payModel.cooperator.platmatModel;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+
+/**
+ * @author TRX
+ * @date 2024/9/6
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ShopBalanceModel {
+
+    @Schema(description = "商户oid")
+    private String shopId;
+
+    @Schema(description = "可提现金额")
+    private BigDecimal amount = BigDecimal.ZERO;
+}

+ 16 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/cooperator/platmatModel/ShopOpenWithDrawModel.java

@@ -1,5 +1,6 @@
 package com.zhongshu.payment.client.payModel.cooperator.platmatModel;
 
+import com.github.microservice.types.unionFrictionlessPayType.WithDrawOpenState;
 import com.zhongshu.card.client.model.base.SuperModel;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
@@ -24,6 +25,21 @@ public class ShopOpenWithDrawModel extends SuperModel {
     @Schema(description = "商户号")
     private String mchntNo;
 
+    @Schema(description = "开通状态")
+    private WithDrawOpenState withDrawOpenState;
+
+    private String withDrawOpenStateName;
+
+    public String getWithDrawOpenStateName() {
+        if (withDrawOpenState != null) {
+            return withDrawOpenState.getName();
+        }
+        return "";
+    }
+
+    @Schema(description = "开通时间")
+    private Long openTime;
+
     @Schema(description = "是否满足开通D0标记 00:不满90天 01:满足开通条件02:商户异常")
     private String status;
 

+ 21 - 27
PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/unionFrictionlessPay/CooperatorController.java

@@ -7,7 +7,7 @@ import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.model.payment.ExpenseFlowModel;
 import com.zhongshu.card.client.model.payment.ExpenseFlowSearch;
 import com.zhongshu.payment.client.payModel.commn.PayNotifyParam;
-import com.zhongshu.payment.client.payModel.cooperator.CooperatorParam;
+import com.zhongshu.payment.client.payModel.cooperator.*;
 import com.zhongshu.payment.client.payModel.cooperator.platmatModel.ShopOpenWithDrawModel;
 import com.zhongshu.payment.client.payModel.cooperator.platmatModel.ShopWithDrawRecordModel;
 import com.zhongshu.payment.client.payModel.cooperator.platmatModel.ShopWithDrawRecordSearch;
@@ -56,41 +56,42 @@ public class CooperatorController {
     CooperatorService cooperatorService;
 
     //---------------------------业务 start-----------------------------
+
+    @Operation(summary = "收钱吧-查询开通信息")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @PostMapping(value = "queryWithdrawAuthstatus", consumes = MediaType.APPLICATION_JSON_VALUE)
+    public ResultContent queryWithdrawAuthstatus(@RequestBody @Valid WithDrawOpenParam param) {
+        return unionFrictionlessPayMainService.getCooperatorOpenInfo(param);
+    }
+
+    @Operation(summary = "收钱吧-开通提现")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @PostMapping(value = "openWithdraw", consumes = MediaType.APPLICATION_JSON_VALUE)
+    public ResultContent openWithdraw(@RequestBody @Valid WithDrawOpenParam param) {
+        return unionFrictionlessPayMainService.cooperatorOpen(param);
+    }
+
     @Operation(summary = "查询商户可提现金额")
     @ResourceAuth(value = "user", type = AuthType.User)
     @PostMapping(value = "queryWithdrawBalance", consumes = MediaType.APPLICATION_JSON_VALUE)
-    public ResultContent queryWithdrawBalance(@RequestBody @Valid CooperatorParam param) {
+    public ResultContent queryWithdrawBalance(@RequestBody @Valid ShopIdParam param) {
         return unionFrictionlessPayMainService.queryWithdrawBalance(param);
     }
 
     @Operation(summary = "提现")
     @ResourceAuth(value = "user", type = AuthType.User)
     @PostMapping(value = "processWithdraw", consumes = MediaType.APPLICATION_JSON_VALUE)
-    public ResultContent processWithdraw(@RequestBody @Valid CooperatorParam param) {
+    public ResultContent processWithdraw(@RequestBody @Valid ShopProcessWithdrawParam param) {
         return unionFrictionlessPayMainService.processWithdraw(param);
     }
 
     @Operation(summary = "提现状态查询")
     @ResourceAuth(value = "user", type = AuthType.User)
     @PostMapping(value = "queryOrderStatus", consumes = MediaType.APPLICATION_JSON_VALUE)
-    public ResultContent queryOrderStatus(@RequestBody @Valid CooperatorParam param) {
+    public ResultContent queryOrderStatus(@RequestBody @Valid WithQueryParam param) {
         return unionFrictionlessPayMainService.queryOrderStatus(param);
     }
 
-    @Operation(summary = "收钱吧-D+0开通权限查询")
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @PostMapping(value = "queryWithdrawAuthstatus", consumes = MediaType.APPLICATION_JSON_VALUE)
-    public ResultContent queryWithdrawAuthstatus(@RequestBody @Valid CooperatorParam param) {
-        return unionFrictionlessPayMainService.queryWithdrawAuthstatus(param);
-    }
-
-    @Operation(summary = "收钱吧-平台方通知开通D+0提现")
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @PostMapping(value = "openWithdraw", consumes = MediaType.APPLICATION_JSON_VALUE)
-    public ResultContent openWithdraw(@RequestBody @Valid CooperatorParam param) {
-        return unionFrictionlessPayMainService.openWithdraw(param);
-    }
-
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "提现记录-分页列表", description = "提现记录-分页列表")
     @RequestMapping(value = {"pageWithDraw"}, method = {RequestMethod.POST})
@@ -106,27 +107,20 @@ public class CooperatorController {
         return cooperatorService.getWithDrawById(id);
     }
 
-    @Operation(summary = "根据订单号查询记录详情", description = "根据订单号查询记录详情")
+    @Operation(summary = "根据订单号查询提现记录详情", description = "根据订单号查询记录详情")
     @GetMapping(value = "getWithDrawBySysOrderId")
     public ResultContent<ShopWithDrawRecordModel> getWithDrawBySysOrderId(
             @RequestParam("sysOrderId") String sysOrderId) {
         return cooperatorService.getWithDrawBySysOrderId(sysOrderId);
     }
 
-    @Operation(summary = "根据流水号查询记录详情", description = "根据流水号查询记录详情")
+    @Operation(summary = "根据流水号查询提现记录详情", description = "根据流水号查询记录详情")
     @GetMapping(value = "getWithDrawBySsn")
     public ResultContent<ShopWithDrawRecordModel> getWithDrawBySsn(
             @RequestParam("ssn") String ssn) {
         return cooperatorService.getWithDrawBySsn(ssn);
     }
 
-    @Operation(summary = "查询 商户开通提现信息", description = "查询 商户开通提现信息")
-    @GetMapping(value = "getOpenWithDrawInfo")
-    public ResultContent<ShopOpenWithDrawModel> getOpenWithDrawInfo(
-            @RequestParam("shopId") String shopId) {
-        return cooperatorService.getOpenWithDrawInfo(shopId);
-    }
-
     //---------------------------通知 start-----------------------------
     @Operation(summary = "提现结果通知回调")
     @PostMapping(value = "withDrawNotify/{sysOrderId}", consumes = MediaType.APPLICATION_JSON_VALUE)

+ 8 - 1
PaymentServer/src/main/java/com/zhongshu/payment/server/core/domain/unionFrictionlessPay/ShopOpenWithDraw.java

@@ -1,5 +1,6 @@
 package com.zhongshu.payment.server.core.domain.unionFrictionlessPay;
 
+import com.github.microservice.types.unionFrictionlessPayType.WithDrawOpenState;
 import com.zhongshu.payment.server.core.domain.base.SuperMain;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
@@ -24,7 +25,13 @@ public class ShopOpenWithDraw extends SuperMain {
     @Schema(description = "商户号")
     private String mchntNo;
 
-    @Schema(description = "是否满足开通D0标记 00:不满90天 01:满足开通条件02:商户异常")
+    @Schema(description = "开通状态")
+    private WithDrawOpenState withDrawOpenState;
+
+    @Schema(description = "开通时间")
+    private Long openTime;
+
+    @Schema(description = "是否满足开通D0标记 00:不满90天 01:满足开通条件 02:商户异常")
     private String status;
 
     @Schema(description = "是否允许开通")

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

@@ -25,6 +25,9 @@ public class ShopWithDrawRecord extends SuperMain {
     @Schema(description = "商户名称")
     private String shopName;
 
+    @Schema(description = "系统编号")
+    private String sysId;
+
     @Schema(description = "商户号")
     private String mchntNo;
 

+ 1 - 1
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/org/CollectionIdService.java

@@ -42,7 +42,7 @@ public class CollectionIdService {
         String collectionName = sign + shortSdf.format(new Date());
         Long no = collectionIdDao.getNextId(collectionName);
         if (no != null) {
-            return String.format("%s%s%04d", sign, shortSdf.format(new Date()), no);
+            return String.format("%s%s%05d", sign, shortSdf.format(new Date()), no);
         }
         return "";
     }

+ 0 - 11
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/CooperatorService.java

@@ -40,17 +40,6 @@ public class CooperatorService extends SuperService {
     @Autowired
     OrganizationFeignService organizationFeignService;
 
-    /**
-     * 查询 商户开通提现信息
-     *
-     * @param shopId
-     * @return
-     */
-    public ResultContent<ShopOpenWithDrawModel> getOpenWithDrawInfo(String shopId) {
-        ShopOpenWithDraw openInfo = shopOpenWithDrawDao.findTopByShopId(shopId);
-        return ResultContent.buildSuccess(toModel(openInfo));
-    }
-
     /**
      * 提现记录列表
      *

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

@@ -13,7 +13,10 @@ import com.github.microservice.stream.model.OrderStateModel;
 import com.github.microservice.stream.model.SignModel;
 import com.github.microservice.types.OrderState;
 import com.github.microservice.types.RefundStatus;
+import com.github.microservice.types.unionFrictionlessPayType.WithDrawOpenState;
+import com.github.microservice.types.unionFrictionlessPayType.WithDrawState;
 import com.zhongshu.card.client.model.org.OrgUserDetailParam;
+import com.zhongshu.card.client.model.org.OrganizationSimpleModel;
 import com.zhongshu.card.client.model.org.OrganizationUserModel;
 import com.zhongshu.card.client.model.org.UserCountModel;
 import com.zhongshu.card.client.service.feign.OrganizationFeignService;
@@ -27,8 +30,10 @@ 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.cooperator.CooperatorParam;
+import com.zhongshu.payment.client.payModel.cooperator.*;
 import com.zhongshu.payment.client.payModel.cooperator.model.*;
+import com.zhongshu.payment.client.payModel.cooperator.platmatModel.ShopBalanceModel;
+import com.zhongshu.payment.client.payModel.cooperator.platmatModel.ShopOpenWithDrawModel;
 import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.*;
 import com.github.microservice.types.unionFrictionlessPayType.ContractState;
 import com.github.microservice.types.unionFrictionlessPayType.UnionUserOpenType;
@@ -38,8 +43,11 @@ import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.Us
 import com.zhongshu.payment.client.types.TradeType;
 import com.zhongshu.payment.server.core.dao.RechargeRecordDao;
 import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.ShopOpenWithDrawDao;
+import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.ShopWithDrawRecordDao;
 import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.UnionUserOpenInfoDao;
 import com.zhongshu.payment.server.core.dataConfig.TimeConfig;
+import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.ShopOpenWithDraw;
+import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.ShopWithDrawRecord;
 import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.UnionUserOpenInfo;
 import com.zhongshu.payment.server.core.domain.wallet.RechargeRecord;
 import com.zhongshu.payment.server.core.service.org.CollectionIdService;
@@ -116,6 +124,12 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
     @Autowired
     ShopOpenWithDrawDao shopOpenWithDrawDao;
 
+    @Autowired
+    ShopWithDrawRecordDao shopWithDrawRecordDao;
+
+    @Autowired
+    CooperatorService cooperatorService;
+
     /**
      * 发起签约
      *
@@ -720,7 +734,12 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
      * @param param
      * @return
      */
-    public ResultContent queryWithdrawBalance(CooperatorParam param) {
+    public ResultContent<ShopBalanceModel> queryWithdrawBalance(ShopIdParam param) {
+        String shopId = param.getShopId();
+        ResultContent<OrganizationSimpleModel> resultContent = organizationFeignService.getDetail(shopId);
+        if (resultContent.isFailed()) {
+            return ResultContent.buildFail(resultContent.getMsg());
+        }
         QueryWithdrawBalanceParam requestParam = new QueryWithdrawBalanceParam();
         requestParam.setMchntNo(getMchntNo(param.getShopId()));
         requestParam.setSysId(withdrawConfig.getSysid());
@@ -733,7 +752,11 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
             return ResultContent.buildFail(requestAPI.getMsg());
         }
         QueryWithdrawBalanceResponse response = (QueryWithdrawBalanceResponse) requestAPI;
-        return ResultContent.buildSuccess();
+        ShopBalanceModel balanceModel = new ShopBalanceModel();
+        balanceModel.setShopId(shopId);
+        BigDecimal amount = new BigDecimal(response.getT0WithdrawAmt());
+        balanceModel.setAmount(amount);
+        return ResultContent.buildSuccess(balanceModel);
     }
 
     /**
@@ -742,23 +765,56 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
      * @param param
      * @return
      */
-    public ResultContent processWithdraw(CooperatorParam param) {
+    public ResultContent processWithdraw(ShopProcessWithdrawParam param) {
+        String shopId = param.getShopId();
+        ResultContent<OrganizationSimpleModel> resultContent = organizationFeignService.getDetail(shopId);
+        if (resultContent.isFailed()) {
+            return ResultContent.buildFail(resultContent.getMsg());
+        }
+        // 提现金额
+        BigDecimal withdrawAmt = BigDecimal.valueOf(param.getWithdrawAmt());
+
         ProcessWithdrawParam requestParam = new ProcessWithdrawParam();
-        requestParam.setMchntNo(getMchntNo(param.getShopId()));
+        requestParam.setMchntNo(getMchntNo(shopId));
         requestParam.setSysId(withdrawConfig.getSysid());
         requestParam.setAppType(withdrawConfig.getAppType());
         String sysOrderId = collectionIdService.getNextNo();
         requestParam.setSysOrderId(sysOrderId);
-
+        requestParam.setNotifyUrl(payConfig.getNotifyUrl() + "/" + sysOrderId);
+        requestParam.setWithdrawAmt(withdrawAmt.toPlainString()); // 提现金额
+        requestParam.setRemark(param.getRemark());
+        requestParam.setPostscript("提现");
+
+        // 商户信息
+        OrganizationSimpleModel shopInfo = resultContent.getContent();
+        // 提现记录数据
+        ShopWithDrawRecord drawRecord = new ShopWithDrawRecord();
+        drawRecord.setShopId(shopId);
+        drawRecord.setShopName(shopInfo.getName());
+        drawRecord.setMchntNo(getMchntNo(shopId));
+        drawRecord.setUserId(getCurrentUserId());
+        drawRecord.setWithDrawState(WithDrawState.WithDrawing);
+        drawRecord.setSysOrderId(sysOrderId);
+        drawRecord.setWithdrawAmt(withdrawAmt);
+        drawRecord.setTimes();
+        drawRecord.setRequestParam(requestParam);
+        drawRecord.setRemark(param.getRemark());
+        drawRecord.setSysId(requestParam.getSysId());
 
         String url = payApiConfig.getUrl(UnionFrictionlessPayApiConfig.processWithdraw);
         SuperCooperatorResponseModel requestAPI = unionRequestService.requestCooperatorAPI
                 (url, requestParam, ProcessWithdrawResponse.class);
+        drawRecord.setResponse(requestAPI);
         if (requestAPI.isFailed()) {
+            drawRecord.setWithDrawState(WithDrawState.Fail);
+            drawRecord.setDesc(String.format("提现失败,%s", requestAPI.getMsg()));
+            shopWithDrawRecordDao.save(drawRecord);
             return ResultContent.buildFail(requestAPI.getMsg());
         }
         ProcessWithdrawResponse response = (ProcessWithdrawResponse) requestAPI;
-        return ResultContent.buildSuccess();
+        drawRecord.setSsn(response.getSsn());
+        shopWithDrawRecordDao.save(drawRecord);
+        return ResultContent.buildSuccess(drawRecord);
     }
 
     /**
@@ -767,9 +823,16 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
      * @param param
      * @return
      */
-    public ResultContent queryOrderStatus(CooperatorParam param) {
+    public ResultContent<QueryOrderStatusResponse> queryOrderStatus(WithQueryParam param) {
+        ShopWithDrawRecord drawRecord = shopWithDrawRecordDao.findTopBySysOrderId(param.getSysOrderId());
+        if (ObjectUtils.isEmpty(drawRecord)) {
+            return ResultContent.buildFail(String.format("订单号不存在:%s", param.getSysOrderId()));
+        }
         QueryOrderStatusParam requestParam = new QueryOrderStatusParam();
-
+        requestParam.setMchntNo(drawRecord.getMchntNo());
+        requestParam.setSysOrderId(drawRecord.getSysOrderId());
+        requestParam.setTransDate(DateUtils.paresTime(drawRecord.getCreateTime(), DateUtils.pattern1));
+        requestParam.setSysId(drawRecord.getSysId());
         String url = payApiConfig.getUrl(UnionFrictionlessPayApiConfig.queryOrderStatus);
         SuperCooperatorResponseModel requestAPI = unionRequestService.requestCooperatorAPI
                 (url, requestParam, QueryOrderStatusResponse.class);
@@ -777,7 +840,74 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
             return ResultContent.buildFail(requestAPI.getMsg());
         }
         QueryOrderStatusResponse response = (QueryOrderStatusResponse) requestAPI;
-        return ResultContent.buildSuccess();
+
+        return ResultContent.buildSuccess(response);
+    }
+
+    /**
+     * 查询开通收钱吧 状态  业务
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent<ShopOpenWithDrawModel> getCooperatorOpenInfo(WithDrawOpenParam param) {
+        String shopOid = param.getShopOid();
+        ResultContent<OrganizationSimpleModel> resultContent = organizationFeignService.getDetail(shopOid);
+        if (resultContent.isFailed()) {
+            return ResultContent.buildFail(resultContent.getMsg());
+        }
+        ShopOpenWithDraw shopOpenWithDraw = shopOpenWithDrawDao.findTopByShopId(shopOid);
+        if (ObjectUtils.isEmpty(shopOpenWithDraw)) {
+            shopOpenWithDraw = new ShopOpenWithDraw();
+            OrganizationSimpleModel simpleModel = resultContent.getContent();
+            shopOpenWithDraw.setShopId(shopOid);
+            shopOpenWithDraw.setShopName(simpleModel.getName());
+            shopOpenWithDraw.setMchntNo(getMchntNo(shopOid));
+            shopOpenWithDraw.setWithDrawOpenState(WithDrawOpenState.UnOpen);
+            shopOpenWithDrawDao.save(shopOpenWithDraw);
+        }
+        if (shopOpenWithDraw.getWithDrawOpenState() == WithDrawOpenState.UnOpen) {
+            ResultContent<QueryWithdrawAuthstatusResponse> responseResultContent = queryWithdrawAuthstatus(param);
+            if (responseResultContent.isFailed()) {
+                return ResultContent.buildFail(responseResultContent.getMsg());
+            }
+            QueryWithdrawAuthstatusResponse authstatusResponse = responseResultContent.getContent();
+            shopOpenWithDraw.setStatus(authstatusResponse.getStatus());
+            shopOpenWithDrawDao.save(shopOpenWithDraw);
+        }
+        return ResultContent.buildSuccess(toModel(shopOpenWithDraw));
+    }
+
+    /**
+     * 商户开通 收钱吧 提现功能
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent<ShopOpenWithDrawModel> cooperatorOpen(WithDrawOpenParam param) {
+        String shopOid = param.getShopOid();
+        ResultContent<OrganizationSimpleModel> resultContent = organizationFeignService.getDetail(shopOid);
+        if (resultContent.isFailed()) {
+            return ResultContent.buildFail(resultContent.getMsg());
+        }
+        ShopOpenWithDraw shopOpenWithDraw = shopOpenWithDrawDao.findTopByShopId(shopOid);
+        if (ObjectUtils.isEmpty(shopOpenWithDraw)) {
+            return ResultContent.buildFail(String.format("未查询到开通记录:%s", shopOid));
+        }
+        if (shopOpenWithDraw.getWithDrawOpenState() == WithDrawOpenState.UnOpen) {
+            ResultContent<OpenWithdrawResponse> responseResultContent = openWithdraw(param);
+            if (responseResultContent.isFailed()) {
+                return ResultContent.buildFail(responseResultContent.getMsg());
+            }
+            OpenWithdrawResponse response = responseResultContent.getContent();
+            shopOpenWithDraw.setType(response.getType());
+            if (response.getStatus().equals("01")) {
+                // 满足开通条件
+                shopOpenWithDraw.setWithDrawOpenState(WithDrawOpenState.Open);
+            }
+            shopOpenWithDrawDao.save(shopOpenWithDraw);
+        }
+        return ResultContent.buildSuccess(toModel(shopOpenWithDraw));
     }
 
     /**
@@ -786,8 +916,15 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
      * @param param
      * @return
      */
-    public ResultContent queryWithdrawAuthstatus(CooperatorParam param) {
+    public ResultContent<QueryWithdrawAuthstatusResponse> queryWithdrawAuthstatus(WithDrawOpenParam param) {
+        String shopId = param.getShopOid();
+        ResultContent<OrganizationSimpleModel> resultContent = organizationFeignService.getDetail(shopId);
+        if (resultContent.isFailed()) {
+            return ResultContent.buildFail(resultContent.getMsg());
+        }
         QueryWithdrawAuthstatusParam requestParam = new QueryWithdrawAuthstatusParam();
+        requestParam.setMchntNo(getMchntNo(shopId));
+        requestParam.setSysId(withdrawConfig.getSysid());
 
         String url = payApiConfig.getUrl(UnionFrictionlessPayApiConfig.queryWithdrawAuthstatus);
         SuperCooperatorResponseModel requestAPI = unionRequestService.requestCooperatorAPI
@@ -796,7 +933,7 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
             return ResultContent.buildFail(requestAPI.getMsg());
         }
         QueryWithdrawAuthstatusResponse response = (QueryWithdrawAuthstatusResponse) requestAPI;
-        return ResultContent.buildSuccess();
+        return ResultContent.buildSuccess(response);
     }
 
     /**
@@ -805,7 +942,7 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
      * @param param
      * @return
      */
-    public ResultContent openWithdraw(CooperatorParam param) {
+    public ResultContent<OpenWithdrawResponse> openWithdraw(WithDrawOpenParam param) {
         OpenWithdrawParam requestParam = new OpenWithdrawParam();
         String url = payApiConfig.getUrl(UnionFrictionlessPayApiConfig.openWithdraw);
         SuperCooperatorResponseModel requestAPI = unionRequestService.requestCooperatorAPI
@@ -814,7 +951,6 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
             return ResultContent.buildFail(requestAPI.getMsg());
         }
         OpenWithdrawResponse response = (OpenWithdrawResponse) requestAPI;
-
         return ResultContent.buildSuccess();
     }
 
@@ -904,4 +1040,8 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
         return model;
     }
 
+    public ShopOpenWithDrawModel toModel(ShopOpenWithDraw entity) {
+        return cooperatorService.toModel(entity);
+    }
+
 }

+ 3 - 3
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionRequestService.java

@@ -195,10 +195,10 @@ public class UnionRequestService extends SuperService {
 
             String timestamp = DateUtils.paresTime(System.currentTimeMillis(), DateUtils.unionAuth);
             String nonce = CommonUtil.UUID();
-            String c = String.format("%s%s%s%s", payConfig.getAppId(), timestamp, nonce, sign);
+            String c = String.format("%s%s%s%s", withdrawConfig.getAppId(), timestamp, nonce, sign);
 
-            String signature = AesUtils.signMacSHA256(c, payConfig.getAppKey());
-            String authorization = "OPEN-BODY-SIG AppId=" + "\"" + payConfig.getAppId() + "\""
+            String signature = AesUtils.signMacSHA256(c, withdrawConfig.getAppKey());
+            String authorization = "OPEN-BODY-SIG AppId=" + "\"" + withdrawConfig.getAppId() + "\""
                     + ",Timestamp=" + "\"" + timestamp + "\""
                     + ",Nonce=" + "\"" + nonce + "\""
                     + ",Signature=" + "\"" + signature + "\"";