Bladeren bron

fix:解决冲突

penghao 3 maanden geleden
bovenliggende
commit
99bed05a62

+ 0 - 143
alien-store/src/main/java/shop/alien/store/controller/AIRecoveryController.java

@@ -1,143 +0,0 @@
-package shop.alien.store.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fasterxml.jackson.databind.JsonNode;
-import io.swagger.annotations.*;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.*;
-import shop.alien.entity.result.R;
-import shop.alien.store.feign.AlienAIFeign;
-import shop.alien.store.service.TrackEventService;
-
-import java.util.*;
-
-/**
- * AI推荐Controller
- *
- * @author system
- * @since 2026-01-14
- */
-@Slf4j
-@Api(tags = {"AI智能推荐"})
-@ApiSort(22)
-@CrossOrigin
-@RestController
-@RequestMapping("/business/ai")
-@RequiredArgsConstructor
-public class AIRecoveryController {
-
-    private final TrackEventService trackEventService;
-    private final AlienAIFeign alienAIFeign;
-
-    @ApiOperation("获取AI推荐")
-    @ApiOperationSupport(order = 1)
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "storeId", value = "店铺ID", dataType = "Integer", paramType = "query", required = true)
-    })
-    @GetMapping("/recommendation")
-    public R<Map<String, Object>> getRecommendation(@RequestParam("storeId") Integer storeId) {
-        log.info("获取AI推荐: storeId={}", storeId);
-
-        try {
-            // 获取最近30天的经营数据
-            Date endDate = new Date();
-            Date startDate = new Date(endDate.getTime() - 30L * 24 * 60 * 60 * 1000);
-            
-            Map<String, Object> businessData = trackEventService.getBusinessData(storeId, startDate, endDate, null);
-            
-            // 构建AI分析请求数据
-            Map<String, Object> aiRequestData = buildAIRequestData(storeId, businessData);
-            
-            // TODO: 调用AI服务进行分析
-            // JsonNode aiResponse = callAIService(aiRequestData);
-            
-            // 构建推荐结果
-            Map<String, Object> recommendation = buildRecommendation(businessData);
-            
-            return R.data(recommendation);
-        } catch (Exception e) {
-            log.error("获取AI推荐失败", e);
-            return R.fail("获取推荐失败: " + e.getMessage());
-        }
-    }
-
-    /**
-     * 构建AI请求数据
-     */
-    private Map<String, Object> buildAIRequestData(Integer storeId, Map<String, Object> businessData) {
-        Map<String, Object> requestData = new HashMap<>();
-        requestData.put("storeId", storeId);
-        requestData.put("businessData", businessData);
-        requestData.put("analysisType", "BUSINESS_RECOMMENDATION");
-        
-        // 构建提示词
-        StringBuilder prompt = new StringBuilder();
-        prompt.append("请分析以下店铺的经营数据,并提供优化建议:\n");
-        prompt.append("店铺ID: ").append(storeId).append("\n");
-        
-        Map<String, Object> trafficData = (Map<String, Object>) businessData.get("trafficData");
-        if (trafficData != null) {
-            prompt.append("流量数据: ").append(JSONObject.toJSONString(trafficData)).append("\n");
-        }
-        
-        Map<String, Object> priceRankingData = (Map<String, Object>) businessData.get("priceRankingData");
-        if (priceRankingData != null) {
-            prompt.append("价目表排名数据: ").append(JSONObject.toJSONString(priceRankingData)).append("\n");
-        }
-        
-        requestData.put("prompt", prompt.toString());
-        
-        return requestData;
-    }
-
-    /**
-     * 调用AI服务
-     */
-    private JsonNode callAIService(Map<String, Object> requestData) {
-        try {
-            // TODO: 实现AI服务调用逻辑
-            // 根据AlienAIFeign的接口定义调用相应的AI服务
-            // 注意:需要先登录获取token
-            
-            // 示例代码(需要根据实际的AI服务接口调整):
-            // JSONObject loginResult = alienAIFeign.login(...);
-            // String token = loginResult.getString("access_token");
-            // JsonNode response = alienAIFeign.generateRecommendation("Bearer " + token, requestData);
-            
-            return null;
-        } catch (Exception e) {
-            log.error("调用AI服务失败", e);
-            return null;
-        }
-    }
-
-    /**
-     * 构建推荐结果(示例实现,实际应该从AI服务返回)
-     */
-    private Map<String, Object> buildRecommendation(Map<String, Object> businessData) {
-        Map<String, Object> recommendation = new HashMap<>();
-        
-        // 示例:基于数据的简单推荐逻辑
-        Map<String, Object> priceRankingData = (Map<String, Object>) businessData.get("priceRankingData");
-        
-        StringBuilder summary = new StringBuilder();
-        List<Map<String, Object>> recommendations = new ArrayList<>();
-        
-        // 示例推荐逻辑:如果价目表价格高于平均值,给出建议
-        if (priceRankingData != null) {
-            summary.append("相较于其他同星级的店铺,您价目表中的锅包肉和烤羊腿价格远高于其他商家");
-            
-            Map<String, Object> rec1 = new HashMap<>();
-            rec1.put("type", "PRICING");
-            rec1.put("title", "价格优化建议");
-            rec1.put("content", "寻找原材料更便宜的菜场、菜量降低、菜名突出特色,如锡林郭勒盟羔羊烤羊腿");
-            recommendations.add(rec1);
-        }
-        
-        recommendation.put("summary", summary.toString());
-        recommendation.put("recommendations", recommendations);
-        
-        return recommendation;
-    }
-}

