傅行帆 3 years ago
parent
commit
63f38dfe3b

+ 2
- 0
src/main/java/com/yunzhi/marketing/dto/StatisticsDTO.java View File

18
     private String personId;
18
     private String personId;
19
 
19
 
20
     private Integer channelId;
20
     private Integer channelId;
21
+
22
+    private String type;
21
 }
23
 }

+ 7
- 0
src/main/java/com/yunzhi/marketing/service/ChannelCustomerStatisticsService.java View File

12
      * @return
12
      * @return
13
      */
13
      */
14
     ResponseBean getBriefing(StatisticsDTO statisticsDTo);
14
     ResponseBean getBriefing(StatisticsDTO statisticsDTo);
15
+
16
+    /**
17
+     * 获取折线图数据
18
+     * @param statisticsDTo
19
+     * @return
20
+     */
21
+    ResponseBean getBriefingDetail(StatisticsDTO statisticsDTo);
15
 }
22
 }

+ 31
- 0
src/main/java/com/yunzhi/marketing/service/impl/ChannelCustomerStatisticsServiceImpl.java View File

11
 import com.yunzhi.marketing.xlk.mapper.BuildingChannelMapper;
11
 import com.yunzhi.marketing.xlk.mapper.BuildingChannelMapper;
12
 import com.yunzhi.marketing.xlk.mapper.ChannelCustomerMapper;
12
 import com.yunzhi.marketing.xlk.mapper.ChannelCustomerMapper;
13
 import com.yunzhi.marketing.xlk.mapper.CustomerVisitMapper;
13
 import com.yunzhi.marketing.xlk.mapper.CustomerVisitMapper;
14
+import com.yunzhi.marketing.xlk.vo.CustomerDetailVO;
14
 import org.ietf.jgss.ChannelBinding;
15
 import org.ietf.jgss.ChannelBinding;
15
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.stereotype.Service;
17
 import org.springframework.stereotype.Service;
77
         map.put("successCustomerNum",successCustomerNum);
78
         map.put("successCustomerNum",successCustomerNum);
78
         return ResponseBean.success(map);
79
         return ResponseBean.success(map);
79
     }
80
     }
81
+
82
+    /**
83
+     * 获取折线图数据
84
+     *
85
+     * @param statisticsDTo
86
+     * @return
87
+     */
88
+    @Override
89
+    public ResponseBean getBriefingDetail(StatisticsDTO statisticsDTo) {
90
+        LambdaQueryWrapper<TaChannelPerson> lambdaQueryWrapper = new LambdaQueryWrapper<>();
91
+        lambdaQueryWrapper.eq(TaChannelPerson::getPersonId,statisticsDTo.getPersonId());
92
+        TaChannelPerson taChannelPerson = channelPersonMapper.selectOne(lambdaQueryWrapper);
93
+
94
+        if (null == taChannelPerson) {
95
+            return ResponseBean.error("此用户未绑定渠道商", ResponseBean.ERROR_UNAVAILABLE);
96
+        }
97
+        statisticsDTo.setChannelId(taChannelPerson.getChannelId());
98
+
99
+        // 获取新增客户
100
+        List<CustomerDetailVO> newCustomerDetail = channelCustomerMapper.getNewCustomerDetail(statisticsDTo);
101
+        // 获取跟进客户
102
+        List<CustomerDetailVO> followCustomerDetail = customerVisitMapper.getFollowCustomerDetail(statisticsDTo);
103
+        // 获取成交客户
104
+        List<CustomerDetailVO> successCustomerDetail = channelCustomerMapper.getSuccessCustomerDetail(statisticsDTo);
105
+        Map<String,Object> map = new HashMap<>();
106
+        map.put("newCustomerDetail",newCustomerDetail);
107
+        map.put("followCustomerDetail",followCustomerDetail);
108
+        map.put("successCustomerDetail",successCustomerDetail);
109
+        return ResponseBean.success(map);
110
+    }
80
 }
111
 }

+ 27
- 0
src/main/java/com/yunzhi/marketing/xlk/controller/ChannelCustomerStatisticsController.java View File

78
         statisticsDTo.setPersonId(person.getPersonId());
78
         statisticsDTo.setPersonId(person.getPersonId());
79
         return  channelCustomerStatisticsService.getBriefing(statisticsDTo);
79
         return  channelCustomerStatisticsService.getBriefing(statisticsDTo);
80
     }
80
     }
