Commit 50ea647c by 杨卫

feat:效果分析自测

1 parent ac54a36e
package cn.com.glsx.dj.riskmanage.dto;
import cn.com.glsx.dj.smartcarlife.dto.merchant.CarBrandDTO;
import cn.com.glsx.dj.smartcarlife.response.CarBrandResponse;
import com.google.common.collect.Lists;
import lombok.Data;
import lombok.experimental.Accessors;
......@@ -27,6 +26,11 @@ public class MerchantServiceAndBrandDTO implements Serializable {
private Integer merchantNo;
/**
* 4s店商户名称
*/
private String merchantName;
/**
* 品牌名称
*/
private List<CarBrandDTO> brands = Lists.newArrayList();
......
......@@ -20,6 +20,11 @@ public class YqMerchantConfigDTO implements Serializable {
private Integer merchantId;
/**
* 4s店商户名称
*/
private String merchantName;
/**
* 主服务商商户id
*/
private Integer partnerMerchantId;
......
......@@ -7,6 +7,7 @@ import cn.com.glsx.dj.riskmanage.mapper.ActivityMapper;
import cn.com.glsx.dj.smartcarlife.dto.merchant.CarBrandDTO;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.merchants.model.response.MerchantBrandDTO;
import cn.com.glsx.merchants.model.response.MerchantNameDTO;
import cn.com.glsx.merchants.remote.MerchantRemote;
import cn.com.glsx.scrm.proxy.enums.ProxyRequestSourceEnum;
import cn.com.glsx.scrm.proxy.model.CommonProxyRequest;
......@@ -52,6 +53,10 @@ public class CommonService {
* @return java.util.List<cn.com.glsx.dj.riskmanage.dto.MerchantServiceAndBrandDTO>
*/
public List<MerchantServiceAndBrandDTO> findMerchantListServiceAndBrand(List<Integer> merchantNos, String scene) {
if (CollUtil.isEmpty(merchantNos)) {
return Collections.emptyList();
}
// 主服务商
Integer mainMerchantId = env.getProperty(ConfigCenterConstants.DIRECT_SALE_MERCHANT_ID, Integer.class, 44217690);
......@@ -66,7 +71,22 @@ public class CommonService {
return MapUtil.<Integer, List<YqMerchantConfigDTO>>builder().build();
}
}, taskExecutor);
// 查询商户名称
CompletableFuture<Map<Integer, MerchantNameDTO>> merchantNameFuture =
CompletableFuture.supplyAsync(() -> {
RpcResponse<List<MerchantNameDTO>> merchantNameByMerchantIdsResp = merchantRemote.getMerchantNameByMerchantIds(merchantNos);
if (merchantNameByMerchantIdsResp.isFailed()) {
log.error("查询商户名称失败: {}", merchantNameByMerchantIdsResp.getMessage());
return MapUtil.<Integer, MerchantNameDTO>builder().build();
}
return Optional.ofNullable(merchantNameByMerchantIdsResp.getResult())
.orElseGet(ArrayList::new)
.stream()
.collect(Collectors.toMap(MerchantNameDTO::getMerchantId, Function.identity()));
}, taskExecutor);
// 查询门店主营品牌
CompletableFuture<Map<Integer, List<MerchantBrandDTO>>> merchantBrandFuture =
CompletableFuture.supplyAsync(() -> {
......@@ -102,14 +122,16 @@ public class CommonService {
CompletableFuture<Void> allFutures = CompletableFuture.allOf(
merchantConfigFuture,
merchantBrandFuture,
merchantNameFuture,
carBrandFuture
);
return allFutures.thenApply(v -> {
Map<Integer, List<YqMerchantConfigDTO>> merchantIdGroup = merchantConfigFuture.join();
Map<Integer, List<MerchantBrandDTO>> merchantIdGroupBrand = merchantBrandFuture.join();
Map<Integer, MerchantNameDTO> merchantNameMap = merchantNameFuture.join();
Map<Integer, CarBrandDTO> firstBrandMap = carBrandFuture.join();
return merchantNos.stream().map(merchantNo -> {
MerchantServiceAndBrandDTO merchantServiceAndBrandDTO = new MerchantServiceAndBrandDTO().setMerchantNo(merchantNo);
......@@ -129,6 +151,10 @@ public class CommonService {
CarBrandDTO carBrandResponse = firstBrandMap.get(merchantBrandDTO.getFirstBrandId());
merchantServiceAndBrandDTO.getBrands().add(carBrandResponse);
});
Optional.ofNullable(merchantNameMap.get(merchantNo))
.ifPresent(merchantNameDTO -> merchantServiceAndBrandDTO.setMerchantName(merchantNameDTO.getMerchantName()));
return merchantServiceAndBrandDTO;
}).collect(Collectors.toList());
}).join();
......
......@@ -102,6 +102,7 @@
<select id="getServiceByMerchantId" resultType="cn.com.glsx.dj.riskmanage.dto.YqMerchantConfigDTO">
select
t2.main_merchant_id as merchantId,
t2.main_merchant_name as merchantName,
t1.partner_merchant_id as partnerMerchantId,
t1.partner_merchant_name as partnerMerchantName
from dj_car_life_yqmerchant_config t1
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!