Commit e31fffb5 by 程裕兵

feat:list merchant

parent ff019dd4
......@@ -25,6 +25,9 @@ public class StudioMerchantVO {
@ApiModelProperty("场馆ID")
private Long studioId;
@ApiModelProperty("品牌ID")
private Long brandId;
@ApiModelProperty("渠道号")
private String channelNo;
......
package com.jiejing.fitness.finance.service.global;
import com.jiejing.fitness.finance.service.global.dto.SubChannelInfoDTO;
import com.jiejing.paycenter.common.model.SubChannelConfigInfo;
import java.util.List;
/**
* @author chengyubing
* @since 2024/3/6 18:07
*/
public interface ConfigService {
SubChannelInfoDTO getDefaultBrandSubChannelInfo();
}
package com.jiejing.fitness.finance.service.global.dto;
import com.jiejing.paycenter.common.model.SubChannelConfigInfo;
import com.jiejing.paycenter.common.model.SubChannelInfo;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import lombok.Data;
/**
* @author chengyubing
* @since 2024/3/6 18:08
*/
@Data
public class SubChannelInfoDTO {
@ApiModelProperty("商户子渠道开通列表")
private List<SubChannelInfo> subChannels;
@ApiModelProperty("商户子渠道配置列表")
private List<SubChannelConfigInfo> subChannelConfigs;
}
package com.jiejing.fitness.finance.service.global.impl;
import com.alibaba.fastjson.JSON;
import com.jiejing.common.exception.BizException;
import com.jiejing.fitness.finance.repository.entity.GlobalConfig;
import com.jiejing.fitness.finance.repository.service.GlobalConfigRpService;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.enums.GlobalConfigEnums;
import com.jiejing.fitness.finance.service.global.ConfigService;
import com.jiejing.fitness.finance.service.global.dto.SubChannelInfoDTO;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
/**
* @author chengyubing
* @since 2024/3/6 18:09
*/
@Service
public class ConfigServiceImpl implements ConfigService {
@Resource
private GlobalConfigRpService globalConfigRpService;
@Override
public SubChannelInfoDTO getDefaultBrandSubChannelInfo() {
GlobalConfig config = globalConfigRpService.getById(
GlobalConfigEnums.BRAND_MERCHANT_SUB_CHANNELS.getCode())
.orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
return JSON.parseObject(config.getConfigValue(), SubChannelInfoDTO.class);
}
}
package com.jiejing.fitness.finance.service.merchant;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import java.util.List;
/**
* 品牌商户服务
*
......@@ -24,4 +27,12 @@ public interface BrandMerchantService {
*/
void unbind(Long brandId, Long merchantId);
/**
* 查看品牌绑定的所有商户
*
* @param brandId 品牌ID
* @return 商户
*/
List<StudioMerchantVO> list(Long brandId);
}
......@@ -19,6 +19,7 @@ import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.service.global.dto.SubChannelInfoDTO;
import com.jiejing.fitness.finance.service.merchant.params.ApplyStudioMerchantParams;
import com.jiejing.fitness.finance.service.utils.JsonUtil;
import com.jiejing.paycenter.api.merchant.request.ApplyMerchantRequest;
......@@ -61,7 +62,7 @@ public class MerchantConvert {
public static ApplyMerchantRequest convertRequest(String channelNo, String applyNo,
ApplyStudioMerchantParams params, Map<ResourceTypeEnums, ResourceInfo> resourceMap,
ApplyMerchantRequest subChannelInfo) {
SubChannelInfoDTO subChannelInfo) {
return ApplyMerchantRequest.builder()
.bizCode(PartyTypeEnums.STUDIO.getCode())
.applyNo(applyNo)
......@@ -419,40 +420,9 @@ public class MerchantConvert {
return ResourceInfo.builder().resourceId(id).type(type).build();
}
public static StudioMerchantVO convertStuidoMerchant(PartyToMerchant relation, MerchantVO merchant,
List<SubChannelInfo> defaultSubChannels) {
Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap = convertSubChannelMap(
JsonUtil.convertList(merchant.getSubChannels(), SubChannelInfo.class), defaultSubChannels);
SubChannelInfo ali = channelMap.get(SubChannelOpenTypeEnums.ALI_OFFLINE);
SubChannelInfo wxGzhOffline = channelMap.get(SubChannelOpenTypeEnums.WX_GZH_OFFLINE);
OpenStateEnums wxOfflineState = convertWxOfflineState(channelMap);
String wxOfflineFailMessage = convertWxOfflineFailMessage(channelMap);
OpenStateEnums aliAuthState = convertAliAuthState(
JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class));
OpenStateEnums wxOfflineAuthState = convertWxOfflineAuthState(
JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class));
return StudioMerchantVO.builder()
.studioId(relation.getPartyId())
.channelNo(merchant.getChannelNo())
.merchantId(merchant.getId())
.merchantNo(merchant.getMerchantNo())
.merchantName(merchant.getMerchantName())
.shortName(merchant.getShortName())
.companyType(merchant.getCompanyType())
.aliOpenState(Optional.ofNullable(ali.getState()).map(Enum::name).orElse(null))
.aliAuthState(Optional.ofNullable(aliAuthState).map(Enum::name).orElse(null))
.aliMerchantNo(JSON.toJSONString(ali.getMerchantNos()))
.aliOpenFailMessage(ali.getFailMessage())
.wxOfflineOpenState(Optional.ofNullable(wxOfflineState).map(Enum::name).orElse(null))
.wxOfflineMerchantNo(JSON.toJSONString(wxGzhOffline.getMerchantNos()))
.wxOfflineAuthState(Optional.ofNullable(wxOfflineAuthState).map(Enum::name).orElse(null))
.wxOfflineOpenFailMessage(wxOfflineFailMessage)
.license(JsonUtil.convertObject(merchant.getLicense(), BrandLicenseVO.class))
.legal(convertLegal(merchant.getLegal(), merchant.getContact()))
.bankCard(JsonUtil.convertObject(merchant.getBankCard(), BrandBankCardVO.class))
.resource(convertResource(merchant.getResourceMap()))
.subChannelConfigs(merchant.getSubChannelConfigs())
.build();
public static StudioMerchantVO convertStudioMerchant(PartyToMerchant relation, MerchantVO merchant,
SubChannelInfoDTO dto) {
return convertBrandMerchant(null, relation.getPartyId(), merchant, dto);
}
public static StudioMerchantApplyVO convertApply(StudioMerchantApply apply) {
......@@ -497,4 +467,46 @@ public class MerchantConvert {
return merchant;
}
private static StudioMerchantVO convertBrandMerchant(Long brandId, Long studioId, MerchantVO merchant,
SubChannelInfoDTO dto) {
Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap = convertSubChannelMap(
JsonUtil.convertList(merchant.getSubChannels(), SubChannelInfo.class), dto.getSubChannels());
SubChannelInfo ali = channelMap.get(SubChannelOpenTypeEnums.ALI_OFFLINE);
SubChannelInfo wxGzhOffline = channelMap.get(SubChannelOpenTypeEnums.WX_GZH_OFFLINE);
OpenStateEnums wxOfflineState = convertWxOfflineState(channelMap);
String wxOfflineFailMessage = convertWxOfflineFailMessage(channelMap);
OpenStateEnums aliAuthState = convertAliAuthState(
JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class));
OpenStateEnums wxOfflineAuthState = convertWxOfflineAuthState(
JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class));
return StudioMerchantVO.builder()
.brandId(brandId)
.studioId(studioId)
.channelNo(merchant.getChannelNo())
.merchantId(merchant.getId())
.merchantNo(merchant.getMerchantNo())
.merchantName(merchant.getMerchantName())
.shortName(merchant.getShortName())
.companyType(merchant.getCompanyType())
.aliOpenState(Optional.ofNullable(ali.getState()).map(Enum::name).orElse(null))
.aliAuthState(Optional.ofNullable(aliAuthState).map(Enum::name).orElse(null))
.aliMerchantNo(JSON.toJSONString(ali.getMerchantNos()))
.aliOpenFailMessage(ali.getFailMessage())
.wxOfflineOpenState(Optional.ofNullable(wxOfflineState).map(Enum::name).orElse(null))
.wxOfflineMerchantNo(JSON.toJSONString(wxGzhOffline.getMerchantNos()))
.wxOfflineAuthState(Optional.ofNullable(wxOfflineAuthState).map(Enum::name).orElse(null))
.wxOfflineOpenFailMessage(wxOfflineFailMessage)
.license(JsonUtil.convertObject(merchant.getLicense(), BrandLicenseVO.class))
.legal(convertLegal(merchant.getLegal(), merchant.getContact()))
.bankCard(JsonUtil.convertObject(merchant.getBankCard(), BrandBankCardVO.class))
.resource(convertResource(merchant.getResourceMap()))
.subChannelConfigs(merchant.getSubChannelConfigs())
.build();
}
public static List<StudioMerchantVO> convertBrandMerchantList(Long brandId, List<MerchantVO> merchants,
SubChannelInfoDTO dto) {
return merchants.stream().map(e -> convertBrandMerchant(brandId, null, e, dto))
.collect(Collectors.toList());
}
}
package com.jiejing.fitness.finance.service.merchant.impl;
import com.jiejing.fitness.finance.api.enums.PartyTypeEnums;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService;
import com.jiejing.fitness.finance.service.global.ConfigService;
import com.jiejing.fitness.finance.service.merchant.BrandMerchantService;
import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert;
import com.jiejing.fitness.finance.service.rpc.MerchantRpcService;
import com.jiejing.paycenter.api.merchant.vo.MerchantVO;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
......@@ -31,6 +37,9 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
@Resource
private PartyToMerchantRpService partyToMerchantRpService;
@Resource
private MerchantRpcService merchantRpcService;
@Override
public void bind(Long brandId, Long merchantId) {
PartyToMerchant exist = partyToMerchantRpService.getOneByPartyAndMerchantId(channel, brandId,
......@@ -50,4 +59,18 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
partyToMerchantRpService.deleteByPartyAndMerchantId(brandId, PartyTypeEnums.BRAND, merchantId);
}
@Resource
private ConfigService configService;
@Override
public List<StudioMerchantVO> list(Long brandId) {
List<PartyToMerchant> relations = partyToMerchantRpService.listByParty(brandId, PartyTypeEnums.BRAND,
channel);
List<Long> merchantIds = relations.stream().map(PartyToMerchant::getMerchantId)
.collect(Collectors.toList());
List<MerchantVO> merchants = merchantRpcService.listByIds(merchantIds);
return MerchantConvert.convertBrandMerchantList(brandId, merchants,
configService.getDefaultBrandSubChannelInfo());
}
}
package com.jiejing.fitness.finance.service.merchant.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.jiejing.common.exception.BizException;
import com.jiejing.common.model.PageVO;
......@@ -12,15 +11,13 @@ import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.fitness.finance.repository.entity.GlobalConfig;
import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.query.PageStudioMerchantApplyQuery;
import com.jiejing.fitness.finance.repository.service.GlobalConfigRpService;
import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.enums.GlobalConfigEnums;
import com.jiejing.fitness.finance.service.global.ConfigService;
import com.jiejing.fitness.finance.service.merchant.BrandMerchantService;
import com.jiejing.fitness.finance.service.merchant.StudioMerchantService;
import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert;
......@@ -34,7 +31,6 @@ import com.jiejing.paycenter.api.merchant.vo.AuthSubChannelVO;
import com.jiejing.paycenter.api.merchant.vo.ConfigSubChannelVO;
import com.jiejing.paycenter.api.merchant.vo.MerchantVO;
import com.jiejing.paycenter.api.merchant.vo.SubChannelAuthVO;
import com.jiejing.paycenter.api.merchant.vo.SubChannelConfigVO;
import com.jiejing.paycenter.common.enums.common.OpenStateEnums;
import com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelAuthTypeEnums;
......@@ -86,10 +82,10 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
private PartyToMerchantRpService partyToMerchantRpService;
@Resource
private GlobalConfigRpService globalConfigRpService;
private BrandMerchantService brandMerchantService;
@Resource
private BrandMerchantService brandMerchantService;
private ConfigService configService;
@Resource(name = "financeThreadPool")
private Executor executor;
......@@ -109,7 +105,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
Map<ResourceTypeEnums, ResourceInfo> resourceMap = this.upload(params);
ApplyMerchantRequest request = MerchantConvert.convertRequest(channel, apply.getApplyNo(), params,
resourceMap, getDefaultBrandSubChannelInfo());
resourceMap, configService.getDefaultBrandSubChannelInfo());
merchantRpcService.apply(request);
} catch (Exception e) {
......@@ -172,8 +168,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
return null;
}
MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId());
return MerchantConvert.convertStuidoMerchant(relation, merchant,
getDefaultBrandSubChannelInfo().getSubChannels());
return MerchantConvert.convertStudioMerchant(relation, merchant,
configService.getDefaultBrandSubChannelInfo());
}
@Override
......@@ -243,7 +239,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
StudioMerchantApply apply = studioMerchantApplyRpService.getByIdForUpdate(
Long.parseLong(event.getApplyNo())).orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
StudioMerchantApply toModify = MerchantConvert.convertApply(apply, event,
getDefaultBrandSubChannelInfo().getSubChannels());
configService.getDefaultBrandSubChannelInfo().getSubChannels());
studioMerchantApplyRpService.updateById(toModify);
if (OpenStateEnums.SUCCESS != toModify.getOpenState()) {
return;
......@@ -316,11 +312,4 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
StudioMerchantApply.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);
}
}
......@@ -19,6 +19,7 @@ import com.jiejing.paycenter.common.enums.merchant.AuthPhaseEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelAuthTypeEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelConfigTypeEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelEnums;
import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
......@@ -88,4 +89,10 @@ public class MerchantRpcService {
}
return result.getResult();
}
public List<MerchantVO> listByIds(List<Long> merchantIds) {
// TODO
return null;
}
}
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