Commit 50ea647c by 杨卫

feat:效果分析自测

1 parent ac54a36e
package cn.com.glsx.dj.riskmanage.dto; package cn.com.glsx.dj.riskmanage.dto;
import cn.com.glsx.dj.smartcarlife.dto.merchant.CarBrandDTO; import cn.com.glsx.dj.smartcarlife.dto.merchant.CarBrandDTO;
import cn.com.glsx.dj.smartcarlife.response.CarBrandResponse;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
...@@ -27,6 +26,11 @@ public class MerchantServiceAndBrandDTO implements Serializable { ...@@ -27,6 +26,11 @@ public class MerchantServiceAndBrandDTO implements Serializable {
private Integer merchantNo; private Integer merchantNo;
/** /**
* 4s店商户名称
*/
private String merchantName;
/**
* 品牌名称 * 品牌名称
*/ */
private List<CarBrandDTO> brands = Lists.newArrayList(); private List<CarBrandDTO> brands = Lists.newArrayList();
......
...@@ -20,6 +20,11 @@ public class YqMerchantConfigDTO implements Serializable { ...@@ -20,6 +20,11 @@ public class YqMerchantConfigDTO implements Serializable {
private Integer merchantId; private Integer merchantId;
/** /**
* 4s店商户名称
*/
private String merchantName;
/**
* 主服务商商户id * 主服务商商户id
*/ */
private Integer partnerMerchantId; private Integer partnerMerchantId;
......
...@@ -7,6 +7,7 @@ import cn.com.glsx.dj.riskmanage.mapper.ActivityMapper; ...@@ -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.dj.smartcarlife.dto.merchant.CarBrandDTO;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.merchants.model.response.MerchantBrandDTO; 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.merchants.remote.MerchantRemote;
import cn.com.glsx.scrm.proxy.enums.ProxyRequestSourceEnum; import cn.com.glsx.scrm.proxy.enums.ProxyRequestSourceEnum;
import cn.com.glsx.scrm.proxy.model.CommonProxyRequest; import cn.com.glsx.scrm.proxy.model.CommonProxyRequest;
...@@ -52,6 +53,10 @@ public class CommonService { ...@@ -52,6 +53,10 @@ public class CommonService {
* @return java.util.List<cn.com.glsx.dj.riskmanage.dto.MerchantServiceAndBrandDTO> * @return java.util.List<cn.com.glsx.dj.riskmanage.dto.MerchantServiceAndBrandDTO>
*/ */
public List<MerchantServiceAndBrandDTO> findMerchantListServiceAndBrand(List<Integer> merchantNos, String scene) { 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); Integer mainMerchantId = env.getProperty(ConfigCenterConstants.DIRECT_SALE_MERCHANT_ID, Integer.class, 44217690);
...@@ -66,7 +71,22 @@ public class CommonService { ...@@ -66,7 +71,22 @@ public class CommonService {
return MapUtil.<Integer, List<YqMerchantConfigDTO>>builder().build(); return MapUtil.<Integer, List<YqMerchantConfigDTO>>builder().build();
} }
}, taskExecutor); }, 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<Map<Integer, List<MerchantBrandDTO>>> merchantBrandFuture =
CompletableFuture.supplyAsync(() -> { CompletableFuture.supplyAsync(() -> {
...@@ -102,14 +122,16 @@ public class CommonService { ...@@ -102,14 +122,16 @@ public class CommonService {
CompletableFuture<Void> allFutures = CompletableFuture.allOf( CompletableFuture<Void> allFutures = CompletableFuture.allOf(
merchantConfigFuture, merchantConfigFuture,
merchantBrandFuture, merchantBrandFuture,
merchantNameFuture,
carBrandFuture carBrandFuture
); );
return allFutures.thenApply(v -> { return allFutures.thenApply(v -> {
Map<Integer, List<YqMerchantConfigDTO>> merchantIdGroup = merchantConfigFuture.join(); Map<Integer, List<YqMerchantConfigDTO>> merchantIdGroup = merchantConfigFuture.join();
Map<Integer, List<MerchantBrandDTO>> merchantIdGroupBrand = merchantBrandFuture.join(); Map<Integer, List<MerchantBrandDTO>> merchantIdGroupBrand = merchantBrandFuture.join();
Map<Integer, MerchantNameDTO> merchantNameMap = merchantNameFuture.join();
Map<Integer, CarBrandDTO> firstBrandMap = carBrandFuture.join(); Map<Integer, CarBrandDTO> firstBrandMap = carBrandFuture.join();
return merchantNos.stream().map(merchantNo -> { return merchantNos.stream().map(merchantNo -> {
MerchantServiceAndBrandDTO merchantServiceAndBrandDTO = new MerchantServiceAndBrandDTO().setMerchantNo(merchantNo); MerchantServiceAndBrandDTO merchantServiceAndBrandDTO = new MerchantServiceAndBrandDTO().setMerchantNo(merchantNo);
...@@ -129,6 +151,10 @@ public class CommonService { ...@@ -129,6 +151,10 @@ public class CommonService {
CarBrandDTO carBrandResponse = firstBrandMap.get(merchantBrandDTO.getFirstBrandId()); CarBrandDTO carBrandResponse = firstBrandMap.get(merchantBrandDTO.getFirstBrandId());
merchantServiceAndBrandDTO.getBrands().add(carBrandResponse); merchantServiceAndBrandDTO.getBrands().add(carBrandResponse);
}); });
Optional.ofNullable(merchantNameMap.get(merchantNo))
.ifPresent(merchantNameDTO -> merchantServiceAndBrandDTO.setMerchantName(merchantNameDTO.getMerchantName()));
return merchantServiceAndBrandDTO; return merchantServiceAndBrandDTO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
}).join(); }).join();
......
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
<select id="getServiceByMerchantId" resultType="cn.com.glsx.dj.riskmanage.dto.YqMerchantConfigDTO"> <select id="getServiceByMerchantId" resultType="cn.com.glsx.dj.riskmanage.dto.YqMerchantConfigDTO">
select select
t2.main_merchant_id as merchantId, t2.main_merchant_id as merchantId,
t2.main_merchant_name as merchantName,
t1.partner_merchant_id as partnerMerchantId, t1.partner_merchant_id as partnerMerchantId,
t1.partner_merchant_name as partnerMerchantName t1.partner_merchant_name as partnerMerchantName
from dj_car_life_yqmerchant_config t1 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!