fuxingfan 3 years ago
parent
commit
37ad778cd4

+ 23
- 1
src/main/java/com/yunzhi/marketing/xlk/controller/PcIndexStatisticsController.java View File

@@ -5,19 +5,24 @@ import com.yunzhi.marketing.base.ResponseBean;
5 5
 import com.yunzhi.marketing.center.taUser.entity.TaUser;
6 6
 import com.yunzhi.marketing.center.taUser.service.ITaUserService;
7 7
 import com.yunzhi.marketing.xlk.dto.ChannelCustomerDTO;
8
+import com.yunzhi.marketing.xlk.dto.PcStatisticsDTO;
8 9
 import com.yunzhi.marketing.xlk.service.IPcStatisticsService;
9 10
 import io.swagger.annotations.Api;
10 11
 import io.swagger.annotations.ApiOperation;
11 12
 import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.format.annotation.DateTimeFormat;
12 14
 import org.springframework.web.bind.annotation.GetMapping;
13 15
 import org.springframework.web.bind.annotation.PathVariable;
14 16
 import org.springframework.web.bind.annotation.RequestBody;
15 17
 import org.springframework.web.bind.annotation.RequestHeader;
16 18
 import org.springframework.web.bind.annotation.RequestMapping;
17 19
 import org.springframework.web.bind.annotation.RequestMethod;
20
+import org.springframework.web.bind.annotation.RequestParam;
18 21
 import org.springframework.web.bind.annotation.RestController;
19 22
 
20 23
 import javax.servlet.http.HttpServletRequest;
24
+import java.time.LocalDate;
25
+import java.time.LocalDateTime;
21 26
 
22 27
 @RestController
23 28
 @RequestMapping("/api")
@@ -77,5 +82,22 @@ public class PcIndexStatisticsController extends BaseController {
77 82
         return pcStatisticsService.getUserAuthorStatistics(taUser);
78 83
     }
79 84
 
80
-
85
+    /**
86
+     * 项目排行统计图
87
+     * @return
88
+     */
89
+    @GetMapping(value = "/admin/statistics/barList")
90
+    public ResponseBean selectBuildingBar(@RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startDate,
91
+                                          @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDateTime endDate,
92
+                                          @RequestParam(value = "cityId", required = false) String cityId,
93
+                                          HttpServletRequest request) {
94
+        Integer userId = getUserId(request);
95
+        TaUser taUser = iTaUserService.getById(userId);
96
+        PcStatisticsDTO pcStatisticsDTO = new PcStatisticsDTO();
97
+        pcStatisticsDTO.setOrgId(taUser.getOrgId());
98
+        pcStatisticsDTO.setStartTime(startDate);
99
+        pcStatisticsDTO.setEndTime(endDate);
100
+        pcStatisticsDTO.setCityId(cityId);
101
+        return pcStatisticsService.getStatsBarList(taUser, pcStatisticsDTO);
102
+    }
81 103
 }

+ 15
- 0
src/main/java/com/yunzhi/marketing/xlk/dto/PcStatisticsDTO.java View File

