Commit d72b2281 by 程裕兵

feat:remove invalid code

parent 577ad23f
/*
* Copyright © 2024 Hangzhou Jiejing Technology Co., Ltd. All rights reserved.
*
* The copyright of the company's program code belongs to Hangzhou Jiejing Technology Co., Ltd. No one can illegally copy it without the explicit permission of this website.
* Official website: www.xiaomai5.com
*
*
*
* Copyright © 2024 杭州杰竞科技有限公司 版权所有.
*
* 本公司程序代码的版权归杭州杰竞科技有限公司所有,未经本网站的明确许可,任何人不得非法复制。
* 官网: www.xiaomai5.com
*/
package com.jiejing.fitness.finance.repository.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* <p>
* 全局配置
* </p>
*
* @author chengyubing, created on 2024-02-26
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class GlobalConfig implements Serializable {
private static final long serialVersionUID = -1305569959560661375L;
/**
* 备注: Key 是否允许为null: NO
*/
@TableId(value = "config_key", type = IdType.ID_WORKER)
private String configKey;
/**
* 是否允许为null: YES
*/
private String configValue;
public static final String CONFIG_KEY = "config_key";
public static final String CONFIG_VALUE = "config_value";
}
/*
* Copyright © 2024 Hangzhou Jiejing Technology Co., Ltd. All rights reserved.
*
* The copyright of the company's program code belongs to Hangzhou Jiejing Technology Co., Ltd. No one can illegally copy it without the explicit permission of this website.
* Official website: www.xiaomai5.com
*
*
*
* Copyright © 2024 杭州杰竞科技有限公司 版权所有.
*
* 本公司程序代码的版权归杭州杰竞科技有限公司所有,未经本网站的明确许可,任何人不得非法复制。
* 官网: www.xiaomai5.com
*/
package com.jiejing.fitness.finance.repository.mapper;
import com.jiejing.fitness.finance.repository.entity.GlobalConfig;
import com.jiejing.mbp.inject.XBaseMapper;
/**
* <p>
* 全局配置 Mapper 接口
* </p>
*
* @author chengyubing, created on 2024-02-26
*/
public interface GlobalConfigMapper extends XBaseMapper<GlobalConfig> {
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright © 2024 Hangzhou Jiejing Technology Co., Ltd. All rights reserved.
~
~ The copyright of the company's program code belongs to Hangzhou Jiejing Technology Co., Ltd. No one can illegally copy it without the explicit permission of this website.
~ Official website: www.xiaomai5.com
~
~
~
~ Copyright © 2024 杭州杰竞科技有限公司 版权所有.
~
~ 本公司程序代码的版权归杭州杰竞科技有限公司所有,未经本网站的明确许可,任何人不得非法复制。
~ 官网: www.xiaomai5.com
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jiejing.fitness.finance.repository.mapper.GlobalConfigMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
config_key, config_value
</sql>
</mapper>
/*
* Copyright © 2024 Hangzhou Jiejing Technology Co., Ltd. All rights reserved.
*
* The copyright of the company's program code belongs to Hangzhou Jiejing Technology Co., Ltd. No one can illegally copy it without the explicit permission of this website.
* Official website: www.xiaomai5.com
*
*
*
* Copyright © 2024 杭州杰竞科技有限公司 版权所有.
*
* 本公司程序代码的版权归杭州杰竞科技有限公司所有,未经本网站的明确许可,任何人不得非法复制。
* 官网: www.xiaomai5.com
*/
package com.jiejing.fitness.finance.repository.service;
import com.jiejing.fitness.finance.repository.entity.GlobalConfig;
import com.jiejing.fitness.finance.repository.mapper.GlobalConfigMapper;
import com.jiejing.mbp.MapperRepoService;
import org.springframework.stereotype.Service;
/**
* <p>
* 全局配置 服务实现类
* </p>
*
* @author chengyubing, created on 2024-02-26
*/
@Service
public class GlobalConfigRpService extends MapperRepoService<String, GlobalConfig, GlobalConfigMapper> {
}
...@@ -51,8 +51,9 @@ public class GeneratorServiceEntity { ...@@ -51,8 +51,9 @@ public class GeneratorServiceEntity {
*/ */
private String author = "chengyubing"; private String author = "chengyubing";
private String[] tableNames = { private String[] tableNames = {
"brand_merchant_apply", // "brand_merchant_apply",
"brand_to_merchant" // "brand_to_merchant",
"global_config"
}; };
/** /**
......
package com.jiejing.fitness.finance.service.enums;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author chengyubing
* @since 2024/2/26 09:37
*/
@Getter
@AllArgsConstructor
public enum GlobalConfigEnums {
/**
* 全局配置key
*/
BRAND_MERCHANT_SUB_CHANNELS("BRAND_MERCHANT_SUB_CHANNELS", "品牌商户默认开通的子渠道以及对应费率"),
;
@EnumValue
private final String code;
private final String desc;
}
...@@ -3,7 +3,6 @@ package com.jiejing.fitness.finance.service.merchant.convert; ...@@ -3,7 +3,6 @@ package com.jiejing.fitness.finance.service.merchant.convert;
import static com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums.*; import static com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums.*;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.jiejing.common.utils.convert.BeanUtil; import com.jiejing.common.utils.convert.BeanUtil;
import com.jiejing.common.utils.crypt.AesUtil; import com.jiejing.common.utils.crypt.AesUtil;
import com.jiejing.filecenter.api.resource.vo.ResourceInfoVO; import com.jiejing.filecenter.api.resource.vo.ResourceInfoVO;
...@@ -41,7 +40,6 @@ import com.jiejing.paycenter.common.model.ResourceInfo; ...@@ -41,7 +40,6 @@ import com.jiejing.paycenter.common.model.ResourceInfo;
import com.jiejing.paycenter.common.model.SubChannelAuthInfo; import com.jiejing.paycenter.common.model.SubChannelAuthInfo;
import com.jiejing.paycenter.common.model.SubChannelInfo; import com.jiejing.paycenter.common.model.SubChannelInfo;
import com.jiejing.studio.api.studio.vo.StudioVO; import com.jiejing.studio.api.studio.vo.StudioVO;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -56,21 +54,9 @@ import java.util.stream.Collectors; ...@@ -56,21 +54,9 @@ import java.util.stream.Collectors;
*/ */
public class MerchantConvert { public class MerchantConvert {
private final static BigDecimal ALI_OFFLINE_FEE_RATE = new BigDecimal("0.38");
private final static BigDecimal WX_OFFLINE_FEE_RATE = new BigDecimal("0.38");
private final static List<SubChannelInfo> DEFAULT_SUB_CHANNELS = Lists.newArrayList(
SubChannelInfo.builder().openType(SubChannelOpenTypeEnums.ALI_OFFLINE).feeRate(ALI_OFFLINE_FEE_RATE)
.build(),
SubChannelInfo.builder().openType(SubChannelOpenTypeEnums.WX_GZH_OFFLINE).feeRate(WX_OFFLINE_FEE_RATE)
.build(),
SubChannelInfo.builder().openType(SubChannelOpenTypeEnums.WX_XCX_OFFLINE).feeRate(WX_OFFLINE_FEE_RATE)
.build()
);
public static ApplyMerchantRequest convertRequest(String channelNo, String applyNo, public static ApplyMerchantRequest convertRequest(String channelNo, String applyNo,
ApplyBrandMerchantParams params, Map<ResourceTypeEnums, ResourceInfo> resourceMap) { ApplyBrandMerchantParams params, Map<ResourceTypeEnums, ResourceInfo> resourceMap,
ApplyMerchantRequest subChannelInfo) {
return ApplyMerchantRequest.builder() return ApplyMerchantRequest.builder()
.bizCode(MerchantTypeEnums.BRAND.getCode()) .bizCode(MerchantTypeEnums.BRAND.getCode())
.applyNo(applyNo) .applyNo(applyNo)
...@@ -83,8 +69,9 @@ public class MerchantConvert { ...@@ -83,8 +69,9 @@ public class MerchantConvert {
.license(convertLicense(params)) .license(convertLicense(params))
.business(convertBusiness(params)) .business(convertBusiness(params))
.contact(convertContact(params)) .contact(convertContact(params))
.subChannels(DEFAULT_SUB_CHANNELS)
.resourceMap(resourceMap) .resourceMap(resourceMap)
.subChannels(subChannelInfo.getSubChannels())
.subChannelConfigs(subChannelInfo.getSubChannelConfigs())
.build(); .build();
} }
...@@ -220,10 +207,12 @@ public class MerchantConvert { ...@@ -220,10 +207,12 @@ public class MerchantConvert {
.build(); .build();
} }
public static BrandMerchantApply convertApply(BrandMerchantApply apply, MerchantEvent event) { public static BrandMerchantApply convertApply(BrandMerchantApply apply, MerchantEvent event,
List<SubChannelInfo> defaultSubChannels) {
// 品牌商户规则:微信线下公众号、微信线下小程序、支付宝线下通道全部开通成功才算成功 // 品牌商户规则:微信线下公众号、微信线下小程序、支付宝线下通道全部开通成功才算成功
Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap = convertSubChannelMap(event.getSubChannels()); Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap = convertSubChannelMap(event.getSubChannels(),
OpenStateEnums state = convertOpenState(channelMap); defaultSubChannels);
OpenStateEnums state = convertOpenState(channelMap, defaultSubChannels);
String openFailMessage = OpenStateEnums.FAIL == state ? convertFailMessage(event.getSubChannels()) : null; String openFailMessage = OpenStateEnums.FAIL == state ? convertFailMessage(event.getSubChannels()) : null;
SubChannelInfo ali = channelMap.get(SubChannelOpenTypeEnums.ALI_OFFLINE); SubChannelInfo ali = channelMap.get(SubChannelOpenTypeEnums.ALI_OFFLINE);
SubChannelInfo wxGzhOffline = channelMap.get(SubChannelOpenTypeEnums.WX_GZH_OFFLINE); SubChannelInfo wxGzhOffline = channelMap.get(SubChannelOpenTypeEnums.WX_GZH_OFFLINE);
...@@ -347,9 +336,10 @@ public class MerchantConvert { ...@@ -347,9 +336,10 @@ public class MerchantConvert {
.orElse(null); .orElse(null);
} }
private static OpenStateEnums convertOpenState(Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap) { private static OpenStateEnums convertOpenState(Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap,
List<SubChannelInfo> defaultSubChannels) {
List<SubChannelOpenTypeEnums> sceneList = getDefaultScene(); List<SubChannelOpenTypeEnums> sceneList = getDefaultScene(defaultSubChannels);
OpenStateEnums state = OpenStateEnums.SUCCESS; OpenStateEnums state = OpenStateEnums.SUCCESS;
for (SubChannelOpenTypeEnums scene : sceneList) { for (SubChannelOpenTypeEnums scene : sceneList) {
...@@ -365,10 +355,10 @@ public class MerchantConvert { ...@@ -365,10 +355,10 @@ public class MerchantConvert {
} }
private static Map<SubChannelOpenTypeEnums, SubChannelInfo> convertSubChannelMap( private static Map<SubChannelOpenTypeEnums, SubChannelInfo> convertSubChannelMap(
List<SubChannelInfo> subChannels) { List<SubChannelInfo> subChannels, List<SubChannelInfo> defaultSubChannels) {
Map<SubChannelOpenTypeEnums, SubChannelInfo> map = subChannels.stream() Map<SubChannelOpenTypeEnums, SubChannelInfo> map = subChannels.stream()
.collect(Collectors.toMap(SubChannelInfo::getOpenType, e -> e)); .collect(Collectors.toMap(SubChannelInfo::getOpenType, e -> e));
for (SubChannelInfo defaultSubChannel : DEFAULT_SUB_CHANNELS) { for (SubChannelInfo defaultSubChannel : defaultSubChannels) {
if (null == map.get(defaultSubChannel.getOpenType())) { if (null == map.get(defaultSubChannel.getOpenType())) {
map.put(defaultSubChannel.getOpenType(), map.put(defaultSubChannel.getOpenType(),
SubChannelInfo.builder().openType(defaultSubChannel.getOpenType()).state(OpenStateEnums.PROCESS) SubChannelInfo.builder().openType(defaultSubChannel.getOpenType()).state(OpenStateEnums.PROCESS)
...@@ -378,8 +368,8 @@ public class MerchantConvert { ...@@ -378,8 +368,8 @@ public class MerchantConvert {
return map; return map;
} }
public static List<SubChannelOpenTypeEnums> getDefaultScene() { public static List<SubChannelOpenTypeEnums> getDefaultScene(List<SubChannelInfo> defaultSubChannels) {
return DEFAULT_SUB_CHANNELS.stream().map(SubChannelInfo::getOpenType) return defaultSubChannels.stream().map(SubChannelInfo::getOpenType)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
......
package com.jiejing.fitness.finance.service.merchant.impl; package com.jiejing.fitness.finance.service.merchant.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.jiejing.common.exception.BizException; import com.jiejing.common.exception.BizException;
import com.jiejing.common.model.PageVO; import com.jiejing.common.model.PageVO;
...@@ -9,10 +10,13 @@ import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO; ...@@ -9,10 +10,13 @@ import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.fitness.finance.repository.entity.BrandMerchantApply; import com.jiejing.fitness.finance.repository.entity.BrandMerchantApply;
import com.jiejing.fitness.finance.repository.entity.BrandToMerchant; import com.jiejing.fitness.finance.repository.entity.BrandToMerchant;
import com.jiejing.fitness.finance.repository.entity.GlobalConfig;
import com.jiejing.fitness.finance.repository.query.PageBrandMerchantApplyQuery; import com.jiejing.fitness.finance.repository.query.PageBrandMerchantApplyQuery;
import com.jiejing.fitness.finance.repository.service.BrandMerchantApplyRpService; import com.jiejing.fitness.finance.repository.service.BrandMerchantApplyRpService;
import com.jiejing.fitness.finance.repository.service.BrandToMerchantRpService; import com.jiejing.fitness.finance.repository.service.BrandToMerchantRpService;
import com.jiejing.fitness.finance.repository.service.GlobalConfigRpService;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums; import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.enums.GlobalConfigEnums;
import com.jiejing.fitness.finance.service.merchant.BrandMerchantService; import com.jiejing.fitness.finance.service.merchant.BrandMerchantService;
import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert; import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert;
import com.jiejing.fitness.finance.service.merchant.params.ApplyBrandMerchantParams; import com.jiejing.fitness.finance.service.merchant.params.ApplyBrandMerchantParams;
...@@ -26,6 +30,7 @@ import com.jiejing.paycenter.common.enums.common.OpenStateEnums; ...@@ -26,6 +30,7 @@ import com.jiejing.paycenter.common.enums.common.OpenStateEnums;
import com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums; import com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums;
import com.jiejing.paycenter.common.event.MerchantEvent; import com.jiejing.paycenter.common.event.MerchantEvent;
import com.jiejing.paycenter.common.model.ResourceInfo; import com.jiejing.paycenter.common.model.ResourceInfo;
import com.jiejing.paycenter.common.model.SubChannelInfo;
import com.jiejing.studio.api.studio.vo.StudioVO; import com.jiejing.studio.api.studio.vo.StudioVO;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -68,6 +73,9 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -68,6 +73,9 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
@Resource @Resource
private BrandToMerchantRpService brandToMerchantRpService; private BrandToMerchantRpService brandToMerchantRpService;
@Resource
private GlobalConfigRpService globalConfigRpService;
@Async(value = "financeThreadPool") @Async(value = "financeThreadPool")
@Override @Override
...@@ -75,8 +83,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -75,8 +83,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
Long id = IdWorker.getId(); Long id = IdWorker.getId();
StudioVO studio = studioRpcService.getStudio(params.getStudioId()); StudioVO studio = studioRpcService.getStudio(params.getStudioId());
BrandMerchantApply exist = brandMerchantApplyRpService.getLatestOneSuccessByBrandId( BrandMerchantApply exist = brandMerchantApplyRpService.getLatestOneSuccessByBrandId(studio.getBrandId());
studio.getBrandId());
BrandMerchantApply apply = MerchantConvert.convertApply(id, params, studio, exist, channel); BrandMerchantApply apply = MerchantConvert.convertApply(id, params, studio, exist, channel);
brandMerchantApplyRpService.insert(apply); brandMerchantApplyRpService.insert(apply);
...@@ -85,7 +92,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -85,7 +92,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
Map<ResourceTypeEnums, ResourceInfo> resourceMap = this.upload(params); Map<ResourceTypeEnums, ResourceInfo> resourceMap = this.upload(params);
ApplyMerchantRequest request = MerchantConvert.convertRequest(channel, apply.getApplyNo(), params, ApplyMerchantRequest request = MerchantConvert.convertRequest(channel, apply.getApplyNo(), params,
resourceMap); resourceMap, getDefaultBrandSubChannelInfo());
merchantRpcService.apply(request); merchantRpcService.apply(request);
} catch (Exception e) { } catch (Exception e) {
...@@ -142,7 +149,8 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -142,7 +149,8 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
BrandMerchantApply apply = brandMerchantApplyRpService.getByIdForUpdate( BrandMerchantApply apply = brandMerchantApplyRpService.getByIdForUpdate(
Long.parseLong(event.getApplyNo())).orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST)); Long.parseLong(event.getApplyNo())).orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
BrandMerchantApply applyToModify = MerchantConvert.convertApply(apply, event); BrandMerchantApply applyToModify = MerchantConvert.convertApply(apply, event,
getDefaultBrandSubChannelInfo().getSubChannels());
if (OpenStateEnums.SUCCESS == applyToModify.getOpenState()) { if (OpenStateEnums.SUCCESS == applyToModify.getOpenState()) {
// 所有子通道全部开通成功 // 所有子通道全部开通成功
BrandToMerchant exist = brandToMerchantRpService.getByBrandId(apply.getBrandId()); BrandToMerchant exist = brandToMerchantRpService.getByBrandId(apply.getBrandId());
...@@ -191,4 +199,11 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -191,4 +199,11 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
BrandMerchantApply.builder().id(id).openState(OpenStateEnums.PROCESS).build()); BrandMerchantApply.builder().id(id).openState(OpenStateEnums.PROCESS).build());
} }
private ApplyMerchantRequest getDefaultBrandSubChannelInfo() {
GlobalConfig config = globalConfigRpService.getById(
GlobalConfigEnums.BRAND_MERCHANT_SUB_CHANNELS.getCode())
.orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
return JSON.parseObject(config.getConfigValue(), ApplyMerchantRequest.class);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment