Explorar o código

实现通过订单服务获取服务时效列表的价格映射逻辑

jintao.geng hai 4 semanas
pai
achega
8599a43a37

+ 4 - 7
mango-application/src/main/resources/application.yml

@@ -270,12 +270,12 @@ generate-service:
 pay-service:
 pay-service:
   url: http://192.168.77.249:7756
   url: http://192.168.77.249:7756
 
 
-coupon-service:
-  url: http://coupon
-
 order-service:
 order-service:
-  url: http://order
+  url: ${ORDER_URL:192.168.31.111:8090}
 
 
+# ratingApp
+rating-app:
+  url: ${RATING_APP_URL:192.168.31.111:8091}
 
 
 # Feign配置
 # Feign配置
 feign:
 feign:
@@ -342,9 +342,6 @@ ai:
   connect-timeout-ms: 10000
   connect-timeout-ms: 10000
   read-timeout-ms: 120000
   read-timeout-ms: 120000
 
 
-# ratingApp 业务服务地址(AI 助手通过 Feign 远程调其订单/物流接口)
-rating-app:
-  url: ${RATING_APP_URL:192.168.31.111:8091}
 
 
 # 评级时效推荐功能配置
 # 评级时效推荐功能配置
 recommend:
 recommend:

+ 2 - 2
mango-common/src/main/java/com/mangoo/rating/recommend/request/recommend/RecommendCardDTO.java

@@ -37,10 +37,10 @@ public class RecommendCardDTO {
     private String backImageUrl;
     private String backImageUrl;
 
 
     @ApiModelProperty(value = "套餐ID")
     @ApiModelProperty(value = "套餐ID")
-    private Long id;
+    private Long packageId;
 
 
     @ApiModelProperty(value = "套餐价格")
     @ApiModelProperty(value = "套餐价格")
-    private BigDecimal price;
+    private BigDecimal packagePrice;
 
 
     /**
     /**
      * 运动项目
      * 运动项目

+ 53 - 0
mango-domain/src/main/java/com/mangoo/rating/recommend/client/OrderApiClient.java

@@ -0,0 +1,53 @@
+package com.mangoo.rating.recommend.client;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.mangoo.rating.recommend.client.feign.OrderServiceClient;
+import com.mangoo.rating.recommend.client.feign.dto.*;
+import com.mangoo.rating.recommend.dto.home.HomeBannerAppDTO;
+import com.mangoo.rating.recommend.dto.home.HomeDiamondAppDTO;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 摄像头服务客户端
+ *
+ * @author gengjintao
+ * @date 2026/04/16
+ */
+@Log4j2
+@Component
+public class OrderApiClient {
+
+    @Resource
+    private OrderServiceClient orderServiceClient;
+
+
+
+
+   /**
+     * 获取产品服务时效列表
+     *
+     * @param levelName     套餐类型
+     * @return 是否成功
+     */
+    public List<ProductServiceLevelDTO> serviceList(String levelName) {
+        try {
+            ProductServiceLevelRequest request = new ProductServiceLevelRequest();
+            log.info("获取产品服务时效列表参数:{}", request);
+            JSONObject result = orderServiceClient.serviceList(request);
+            if (result != null && result.getInteger("code") == 0) {
+                Object object = result.get("data");
+                return JSON.parseArray(JSON.toJSONString(object), ProductServiceLevelDTO.class);
+            }
+        } catch (Exception e) {
+            log.error("获取产品服务失效列表异常", e);
+        }
+        return null;
+    }
+
+
+}

+ 30 - 0
mango-domain/src/main/java/com/mangoo/rating/recommend/client/feign/OrderServiceClient.java

@@ -0,0 +1,30 @@
+package com.mangoo.rating.recommend.client.feign;
+
+import com.alibaba.fastjson.JSONObject;
+import com.mangoo.rating.recommend.client.feign.dto.ProductServiceLevelRequest;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * 摄像头服务Feign客户端
+ *
+ * @author gengjintao
+ * @date 2026/04/16
+ */
+@FeignClient(name = "order-service", url = "${order-service.url}")
+public interface OrderServiceClient {
+
+
+
+    /**
+     * 获取产品服务标签列表
+     *
+     * @param request 获取请求
+     * @return 服务标签列表
+     */
+    @PostMapping("/api/app/product/service-list")
+    JSONObject serviceList(@RequestBody ProductServiceLevelRequest request);
+
+
+}

+ 1 - 1
mango-domain/src/main/java/com/mangoo/rating/recommend/client/feign/PreOrderFeignClient.java

@@ -23,7 +23,7 @@ public interface PreOrderFeignClient {
      * @param body       预订单整包
      * @param body       预订单整包
      * @return AjaxResult,code=0 时 data.preOrderNo 为预订单号
      * @return AjaxResult,code=0 时 data.preOrderNo 为预订单号
      */
      */
-    @PostMapping("/api/preorder/save")
+    @PostMapping("/api/pre-order/save")
     AjaxResult savePreOrder(@RequestHeader(value = "X-USER-BASE64", required = false) String userHeader,
     AjaxResult savePreOrder(@RequestHeader(value = "X-USER-BASE64", required = false) String userHeader,
                             @RequestBody PreOrderSaveDTO body);
                             @RequestBody PreOrderSaveDTO body);
 }
 }

