Browse Source

Merge branch 'feature/0721-tenant'

liujc 1 year ago
parent
commit
d03b33e1d8

+ 4 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/SysUserFeignService.java

@@ -66,6 +66,10 @@ public interface SysUserFeignService {
 	@ApiOperation(value = "退出登录")
 	HttpResponseResult<String> logout();
 
+	@GetMapping(value = "exit/{clientId}/{phone}")
+	@ApiOperation(value = "退出登录")
+	HttpResponseResult<String> logout(@PathVariable("clientId") String clientId, @PathVariable("phone") String phone);
+
 	@PostMapping(value = "user/list")
 	HttpResponseResult<List<SysUser>> page(@RequestBody SysUserQueryInfo queryInfo);
 

+ 4 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/fallback/SysUserFeignServiceFallback.java

@@ -77,6 +77,10 @@ public class SysUserFeignServiceFallback implements SysUserFeignService {
 		return HttpResponseResult.failed("请求失败");
 	}
 
+	@Override
+	public HttpResponseResult<String> logout(String phone, String client) {
+		return null;
+	}
 
 	@Override
 	public HttpResponseResult<List<SysUser>> page(SysUserQueryInfo queryInfo) {

+ 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;
 

+ 5 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/execl/analysis/TenantAccountRecordImportAnalysis.java

@@ -102,6 +102,11 @@ public class TenantAccountRecordImportAnalysis extends DataAnalysis<TenantAccoun
             tenantAccountRecord = recordMap.get(item.getId());
             if (Objects.isNull(tenantAccountRecord)) {
                 ret += "流水记录编号无效:" + item.getId();
+                if (StringUtils.isNotEmpty(ret)) {
+                    verifyDataMap.put(item.getRowIndex(), ret);
+                    ret = ""; // 重置数据状态
+                }
+                continue;
             }
 
             // 检测机构编号,金额,订单号,结算状态

+ 76 - 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;
@@ -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);
     }
 
     /**

+ 11 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantInfoServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.biz.dal.dao.StudentDao;
 import com.yonge.cooleshow.biz.dal.dao.TeacherDao;
 import com.yonge.cooleshow.biz.dal.entity.SysArea;
@@ -13,6 +14,7 @@ import com.yonge.cooleshow.biz.dal.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.entity.Teacher;
 import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantApplyRecordMapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantEntryRecordMapper;
@@ -30,10 +32,12 @@ import com.yonge.cooleshow.common.enums.SysUserType;
 import com.yonge.cooleshow.common.enums.UserLockFlag;
 import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.utils.obj.ObjectUtil;
+import feign.Client;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.token.TokenService;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -87,6 +91,9 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
     @Autowired
     private StudentDao studentDao;
 
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
 
     /**
      * 查询详情
@@ -423,7 +430,10 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
         }
 
         //判断修改手机号后所属
-
+        if (!info.getPhone().equals(oldTenantInfo.getPhone())) {
+            // 清除登录token信息
+            sysUserFeignService.logout(ClientEnum.ORGANIZATION.getCode(), oldTenantInfo.getPhone());
+        }
         tenantInfoMapper.update(null, Wrappers.<TenantInfo>lambdaUpdate()
                 .set(TenantInfo::getName, info.getName())
                 .set(TenantInfo::getLogo, info.getLogo())