Pārlūkot izejas kodu

Merge branch 'feature/0721-tenant' into develop

Eric 1 gadu atpakaļ
vecāks
revīzija
4147dbd257

+ 42 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserPaymentCoreServiceImpl.java

@@ -736,12 +736,26 @@ public class UserPaymentCoreServiceImpl implements UserPaymentCoreService {
         // 查询订单状态
         UserPaymentOrderWrapper.UserPaymentOrder userPaymentOrder = userPaymentOrderService.getUserPaymentOrderByUserId(Long.parseLong(reqConfig.getUserId()),
             reqConfig.getMerOrderNo());
+
+        // 默认支付三方
+        if (StringUtils.isNotEmpty(reqConfig.getPaymentVendor())
+                && !reqConfig.getPaymentVendor().equals(userPaymentOrder.getPaymentVendor())) {
+            // 原生支付拉起支付时,可以切换支付渠道
+            UserPaymentOrderWrapper.UserPaymentOrder update = UserPaymentOrderWrapper.UserPaymentOrder
+                .builder()
+                .id(userPaymentOrder.getId())
+                .paymentVendor(reqConfig.getPaymentVendor())
+                .build();
+            userPaymentOrderService.updateById(update);
+
+            // 重置支付三方渠道
+            userPaymentOrder.setPaymentVendor(reqConfig.getPaymentVendor());
+        }
+
         if (Objects.isNull(userPaymentOrder)) {
             throw new BizException("订单不存在");
         }
 
-
-
 //         订单支付已完成
         switch (userPaymentOrder.getStatus()) {
             case PAID:
@@ -1045,11 +1059,33 @@ public class UserPaymentCoreServiceImpl implements UserPaymentCoreService {
         }
         
         // 结算给机构的,检测机构的主账户,没有主账户的,查询-1的主账户
-        PaymentMerchantConfig merchantConfig = paymentMerchantConfigService.getByPaymentVendor(paymentServiceContext.getProperties().getDefaultService());
-        if (Objects.isNull(merchantConfig)) {
-            throw new BizException("平台主账户信息不存在");
+        String defaultService = paymentServiceContext.getProperties().getDefaultService();
+        if (EPayerType.ORIGINAL.getCode().toLowerCase().equals(defaultService)) {
+            // 微信、支付宝原生支付
+            if (Objects.isNull(payTypeReq.getClientType())) {
+                throw new BizException("支付客户端类型不能为空");
+            }
+            List<PaymentMerchantConfig> configs = paymentMerchantConfigService.lambdaQuery()
+                    .eq(PaymentMerchantConfig::getPayerType, EPayerType.ORIGINAL.getCode())
+                    .eq(PaymentMerchantConfig::getPaymentClient, payTypeReq.getClientType().getCode())
+                    .eq(PaymentMerchantConfig::getStatus, true)
+                    .list();
+            if (CollectionUtils.isEmpty(configs)) {
+                throw new BizException("平台主账户信息不存在");
+            }
+            // 默认支付服务
+            resp.setPaymentVendor(configs.get(0).getPaymentVendor());
+
+            // 设置支付服务渠道
+            resp.setPaymentChannels(configs.stream().map(PaymentMerchantConfig::getPaymentVendor).distinct().collect(Collectors.toList()));
+        } else {
+            // 易宝,汇付三方支付
+            PaymentMerchantConfig merchantConfig = paymentMerchantConfigService.getByPaymentVendor(defaultService);
+            if (Objects.isNull(merchantConfig)) {
+                throw new BizException("平台主账户信息不存在");
+            }
+            resp.setPaymentVendor(merchantConfig.getPaymentVendor());
         }
-        resp.setPaymentVendor(merchantConfig.getPaymentVendor());
         return resp;
     }
 

+ 7 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/UserPaymentOrderWrapper.java

@@ -10,6 +10,7 @@ import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.enums.GoodTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.OrderStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.OrderTypeEnum;
+import com.yonge.cooleshow.common.enums.EPayerType;
 import com.yonge.cooleshow.common.enums.EPaymentVersion;
 import com.yonge.cooleshow.common.enums.payment.EGoodsType;
 import com.yonge.cooleshow.common.enums.payment.EPaymentStatus;
@@ -542,6 +543,9 @@ public class UserPaymentOrderWrapper {
     @ApiModel("订单支付参数配置")
     public static class PaymentOrderReqConfig implements Serializable {
 
+        @ApiModelProperty("支付三方")
+        private String paymentVendor;
+
         @ApiModelProperty("支付渠道")
         private String paymentChannel;
 
@@ -896,6 +900,9 @@ public class UserPaymentOrderWrapper {
 
         @ApiModelProperty("支付厂商")
         private String paymentVendor;
+
+        @ApiModelProperty("支付渠道")
+        private List<String> paymentChannels;
     }
 
 

+ 3 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/UserOrderController.java

@@ -105,6 +105,9 @@ public class UserOrderController {
         // 用户下单请求
         UserPaymentOrderWrapper.PaymentOrderReqConfig reqConfig = UserPaymentOrderWrapper.PaymentOrderReqConfig.from(config.jsonString());
 
+        // 支付三方
+        reqConfig.setPaymentVendor(config.getPaymentVendor());
+        // 请示IP地址
         reqConfig.setIp(ServletUtil.getClientIP(request));
         // 创建用户支付数据
         UserPaymentOrderWrapper.PaymentReq paymentConfig = userPaymentCoreService.executePayment(JwtUserInfo.builder()

+ 3 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/vo/UserPaymentOrderVo.java

@@ -197,6 +197,9 @@ public class UserPaymentOrderVo {
     @ApiModel("订单支付参数配置")
     public static class PaymentReqConfig implements Serializable {
 
+        @ApiModelProperty("支付三方")
+        private String paymentVendor;
+
         @ApiModelProperty("支付渠道")
         private String paymentChannel;