lyhzzz 2 лет назад
Родитель
Сommit
994f475f34
23 измененных файлов с 269 добавлено и 181 удалено
  1. 21 0
      src/main/java/com/cdf/controller/SceneSourceDataController.java
  2. 30 17
      src/main/java/com/cdf/controller/api/PageDataApiController.java
  3. 4 3
      src/main/java/com/cdf/controller/back/TestController.java
  4. 2 2
      src/main/java/com/cdf/entity/PageData.java
  5. 56 0
      src/main/java/com/cdf/entity/SceneSourceData.java
  6. 9 1
      src/main/java/com/cdf/entity/TotalData.java
  7. 0 73
      src/main/java/com/cdf/entity/TotalDataHk.java
  8. 1 1
      src/main/java/com/cdf/generate/AutoGenerate.java
  9. 3 3
      src/main/java/com/cdf/httpClient/client/CdfClient.java
  10. 3 3
      src/main/java/com/cdf/mapper/ITotalDataHkMapper.java
  11. 2 2
      src/main/java/com/cdf/mapper/ITotalDataMapper.java
  12. 45 33
      src/main/java/com/cdf/schedule/ScheduleTask.java
  13. 2 0
      src/main/java/com/cdf/service/IProductSourceService.java
  14. 3 3
      src/main/java/com/cdf/service/ITotalDataHkService.java
  15. 3 3
      src/main/java/com/cdf/service/ITotalDataService.java
  16. 16 0
      src/main/java/com/cdf/service/impl/ProductSourceServiceImpl.java
  17. 20 0
      src/main/java/com/cdf/service/impl/SceneSourceDataServiceImpl.java
  18. 4 0
      src/main/java/com/cdf/service/impl/SceneSourceServiceImpl.java
  19. 0 20
      src/main/java/com/cdf/service/impl/TotalDataHkServiceImpl.java
  20. 38 12
      src/main/java/com/cdf/service/impl/TotalDataServiceImpl.java
  21. 1 1
      src/main/resources/mapper/TotalDataHkMapper.xml
  22. 2 2
      src/main/resources/mapper/TotalDataMapper.xml
  23. 4 2
      vr场景统计结果接口文档.md

+ 21 - 0
src/main/java/com/cdf/controller/SceneSourceDataController.java

@@ -0,0 +1,21 @@
+package com.cdf.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-07
+ */
+@RestController
+@RequestMapping("/sceneSourceData")
+public class SceneSourceDataController {
+
+}
+

+ 30 - 17
src/main/java/com/cdf/controller/api/PageDataApiController.java

@@ -7,11 +7,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.cdf.common.ResultCode;
 import com.cdf.common.ResultData;
 import com.cdf.entity.PageData;
+import com.cdf.entity.ProductSource;
 import com.cdf.entity.TotalData;
 import com.cdf.exception.BusinessException;
 import com.cdf.httpClient.client.CdfClient;
+import com.cdf.httpClient.client.CdfHKClient;
 import com.cdf.httpClient.request.CdfChannelclick;
 import com.cdf.service.IPageDataService;
+import com.cdf.service.IProductSourceService;
+import com.cdf.service.ISceneSourceService;
 import com.cdf.service.ITotalDataService;
 import com.cdf.util.DateUtil;
 import org.apache.commons.lang3.StringUtils;