+ 2 - 2
mango-domain/src/main/java/com/mangoo/rating/recommend/service/impl/RecommendServiceImpl.java

@@ -199,8 +199,8 @@ public class RecommendServiceImpl implements RecommendService {
         vo.setFrontImageUrl(dto.getFrontImageUrl());
         vo.setFrontImageUrl(dto.getFrontImageUrl());
         vo.setBackImageUrl(dto.getBackImageUrl());
         vo.setBackImageUrl(dto.getBackImageUrl());
         // 透传套餐ID与套餐价格(入参字段名 id/price,响应改业务命名 packageId/packagePrice)
         // 透传套餐ID与套餐价格(入参字段名 id/price,响应改业务命名 packageId/packagePrice)
-        vo.setPackageId(dto.getId());
-        vo.setPackagePrice(dto.getPrice());
+        vo.setPackageId(dto.getPackageId());
+        vo.setPackagePrice(dto.getPackagePrice());
         // 透传全部识别字段(用于落库存全量)
         // 透传全部识别字段(用于落库存全量)
         vo.setSportEvent(dto.getSportEvent());
         vo.setSportEvent(dto.getSportEvent());
         vo.setCardType(dto.getCardType());
         vo.setCardType(dto.getCardType());

+ 12 - 13
mango-domain/src/main/java/com/mangoo/rating/recommend/service/recommend/impl/EfficiencyPriceProviderImpl.java

@@ -1,5 +1,7 @@
 package com.mangoo.rating.recommend.service.recommend.impl;
 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.config.RecommendProperties;
 import com.mangoo.rating.recommend.dto.product.ProductServiceLevelCacheDTO;
 import com.mangoo.rating.recommend.dto.product.ProductServiceLevelCacheDTO;
 import com.mangoo.rating.recommend.enums.EvaluateEfficiencyEnum;
 import com.mangoo.rating.recommend.enums.EvaluateEfficiencyEnum;
@@ -28,30 +30,27 @@ public class EfficiencyPriceProviderImpl implements EfficiencyPriceProvider {
     @Resource
     @Resource
     private RecommendProperties recommendProperties;
     private RecommendProperties recommendProperties;
 
 
+    @Resource
+    private OrderApiClient orderApiClient;
+
     @Override
     @Override
     public Map<Long, BigDecimal> loadEfficiencyPrices() {
     public Map<Long, BigDecimal> loadEfficiencyPrices() {
         try {
         try {
             // 1. 从订单服务获取全部服务等级(预留口子,当前返回空列表 → 触发降级)
             // 1. 从订单服务获取全部服务等级(预留口子,当前返回空列表 → 触发降级)
-            List<ProductServiceLevelCacheDTO> levels = fetchServiceLevels();
+            List<ProductServiceLevelDTO> levels = fetchServiceLevels();
             if (levels == null || levels.isEmpty()) {
             if (levels == null || levels.isEmpty()) {
                 log.info("时效价格未配置或订单服务未接通,全部走'待计算'降级");
                 log.info("时效价格未配置或订单服务未接通,全部走'待计算'降级");
                 return Collections.emptyMap();
                 return Collections.emptyMap();
             }
             }
 
 
-            // 2. 服务等级的 timeLimit(字符串) → EvaluateEfficiencyEnum.code 后聚合
+            // 2. 服务等级
             Map<Long, BigDecimal> priceMap = new LinkedHashMap<>();
             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) {
                 if (lvl == null || lvl.getTimeLimit() == null || lvl.getPrice() == null) {
                     continue;
                     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;
             return priceMap;
         } catch (Exception e) {
         } catch (Exception e) {
@@ -65,8 +64,8 @@ public class EfficiencyPriceProviderImpl implements EfficiencyPriceProvider {
      * 调订单服务取全部服务等级 —— 预留口子。
      * 调订单服务取全部服务等级 —— 预留口子。
      * 本期返回空列表(不接 Feign),后续接通时实现真实调用。
      * 本期返回空列表(不接 Feign),后续接通时实现真实调用。
      */
      */
-    private List<ProductServiceLevelCacheDTO> fetchServiceLevels() {
+    private List<ProductServiceLevelDTO> fetchServiceLevels() {
         // TODO: 后续接入 order-service Feign 客户端:调用其"全部服务等级"接口
         // TODO: 后续接入 order-service Feign 客户端:调用其"全部服务等级"接口
-        return Collections.emptyList();
+        return orderApiClient.serviceList(null);
     }
     }
 }
 }