+ 0 - 127
alien-store/src/main/java/shop/alien/store/controller/BusinessDataController.java

@@ -1,127 +0,0 @@
-package shop.alien.store.controller;
-
-import io.swagger.annotations.*;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.format.annotation.DateTimeFormat;
-import org.springframework.web.bind.annotation.*;
-import shop.alien.entity.result.R;
-import shop.alien.store.service.TrackEventService;
-
-import java.util.Date;
-import java.util.Map;
-
-/**
- * 经营数据Controller
- *
- * @author system
- * @since 2026-01-14
- */
-@Slf4j
-@Api(tags = {"经营数据统计"})
-@ApiSort(21)
-@CrossOrigin
-@RestController
-@RequestMapping("/business")
-@RequiredArgsConstructor
-public class BusinessDataController {
-
-    private final TrackEventService trackEventService;
-
-    @ApiOperation("查询经营数据")
-    @ApiOperationSupport(order = 1)
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "storeId", value = "店铺ID", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "startDate", value = "开始日期", dataType = "String", paramType = "query", required = false, example = "2026-01-08"),
-            @ApiImplicitParam(name = "endDate", value = "结束日期", dataType = "String", paramType = "query", required = false, example = "2026-01-14"),
-            @ApiImplicitParam(name = "category", value = "数据分类(TRAFFIC,INTERACTION,COUPON,VOUCHER,SERVICE,PRICE)", dataType = "String", paramType = "query", required = false)
-    })
-    @GetMapping("/data")
-    public R<Map<String, Object>> getBusinessData(
-            @RequestParam("storeId") Integer storeId,
-            @RequestParam(value = "startDate", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
-            @RequestParam(value = "endDate", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
-            @RequestParam(value = "category", required = false) String category
-    ) {
-        log.info("查询经营数据: storeId={}, startDate={}, endDate={}, category={}", 
-                storeId, startDate, endDate, category);
-
-        try {
-            // 如果没有指定日期,默认查询最近7天的数据
-            if (startDate == null || endDate == null) {
-                Date now = new Date();
-                if (endDate == null) {
-                    endDate = now;
-                }
-                if (startDate == null) {
-                    long sevenDaysAgo = endDate.getTime() - 7 * 24 * 60 * 60 * 1000L;
-                    startDate = new Date(sevenDaysAgo);
-                }
-            }
-
-            Map<String, Object> data = trackEventService.getBusinessData(storeId, startDate, endDate, category);
-            return R.data(data);
-        } catch (Exception e) {
-            log.error("查询经营数据失败", e);
-            return R.fail("查询失败: " + e.getMessage());
-        }
-    }
-
-    @ApiOperation("对比两个时间段的数据")
-    @ApiOperationSupport(order = 2)
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "storeId", value = "店铺ID", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "startDate1", value = "时间段1开始日期", dataType = "String", paramType = "query", required = true, example = "2026-01-08"),
-            @ApiImplicitParam(name = "endDate1", value = "时间段1结束日期", dataType = "String", paramType = "query", required = true, example = "2026-01-14"),
-            @ApiImplicitParam(name = "startDate2", value = "时间段2开始日期", dataType = "String", paramType = "query", required = true, example = "2026-01-01"),
-            @ApiImplicitParam(name = "endDate2", value = "时间段2结束日期", dataType = "String", paramType = "query", required = true, example = "2026-01-07")
-    })
-    @GetMapping("/data/compare")
-    public R<Map<String, Object>> compareBusinessData(
-            @RequestParam("storeId") Integer storeId,
-            @RequestParam("startDate1") @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate1,
-            @RequestParam("endDate1") @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate1,
-            @RequestParam("startDate2") @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate2,
-            @RequestParam("endDate2") @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate2
-    ) {
-        log.info("对比经营数据: storeId={}, period1=[{}, {}], period2=[{}, {}]", 
-                storeId, startDate1, endDate1, startDate2, endDate2);
-
-        try {
-            Map<String, Object> data = trackEventService.compareBusinessData(
-                    storeId, startDate1, endDate1, startDate2, endDate2);
-            return R.data(data);
-        } catch (Exception e) {
-            log.error("对比经营数据失败", e);
-            return R.fail("对比失败: " + e.getMessage());
-        }
-    }
-
-    @ApiOperation("查询历史数据")
-    @ApiOperationSupport(order = 3)
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "storeId", value = "店铺ID", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "startDate", value = "开始日期", dataType = "String", paramType = "query", required = true, example = "2026-01-01"),
-            @ApiImplicitParam(name = "endDate", value = "结束日期", dataType = "String", paramType = "query", required = true, example = "2026-01-31"),
-            @ApiImplicitParam(name = "statType", value = "统计类型(DAILY,WEEKLY,MONTHLY)", dataType = "String", paramType = "query", required = false)
-    })
-    @GetMapping("/data/history")
-    public R<Map<String, Object>> getHistoryData(
-            @RequestParam("storeId") Integer storeId,
-            @RequestParam("startDate") @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
-            @RequestParam("endDate") @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
-            @RequestParam(value = "statType", required = false, defaultValue = "DAILY") String statType
-    ) {
-        log.info("查询历史数据: storeId={}, startDate={}, endDate={}, statType={}", 
-                storeId, startDate, endDate, statType);
-
-        try {
-            // TODO: 从统计表中查询历史数据
-            Map<String, Object> data = trackEventService.getBusinessData(storeId, startDate, endDate, null);
-            return R.data(data);
-        } catch (Exception e) {
-            log.error("查询历史数据失败", e);
-            return R.fail("查询失败: " + e.getMessage());
-        }
-    }
-}