@@ -38,7 +42,9 @@ public class PageDataApiController {
     @Autowired
     ITotalDataService totalDataService;
     @Resource
-    CdfClient cdfClient;
+    CdfHKClient cdfHKClient;
+    @Autowired
+    ISceneSourceService sceneSourceService;
 
 
     @GetMapping("/point")
@@ -49,7 +55,7 @@ public class PageDataApiController {
                                   @RequestParam(required = false) String whereUrl,
                                   @RequestParam(required = false) Integer type,
                                   @RequestParam(required = false) String productId,
-                                  @RequestParam(required = false,defaultValue = "22") Integer deptId,
+                                  @RequestParam(required = false) String sceneNum,
                                   HttpServletRequest request) throws Exception {
 
         LambdaQueryWrapper<PageData> wrapper = new LambdaQueryWrapper<>();
@@ -57,10 +63,14 @@ public class PageDataApiController {
         wrapper.eq(PageData::getDay,DateUtil.getDay(new Date()));
 
         List<PageData> list = pageDataService.list(wrapper);
+        ProductSource productSource = sceneSourceService.getByNum(sceneNum);
+        if(productSource.getId().equals(1)){
+            sceneNum = null;
+        }
         PageData pageData;
         if(list.size() <=0){
             pageData = new PageData();
-            pageData.setDeptId(deptId);
+            pageData.setSceneNum(sceneNum);
             pageData.setCdfUserId(userId);
             pageData.setCdfToken(AccessToken);
             pageData.setCdfCookieId(cookieId);
@@ -71,6 +81,7 @@ public class PageDataApiController {
             pageData = list.get(0);
         }
         pageData.setUrl(whereUrl);
+
         switch (type){
             case 0:     //用戶打开页面
                 pageData.setInPageTime(DateUtil.getDateTime(new Date()));
@@ -87,9 +98,7 @@ public class PageDataApiController {
                 pageData.setIsClickGame(1);
                 break;
             case 3:     //用戶点击商品详情
-                if(deptId == 22){
-                    sendCdf(productId,cookieId,AccessToken,userId);
-                }
+                sendCdf(productSource,productId,cookieId,AccessToken,userId);
                 pageData.setIsClickShop(1);
                 break;
             case 4:     //用戶点击場景点位
@@ -100,9 +109,7 @@ public class PageDataApiController {
                 break;
             case 6:     //用戶点击收藏
             case 7:     //加入购物车
-                if(deptId == 22){
-                    sendCdf(productId,cookieId,AccessToken,userId);
-                }
+                sendCdf(productSource,productId,cookieId,AccessToken,userId);
                 return ResultData.ok();
         }
         pageData.setUpdateTime(null);
@@ -110,13 +117,13 @@ public class PageDataApiController {
         return ResultData.ok();
     }
 
-    private void sendCdf(String productId,String cookieId,String accesstoken,String userId){
-        if(StringUtils.isEmpty(productId)){
+    private void sendCdf(ProductSource productSource,String productId,String cookieId,String accesstoken,String userId){
+        if(StringUtils.isEmpty(productId) || productSource == null || productSource.getMchType() == 1){
             return;
         }
         CdfChannelclick cdfChannelclick = new CdfChannelclick();
         cdfChannelclick.setProductId(productId);
-        cdfClient.channelclick(cookieId,accesstoken,userId,cdfChannelclick);
+        cdfHKClient.channelclick(productSource.getCdfHost(),productSource.getCdfMchId(),cookieId,accesstoken,userId,cdfChannelclick);
     }
 
 
@@ -124,17 +131,19 @@ public class PageDataApiController {
     public ResultData getPageData(@RequestParam(required = false) String day,
                                   @RequestParam(required = false,defaultValue = "0") Integer type,
                                   @RequestParam(required = false) String startDay,
-                                  @RequestParam(required = false) String endDay) throws Exception {
-        return ResultData.ok(totalDataService.getByType(type,day,startDay,endDay));
+                                  @RequestParam(required = false) String endDay,
+                                  @RequestParam(required = false,defaultValue = "600667208") String mchId) throws Exception {
+        return ResultData.ok(totalDataService.getByType(type,day,startDay,endDay,mchId));
     }
 
     @GetMapping("/pageDataTime")
     public ResultData pageDataTime(@RequestParam(required = false) String startDay,
-                                  @RequestParam(required = false) String endDay) {
+                                  @RequestParam(required = false) String endDay,
+                                   @RequestParam(required = false,defaultValue = "600667208") String mchId) {
         if(StringUtils.isEmpty(startDay) || StringUtils.isEmpty(endDay)){
             throw new BusinessException(ResultCode.PARAM_MISS);
         }
-        return ResultData.ok(totalDataService.pageDataTime(startDay,endDay));
+        return ResultData.ok(totalDataService.pageDataTime(startDay,endDay,mchId));
     }
 
     @PostMapping("/pageDataList")
@@ -143,8 +152,12 @@ public class PageDataApiController {
         if(jsonArray == null || jsonArray.size() <=0){
             return  ResultData.ok(new ArrayList<>());
         }
+        String mchId = jsonObject.getString("mchId");
+        if(StringUtils.isBlank(mchId)){
+            mchId = "600667208";
+        }
         List<String> days = new ArrayList(jsonArray);
-        return ResultData.ok(totalDataService.getListByType(days));
+        return ResultData.ok(totalDataService.getListByType(days,mchId));
     }
 }
 

+ 4 - 3
src/main/java/com/cdf/controller/back/TestController.java

@@ -41,6 +41,7 @@ import java.util.List;
 
 
 @RestController
+@RequestMapping("/api")
 public class TestController {
 
     @Autowired
@@ -113,7 +114,7 @@ public class TestController {
         return ResultData.ok(allScene);
     }
 
-    @GetMapping("/export")
+    @GetMapping("/test/export")
     public void export(HttpServletRequest request, HttpServletResponse response) throws Exception {
         ShopRequest param = new ShopRequest();
         param.setPageNum(1);
@@ -124,7 +125,7 @@ public class TestController {
 
     }
 
-    @PostMapping("uploadExcel")
+    @PostMapping("/test/uploadExcel")
     public ResultData uploadExcel(@RequestParam(required = false) MultipartFile file) throws IOException {
         List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
         for (HashMap<Integer, String> map : excelRowList) {
@@ -137,7 +138,7 @@ public class TestController {
         }
         return ResultData.ok();
     }
-    @PostMapping("/uploadExcelHK")
+    @PostMapping("/test/uploadExcelHK")
     public ResultData uploadExcelHK(@RequestParam(required = false) MultipartFile file) throws IOException {
         String baseUrl = "https://hkairportshop.com/";
         String imageBasePath = "http://glp-vr.cdfmembers.com/cdf/HK/ImageFiles";

+ 2 - 2
src/main/java/com/cdf/entity/PageData.java

@@ -77,7 +77,7 @@ public class PageData implements Serializable {
     @TableField("out_page_time")
     private String outPageTime;
 
-    @TableField("dept_id")
-    private Integer deptId;
+    @TableField("scene_num")
+    private String sceneNum;
 
 }

+ 56 - 0
src/main/java/com/cdf/entity/SceneSourceData.java

@@ -0,0 +1,56 @@
+package com.cdf.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-07
+ */
+@Getter
+@Setter
+@TableName("t_scene_source_data")
+public class SceneSourceData implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 场景对应商品来源关系
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 场景码
+     */
+    @TableField("scene_num")
+    private String sceneNum;
+
+    @TableField("product_source_id")
+    private Integer productSourceId;
+
+    @TableField("tb_status")
+    @TableLogic
+    private Integer tbStatus;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+
+}

+ 9 - 1
src/main/java/com/cdf/entity/TotalData.java

@@ -1,5 +1,6 @@
 package com.cdf.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -8,6 +9,7 @@ import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import lombok.Getter;
 import lombok.Setter;
+import org.apache.commons.lang3.StringUtils;
 
 /**
  * <p>
@@ -24,9 +26,12 @@ public class TotalData implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId("id")
+    @TableId(value = "id",type = IdType.AUTO)
     private String id;
 
+    @TableField("day_time")
+    private String dayTime;
+
     /**
      * 平均停留时间 /秒
      */
@@ -61,6 +66,9 @@ public class TotalData implements Serializable {
     @TableField("video_num")
     private Long videoNum;
 
+    @TableField("product_source_id")
+    private Integer productSourceId;
+
     @TableField("create_time")
     private String createTime;
 

+ 0 - 73
src/main/java/com/cdf/entity/TotalDataHk.java

@@ -1,73 +0,0 @@
-package com.cdf.entity;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.time.LocalDateTime;
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * <p>
- * 
- * </p>
- *
- * @author 
- * @since 2022-11-08
- */
-@Getter
-@Setter
-@TableName("t_total_data_hk")
-public class TotalDataHk implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId("id")
-    private String id;
-
-    /**
-     * 平均停留时间 /秒
-     */
-    @TableField("avg_stop_time")
-    private Long avgStopTime;
-
-    /**
-     * 跳出率
-     */
-    @TableField("avg_jump")
-    private BigDecimal avgJump;
-
-    /**
-     * 寻宝游戏点击率
-     */
-    @TableField("avg_click_game")
-    private BigDecimal avgClickGame;
-
-    /**
-     * 商品详情点击率
-     */
-    @TableField("avg_click_shop")
-    private BigDecimal avgClickShop;
-
-    /**
-     * 平均步数
-     */
-    @TableField("avg_step_num")
-    private Long avgStepNum;
-
-    /**
-     * 视频点击次数
-     */
-    @TableField("video_num")
-    private Long videoNum;
-
-    @TableField("create_time")
-    private String createTime;
-
-    @TableField("update_time")
-    private String updateTime;
-
-
-}

+ 1 - 1
src/main/java/com/cdf/generate/AutoGenerate.java

@@ -20,7 +20,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir") ;
 
         generate(path,"", getTables(new String[]{
-                "t_scene_source"
+                "t_scene_source_data"
         }));
 
 //        generate(path,"goods", getTables(new String[]{

+ 3 - 3
src/main/java/com/cdf/httpClient/client/CdfClient.java

@@ -65,10 +65,10 @@ public interface CdfClient {
      */
     @Post(url = "/api/prodextra/channelclick",
         headers = {
-            "app-key: h5sqBuyer_600667208",
+            "app-key: h5sqBuyer_{mchId}",
             "app-version: 6.6.88",
             "cookieid: {cookieId}",
-            "ymt-pars: appid=71&accesstoken={accessToken}&userid={userId}&mchId=600667208&language=zh_CN&format=json",
+            "ymt-pars: appid=71&accesstoken={accessToken}&userid={userId}&mchId={mchid}&language=zh_CN&format=json",
         })
-    JSONObject channelclick(@Var("cookieId") String cookieId, @Var("accessToken") String accessToken, @Var("userId")String userId, @JSONBody CdfChannelclick request);
+    JSONObject channelclick(@Var("mchId")String mchId,@Var("cookieId") String cookieId, @Var("accessToken") String accessToken, @Var("userId")String userId, @JSONBody CdfChannelclick request);
 }

+ 3 - 3
src/main/java/com/cdf/mapper/ITotalDataHkMapper.java

@@ -1,6 +1,6 @@
 package com.cdf.mapper;
 
-import com.cdf.entity.TotalDataHk;
+import com.cdf.entity.SceneSourceData;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 
@@ -10,9 +10,9 @@ import org.apache.ibatis.annotations.Mapper;
  * </p>
  *
  * @author 
- * @since 2022-11-08
+ * @since 2023-03-07
  */
 @Mapper
-public interface ITotalDataHkMapper extends BaseMapper<TotalDataHk> {
+public interface ISceneSourceDataMapper extends BaseMapper<SceneSourceData> {
 
 }

+ 2 - 2
src/main/java/com/cdf/mapper/ITotalDataMapper.java

@@ -16,7 +16,7 @@ import org.apache.ibatis.annotations.Param;
 @Mapper
 public interface ITotalDataMapper extends BaseMapper<TotalData> {
 
-    TotalData getMonth(@Param("time") String time);
+    TotalData getMonth(@Param("productSourceId") Integer productSourceId,@Param("time") String time);
 
-    TotalData getWeek(@Param("startTime") String weekStart, @Param("endTime") String weekEnd);
+    TotalData getWeek(@Param("productSourceId") Integer productSourceId,@Param("startTime") String weekStart, @Param("endTime") String weekEnd);
 }

+ 45 - 33
src/main/java/com/cdf/schedule/ScheduleTask.java

@@ -2,10 +2,12 @@ package com.cdf.schedule;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.cdf.entity.PageData;
+import com.cdf.entity.SceneSource;
+import com.cdf.entity.SceneSourceData;
 import com.cdf.entity.TotalData;
-import com.cdf.entity.TotalDataHk;
 import com.cdf.service.IPageDataService;
-import com.cdf.service.ITotalDataHkService;
+import com.cdf.service.ISceneSourceDataService;
+import com.cdf.service.ISceneSourceService;
 import com.cdf.service.ITotalDataService;
 import com.cdf.util.DateUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -16,8 +18,7 @@ import org.springframework.stereotype.Component;
 
 import javax.naming.ldap.PagedResultsControl;
 import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 @Component
 @Slf4j
@@ -28,7 +29,7 @@ public class ScheduleTask {
     @Autowired
     ITotalDataService totalDataService;
     @Autowired
-    ITotalDataHkService totalDataHkService;
+    ISceneSourceDataService sceneSourceDataService;
 
     public static String day = null;
 
@@ -39,23 +40,44 @@ public class ScheduleTask {
             day = DateUtil.getDay(new Date(), -1);
         }
         log.info("开始统计{}的数据,{}",day,DateUtil.getDateTime(new Date()));
-        TotalData totalData = new TotalData();
-        TotalDataHk totalDatahk = new TotalDataHk();
-
-        this.dataT(totalData,totalDatahk,22);
-        totalDataService.saveOrUpdate(totalData);
-        this.dataT(totalData,totalDatahk,33);
-        totalDataHkService.saveOrUpdate(totalDatahk);
+        this.dataT();
         //待添加传输
         log.info("{结束统计{}的数据,{}",day,DateUtil.getDateTime(new Date()));
         day = null;
     }
 
-    private void dataT(TotalData totalData,TotalDataHk totalDataHk,Integer deptId) throws Exception {
+    private void dataT() throws Exception {
+        List<SceneSourceData> sceneSources = sceneSourceDataService.list();
+        HashMap<Integer,List<String>> sceneMap = new HashMap<>();
+        for (SceneSourceData sceneSource : sceneSources) {
+            if(sceneMap.get(sceneSource.getProductSourceId()) == null){
+                List<String> nums = new ArrayList<>();
+                nums.add(sceneSource.getSceneNum());
+                sceneMap.put(sceneSource.getProductSourceId(),nums);
+            }else {
+                sceneMap.get(sceneSource.getProductSourceId()).add(sceneSource.getSceneNum());
+            }
+        }
+        for (Integer productSourceId : sceneMap.keySet()) {
+            LambdaQueryWrapper<PageData> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(PageData::getDay,day);
+            if(sceneMap.get(productSourceId).size() <=0 ){
+                continue;
+            }
+            wrapper.in(PageData::getSceneNum,sceneMap.get(productSourceId));
+            List<PageData> list = pageDataService.list(wrapper);
+            this.saveData(list,productSourceId);
+        }
+
         LambdaQueryWrapper<PageData> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(PageData::getDeptId,deptId);
         wrapper.eq(PageData::getDay,day);
+        wrapper.isNull(PageData::getSceneNum);
         List<PageData> list = pageDataService.list(wrapper);
+        this.saveData(list,1);
+    }
+
+    private void saveData( List<PageData> list,Integer productSourceId) throws Exception {
+        TotalData totalData = new TotalData();
         Long stopTimeCount = 0L;
         BigDecimal jumpCount = BigDecimal.ZERO;
         BigDecimal clickGameCount = BigDecimal.ZERO;
@@ -101,25 +123,15 @@ public class ScheduleTask {
             avgClickShop = clickShopCount.divide(new BigDecimal(list.size()),4,BigDecimal.ROUND_HALF_UP);
             avgStepNum = totalStepNum / list.size();
         }
-        if(deptId == 22){
-            totalData.setId(day);
-            totalData.setAvgStopTime(avgStopTime);
-            totalData.setAvgJump(avgJump);
-            totalData.setAvgClickGame(avgClickGame);
-            totalData.setAvgClickShop(avgClickShop);
-            totalData.setVideoNum(totalVideoNum);
-            totalData.setAvgStepNum(avgStepNum);
-        }
-        if(deptId == 33){
-            totalDataHk.setId(day);
-            totalDataHk.setAvgStopTime(avgStopTime);
-            totalDataHk.setAvgJump(avgJump);
-            totalDataHk.setAvgClickGame(avgClickGame);
-            totalDataHk.setAvgClickShop(avgClickShop);
-            totalDataHk.setVideoNum(totalVideoNum);
-            totalDataHk.setAvgStepNum(avgStepNum);
-        }
-
+        totalData.setDayTime(day);
+        totalData.setAvgStopTime(avgStopTime);
+        totalData.setAvgJump(avgJump);
+        totalData.setAvgClickGame(avgClickGame);
+        totalData.setAvgClickShop(avgClickShop);
+        totalData.setVideoNum(totalVideoNum);
+        totalData.setAvgStepNum(avgStepNum);
+        totalData.setProductSourceId(productSourceId);
+        totalDataService.save(totalData);
     }
 
 }

+ 2 - 0
src/main/java/com/cdf/service/IProductSourceService.java

@@ -19,4 +19,6 @@ public interface IProductSourceService extends IService<ProductSource> {
     List<ProductSource> getProductHk(String type);
 
     Object getBySource(CdfProductListRequest param,ProductSource productSource);
+
+    ProductSource getByMchId(String mchId);
 }

+ 3 - 3
src/main/java/com/cdf/service/ITotalDataHkService.java

@@ -1,6 +1,6 @@
 package com.cdf.service;
 
-import com.cdf.entity.TotalDataHk;
+import com.cdf.entity.SceneSourceData;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 /**
@@ -9,8 +9,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * </p>
  *
  * @author 
- * @since 2022-11-08
+ * @since 2023-03-07
  */
-public interface ITotalDataHkService extends IService<TotalDataHk> {
+public interface ISceneSourceDataService extends IService<SceneSourceData> {
 
 }

+ 3 - 3
src/main/java/com/cdf/service/ITotalDataService.java

@@ -15,9 +15,9 @@ import java.util.List;
  */
 public interface ITotalDataService extends IService<TotalData> {
 
-    TotalData getByType(Integer type, String day,String startDay,String endDay) throws Exception;
+    TotalData getByType(Integer type, String day,String startDay,String endDay,String mchId) throws Exception;
 
-    List<TotalData> getListByType( List<String> days) throws Exception;
+    List<TotalData> getListByType( List<String> days,String mchId) throws Exception;
 
-    List<TotalData> pageDataTime(String startDay, String endDay);
+    List<TotalData> pageDataTime(String startDay, String endDay,String mchId);
 }

+ 16 - 0
src/main/java/com/cdf/service/impl/ProductSourceServiceImpl.java

@@ -12,7 +12,9 @@ import com.cdf.httpClient.response.cdf.*;
 import com.cdf.mapper.IProductSourceMapper;
 import com.cdf.service.IProductSourceService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cdf.service.ISceneSourceService;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -69,4 +71,18 @@ public class ProductSourceServiceImpl extends ServiceImpl<IProductSourceMapper,
         PageInfo pageInfo = PageInfo.PageInfo(param.getPageIndex(), 20L, productList.getCount()*20, productList.getList());
         return pageInfo;
     }
+
+    @Override
+    public ProductSource getByMchId(String mchId) {
+        if(StringUtils.isBlank(mchId)){
+            return this.getById(1);
+        }
+        LambdaQueryWrapper<ProductSource> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(ProductSource::getCdfMchId,mchId);
+        List<ProductSource> list = this.list(wrapper);
+        if(list != null && list.size() >0){
+            return list.get(0);
+        }
+        return this.getById(1);
+    }
 }

+ 20 - 0
src/main/java/com/cdf/service/impl/SceneSourceDataServiceImpl.java

@@ -0,0 +1,20 @@
+package com.cdf.service.impl;
+
+import com.cdf.entity.SceneSourceData;
+import com.cdf.mapper.ISceneSourceDataMapper;
+import com.cdf.service.ISceneSourceDataService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-07
+ */
+@Service
+public class SceneSourceDataServiceImpl extends ServiceImpl<ISceneSourceDataMapper, SceneSourceData> implements ISceneSourceDataService {
+
+}

+ 4 - 0
src/main/java/com/cdf/service/impl/SceneSourceServiceImpl.java

@@ -7,6 +7,7 @@ import com.cdf.mapper.ISceneSourceMapper;
 import com.cdf.service.IProductSourceService;
 import com.cdf.service.ISceneSourceService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -28,6 +29,9 @@ public class SceneSourceServiceImpl extends ServiceImpl<ISceneSourceMapper, Scen
 
     @Override
     public ProductSource getByNum(String num) {
+        if(StringUtils.isBlank(num)){
+            return productSourceService.getById(1);
+        }
         LambdaQueryWrapper<SceneSource> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(SceneSource::getSceneNum,num);
         List<SceneSource> list = this.list(wrapper);

+ 0 - 20
src/main/java/com/cdf/service/impl/TotalDataHkServiceImpl.java

@@ -1,20 +0,0 @@
-package com.cdf.service.impl;
-
-import com.cdf.entity.TotalDataHk;
-import com.cdf.mapper.ITotalDataHkMapper;
-import com.cdf.service.ITotalDataHkService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author 
- * @since 2022-11-08
- */
-@Service
-public class TotalDataHkServiceImpl extends ServiceImpl<ITotalDataHkMapper, TotalDataHk> implements ITotalDataHkService {
-
-}

+ 38 - 12
src/main/java/com/cdf/service/impl/TotalDataServiceImpl.java

@@ -1,12 +1,15 @@
 package com.cdf.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.cdf.entity.ProductSource;
 import com.cdf.entity.TotalData;
 import com.cdf.mapper.ITotalDataMapper;
+import com.cdf.service.IProductSourceService;
 import com.cdf.service.ITotalDataService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cdf.util.DateUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
@@ -26,15 +29,19 @@ import java.util.List;
 @Service
 public class TotalDataServiceImpl extends ServiceImpl<ITotalDataMapper, TotalData> implements ITotalDataService {
 
+    @Autowired
+    IProductSourceService productSourceService;
+
     @Override
-    public TotalData getByType(Integer type, String time,String startDay,String endDay) throws Exception {
+    public TotalData getByType(Integer type, String time,String startDay,String endDay,String mchId) throws Exception {
+        ProductSource productSource = productSourceService.getByMchId(mchId);
+
         switch (type){
             case 0:     //日
                 if(StringUtils.isEmpty(time)){
                     time = DateUtil.getDay(new Date(),-1);
                 }
-                TotalData byId = this.getById(time);
-                return  byId == null ? newTotalData(time) : byId;
+                return this.getByDay(time,productSource.getId());
             case 1:     //周
                 String weekStart =null;
                 if(StringUtils.isEmpty(time)){
@@ -44,10 +51,11 @@ public class TotalDataServiceImpl extends ServiceImpl<ITotalDataMapper, TotalDat
                     weekStart = DateUtil.getWeekStart(date);
                 }
                 String weekEnd = DateUtil.getWeekEnd(weekStart);
-                TotalData week = this.getBaseMapper().getWeek(weekStart, weekEnd);
+                TotalData week = this.getBaseMapper().getWeek(productSource.getId(),weekStart, weekEnd);
                 if(week == null){
                     week = newTotalData(weekStart);
                 }
+                week.setDayTime(weekStart);
                 week.setId(weekStart);
                 return week;
             case 2:     //月
@@ -55,15 +63,16 @@ public class TotalDataServiceImpl extends ServiceImpl<ITotalDataMapper, TotalDat
                     time = DateUtil.getLastMonth();
                 }
                 time = DateUtil.getMonth(time);
-                TotalData month = this.getBaseMapper().getMonth(time);
+                TotalData month = this.getBaseMapper().getMonth(productSource.getId(),time);
                 if(month == null){
                     month = newTotalData(time);
                 }
                 month.setId(time);
+                month.setDayTime(time);
                 return month;
             case 3:     //时间段
                 if(StringUtils.isNotBlank(startDay) && StringUtils.isNotBlank(endDay)){
-                    TotalData totalData = this.getBaseMapper().getWeek(startDay, endDay);
+                    TotalData totalData = this.getBaseMapper().getWeek(productSource.getId(),startDay, endDay);
                     if(totalData == null){
                         totalData = newTotalData(startDay +"-"+endDay);
                     }
@@ -73,30 +82,46 @@ public class TotalDataServiceImpl extends ServiceImpl<ITotalDataMapper, TotalDat
                 if(StringUtils.isEmpty(time)){
                     time = DateUtil.getDay(new Date(),-1);
                 }
-                return  this.getById(time) == null ? newTotalData(time) : this.getById(time);
+                return  this.getByDay(time,productSource.getId());
             default:
                 throw new IllegalStateException("Unexpected value: " + type);
         }
     }
 
+    private TotalData getByDay(String time, Integer productSourceId) {
+        LambdaQueryWrapper<TotalData> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(TotalData::getId,time);
+        wrapper.eq(TotalData::getProductSourceId,productSourceId);
+        List<TotalData> list = this.list(wrapper);
+        if(list !=null && list.size() >0 ){
+            return list.get(0);
+        }
+        return newTotalData(time);
+    }
+
     @Override
-    public List<TotalData> pageDataTime(String startDay, String endDay) {
+    public List<TotalData> pageDataTime(String startDay, String endDay,String mchId) {
+        ProductSource productSource = productSourceService.getByMchId(mchId);
         LambdaQueryWrapper<TotalData> wrapper = new LambdaQueryWrapper<>();
-        wrapper.between(TotalData::getId,startDay,endDay);
+        wrapper.between(TotalData::getDayTime,startDay,endDay);
+        wrapper.eq(TotalData::getProductSourceId,productSource.getId());
         wrapper.orderByAsc(TotalData::getId);
         return this.list(wrapper);
     }
 
     @Override
-    public List<TotalData> getListByType(List<String> days) throws Exception {
+    public List<TotalData> getListByType(List<String> days,String mchId) throws Exception {
+        ProductSource productSource = productSourceService.getByMchId(mchId);
+
         LambdaQueryWrapper<TotalData> wrapper = new LambdaQueryWrapper<>();
-        wrapper.in(TotalData::getId,days);
+        wrapper.in(TotalData::getDayTime,days);
+        wrapper.eq(TotalData::getProductSourceId,productSource.getId());
         List<TotalData> list = this.list(wrapper);
 
         List<TotalData> voList = new ArrayList<>();
         HashMap<String,TotalData> map = new HashMap<>();
         for (TotalData totalData : list) {
-            map.put(totalData.getId(),totalData);
+            map.put(totalData.getDayTime(),totalData);
         }
         for (String day : days) {
             TotalData totalData = map.get(day);
@@ -111,6 +136,7 @@ public class TotalDataServiceImpl extends ServiceImpl<ITotalDataMapper, TotalDat
     private TotalData newTotalData(String id ){
         TotalData totalData = new TotalData();
         totalData.setId(id);
+        totalData.setDayTime(id);
         totalData.setAvgStopTime(0L);
         totalData.setAvgStepNum(0L);
         totalData.setVideoNum(0L);

+ 1 - 1
src/main/resources/mapper/TotalDataHkMapper.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.cdf.mapper.ITotalDataHkMapper">
+<mapper namespace="com.cdf.mapper.ISceneSourceDataMapper">
 
 </mapper>

+ 2 - 2
src/main/resources/mapper/TotalDataMapper.xml

@@ -15,12 +15,12 @@
     <select id="getMonth" resultType="com.cdf.entity.TotalData">
         SELECT
         <include refid="baseRow"></include>
-        FROM t_total_data WHERE id like CONCAT('%',#{time},'%')
+        FROM t_total_data WHERE product_source_id = #{productSourceId} and day_time like CONCAT('%',#{time},'%')
     </select>
 
     <select id="getWeek" resultType="com.cdf.entity.TotalData">
         SELECT
          <include refid="baseRow"></include>
-        FROM t_total_data WHERE id &gt;= #{startTime} and id &lt;=#{endTime}
+        FROM t_total_data WHERE product_source_id = #{productSourceId} and day_time &gt;= #{startTime} and day_time &lt;=#{endTime}
     </select>
 </mapper>

+ 4 - 2
vr场景统计结果接口文档.md

@@ -21,7 +21,7 @@
  | type          | 类型(0:日,1:周,2:月,3:自定义时间段)默认0    |  false   |   int      |0    |
  | startDay          | 开始天数 (当type 为3时,不为空)   |  false   |   string      |2022-06-18   |
  | endDay          | 结束天数 (当type 为3时,不为空)    |  false   |   string      |2022-06-30  |
-
+  | mchId          | 店铺Id (新增)  |  true   |   string      |604163192 |
  
  
  
@@ -61,6 +61,7 @@
  | ------------ | -----------   | -------- | -------     | -----    |
  | startDay          | 开始天数,不为空   |  true   |   string      |2022-06-18   |
  | endDay          | 结束天数 ,不为空    |  true   |   string      |2022-09-18 |
+  | mchId          | 店铺Id (新增)  |  true   |   string      |604163192 |
 
  
  
@@ -103,7 +104,8 @@
  
   ```json
 {
-    "days": ["2022-06-18","2022-06-19","2022-09-14"]
+    "days": ["2022-06-18","2022-06-19","2022-09-14"],
+   "mchId": 604163192
 }
   ```