|
@@ -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;
|
|
@@ -19,6 +22,7 @@ import com.yonge.cooleshow.biz.dal.service.PaymentMerchantConfigService;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
|
|
|
* 支付三方账户配置
|
|
@@ -39,9 +43,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 +63,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 +89,80 @@ 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());
|
|
|
+ if (Objects.nonNull(properties.getWxpay())) {
|
|
|
+ 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.setPayType(config.getPaymentVendor());
|
|
|
+ aliPayConfig.setPayNotifyUrl(properties.getPayNotifyUrl());
|
|
|
+ aliPayConfig.setRefundNotifyUrl(properties.getRefundNotifyUrl());
|
|
|
+ if (Objects.nonNull(properties.getAlipay())) {
|
|
|
+ aliPayConfig.setFeeRate(properties.getAlipay().getFeeRate());
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
|