@@ -9,6 +9,11 @@ public class PcStatisticsDTO {
9 9
 
10 10
     private Integer orgId;
11 11
 
12
+    /**
13
+     * 城市id
14
+     */
15
+    private String cityId;
16
+
12 17
     /**
13 18
      * 当天日期
14 19
      */
@@ -18,4 +23,14 @@ public class PcStatisticsDTO {
18 23
      * 组织机构code
19 24
      */
20 25
     private String institutionCode;
26
+
27
+    /**
28
+     * 开始时间
29
+     */
30
+    private LocalDateTime startTime;
31
+
32
+    /**
33
+     * 结束时间
34
+     */
35
+    private LocalDateTime endTime;
21 36
 }

+ 31
- 0
src/main/java/com/yunzhi/marketing/xlk/mapper/PcStatisticsMapper.java View File

@@ -3,10 +3,13 @@ package com.yunzhi.marketing.xlk.mapper;
3 3
 import com.yunzhi.marketing.center.taUser.entity.TaUser;
4 4
 import com.yunzhi.marketing.xlk.dto.PcStatisticsDTO;
5 5
 import com.yunzhi.marketing.xlk.vo.PcStatisticsGenderVO;
6
+import com.yunzhi.marketing.xlk.vo.PcStatisticsLeaderboardVO;
6 7
 import com.yunzhi.marketing.xlk.vo.PcStatisticsVO;
7 8
 import org.apache.ibatis.annotations.Mapper;
8 9
 import org.apache.ibatis.annotations.Param;
9 10
 
11
+import java.util.List;
12
+
10 13
 @Mapper
11 14
 public interface PcStatisticsMapper {
12 15
     /**
@@ -61,4 +64,32 @@ public interface PcStatisticsMapper {
61 64
      * @return
62 65
      */
63 66
     PcStatisticsGenderVO getuserGenderStatistics(@Param("params") PcStatisticsDTO statisticsDTO);
67
+
68
+    /**
69
+     * 公客排行榜
70
+     * @param pcStatisticsDTO
71
+     * @return
72
+     */
73
+    List<PcStatisticsLeaderboardVO> getGkLeaderboard(@Param("params") PcStatisticsDTO pcStatisticsDTO);
74
+
75
+    /**
76
+     * 私客排行榜
77
+     * @param pcStatisticsDTO
78
+     * @return
79
+     */
80
+    List<PcStatisticsLeaderboardVO> getSkLeaderboard(@Param("params") PcStatisticsDTO pcStatisticsDTO);
81
+
82
+    /**
83
+     * 项目访问次数排行榜
84
+     * @param pcStatisticsDTO
85
+     * @return
86
+     */
87
+    List<PcStatisticsLeaderboardVO> getVisitNumLeaderboard(@Param("params") PcStatisticsDTO pcStatisticsDTO);
88
+
89
+    /**
90
+     * 项目成交排行榜
91
+     * @param pcStatisticsDTO
92
+     * @return
93
+     */
94
+    List<PcStatisticsLeaderboardVO> getSuccessLeaderboard(@Param("params") PcStatisticsDTO pcStatisticsDTO);
64 95
 }

+ 9
- 0
src/main/java/com/yunzhi/marketing/xlk/service/IPcStatisticsService.java View File

@@ -2,6 +2,7 @@ package com.yunzhi.marketing.xlk.service;
2 2
 
3 3
 import com.yunzhi.marketing.base.ResponseBean;
4 4
 import com.yunzhi.marketing.center.taUser.entity.TaUser;
5
+import com.yunzhi.marketing.xlk.dto.PcStatisticsDTO;
5 6
 
6 7
 public interface IPcStatisticsService {
7 8
 
@@ -32,4 +33,12 @@ public interface IPcStatisticsService {
32 33
      * @return
33 34
      */
34 35
     ResponseBean getUserAuthorStatistics(TaUser taUser);
36
+
37
+    /**
38
+     * 项目统计排行榜
39
+     * @param taUser
40
+     * @param pcStatisticsDTO
41
+     * @return
42
+     */
43
+    ResponseBean getStatsBarList(TaUser taUser, PcStatisticsDTO pcStatisticsDTO);
35 44
 }

+ 30
- 0
src/main/java/com/yunzhi/marketing/xlk/service/impl/IPcStatisticsServiceimpl.java View File

@@ -11,12 +11,14 @@ import com.yunzhi.marketing.xlk.mapper.PcStatisticsMapper;
11 11
 import com.yunzhi.marketing.xlk.service.IInstitutionService;
12 12
 import com.yunzhi.marketing.xlk.service.IPcStatisticsService;
13 13
 import com.yunzhi.marketing.xlk.vo.PcStatisticsGenderVO;
14
+import com.yunzhi.marketing.xlk.vo.PcStatisticsLeaderboardVO;
14 15
 import com.yunzhi.marketing.xlk.vo.PcStatisticsVO;
15 16
 import org.springframework.beans.factory.annotation.Autowired;
16 17
 import org.springframework.stereotype.Service;
17 18
 
18 19
 import java.time.LocalDateTime;
19 20
 import java.util.HashMap;
21
+import java.util.List;
20 22
 import java.util.Map;
21 23
 
22 24
 @Service
@@ -119,4 +121,32 @@ public class IPcStatisticsServiceimpl implements IPcStatisticsService {
119 121
         map.put("registerPersonNum",registerPersonNum);
120 122
         return ResponseBean.success(map);
121 123
     }
124
+
125
+    /**
126
+     * 项目统计排行榜
127
+     *
128
+     * @param taUser
129
+     * @param pcStatisticsDTO
130
+     * @return
131
+     */
132
+    @Override
133
+    public ResponseBean getStatsBarList(TaUser taUser, PcStatisticsDTO pcStatisticsDTO) {
134
+        Institution institution = institutionMapper.selectById(taUser.getInstitutionId());
135
+        pcStatisticsDTO.setInstitutionCode(institution.getInstitutionCode());
136
+        // 获取公客排行榜
137
+        List<PcStatisticsLeaderboardVO> gkList = pcStatisticsMapper.getGkLeaderboard(pcStatisticsDTO);
138
+        // 获取私客排行榜
139
+        List<PcStatisticsLeaderboardVO> skList = pcStatisticsMapper.getSkLeaderboard(pcStatisticsDTO);
140
+        // 获取项目访问次数排行榜
141
+        List<PcStatisticsLeaderboardVO> visitList = pcStatisticsMapper.getVisitNumLeaderboard(pcStatisticsDTO);
142
+        // 获取项目成交排行
143
+        List<PcStatisticsLeaderboardVO> successList = pcStatisticsMapper.getSuccessLeaderboard(pcStatisticsDTO);
144
+
145
+        Map<String,Object> map = new HashMap<>();
146
+        map.put("gkList",gkList);
147
+        map.put("skList",skList);
148
+        map.put("visitList",visitList);
149
+        map.put("successList",successList);
150
+        return ResponseBean.success(map);
151
+    }
122 152
 }

+ 23
- 0
src/main/java/com/yunzhi/marketing/xlk/vo/PcStatisticsLeaderboardVO.java View File

@@ -0,0 +1,23 @@
1
+package com.yunzhi.marketing.xlk.vo;
2
+
3
+import lombok.Data;
4
+
5
+@Data
6
+public class PcStatisticsLeaderboardVO {
7
+
8
+    /**
9
+     * 人数
10
+     */
11
+    private Integer num;
12
+
13
+    /**
14
+     * 楼盘名称
15
+     */
16
+    private String buildingName;
17
+
18
+    /**
19
+     * 楼盘id
20
+     *
21
+     */
22
+    private String buildingId;
23
+}

+ 118
- 0
src/main/resources/mapper/xlk/PcStatisticsMapper.xml View File

@@ -58,4 +58,122 @@
58 58
             sum(if(gender = '2', 1, 0)) as female_num
59 59
         from ta_person
60 60
     </select>
61
+    <select id="getGkLeaderboard" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsLeaderboardVO">
62
+        SELECT
63
+            count(1) as num,
64
+            b.building_id,
65
+            d.building_name
66
+        FROM
67
+            ta_recommend_customer b
68
+            LEFT JOIN ta_building d ON b.building_id = d.building_id
69
+            LEFT JOIN xlk_institution i ON b.institution_id = i.institution_id
70
+        WHERE
71
+            b.STATUS > 0
72
+            AND b.org_id = 1
73
+            AND b.verify_status = 1
74
+            AND ( b.realty_consultant IS NULL OR b.realty_consultant = '' )
75
+            AND b.building_id IS NOT NULL
76
+            <if test="params.cityId != null">
77
+                and d.city_id = #{params.cityId}
78
+            </if>
79
+            <if test="params.startTime != null">
80
+                and  TO_DAYS(b.create_date) >= TO_DAYS(#{params.startTime})
81
+            </if>
82
+            <if test="params.endTime != null">
83
+                and  TO_DAYS(b.create_date) &lt;= TO_DAYS(#{params.endTime})
84
+            </if>
85
+            AND i.institution_code like CONCAT(#{params.institutionCode}, '%')
86
+        GROUP BY b.building_id
87
+        ORDER BY num desc
88
+        LIMIT 6
89
+    </select>
90
+    <select id="getSkLeaderboard" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsLeaderboardVO">
91
+        SELECT
92
+            count(1) as num,
93
+            b.building_id,
94
+            d.building_name
95
+        FROM
96
+            ta_recommend_customer b
97
+        LEFT JOIN ta_building d ON b.building_id = d.building_id
98
+        LEFT JOIN xlk_institution i ON b.institution_id = i.institution_id
99
+        WHERE
100
+            b.STATUS > 0
101
+        AND b.org_id = 1
102
+        AND b.verify_status = 1
103
+        AND b.realty_consultant IS NOT NULL
104
+        AND b.realty_consultant != ''
105
+        AND b.building_id IS NOT NULL
106
+        <if test="params.cityId != null">
107
+            and d.city_id = #{params.cityId}
108
+        </if>
109
+        <if test="params.startTime != null">
110
+            and  TO_DAYS(b.create_date) >= TO_DAYS(#{params.startTime})
111
+        </if>
112
+        <if test="params.endTime != null">
113
+            and  TO_DAYS(b.create_date) &lt;= TO_DAYS(#{params.endTime})
114
+        </if>
115
+        AND i.institution_code like CONCAT(#{params.institutionCode}, '%')
116
+        GROUP BY b.building_id
117
+        ORDER BY num desc
118
+        LIMIT 6
119
+    </select>
120
+    <select id="getVisitNumLeaderboard" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsLeaderboardVO">
121
+        SELECT
122
+            count( * ) AS num,
123
+            a.be_uv AS building_id,
124
+            d.building_name
125
+        FROM
126
+            ta_uv a
127
+            LEFT JOIN ta_building d ON a.be_uv = d.building_id
128
+            LEFT JOIN xlk_institution i ON d.institution_id = i.institution_id
129
+        WHERE
130
+            a.tagert_type = 'project'
131
+            AND d.org_id = 1
132
+            AND a.be_uv != "undefined"
133
+        <if test="params.cityId != null">
134
+            and d.city_id = #{params.cityId}
135
+        </if>
136
+        <if test="params.startTime != null">
137
+            and  TO_DAYS(a.create_date) >= TO_DAYS(#{params.startTime})
138
+        </if>
139
+        <if test="params.endTime != null">
140
+            and  TO_DAYS(a.create_date) &lt;= TO_DAYS(#{params.endTime})
141
+        </if>
142
+        AND i.institution_code like CONCAT(#{params.institutionCode}, '%')
143
+        GROUP BY
144
+            a.be_uv
145
+        ORDER BY
146
+            num DESC
147
+            LIMIT 6
148
+    </select>
149
+    <select id="getSuccessLeaderboard" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsLeaderboardVO">
150
+        SELECT
151
+            count(1) as num,
152
+            b.building_id,
153
+            d.building_name
154
+        FROM
155
+            ta_recommend_customer b
156
+        LEFT JOIN ta_building d ON b.building_id = d.building_id
157
+        LEFT JOIN xlk_institution i ON b.institution_id = i.institution_id
158
+        WHERE
159
+            b.STATUS > 3
160
+        AND b.org_id = 1
161
+        AND b.verify_status = 1
162
+        AND b.realty_consultant IS NOT NULL
163
+        AND b.realty_consultant != ''
164
+        AND b.building_id IS NOT NULL
165
+        <if test="params.cityId != null">
166
+            and d.city_id = #{params.cityId}
167
+        </if>
168
+        <if test="params.startTime != null">
169
+            and  TO_DAYS(b.create_date) >= TO_DAYS(#{params.startTime})
170
+        </if>
171
+        <if test="params.endTime != null">
172
+            and  TO_DAYS(b.create_date) &lt;= TO_DAYS(#{params.endTime})
173
+        </if>
174
+        AND i.institution_code like CONCAT(#{params.institutionCode}, '%')
175
+        GROUP BY b.building_id
176
+        ORDER BY num desc
177
+        LIMIT 6
178
+    </select>
61 179
 </mapper>