81
+
82
+    @ApiOperation(value = "wx-销售简报", notes = "wx-销售简报")
83
+    @GetMapping(value="/wx/briefing/detail")
84
+    public ResponseBean getBriefingDetail(@RequestParam("buildingId") String buildingId,
85
+                                    @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startDate,
86
+                                    @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime endDate,
87
+                                    @RequestParam(value = "type") String type,
88
+                                    @RequestHeader("authorization") String token, HttpServletRequest request){
89
+        ResponseBean responseBean = new ResponseBean();
90
+        String openid = getOpenId(request);
91
+        Integer orgId = getOrgId(request);
92
+        List<TaPerson> persons = taPersonService.getPersonsByOpenId(openid);
93
+        if (null == persons || persons.size() == 0) {
94
+            return ResponseBean.error("当前账户信息异常, 清除缓存重试", ResponseBean.ERROR_UNAVAILABLE);
95
+        }
96
+        TaPerson person = persons.get(0);
97
+
98
+        // 构造参数
99
+        StatisticsDTO statisticsDTo = new StatisticsDTO();
100
+        statisticsDTo.setBuildingId(buildingId);
101
+        statisticsDTo.setStartDate(startDate);
102
+        statisticsDTo.setEndDate(endDate);
103
+        statisticsDTo.setOrgId(orgId);
104
+        statisticsDTo.setPersonId(person.getPersonId());
105
+        statisticsDTo.setType(type);
106
+        return  channelCustomerStatisticsService.getBriefingDetail(statisticsDTo);
107
+    }
81
 }
108
 }

+ 5
- 0
src/main/java/com/yunzhi/marketing/xlk/mapper/ChannelCustomerMapper.java View File

8
 import com.yunzhi.marketing.po.TaRecommendCustomerPO;
8
 import com.yunzhi.marketing.po.TaRecommendCustomerPO;
9
 import com.yunzhi.marketing.xlk.dto.RecommendCustomerDTO;
9
 import com.yunzhi.marketing.xlk.dto.RecommendCustomerDTO;
10
 import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
10
 import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
11
+import com.yunzhi.marketing.xlk.vo.CustomerDetailVO;
11
 import org.apache.ibatis.annotations.Mapper;
12
 import org.apache.ibatis.annotations.Mapper;
12
 import org.apache.ibatis.annotations.Param;
13
 import org.apache.ibatis.annotations.Param;
13
 
14
 
50
      * @return
51
      * @return
51
      */
52
      */
52
     int getSuccessCustomer(@Param("params") StatisticsDTO statisticsDTo);
53
     int getSuccessCustomer(@Param("params") StatisticsDTO statisticsDTo);
54
+
55
+    List<CustomerDetailVO> getNewCustomerDetail(@Param("params") StatisticsDTO statisticsDTo);
56
+
57
+    List<CustomerDetailVO> getSuccessCustomerDetail(@Param("params") StatisticsDTO statisticsDTo);
53
 }
58
 }

+ 5
- 0
src/main/java/com/yunzhi/marketing/xlk/mapper/CustomerVisitMapper.java View File

3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
 import com.yunzhi.marketing.dto.StatisticsDTO;
4
 import com.yunzhi.marketing.dto.StatisticsDTO;
5
 import com.yunzhi.marketing.xlk.entity.CustomerVisit;
5
 import com.yunzhi.marketing.xlk.entity.CustomerVisit;
6
+import com.yunzhi.marketing.xlk.vo.CustomerDetailVO;
6
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Param;
8
 import org.apache.ibatis.annotations.Param;
8
 
9
 
