fuxingfan před 3 roky
rodič
revize
055cca55f6

+ 5
- 0
src/main/java/com/yunzhi/marketing/center/taUser/entity/TaUser.java Zobrazit soubor

120
      */
120
      */
121
     private String jobNumber;
121
     private String jobNumber;
122
 
122
 
123
+    /**
124
+     * 组织结构id
125
+     */
126
+    private String institutionId;
127
+
123
     /**
128
     /**
124
      * 组织机构编号
129
      * 组织机构编号
125
      */
130
      */

+ 67
- 0
src/main/java/com/yunzhi/marketing/xlk/controller/PcIndexStatisticsController.java Zobrazit soubor

1
+package com.yunzhi.marketing.xlk.controller;
2
+
3
+import com.yunzhi.marketing.base.BaseController;
4
+import com.yunzhi.marketing.base.ResponseBean;
5
+import com.yunzhi.marketing.center.taUser.entity.TaUser;
6
+import com.yunzhi.marketing.center.taUser.service.ITaUserService;
7
+import com.yunzhi.marketing.xlk.dto.ChannelCustomerDTO;
8
+import com.yunzhi.marketing.xlk.service.IPcStatisticsService;
9
+import io.swagger.annotations.Api;
10
+import io.swagger.annotations.ApiOperation;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.web.bind.annotation.GetMapping;
13
+import org.springframework.web.bind.annotation.PathVariable;
14
+import org.springframework.web.bind.annotation.RequestBody;
15
+import org.springframework.web.bind.annotation.RequestHeader;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestMethod;
18
+import org.springframework.web.bind.annotation.RestController;
19
+
20
+import javax.servlet.http.HttpServletRequest;
21
+
22
+@RestController
23
+@RequestMapping("/api")
24
+@Api(value = "xlk-pc端首页统计接口", tags = "xlk-pc端首页统计接口")
25
+public class PcIndexStatisticsController extends BaseController {
26
+
27
+    @Autowired
28
+    private IPcStatisticsService pcStatisticsService;
29
+    @Autowired
30
+    public ITaUserService iTaUserService;
31
+
32
+    /**
33
+     * 首页六个用户数统计
34
+     * @return
35
+     */
36
+    @ApiOperation(value = "admin-首页六个用户数统计", notes = "admin-首页六个用户数统计")
37
+    @GetMapping(value="/admin/statistics/user")
38
+    public ResponseBean getUserStatistics(@RequestHeader("authorization") String token, HttpServletRequest request){
39
+        Integer userId = getUserId(request);
40
+        TaUser taUser = iTaUserService.getById(userId);
41
+        return pcStatisticsService.getUserStatistics(taUser);
42
+    }
43
+
44
+    /**
45
+     * 首页用户来源
46
+     * @return
47
+     */
48
+    @ApiOperation(value = "admin-首页用户来源统计", notes = "admin-首页用户来源统计")
49
+    @GetMapping(value="/admin/statistics/userOrigin")
50
+    public ResponseBean getUserOriginStatistics(@RequestHeader("authorization") String token, HttpServletRequest request){
51
+        Integer userId = getUserId(request);
52
+        TaUser taUser = iTaUserService.getById(userId);
53
+        return pcStatisticsService.getUserOriginStatistics(taUser);
54
+    }
55
+
56
+    /**
57
+     * 首页性别比例
58
+     * @return
59
+     */
60
+    @ApiOperation(value = "admin-首页性别比例统计", notes = "admin-首页性别比例统计")
61
+    @GetMapping(value="/admin/statistics/userGender")
62
+    public ResponseBean getuserGenderStatistics(@RequestHeader("authorization") String token, HttpServletRequest request){
63
+        Integer userId = getUserId(request);
64
+        TaUser taUser = iTaUserService.getById(userId);
65
+        return pcStatisticsService.getuserGenderStatistics(taUser);
66
+    }
67
+}

+ 21
- 0
src/main/java/com/yunzhi/marketing/xlk/dto/PcStatisticsDTO.java Zobrazit soubor

1
+package com.yunzhi.marketing.xlk.dto;
2
+
3
+import lombok.Data;
4
+
5
+import java.time.LocalDateTime;
6
+
7
+@Data
8
+public class PcStatisticsDTO {
9
+
10
+    private Integer orgId;
11
+
12
+    /**
13
+     * 当天日期
14
+     */
15
+    private LocalDateTime todayTime;
16
+
17
+    /**
18
+     * 组织机构code
19
+     */
20
+    private String institutionCode;
21
+}

