|
|
@@ -1,5 +1,7 @@
|
|
|
package com.mangoo.rating.recommend.service.recommend.impl;
|
|
|
|
|
|
+import com.mangoo.rating.recommend.client.OrderApiClient;
|
|
|
+import com.mangoo.rating.recommend.client.feign.dto.ProductServiceLevelDTO;
|
|
|
import com.mangoo.rating.recommend.config.RecommendProperties;
|
|
|
import com.mangoo.rating.recommend.dto.product.ProductServiceLevelCacheDTO;
|
|
|
import com.mangoo.rating.recommend.enums.EvaluateEfficiencyEnum;
|
|
|
@@ -28,30 +30,27 @@ public class EfficiencyPriceProviderImpl implements EfficiencyPriceProvider {
|
|
|
@Resource
|
|
|
private RecommendProperties recommendProperties;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private OrderApiClient orderApiClient;
|
|
|
+
|
|
|
@Override
|
|
|
public Map<Long, BigDecimal> loadEfficiencyPrices() {
|
|
|
try {
|
|
|
// 1. 从订单服务获取全部服务等级(预留口子,当前返回空列表 → 触发降级)
|
|
|
- List<ProductServiceLevelCacheDTO> levels = fetchServiceLevels();
|
|
|
+ List<ProductServiceLevelDTO> levels = fetchServiceLevels();
|
|
|
if (levels == null || levels.isEmpty()) {
|
|
|
log.info("时效价格未配置或订单服务未接通,全部走'待计算'降级");
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
|
|
|
|
- // 2. 将服务等级的 timeLimit(字符串) → EvaluateEfficiencyEnum.code 后聚合
|
|
|
+ // 2. 服务等级
|
|
|
Map<Long, BigDecimal> priceMap = new LinkedHashMap<>();
|
|
|
- Map<String, Long> mapping = recommendProperties.getTimeLimitMapping();
|
|
|
- for (ProductServiceLevelCacheDTO lvl : levels) {
|
|
|
+ for (ProductServiceLevelDTO lvl : levels) {
|
|
|
if (lvl == null || lvl.getTimeLimit() == null || lvl.getPrice() == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- Long effCode = mapping == null ? null : mapping.get(lvl.getTimeLimit().trim());
|
|
|
- if (Objects.isNull(effCode)) {
|
|
|
- log.debug("无法映射服务等级 timeLimit={} 到时效 code,跳过", lvl.getTimeLimit());
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 同档存在多条时,保留首个(订单服务侧应已去重;此处简单防御)
|
|
|
- priceMap.putIfAbsent(effCode, lvl.getPrice());
|
|
|
+ // 同档存在多条时
|
|
|
+ priceMap.putIfAbsent(lvl.getId(), lvl.getPrice());
|
|
|
}
|
|
|
return priceMap;
|
|
|
} catch (Exception e) {
|
|
|
@@ -65,8 +64,8 @@ public class EfficiencyPriceProviderImpl implements EfficiencyPriceProvider {
|
|
|
* 调订单服务取全部服务等级 —— 预留口子。
|
|
|
* 本期返回空列表(不接 Feign),后续接通时实现真实调用。
|
|
|
*/
|
|
|
- private List<ProductServiceLevelCacheDTO> fetchServiceLevels() {
|
|
|
+ private List<ProductServiceLevelDTO> fetchServiceLevels() {
|
|
|
// TODO: 后续接入 order-service Feign 客户端:调用其"全部服务等级"接口
|
|
|
- return Collections.emptyList();
|
|
|
+ return orderApiClient.serviceList(null);
|
|
|
}
|
|
|
}
|