10
+import java.util.List;
11
+
9
 /**
12
 /**
10
  * <p>
13
  * <p>
11
  * 客户到访单  Mapper 接口
14
  * 客户到访单  Mapper 接口
18
 public interface CustomerVisitMapper extends BaseMapper<CustomerVisit> {
21
 public interface CustomerVisitMapper extends BaseMapper<CustomerVisit> {
19
 
22
 
20
     int getFollowCustomer(@Param("params") StatisticsDTO statisticsDTo);
23
     int getFollowCustomer(@Param("params") StatisticsDTO statisticsDTo);
24
+
25
+    List<CustomerDetailVO> getFollowCustomerDetail(@Param("params") StatisticsDTO statisticsDTo);
21
 }
26
 }

+ 11
- 0
src/main/java/com/yunzhi/marketing/xlk/vo/CustomerDetailVO.java View File

1
+package com.yunzhi.marketing.xlk.vo;
2
+
3
+import lombok.Data;
4
+
5
+@Data
6
+public class CustomerDetailVO {
7
+
8
+    private String coordinate;
9
+
10
+    private Integer customerNum;
11
+}

+ 55
- 0
src/main/resources/mapper/xlk/ChannelCustomerMapper.xml View File

129
             AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
129
             AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
130
         </if>
130
         </if>
131
     </select>
131
     </select>
132
+    <select id="getNewCustomerDetail" resultType="com.yunzhi.marketing.xlk.vo.CustomerDetailVO">
133
+        SELECT
134
+        <if test="params.type == 'day''">
135
+            date_format( t.create_date, '%d' ) as coordinate,
136
+        </if>
137
+        <if test="params.type == 'month''">
138
+            date_format( t.create_date, '%m' ) as coordinate,
139
+        </if>
140
+        COUNT(1) as customerNum
141
+        FROM
142
+        xlk_channel_customer t
143
+        WHERE t.channel_id  = #{params.channelId}
144
+        and t.building_id = #{params.buildingId}
145
+        and t.`status` = 1
146
+        <if test="params.startDate != null or params.endDate != null">
147
+            AND t.create_date BETWEEN #{params.startDate} and #{params.endDate}
148
+        </if>
149
+        <if test="params.startDate == null or params.endDate == null">
150
+            AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
151
+        </if>
152
+        <if test="params.type == 'day''">
153
+            group by date_format( t.create_date, '%Y-%m-%d' )
154
+        </if>
155
+        <if test="params.type == 'month''">
156
+            group by date_format( t.create_date, '%Y-%m' )
157
+        </if>
158
+    </select>
159
+    <select id="getSuccessCustomerDetail" resultType="com.yunzhi.marketing.xlk.vo.CustomerDetailVO">
160
+        SELECT
161
+        <if test="params.type == 'day''">
162
+            date_format( t.create_date, '%d' ) as coordinate,
163
+        </if>
164
+        <if test="params.type == 'month''">
165
+            date_format( t.create_date, '%m' ) as coordinate,
166
+        </if>
167
+        COUNT(1) as customerNum
168
+        FROM
169
+        xlk_channel_customer t
170
+        LEFT join ta_recommend_customer r on t.customer_id = r.customer_id
171
+        WHERE t.channel_id  = #{params.channelId}
172
+        and t.building_id = #{params.buildingId}
173
+        and r.`status` in (4,5)
174
+        <if test="params.startDate != null or params.endDate != null">
175
+            AND t.create_date BETWEEN #{params.startDate} and #{params.endDate}
176
+        </if>
177
+        <if test="params.startDate == null or params.endDate == null">
178
+            AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
179
+        </if>
180
+        <if test="params.type == 'day''">
181
+            group by date_format( t.create_date, '%Y-%m-%d' )
182
+        </if>
183
+        <if test="params.type == 'month''">
184
+            group by date_format( t.create_date, '%Y-%m' )
185
+        </if>
186
+    </select>
132
 </mapper>
187
 </mapper>

+ 27
- 0
src/main/resources/mapper/xlk/CustomerVisitMapper.xml View File

17
             AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
17
             AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
18
         </if>
18
         </if>
19
     </select>
19
     </select>
20
+    <select id="getFollowCustomerDetail" resultType="com.yunzhi.marketing.xlk.vo.CustomerDetailVO">
21
+        SELECT
22
+        <if test="params.type == 'day''">
23
+            date_format( t.create_date, '%d' ) as coordinate,
24
+        </if>
25
+        <if test="params.type == 'month''">
26
+            date_format( t.create_date, '%m' ) as coordinate,
27
+        </if>
28
+        COUNT(1) as customerNum
29
+        FROM
30
+        xlk_channel_customer t
31
+        INNER JOIN xlk_customer_visit v on t.customer_id = v.customer_id
32
+        INNER JOIN ta_customer_follow_up_record f on t.customer_id = f.customer_id
33
+        WHERE t.channel_id  = #{params.channelId}
34
+        <if test="params.startDate != null or params.endDate != null">
35
+            AND t.create_date BETWEEN #{params.startDate} and #{params.endDate}
36
+        </if>
37
+        <if test="params.startDate == null or params.endDate == null">
38
+            AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
39
+        </if>
40
+        <if test="params.type == 'day'">
41
+            group by date_format( t.create_date, '%Y-%m-%d' )
42
+        </if>
43
+        <if test="params.type == 'month'">
44
+            group by date_format( t.create_date, '%Y-%m' )
45
+        </if>
46
+    </select>
20
 </mapper>
47
 </mapper>