Browse Source

Merge remote-tracking branch 'origin/feature/0721-tenant' into feature/0721-tenant

yuanliang 1 năm trước cách đây
mục cha
commit
e05522ed6b

+ 1 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/enums/EPayerType.java

@@ -7,6 +7,7 @@ public enum EPayerType implements BaseEnum<String, EPayerType> {
 
     ADAPAY("adapay"),
     YEEPAY("yeepay"),
+    ORIGINAL("original"),
     ;
 
     @EnumValue

+ 57 - 17
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/PaymentMerchantConfig.java

@@ -24,9 +24,8 @@ import java.util.Date;
 public class PaymentMerchantConfig implements Serializable {
 
     @ApiModelProperty("主键") 
-
     @TableId(value = "id_", type = IdType.AUTO)
-	    private Long id;
+    private Long id;
 
     @ApiModelProperty("机构ID") 
 	@TableField(value = "tenant_id_")
@@ -48,8 +47,7 @@ public class PaymentMerchantConfig implements Serializable {
     @TableField(value = "platform_payee_member_id_")
     private String platformPayeeMemberId;
 
-
-    @ApiModelProperty("商户ID") 
+    @ApiModelProperty("商户ID")
 	@TableField(value = "app_id_")
     private String appId;
 
@@ -85,29 +83,71 @@ public class PaymentMerchantConfig implements Serializable {
 	@TableField(value = "wx_app_secret_")
     private String wxAppSecret;
 
-    @ApiModelProperty("支付宝Key") 
-	@TableField(value = "alipay_app_id_")
+    @ApiModelProperty("小程序appId")
+    @TableField(value = "mini_app_id_")
+    private String miniAppId;
+
+    @ApiModelProperty("小程序secret")
+    @TableField(value = "mini_app_secret_")
+    private String miniAppSerret;
+
+    @ApiModelProperty("支付客户端")
+    @TableField(value = "payment_client_")
+    private String paymentClient;
+
+    @ApiModelProperty("支付商户号")
+    @TableField(value = "wx_merchant_id_")
+    private String wxMerchantId;
+
+    @ApiModelProperty("支付私钥")
+    @TableField(value = "wx_merchant_private_key_")
+    private String wxMerchantPrivateKey;
+
+    @ApiModelProperty("微信商户序列号")
+    @TableField(value = "wx_merchant_serial_number_")
+    private String wxMerchantSerialNumber;
+
+    @ApiModelProperty("接口签名密钥")
+    @TableField(value = "wx_api_v3_key_")
+    private String wxApiV3Key;
+
+    @ApiModelProperty("私钥证书地址")
+    @TableField(value = "wx_private_cert_path_")
+    private String wxPrivateCertPath;
+
+    @ApiModelProperty("私钥Key地址")
+    @TableField(value = "wx_private_key_path_")
+    private String wxPrivateKeyPath;
+
+    @ApiModelProperty("支付宝Key")
+    @TableField(value = "alipay_app_id_")
     private String alipayAppId;
 
-    @ApiModelProperty("支付宝私钥") 
-	@TableField(value = "alipay_private_key_")
+    @ApiModelProperty("支付宝私钥")
+    @TableField(value = "alipay_private_key_")
     private String alipayPrivateKey;
 
-    @ApiModelProperty("支付宝公钥") 
-	@TableField(value = "alipay_public_key_")
+    @ApiModelProperty("支付宝公钥")
+    @TableField(value = "alipay_public_key_")
     private String alipayPublicKey;
 
+    @ApiModelProperty("签名方式")
+    @TableField(value = "alipay_sign_type_")
+    private String aliPaySignType;
 
-    @ApiModelProperty("小程序appId")
-    @TableField(value = "mini_app_id_")
-    private String miniAppId;
+    @ApiModelProperty("内容签名方式")
+    @TableField(value = "alipay_content_sign_type_")
+    private String alipayContentSignType;
 
-    @ApiModelProperty("小程序secret")
-    @TableField(value = "mini_app_secret_")
-    private String miniAppSerret;
+    @ApiModelProperty("内容签名密钥")
+    @TableField(value = "alipay_content_sign_key_")
+    private String aliPayContentSignKey;
 
+    @ApiModelProperty("启用标识")
+    @TableField(value = "status_")
+    private Boolean status;
 
-    @ApiModelProperty("创建时间") 
+    @ApiModelProperty("创建时间")
 	@TableField(value = "create_time_")
     private Date createTime;
 

+ 71 - 8
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/PaymentMerchantConfigServiceImpl.java

@@ -3,8 +3,11 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
 import com.microsvc.toolkit.middleware.payment.common.api.PaymentServiceContext;
 import com.microsvc.toolkit.middleware.payment.impl.AdapayPaymentServicePlugin;
+import com.microsvc.toolkit.middleware.payment.impl.AliPaymentServicePlugin;
+import com.microsvc.toolkit.middleware.payment.impl.WxPaymentServicePlugin;
 import com.microsvc.toolkit.middleware.payment.impl.YeepayPaymentServicePlugin;
 import com.microsvc.toolkit.middleware.payment.properties.PayConfigProperties;
 import com.yonge.cooleshow.common.enums.EPayerType;
@@ -39,9 +42,11 @@ public class PaymentMerchantConfigServiceImpl extends ServiceImpl<PaymentMerchan
         if(CollectionUtils.isEmpty(list)) {
             return;
         }
+
+        List<String> pluginNames = Lists.newArrayList();
         for (PaymentMerchantConfig config : list) {
             if (config.getPayerType() == null) {
-
+                log.error("数据错误 {}", config);
             } else if (config.getPayerType().equals(EPayerType.ADAPAY)) {
 
                 PayConfigProperties.AdapayPayConfig adapayPayConfig = new PayConfigProperties.AdapayPayConfig();
@@ -57,12 +62,13 @@ public class PaymentMerchantConfigServiceImpl extends ServiceImpl<PaymentMerchan
                 adapayPayConfig.setWxAppId(config.getWxAppId());
                 adapayPayConfig.setWxAppSecret(config.getWxAppSecret());
                 adapayPayConfig.setSupportCreditCards(properties.getSupportCreditCards());
-                AdapayPaymentServicePlugin plugin = null;
                 try {
-                    plugin = new AdapayPaymentServicePlugin(config.getPaymentVendor(), adapayPayConfig, false);
+                    AdapayPaymentServicePlugin plugin = new AdapayPaymentServicePlugin(config.getPaymentVendor(), adapayPayConfig, false);
                     PaymentServiceContext.addPlugin(plugin);
+
+                    pluginNames.add(plugin.venderName());
                 } catch (Exception e) {
-                    log.error("初始化支付插件失败", e);
+                    log.error("初始[汇付]化支付插件失败", e);
                 }
             } else if (config.getPayerType().equals(EPayerType.YEEPAY)){
                 PayConfigProperties.YeepayPayConfig yeepayPayConfig = new PayConfigProperties.YeepayPayConfig();
@@ -82,19 +88,76 @@ public class PaymentMerchantConfigServiceImpl extends ServiceImpl<PaymentMerchan
                 yeepayPayConfig.setAlipayPublicKey(config.getAlipayPublicKey());
                 yeepayPayConfig.setMiniAppId(config.getMiniAppId());
                 yeepayPayConfig.setMiniAppSecret(config.getMiniAppSerret());
-                YeepayPaymentServicePlugin plugin;
                 try {
-                    plugin = new YeepayPaymentServicePlugin(config.getPaymentVendor(), yeepayPayConfig, false);
+                    YeepayPaymentServicePlugin plugin = new YeepayPaymentServicePlugin(config.getPaymentVendor(), yeepayPayConfig, false);
                     PaymentServiceContext.addPlugin(plugin);
+
+                    pluginNames.add(plugin.venderName());
                 } catch (Exception e) {
-                    log.error("初始化支付插件失败", e);
+                    log.error("初始化[易宝]支付插件失败", e);
+                }
+            } else if (config.getPayerType().equals(EPayerType.ORIGINAL)) {
+
+                // 原生微信支付
+                if (config.getPaymentVendor().startsWith("wxpay")) {
+                    PayConfigProperties.WxPayConfig wxPayConfig = new PayConfigProperties.WxPayConfig();
+                    wxPayConfig.setEnable(true);
+                    wxPayConfig.setWxAppId(config.getWxAppId());
+                    wxPayConfig.setWxAppSecret(config.getWxAppSecret());
+                    wxPayConfig.setMerchantId(config.getWxMerchantId());
+                    wxPayConfig.setMerchantPrivateKey(config.getWxMerchantPrivateKey());
+                    wxPayConfig.setMerchantSerialNumber(config.getWxMerchantSerialNumber());
+                    wxPayConfig.setApiV3Key(config.getWxApiV3Key());
+                    wxPayConfig.setPrivateCertPath(config.getWxPrivateCertPath());
+                    wxPayConfig.setPrivateKeyPath(config.getWxPrivateKeyPath());
+                    wxPayConfig.setPayType(config.getPaymentVendor());
+                    wxPayConfig.setPayNotifyUrl(properties.getPayNotifyUrl());
+                    wxPayConfig.setRefundNotifyUrl(properties.getRefundNotifyUrl());
+                    wxPayConfig.setFeeRate(properties.getWxpay().getFeeRate());
+
+                    try {
+                        // 初始化微信支付插件
+                        WxPaymentServicePlugin plugin = new WxPaymentServicePlugin(config.getPaymentVendor(), wxPayConfig, false);
+                        PaymentServiceContext.addPlugin(plugin);
+
+                        pluginNames.add(plugin.venderName());
+                    } catch (Exception e) {
+                        log.error("初始化[微信]支付插件失败", e);
+                    }
+                }
+
+                // 原生支付宝支付
+                if (config.getPaymentVendor().startsWith("alipay")) {
+                    PayConfigProperties.AliPayConfig aliPayConfig = new PayConfigProperties.AliPayConfig();
+                    aliPayConfig.setEnable(true);
+                    aliPayConfig.setAppId(config.getAlipayAppId());
+                    aliPayConfig.setPrivateKey(config.getAlipayPrivateKey());
+                    aliPayConfig.setPublicKey(config.getAlipayPublicKey());
+                    aliPayConfig.setSignType(config.getAliPaySignType());
+                    aliPayConfig.setEncryptType(config.getAlipayContentSignType());
+                    aliPayConfig.setEncryptKey(config.getAliPayContentSignKey());
+                    aliPayConfig.setUseCert(false);
+                    aliPayConfig.setPayNotifyUrl(properties.getPayNotifyUrl());
+                    aliPayConfig.setRefundNotifyUrl(properties.getRefundNotifyUrl());
+                    aliPayConfig.setFeeRate(properties.getAlipay().getFeeRate());
+                    aliPayConfig.setPayType(config.getPaymentVendor());
+
+                    try {
+                        // 初始化支付宝支付插件
+                        AliPaymentServicePlugin plugin = new AliPaymentServicePlugin(config.getPaymentVendor(), aliPayConfig, false);
+                        PaymentServiceContext.addPlugin(plugin);
+
+                        pluginNames.add(plugin.venderName());
+                    } catch (Exception e) {
+                        log.error("初始化[支付宝]支付插件失败", e);
+                    }
                 }
             } else {
                 log.error("数据错误 {}", config);
             }
 
         }
-
+        log.info("初始化支付插件完成, plugins={}", pluginNames);
     }
 
     /**