+ 64
- 0
src/main/java/com/yunzhi/marketing/xlk/mapper/PcStatisticsMapper.java Zobrazit soubor

1
+package com.yunzhi.marketing.xlk.mapper;
2
+
3
+import com.yunzhi.marketing.center.taUser.entity.TaUser;
4
+import com.yunzhi.marketing.xlk.dto.PcStatisticsDTO;
5
+import com.yunzhi.marketing.xlk.vo.PcStatisticsGenderVO;
6
+import com.yunzhi.marketing.xlk.vo.PcStatisticsVO;
7
+import org.apache.ibatis.annotations.Mapper;
8
+import org.apache.ibatis.annotations.Param;
9
+
10
+@Mapper
11
+public interface PcStatisticsMapper {
12
+    /**
13
+     * 总用户数
14
+     * @return
15
+     */
16
+    int selectAllPerson(@Param("params") PcStatisticsDTO taUser);
17
+
18
+    /**
19
+     * 注册用户数
20
+     * @return
21
+     */
22
+    int selectRegisterPerson(@Param("params") PcStatisticsDTO taUser);
23
+
24
+    /**
25
+     * 今日访问次数
26
+     * @return
27
+     */
28
+    int selectTodayVisitNum(@Param("params") PcStatisticsDTO statisticsDTO);
29
+
30
+    /**
31
+     * 今日新增客户
32
+     * @param statisticsDTO
33
+     * @return
34
+     */
35
+    int selectTodayAddPerson(@Param("params") PcStatisticsDTO statisticsDTO);
36
+
37
+    /**
38
+     * 渠道数量
39
+     * @param statisticsDTO
40
+     * @return
41
+     */
42
+    int selectChannelNum(@Param("params") PcStatisticsDTO statisticsDTO);
43
+
44
+    /**
45
+     * 经纪人数量
46
+     * @param statisticsDTO
47
+     * @return
48
+     */
49
+    int selectEstateAgentNum(@Param("params") PcStatisticsDTO statisticsDTO);
50
+
51
+    /**
52
+     * 来源统计
53
+     * @param statisticsDTO
54
+     * @return
55
+     */
56
+    PcStatisticsVO getUserOriginStatistics(@Param("params") PcStatisticsDTO statisticsDTO);
57
+
58
+    /**
59
+     * 性别统计
60
+     * @param statisticsDTO
61
+     * @return
62
+     */
63
+    PcStatisticsGenderVO getuserGenderStatistics(@Param("params") PcStatisticsDTO statisticsDTO);
64
+}

+ 28
- 0
src/main/java/com/yunzhi/marketing/xlk/service/IPcStatisticsService.java Zobrazit soubor

1
+package com.yunzhi.marketing.xlk.service;
2
+
3
+import com.yunzhi.marketing.base.ResponseBean;
4
+import com.yunzhi.marketing.center.taUser.entity.TaUser;
5
+
6
+public interface IPcStatisticsService {
7
+
8
+    /**
9
+     * 获取首页六个卡片的数值
10
+     * @param taUser
11
+     * @return
12
+     */
13
+    ResponseBean getUserStatistics(TaUser taUser);
14
+
15
+    /**
16
+     * 首页用户来源统计
17
+     * @param taUser
18
+     * @return
19
+     */
20
+    ResponseBean getUserOriginStatistics(TaUser taUser);
21
+
22
+    /**
23
+     * 性别比例
24
+     * @param taUser
25
+     * @return
26
+     */
27
+    ResponseBean getuserGenderStatistics(TaUser taUser);
28
+}

+ 98
- 0
src/main/java/com/yunzhi/marketing/xlk/service/impl/IPcStatisticsServiceimpl.java Zobrazit soubor

