Commit 006341a9 by 程裕兵

feat:list merchant

parent 753b47cd
...@@ -4,6 +4,7 @@ import com.jiejing.common.model.JsonResult; ...@@ -4,6 +4,7 @@ import com.jiejing.common.model.JsonResult;
import com.jiejing.fitness.finance.api.merchant.request.BindBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.BindBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.ListBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.ListBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.UnbindBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.UnbindBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
...@@ -29,6 +30,6 @@ public interface BrandMerchantApi { ...@@ -29,6 +30,6 @@ public interface BrandMerchantApi {
@ApiOperation(value = "查询品牌商户列表", tags = {TAG}) @ApiOperation(value = "查询品牌商户列表", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/list") @PostMapping(value = "/private/brandMerchant/list")
JsonResult<List<StudioMerchantVO>> list(ListBrandMerchantRequest request); JsonResult<List<BrandMerchantVO>> list(ListBrandMerchantRequest request);
} }
...@@ -4,7 +4,7 @@ import com.jiejing.common.model.JsonResult; ...@@ -4,7 +4,7 @@ import com.jiejing.common.model.JsonResult;
import com.jiejing.fitness.finance.api.merchant.request.BindBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.BindBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.ListBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.ListBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.UnbindBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.UnbindBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import java.util.List; import java.util.List;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -30,7 +30,7 @@ public class BrandMerchantApiFallback implements FallbackFactory<BrandMerchantAp ...@@ -30,7 +30,7 @@ public class BrandMerchantApiFallback implements FallbackFactory<BrandMerchantAp
} }
@Override @Override
public JsonResult<List<StudioMerchantVO>> list(ListBrandMerchantRequest request) { public JsonResult<List<BrandMerchantVO>> list(ListBrandMerchantRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
}; };
......
package com.jiejing.fitness.finance.api.merchant.vo;
import com.jiejing.paycenter.api.merchant.vo.SubChannelConfigVO;
import com.jiejing.paycenter.common.enums.common.OpenStateEnums;
import com.jiejing.paycenter.common.enums.merchant.CompanyTypeEnums;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author chengyubing
* @since 2024/2/22 16:22
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(description = "品牌当前绑定的商户信息VO")
public class BrandMerchantVO {
@ApiModelProperty("品牌ID")
private Long brandId;
@ApiModelProperty("已经绑定的场馆名称集合")
private List<String> studioNames;
@ApiModelProperty("渠道号")
private String channelNo;
@ApiModelProperty("商户ID(pay center提供)")
private Long merchantId;
@ApiModelProperty("三方商户号")
private String merchantNo;
@ApiModelProperty("商户名称")
private String merchantName;
@ApiModelProperty("商户简称")
private String shortName;
/**
* @see CompanyTypeEnums
*/
@ApiModelProperty("企业类型")
private String companyType;
/**
* @see OpenStateEnums
*/
@ApiModelProperty("支付宝开通状态:I-初始态;S-成功;F-失败 默认值: I")
private String aliOpenState;
/**
* @see OpenStateEnums
*/
@ApiModelProperty("支付宝认证状态")
private String aliAuthState;
@ApiModelProperty("支付宝商户号")
private String aliMerchantNo;
@ApiModelProperty("支付宝开通失败原因")
private String aliOpenFailMessage;
/**
* @see OpenStateEnums
*/
@ApiModelProperty("微信线下通道开通状态:I-初始态;S-成功;F-失败 默认值: I")
private String wxOfflineOpenState;
/**
* @see OpenStateEnums
*/
@ApiModelProperty("微信线下通道认证状态:I-初始态;S-成功;F-失败 默认值: I")
private String wxOfflineAuthState;
@ApiModelProperty("微信线下通道商户号")
private String wxOfflineMerchantNo;
@ApiModelProperty("微信线下通道开通失败原因")
private String wxOfflineOpenFailMessage;
/**
* @see OpenStateEnums
*/
@ApiModelProperty("微信线上通道开通状态:I-初始态;S-成功;F-失败 默认值: I")
private String wxOnlineOpenState;
/**
* @see OpenStateEnums
*/
@ApiModelProperty("微信线上通道认证状态:I-初始态;S-成功;F-失败 默认值: I")
private String wxOnlineAuthState;
@ApiModelProperty("微信线上通道商户号")
private String wxOnlineMerchantNo;
@ApiModelProperty("微信线下通道开通失败原因")
private String wxOnlineOpenFailMessage;
@ApiModelProperty(value = "营业执照")
private BrandLicenseVO license;
@ApiModelProperty(value = "法人信息")
private BrandLegalVO legal;
@ApiModelProperty(value = "结算卡信息")
private BrandBankCardVO bankCard;
@ApiModelProperty(value = "进件所需资料")
private BrandResourceVO resource;
@ApiModelProperty("子渠道配置记录")
private List<SubChannelConfigVO> subChannelConfigs;
}
...@@ -5,7 +5,7 @@ import com.jiejing.fitness.finance.api.merchant.BrandMerchantApi; ...@@ -5,7 +5,7 @@ import com.jiejing.fitness.finance.api.merchant.BrandMerchantApi;
import com.jiejing.fitness.finance.api.merchant.request.BindBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.BindBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.ListBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.ListBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.UnbindBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.UnbindBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.fitness.finance.service.merchant.BrandMerchantService; import com.jiejing.fitness.finance.service.merchant.BrandMerchantService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
...@@ -44,7 +44,7 @@ public class BrandMerchantController implements BrandMerchantApi { ...@@ -44,7 +44,7 @@ public class BrandMerchantController implements BrandMerchantApi {
@ApiOperation(value = "查询品牌商户列表", tags = {TAG}) @ApiOperation(value = "查询品牌商户列表", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/list") @PostMapping(value = "/private/brandMerchant/list")
@Override @Override
public JsonResult<List<StudioMerchantVO>> list(@RequestBody @Valid ListBrandMerchantRequest request) { public JsonResult<List<BrandMerchantVO>> list(@RequestBody @Valid ListBrandMerchantRequest request) {
return JsonResult.success(brandMerchantService.list(request.getBrandId())); return JsonResult.success(brandMerchantService.list(request.getBrandId()));
} }
......
...@@ -75,4 +75,12 @@ public class PartyToMerchantRpService extends ...@@ -75,4 +75,12 @@ public class PartyToMerchantRpService extends
wrapper.eq(PartyToMerchant.MERCHANT_ID, merchantId); wrapper.eq(PartyToMerchant.MERCHANT_ID, merchantId);
this.baseMapper.delete(wrapper); this.baseMapper.delete(wrapper);
} }
public List<PartyToMerchant> listByMerchantIdsAndPartyType(List<Long> merchantIds,
PartyTypeEnums partyType) {
QueryWrapper<PartyToMerchant> wrapper = new QueryWrapper<>();
wrapper.in(PartyToMerchant.MERCHANT_ID, merchantIds);
wrapper.eq(PartyToMerchant.PARTY_TYPE, partyType);
return this.baseMapper.selectList(wrapper);
}
} }
package com.jiejing.fitness.finance.service.merchant; package com.jiejing.fitness.finance.service.merchant;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import java.util.List; import java.util.List;
...@@ -33,6 +34,6 @@ public interface BrandMerchantService { ...@@ -33,6 +34,6 @@ public interface BrandMerchantService {
* @param brandId 品牌ID * @param brandId 品牌ID
* @return 商户 * @return 商户
*/ */
List<StudioMerchantVO> list(Long brandId); List<BrandMerchantVO> list(Long brandId);
} }
...@@ -15,6 +15,7 @@ import com.jiejing.fitness.finance.api.merchant.request.model.BrandResourceInfo; ...@@ -15,6 +15,7 @@ import com.jiejing.fitness.finance.api.merchant.request.model.BrandResourceInfo;
import com.jiejing.fitness.finance.api.merchant.vo.BrandBankCardVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandBankCardVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandLegalVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandLegalVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandLicenseVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandLicenseVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandResourceVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandResourceVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
...@@ -456,7 +457,38 @@ public class MerchantConvert { ...@@ -456,7 +457,38 @@ public class MerchantConvert {
public static StudioMerchantVO convertStudioMerchant(PartyToMerchant relation, MerchantVO merchant, public static StudioMerchantVO convertStudioMerchant(PartyToMerchant relation, MerchantVO merchant,
SubChannelInfoDTO dto, Map<Long, String> urlMap) { SubChannelInfoDTO dto, Map<Long, String> urlMap) {
return convertBrandMerchant(null, relation.getPartyId(), merchant, dto, urlMap); 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()
.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(), urlMap))
.subChannelConfigs(merchant.getSubChannelConfigs())
.build();
} }
public static StudioMerchantApplyVO convertApply(StudioMerchantApply apply) { public static StudioMerchantApplyVO convertApply(StudioMerchantApply apply) {
...@@ -501,8 +533,8 @@ public class MerchantConvert { ...@@ -501,8 +533,8 @@ public class MerchantConvert {
return merchant; return merchant;
} }
private static StudioMerchantVO convertBrandMerchant(Long brandId, Long studioId, MerchantVO merchant, private static BrandMerchantVO convertBrandMerchant(Long brandId, List<String> studioNames,
SubChannelInfoDTO dto, Map<Long, String> urlMap) { MerchantVO merchant, SubChannelInfoDTO dto) {
Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap = convertSubChannelMap( Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap = convertSubChannelMap(
JsonUtil.convertList(merchant.getSubChannels(), SubChannelInfo.class), dto.getSubChannels()); JsonUtil.convertList(merchant.getSubChannels(), SubChannelInfo.class), dto.getSubChannels());
SubChannelInfo ali = channelMap.get(SubChannelOpenTypeEnums.ALI_OFFLINE); SubChannelInfo ali = channelMap.get(SubChannelOpenTypeEnums.ALI_OFFLINE);
...@@ -513,9 +545,9 @@ public class MerchantConvert { ...@@ -513,9 +545,9 @@ public class MerchantConvert {
JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class)); JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class));
OpenStateEnums wxOfflineAuthState = convertWxOfflineAuthState( OpenStateEnums wxOfflineAuthState = convertWxOfflineAuthState(
JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class)); JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class));
return StudioMerchantVO.builder() return BrandMerchantVO.builder()
.brandId(brandId) .brandId(brandId)
.studioId(studioId) .studioNames(studioNames)
.channelNo(merchant.getChannelNo()) .channelNo(merchant.getChannelNo())
.merchantId(merchant.getId()) .merchantId(merchant.getId())
.merchantNo(merchant.getMerchantNo()) .merchantNo(merchant.getMerchantNo())
...@@ -533,14 +565,16 @@ public class MerchantConvert { ...@@ -533,14 +565,16 @@ public class MerchantConvert {
.license(JsonUtil.convertObject(merchant.getLicense(), BrandLicenseVO.class)) .license(JsonUtil.convertObject(merchant.getLicense(), BrandLicenseVO.class))
.legal(convertLegal(merchant.getLegal(), merchant.getContact())) .legal(convertLegal(merchant.getLegal(), merchant.getContact()))
.bankCard(JsonUtil.convertObject(merchant.getBankCard(), BrandBankCardVO.class)) .bankCard(JsonUtil.convertObject(merchant.getBankCard(), BrandBankCardVO.class))
.resource(convertResource(merchant.getResourceMap(), urlMap))
.subChannelConfigs(merchant.getSubChannelConfigs()) .subChannelConfigs(merchant.getSubChannelConfigs())
.build(); .build();
} }
public static List<StudioMerchantVO> convertBrandMerchantList(Long brandId, List<MerchantVO> merchants, public static List<BrandMerchantVO> convertBrandMerchantList(Long brandId, List<MerchantVO> merchants,
SubChannelInfoDTO dto) { SubChannelInfoDTO dto, Map<Long, List<StudioVO>> studioMap) {
return merchants.stream().map(e -> convertBrandMerchant(brandId, null, e, dto, null)) return merchants.stream().map(e -> {
.collect(Collectors.toList()); List<String> studioNames = studioMap.getOrDefault(e.getId(), new ArrayList<>()).stream()
.map(StudioVO::getName).collect(Collectors.toList());
return convertBrandMerchant(brandId, studioNames, e, dto);
}).collect(Collectors.toList());
} }
} }
package com.jiejing.fitness.finance.service.merchant.impl; package com.jiejing.fitness.finance.service.merchant.impl;
import com.jiejing.fitness.finance.api.enums.PartyTypeEnums; import com.jiejing.fitness.finance.api.enums.PartyTypeEnums;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.fitness.finance.repository.entity.PartyToMerchant; import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply; import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService; import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
...@@ -10,9 +10,11 @@ import com.jiejing.fitness.finance.service.global.ConfigService; ...@@ -10,9 +10,11 @@ import com.jiejing.fitness.finance.service.global.ConfigService;
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.rpc.MerchantRpcService; import com.jiejing.fitness.finance.service.rpc.MerchantRpcService;
import com.jiejing.fitness.finance.service.rpc.ResourceRpcService; import com.jiejing.fitness.finance.service.rpc.StudioRpcService;
import com.jiejing.paycenter.api.merchant.vo.MerchantVO; import com.jiejing.paycenter.api.merchant.vo.MerchantVO;
import com.jiejing.studio.api.studio.vo.StudioVO;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -45,7 +47,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -45,7 +47,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
private ConfigService configService; private ConfigService configService;
@Resource @Resource
private ResourceRpcService resourceRpcService; private StudioRpcService studioRpcService;
@Override @Override
public void bind(Long brandId, Long merchantId) { public void bind(Long brandId, Long merchantId) {
...@@ -67,14 +69,19 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -67,14 +69,19 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
} }
@Override @Override
public List<StudioMerchantVO> list(Long brandId) { public List<BrandMerchantVO> list(Long brandId) {
List<PartyToMerchant> relations = partyToMerchantRpService.listByParty(brandId, PartyTypeEnums.BRAND, List<PartyToMerchant> relations = partyToMerchantRpService.listByParty(brandId, PartyTypeEnums.BRAND,
channel); channel);
List<Long> merchantIds = relations.stream().map(PartyToMerchant::getMerchantId) List<Long> merchantIds = relations.stream().map(PartyToMerchant::getMerchantId)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<PartyToMerchant> studioRelations = partyToMerchantRpService.listByMerchantIdsAndPartyType(
merchantIds, PartyTypeEnums.STUDIO);
List<Long> studioIds = studioRelations.stream().map(PartyToMerchant::getPartyId)
.collect(Collectors.toList());
Map<Long, List<StudioVO>> studioMap = studioRpcService.mapStudioByBrandId(studioIds);
List<MerchantVO> merchants = merchantRpcService.listByIds(merchantIds); List<MerchantVO> merchants = merchantRpcService.listByIds(merchantIds);
return MerchantConvert.convertBrandMerchantList(brandId, merchants, return MerchantConvert.convertBrandMerchantList(brandId, merchants,
configService.getDefaultBrandSubChannelInfo()); configService.getDefaultBrandSubChannelInfo(), studioMap);
} }
} }
...@@ -119,8 +119,11 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -119,8 +119,11 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
} }
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@Override @Override
public void bind(Long studioId, Long merchantId) { public void bind(Long studioId, Long merchantId) {
// 解绑后,绑定新商户
this.unbindAll(studioId);
PartyToMerchant relation = getRelation(studioId); PartyToMerchant relation = getRelation(studioId);
StudioMerchantApply apply = studioMerchantApplyRpService.getLatestOneSuccessByMerchantId(merchantId); StudioMerchantApply apply = studioMerchantApplyRpService.getLatestOneSuccessByMerchantId(merchantId);
if (null == relation) { if (null == relation) {
......
...@@ -2,8 +2,14 @@ package com.jiejing.fitness.finance.service.rpc; ...@@ -2,8 +2,14 @@ package com.jiejing.fitness.finance.service.rpc;
import com.jiejing.common.model.JsonResult; import com.jiejing.common.model.JsonResult;
import com.jiejing.common.request.IdRequest; import com.jiejing.common.request.IdRequest;
import com.jiejing.common.request.IdsRequest;
import com.jiejing.studio.api.studio.StudioApi; import com.jiejing.studio.api.studio.StudioApi;
import com.jiejing.studio.api.studio.vo.StudioVO; import com.jiejing.studio.api.studio.vo.StudioVO;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -25,4 +31,20 @@ public class StudioRpcService { ...@@ -25,4 +31,20 @@ public class StudioRpcService {
return result.getResult(); return result.getResult();
} }
public Map<Long, StudioVO> mapStudio(List<Long> studioIds) {
List<StudioVO> list = this.listStudio(studioIds);
return list.stream().collect(Collectors.toMap(StudioVO::getId, e -> e));
}
public List<StudioVO> listStudio(List<Long> studioIds) {
JsonResult<List<StudioVO>> result = studioApi.listStudio(IdsRequest.builder().ids(studioIds).build());
result.assertSuccess();
return Optional.ofNullable(result.getResult()).orElse(new ArrayList<>());
}
public Map<Long, List<StudioVO>> mapStudioByBrandId(List<Long> studioIds) {
return this.listStudio(studioIds)
.stream()
.collect(Collectors.groupingBy(StudioVO::getBrandId));
}
} }
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