Browse Source

内网数据库——获取达人数据

zhaoxian 2 years ago
parent
commit
9ea3507004

+ 30 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/KuaiShouPromoterController.java

@@ -0,0 +1,30 @@
+package org.jeecg.ctop.material.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.ctop.material.service.IKuaishouPromoterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ *
+ */
+@Slf4j
+@RestController
+@RequestMapping("/kuaiShou/promoter")
+public class KuaiShouPromoterController {
+
+    @Autowired
+    IKuaishouPromoterService promoterService;
+
+    /**
+     * 查询达人详细数据
+     */
+    @GetMapping("/getPromoterInfo")
+    public JSONObject getPromoterInfo(Long promoterId) {
+        return promoterService.getPromoterInfo(promoterId);
+    }
+
+}

+ 17 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/KuaishouPromoterMapper.java

@@ -0,0 +1,17 @@
+package org.jeecg.ctop.material.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface KuaishouPromoterMapper {
+
+    JSONObject getPromoterInfo(@Param("promoterId") Long promoterId);
+
+    List<JSONObject> getFansCharacteristic(@Param("promoterId") Long promoterId);
+
+    List<JSONObject> getPromoterShortVideosCommerceInfo(@Param("promoterId") Long promoterId, @Param("startInt") Integer startInt, @Param("endInt") Integer endInt);
+
+    Object getPromoterLiveCommerceInfo(@Param("promoterId") Long promoterId, @Param("startInt") Integer startInt, @Param("endInt") Integer endInt);
+}

+ 73 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/KuaishouPromoterMapper.xml

@@ -0,0 +1,73 @@
+<?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="org.jeecg.ctop.material.mapper.KuaishouPromoterMapper">
+
+    <select id="getPromoterInfo" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.hotSaleChannelInfo,
+               t1.hotSaleBrandInfo,
+               t2.totalSale,
+               t2.promotedProductsNum,
+               t3.promoteLiveCount,
+               t2.liveStreamGMV,
+               t3.liveStreamVisitorCount,
+               t3.avgVisitorOnlineCount,
+               t2.liveStreamGPM,
+               t3.interactionRate,
+               ROUND(avgViewTime / 60000, 0) as 'avgViewTime',
+               t3.maxSameTimeVisitorCount,
+               t2.videoGPM,
+               t2.avgVideoSales,
+               t2.avgVideoViewers,
+               t4.videoCount,
+               t4.videoWatchCount,
+               t4.totalSale as 'videoTotalSale'
+        FROM kwai_promoter.kwai_promoter_info t1
+                 LEFT JOIN kwai_promoter.kwai_promoter_base_info t2 ON t1.promoterId = t2.promoterId
+                 LEFT JOIN kwai_promoter.kwai_promoter_live_base_info t3 ON t1.promoterId = t3.promoterId
+                 LEFT JOIN kwai_promoter.kwai_promoter_video_info t4 ON t1.promoterId = t4.promoterId
+        WHERE t1.promoterId = #{promoterId}
+          AND t3.timeRangeType = 2
+          AND t4.timeRangeType = 2
+    </select>
+
+    <select id="getFansCharacteristic" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT type,
+               CONCAT(type_date, '居多') as 'name',
+               CONCAT(ROUND(MAX(FeatureRate) / 100, 2), '%') as 'roi'
+        FROM kwai_promoter.kwai_promoter_fans_base_info
+        WHERE promoterId = #{promoterId}
+          AND timeRangeType = 2
+        GROUP BY type
+
+    </select>
+
+    <select id="getPromoterLiveCommerceInfo" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT `date`,
+               commentsCount,
+               likesCount,
+               liveMinuteDuration,
+               liveVisitorCount,
+               maxVisitorCount,
+               sharesCount
+        from kwai_promoter.kwai_promoter_live_analyse_info
+        WHERE promoterId = #{promoterId}
+          AND `date` BETWEEN #{startInt}
+            and #{endInt}
+        GROUP BY `date`
+        ORDER BY `date`
+    </select>
+
+    <select id="getPromoterShortVideosCommerceInfo" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT `date`,
+               shareCount,
+               videoWatchCount,
+               likeCount,
+               commentCount
+        from kwai_promoter.kwai_promoter_video_report_analyse_info
+        WHERE promoterId = #{promoterId}
+          AND `date` BETWEEN #{startInt} and #{endInt}
+        GROUP BY `date`
+        ORDER BY `date`
+    </select>
+
+</mapper>

+ 8 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/IKuaishouPromoterService.java

@@ -0,0 +1,8 @@
+package org.jeecg.ctop.material.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+public interface IKuaishouPromoterService {
+
+    JSONObject getPromoterInfo(Long promoterId);
+}

+ 36 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/IKuaishouPromoterServiceImpl.java

@@ -0,0 +1,36 @@
+package org.jeecg.ctop.material.service.impl;
+
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.ctop.material.constants.Check;
+import org.jeecg.ctop.material.mapper.KuaishouPromoterMapper;
+import org.jeecg.ctop.material.service.IKuaishouPromoterService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Slf4j
+@Service
+public class IKuaishouPromoterServiceImpl implements IKuaishouPromoterService {
+
+    @Resource
+    private KuaishouPromoterMapper promoterMapper;
+
+    @Override
+    public JSONObject getPromoterInfo(Long promoterId) {
+        JSONObject data = promoterMapper.getPromoterInfo(promoterId);
+        if (!Check.isNull(data)) {
+            data.put("hotSaleBrandInfo", data.getJSONArray("hotSaleBrandInfo"));
+            data.put("hotSaleChannelInfo", data.getJSONArray("hotSaleChannelInfo"));
+            data.put("fanCharacteristic", promoterMapper.getFansCharacteristic(promoterId));
+            String today = DateUtils.date2Str();
+            Integer startInt = DateUtils.getDateInteger(DateUtils.getLastDay(today, 1));
+            Integer endInt = DateUtils.getDateInteger(DateUtils.getLastDay(today, 31));
+            data.put("liveInfo", promoterMapper.getPromoterLiveCommerceInfo(promoterId, startInt, endInt));
+            data.put("shortVideosInfo", promoterMapper.getPromoterShortVideosCommerceInfo(promoterId, startInt, endInt));
+        }
+        return data;
+    }
+}