Commit 9145f7c5 by 程裕兵

feat:api

parent 204601c8
...@@ -49,4 +49,35 @@ public class BrandResourceVO { ...@@ -49,4 +49,35 @@ public class BrandResourceVO {
@ApiModelProperty(value = "结算卡持卡人证件国徽面(反面)") @ApiModelProperty(value = "结算卡持卡人证件国徽面(反面)")
private Long bankCardCertBackPicId; private Long bankCardCertBackPicId;
@ApiModelProperty(value = "营业执照图片URL")
private String licensePicUrl;
@ApiModelProperty(value = "线下经营门头照URL")
private String storeHeaderPicUrl;
@ApiModelProperty(value = "线下经营内景照URL")
private String storeInnerPicUrl;
@ApiModelProperty(value = "线下经营收银台URL")
private String storeCashierDescPicUrl;
@ApiModelProperty(value = "法人证件人像面(正面)URL")
private String legalCertFrontPicUrl;
@ApiModelProperty(value = "法人证件国徽面(反面)URL")
private String legalCertBackPicUrl;
@ApiModelProperty(value = "银行卡正面URL")
private String bankCardFrontPicUrl;
@ApiModelProperty(value = "银行卡反面URL")
private String bankCardBackPicUrl;
@ApiModelProperty(value = "结算卡持卡人证件人像面(正面)URL")
private String bankCardCertFrontPicUrl;
@ApiModelProperty(value = "结算卡持卡人证件国徽面(反面)URL")
private String bankCardCertBackPicUrl;
} }
...@@ -4,6 +4,7 @@ import static com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums.*; ...@@ -4,6 +4,7 @@ import static com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums.*;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.jiejing.common.utils.collection.CollectionUtil;
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;
...@@ -258,8 +259,42 @@ public class MerchantConvert { ...@@ -258,8 +259,42 @@ public class MerchantConvert {
} }
private static BrandResourceVO convertResource( private static BrandResourceVO convertResource(
Map<String, com.jiejing.paycenter.api.merchant.vo.ResourceInfoVO> resourceMap) { Map<String, com.jiejing.paycenter.api.merchant.vo.ResourceInfoVO> resourceMap,
Map<Long, String> urlMap) {
BrandResourceVO resourceInfo = new BrandResourceVO(); BrandResourceVO resourceInfo = new BrandResourceVO();
setPicId(resourceInfo, resourceMap);
setPicUrl(resourceInfo, urlMap);
return resourceInfo;
}
private static void setPicUrl(BrandResourceVO resourceInfo, Map<Long, String> urlMap) {
if (CollectionUtil.isEmpty(urlMap)) {
return;
}
resourceInfo.setLicensePicUrl(
resourceInfo.getLicensePicId() == null ? null : urlMap.get(resourceInfo.getLicensePicId()));
resourceInfo.setStoreHeaderPicUrl(
resourceInfo.getStoreHeaderPicId() == null ? null : urlMap.get(resourceInfo.getStoreHeaderPicId()));
resourceInfo.setStoreInnerPicUrl(
resourceInfo.getStoreInnerPicId() == null ? null : urlMap.get(resourceInfo.getStoreInnerPicId()));
resourceInfo.setStoreCashierDescPicUrl(resourceInfo.getStoreCashierDescPicId() == null ? null
: urlMap.get(resourceInfo.getStoreCashierDescPicId()));
resourceInfo.setLegalCertFrontPicUrl(resourceInfo.getLegalCertFrontPicId() == null ? null
: urlMap.get(resourceInfo.getLegalCertFrontPicId()));
resourceInfo.setLegalCertBackPicUrl(resourceInfo.getLegalCertBackPicId() == null ? null
: urlMap.get(resourceInfo.getLegalCertBackPicId()));
resourceInfo.setBankCardFrontPicUrl(resourceInfo.getBankCardFrontPicId() == null ? null
: urlMap.get(resourceInfo.getBankCardFrontPicId()));
resourceInfo.setBankCardBackPicUrl(
resourceInfo.getBankCardBackPicId() == null ? null : urlMap.get(resourceInfo.getBankCardBackPicId()));
resourceInfo.setBankCardCertFrontPicUrl(resourceInfo.getBankCardCertFrontPicId() == null ? null
: urlMap.get(resourceInfo.getBankCardCertFrontPicId()));
resourceInfo.setBankCardCertBackPicUrl(resourceInfo.getBankCardCertBackPicId() == null ? null
: urlMap.get(resourceInfo.getBankCardCertBackPicId()));
}
private static void setPicId(BrandResourceVO resourceInfo,
Map<String, com.jiejing.paycenter.api.merchant.vo.ResourceInfoVO> resourceMap) {
resourceInfo.setLicensePicId( resourceInfo.setLicensePicId(
Optional.ofNullable(resourceMap.get(LICENSE.name())).map(e -> e.getResourceId()).orElse(null)); Optional.ofNullable(resourceMap.get(LICENSE.name())).map(e -> e.getResourceId()).orElse(null));
resourceInfo.setStoreHeaderPicId( resourceInfo.setStoreHeaderPicId(
...@@ -288,7 +323,6 @@ public class MerchantConvert { ...@@ -288,7 +323,6 @@ public class MerchantConvert {
resourceInfo.setBankCardCertBackPicId( resourceInfo.setBankCardCertBackPicId(
Optional.ofNullable(resourceMap.get(BANK_CARD_CERT_BACK.name())).map(e -> e.getResourceId()) Optional.ofNullable(resourceMap.get(BANK_CARD_CERT_BACK.name())).map(e -> e.getResourceId())
.orElse(null)); .orElse(null));
return resourceInfo;
} }
private static OpenStateEnums convertWxOfflineAuthState(List<SubChannelAuthInfo> auths) { private static OpenStateEnums convertWxOfflineAuthState(List<SubChannelAuthInfo> auths) {
...@@ -421,8 +455,8 @@ public class MerchantConvert { ...@@ -421,8 +455,8 @@ public class MerchantConvert {
} }
public static StudioMerchantVO convertStudioMerchant(PartyToMerchant relation, MerchantVO merchant, public static StudioMerchantVO convertStudioMerchant(PartyToMerchant relation, MerchantVO merchant,
SubChannelInfoDTO dto) { SubChannelInfoDTO dto, Map<Long, String> urlMap) {
return convertBrandMerchant(null, relation.getPartyId(), merchant, dto); return convertBrandMerchant(null, relation.getPartyId(), merchant, dto, urlMap);
} }
public static StudioMerchantApplyVO convertApply(StudioMerchantApply apply) { public static StudioMerchantApplyVO convertApply(StudioMerchantApply apply) {
...@@ -468,7 +502,7 @@ public class MerchantConvert { ...@@ -468,7 +502,7 @@ public class MerchantConvert {
} }
private static StudioMerchantVO convertBrandMerchant(Long brandId, Long studioId, MerchantVO merchant, private static StudioMerchantVO convertBrandMerchant(Long brandId, Long studioId, MerchantVO merchant,
SubChannelInfoDTO dto) { SubChannelInfoDTO dto, Map<Long, String> urlMap) {
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);
...@@ -499,14 +533,14 @@ public class MerchantConvert { ...@@ -499,14 +533,14 @@ 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())) .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<StudioMerchantVO> convertBrandMerchantList(Long brandId, List<MerchantVO> merchants,
SubChannelInfoDTO dto) { SubChannelInfoDTO dto) {
return merchants.stream().map(e -> convertBrandMerchant(brandId, null, e, dto)) return merchants.stream().map(e -> convertBrandMerchant(brandId, null, e, dto, null))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }
...@@ -10,6 +10,7 @@ import com.jiejing.fitness.finance.service.global.ConfigService; ...@@ -10,6 +10,7 @@ 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.paycenter.api.merchant.vo.MerchantVO; import com.jiejing.paycenter.api.merchant.vo.MerchantVO;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -43,6 +44,9 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -43,6 +44,9 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
@Resource @Resource
private ConfigService configService; private ConfigService configService;
@Resource
private ResourceRpcService resourceRpcService;
@Override @Override
public void bind(Long brandId, Long merchantId) { public void bind(Long brandId, Long merchantId) {
PartyToMerchant exist = partyToMerchantRpService.getOneByPartyAndMerchantId(channel, brandId, PartyToMerchant exist = partyToMerchantRpService.getOneByPartyAndMerchantId(channel, brandId,
......
...@@ -168,8 +168,10 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -168,8 +168,10 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
return null; return null;
} }
MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId()); MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId());
List<Long> resourceIds = this.getResourceIds(merchant);
Map<Long, String> urlMap = resourceRpcService.getResourceUrlMap(studioId, resourceIds);
return MerchantConvert.convertStudioMerchant(relation, merchant, return MerchantConvert.convertStudioMerchant(relation, merchant,
configService.getDefaultBrandSubChannelInfo()); configService.getDefaultBrandSubChannelInfo(), urlMap);
} }
@Override @Override
...@@ -301,6 +303,14 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -301,6 +303,14 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private List<Long> getResourceIds(MerchantVO merchant) {
return merchant.getResourceMap().values().stream()
.map(e -> e.getResourceId())
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
}
private void doOpenMerchantFail(Long id, String failMessage) { private void doOpenMerchantFail(Long id, String failMessage) {
studioMerchantApplyRpService.updateById( studioMerchantApplyRpService.updateById(
StudioMerchantApply.builder().id(id).openState(OpenStateEnums.FAIL) StudioMerchantApply.builder().id(id).openState(OpenStateEnums.FAIL)
......
...@@ -36,4 +36,16 @@ public class ResourceRpcService { ...@@ -36,4 +36,16 @@ public class ResourceRpcService {
.orElse(new HashMap<>(1)); .orElse(new HashMap<>(1));
} }
public Map<Long, String> getResourceUrlMap(Long partyId, List<Long> resourceIds) {
BatchQueryMultiResourceRequest request = new BatchQueryMultiResourceRequest();
request.setAccessTypeEnum(AccessTypeEnum.PUBLIC);
request.setResourceIds(resourceIds);
request.setTenantId(partyId);
request.setExpire(TimeUnit.SECONDS.toMillis(60));
JsonResult<List<ResourceInfoVO>> result = resourceApi.getInfoByIds(request);
return Optional.ofNullable(result.getResult())
.map(list -> list.stream().collect(Collectors.toMap(ResourceInfoVO::getResourceId, e -> e.getUrl())))
.orElse(new HashMap<>(1));
}
} }
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