1
+package com.yunzhi.marketing.xlk.service.impl;
2
+
3
+import com.yunzhi.marketing.base.ResponseBean;
4
+import com.yunzhi.marketing.center.taUser.entity.TaUser;
5
+import com.yunzhi.marketing.common.CommConstant;
6
+import com.yunzhi.marketing.dto.StatisticsDTO;
7
+import com.yunzhi.marketing.xlk.dto.PcStatisticsDTO;
8
+import com.yunzhi.marketing.xlk.entity.Institution;
9
+import com.yunzhi.marketing.xlk.mapper.InstitutionMapper;
10
+import com.yunzhi.marketing.xlk.mapper.PcStatisticsMapper;
11
+import com.yunzhi.marketing.xlk.service.IInstitutionService;
12
+import com.yunzhi.marketing.xlk.service.IPcStatisticsService;
13
+import com.yunzhi.marketing.xlk.vo.PcStatisticsGenderVO;
14
+import com.yunzhi.marketing.xlk.vo.PcStatisticsVO;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.stereotype.Service;
17
+
18
+import java.time.LocalDateTime;
19
+import java.util.HashMap;
20
+import java.util.Map;
21
+
22
+@Service
23
+public class IPcStatisticsServiceimpl implements IPcStatisticsService {
24
+
25
+    @Autowired
26
+    private PcStatisticsMapper pcStatisticsMapper;
27
+
28
+    @Autowired
29
+    private InstitutionMapper institutionMapper;
30
+
31
+    /**
32
+     * 获取首页六个卡片的数值
33
+     *
34
+     * @param taUser
35
+     * @return
36
+     */
37
+    @Override
38
+    public ResponseBean getUserStatistics(TaUser taUser) {
39
+        // 获取当前人员的渠道code
40
+        Institution institution = institutionMapper.selectById(taUser.getInstitutionId());
41
+
42
+        PcStatisticsDTO statisticsDTO = new PcStatisticsDTO();
43
+        statisticsDTO.setOrgId(taUser.getOrgId());
44
+        statisticsDTO.setTodayTime(LocalDateTime.now());
45
+        statisticsDTO.setInstitutionCode(institution.getInstitutionCode());
46
+        // 总用户
47
+        int allPersonNum = pcStatisticsMapper.selectAllPerson(statisticsDTO);
48
+        // 总注册用户
49
+        int registerPersonNum = pcStatisticsMapper.selectRegisterPerson(statisticsDTO);
50
+        // 今日访问次数
51
+        int todayVisitNum = pcStatisticsMapper.selectTodayVisitNum(statisticsDTO);
52
+        // 今日新增用户
53
+        int todayAddPersonNum = pcStatisticsMapper.selectTodayAddPerson(statisticsDTO);
54
+        // 渠道数量
55
+        int channelNum = pcStatisticsMapper.selectChannelNum(statisticsDTO);
56
+        // 经济人数量
57
+        int estateAgentNum = pcStatisticsMapper.selectEstateAgentNum(statisticsDTO);
58
+
59
+        Map<String,Object> map = new HashMap<>();
60
+        map.put("allPersonNum",allPersonNum);
61
+        map.put("registerPersonNum",registerPersonNum);
62
+        map.put("todayVisitNum",todayVisitNum);
63
+        map.put("todayAddPersonNum",todayAddPersonNum);
64
+        map.put("channelNum",channelNum);
65
+        map.put("estateAgentNum",estateAgentNum);
66
+        return ResponseBean.success(map);
67
+    }
68
+
69
+    /**
70
+     * 首页用户来源统计
71
+     *
72
+     * @param taUser
73
+     * @return
74
+     */
75
+    @Override
76
+    public ResponseBean getUserOriginStatistics(TaUser taUser) {
77
+        PcStatisticsDTO statisticsDTO = new PcStatisticsDTO();
78
+        statisticsDTO.setOrgId(taUser.getOrgId());
79
+        PcStatisticsVO userOriginStatistics = pcStatisticsMapper.getUserOriginStatistics(statisticsDTO);
80
+        Integer otherNum = userOriginStatistics.getAllPersonNum() - userOriginStatistics.getConsultantNum() - userOriginStatistics.getCustomerNum() -userOriginStatistics.getEstageNum();
81
+        userOriginStatistics.setOrherNum(otherNum);
82
+        return ResponseBean.success(userOriginStatistics);
83
+    }
84
+
85
+    /**
86
+     * 性别比例
87
+     *
88
+     * @param taUser
89
+     * @return
90
+     */
91
+    @Override
92
+    public ResponseBean getuserGenderStatistics(TaUser taUser) {
93
+        PcStatisticsDTO statisticsDTO = new PcStatisticsDTO();
94
+        statisticsDTO.setOrgId(taUser.getOrgId());
95
+        PcStatisticsGenderVO pcStatisticsGenderVO = pcStatisticsMapper.getuserGenderStatistics(statisticsDTO);
96
+        return ResponseBean.success(pcStatisticsGenderVO);
97
+    }
98
+}

+ 17
- 0
src/main/java/com/yunzhi/marketing/xlk/vo/PcStatisticsGenderVO.java Zobrazit soubor

1
+package com.yunzhi.marketing.xlk.vo;
2
+
3
+import lombok.Data;
4
+
5
+@Data
6
+public class PcStatisticsGenderVO {
7
+
8
+    /**
9
+     * 男
10
+     */
11
+    private Integer maleNum;
12
+
13
+    /**
14
+     * 女
15
+     */
16
+    private Integer femaleNum;
17
+}

+ 32
- 0
src/main/java/com/yunzhi/marketing/xlk/vo/PcStatisticsVO.java Zobrazit soubor

1
+package com.yunzhi.marketing.xlk.vo;
2
+
3
+import lombok.Data;
4
+
5
+@Data
6
+public class PcStatisticsVO {
7
+
8
+    /**
9
+     * 来源置业
10
+     */
11
+    private Integer consultantNum;
12
+
13
+    /**
14
+     * 来源客户
15
+     */
16
+    private Integer customerNum;
17
+
18
+    /**
19
+     * 来源经纪人
20
+     */
21
+    private Integer estageNum;
22
+
23
+    /**
24
+     * 全部人员
25
+     */
26
+    private Integer allPersonNum;
27
+
28
+    /**
29
+     * 来源其他
30
+     */
31
+    private Integer orherNum;
32
+}

+ 61
- 0
src/main/resources/mapper/xlk/PcStatisticsMapper.xml Zobrazit soubor

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.yunzhi.marketing.xlk.mapper.PcStatisticsMapper">
4
+    <select id="selectAllPerson" resultType="java.lang.Integer">
5
+        select count(1) from ta_person where org_id = #{params.orgId}
6
+    </select>
7
+
8
+    <select id="selectRegisterPerson" resultType="java.lang.Integer">
9
+        select count(1) from ta_person where  org_id = #{params.orgId} and phone is not null
10
+    </select>
11
+    <select id="selectTodayVisitNum" resultType="java.lang.Integer">
12
+        SELECT
13
+            COUNT(1)
14
+        FROM
15
+            ta_person_visit_record tp
16
+        where tp.org_id = #{params.orgId} AND
17
+            tp.event  = 'start'
18
+        AND DATE_FORMAT(tp.visit_time,'%Y-%m-%d') = DATE_FORMAT(#{params.todayTime},'%Y-%m-%d')
19
+    </select>
20
+    <select id="selectTodayAddPerson" resultType="java.lang.Integer">
21
+        SELECT
22
+            COUNT(1)
23
+        FROM
24
+        ta_person tp
25
+        where tp.org_id = #{params.orgId}
26
+        AND DATE_FORMAT(tp.create_date,'%Y-%m-%d') = DATE_FORMAT(#{params.todayTime},'%Y-%m-%d')
27
+    </select>
28
+    <select id="selectChannelNum" resultType="java.lang.Integer">
29
+        SELECT
30
+            COUNT(1)
31
+        FROM
32
+            ta_channel t
33
+            LEFT JOIN xlk_institution i ON t.institution_id = i.institution_id
34
+        WHERE
35
+            t.org_id = #{params.orgId}
36
+            AND i.institution_code like CONCAT(#{params.institutionCode}, '%')
37
+    </select>
38
+    <select id="selectEstateAgentNum" resultType="java.lang.Integer">
39
+        SELECT
40
+            COUNT(1)
41
+        FROM
42
+        ta_person tp
43
+        where tp.org_id = #{params.orgId}
44
+        and tp.person_type = 'estate agent'
45
+    </select>
46
+    <select id="getUserOriginStatistics" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsVO">
47
+        SELECT
48
+            sum(if(recommend_person_type = 'Realty Consultant', 1, 0)) as consultant_num,
49
+            sum(if(recommend_person_type = 'customer', 1, 0)) as customer_num,
50
+            sum(if(recommend_person_type in ('estate agent','channel agent'), 1, 0)) as estage_num,
51
+            count(1) as all_person_num
52
+        from ta_person
53
+        where org_id = #{params.orgId}
54
+    </select>
55
+    <select id="getuserGenderStatistics" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsGenderVO">
56
+        SELECT
57
+            sum(if(gender = '1', 1, 0)) as male_num,
58
+            sum(if(gender = '2', 1, 0)) as female_num
59
+        from ta_person
60
+    </select>
61
+</mapper>