瀏覽代碼

新需求

傅行帆 5 年之前
父節點
當前提交
e99e4f07f9

+ 20
- 18
src/main/java/com/huiju/estateagents/controller/TaChannelController.java 查看文件

@@ -1,41 +1,27 @@
1 1
 package com.huiju.estateagents.controller;
2 2
 
3
-import com.alibaba.fastjson.JSONObject;
4
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
6 4
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7 5
 import com.huiju.estateagents.base.BaseController;
8 6
 import com.huiju.estateagents.base.ResponseBean;
9
-import io.swagger.annotations.ApiOperation;
10
-import com.huiju.estateagents.common.JWTUtils;
11
-import com.huiju.estateagents.common.StringUtils;
12
-import com.huiju.estateagents.entity.TaBuildingReport;
13 7
 import com.huiju.estateagents.entity.TaChannel;
14
-import com.huiju.estateagents.entity.TaPerson;
15 8
 import com.huiju.estateagents.mapper.TaChannelMapper;
16 9
 import com.huiju.estateagents.service.ITaPersonService;
17 10
 import com.huiju.estateagents.service.TaChannelService;
18 11
 import io.swagger.annotations.Api;
19 12
 import io.swagger.annotations.ApiImplicitParam;
20 13
 import io.swagger.annotations.ApiImplicitParams;
21
-import org.apache.http.HttpRequest;
14
+import io.swagger.annotations.ApiOperation;
22 15
 import org.slf4j.Logger;
23 16
 import org.slf4j.LoggerFactory;
24 17
 import org.springframework.beans.factory.annotation.Autowired;
25
-import org.springframework.web.bind.annotation.PathVariable;
26
-import org.springframework.web.bind.annotation.RequestBody;
27
-import org.springframework.web.bind.annotation.RequestMapping;
28
-import org.springframework.web.bind.annotation.RequestMethod;
29
-import org.springframework.web.bind.annotation.RequestParam;
30
-import org.springframework.web.bind.annotation.ResponseBody;
31
-import org.springframework.web.bind.annotation.RestController;
18
+import org.springframework.format.annotation.DateTimeFormat;
19
+import org.springframework.web.bind.annotation.*;
32 20
 
33 21
 import javax.servlet.http.HttpServletRequest;
34
-
35
-import java.time.LocalDateTime;
22
+import java.time.LocalDate;
36 23
 import java.util.HashMap;
37 24
 import java.util.List;
38
-import java.util.stream.Collectors;
39 25
 
40 26
 
41 27
 /**
@@ -260,4 +246,20 @@ public class TaChannelController extends BaseController {
260 246
         ResponseBean taPerson =  taPersonService.InviteClientsList(id,phone,pageNum,pageSize);
261 247
         return taPerson;
262 248
     }
249
+
250
+    /**
251
+     * 渠道引进客户统计
252
+     * @return
253
+     */
254
+    @GetMapping(value = "/admin/channel/introductionList")
255
+    public ResponseBean getChannelIntroductionList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
256
+                                                     @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize,
257
+                                                     @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
258
+                                                     @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate endDate,
259
+                                                     @RequestParam(value = "channelType", required = false)String channelType,
260
+                                                     @RequestParam(value = "buildingId", required = false)String buildingId,
261
+                                                     @RequestParam(value = "channelId") Integer channelId,
262
+                                                     HttpServletRequest request) {
263
+        return taChannelService.getChannelIntroductionList(pageNum, pageSize, getOrgId(request), startDate, endDate, channelType, buildingId, channelId);
264
+    }
263 265
 }

+ 8
- 4
src/main/java/com/huiju/estateagents/entity/TaChannel.java 查看文件

@@ -1,15 +1,16 @@
1 1
 package com.huiju.estateagents.entity;
2 2
 
3
-import com.baomidou.mybatisplus.annotation.TableField;
4
-import com.baomidou.mybatisplus.annotation.TableName;
5 3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
6 5
 import com.baomidou.mybatisplus.annotation.TableId;
7
-import java.time.LocalDateTime;
8
-import java.io.Serializable;
6
+import com.baomidou.mybatisplus.annotation.TableName;
9 7
 import lombok.Data;
10 8
 import lombok.EqualsAndHashCode;
11 9
 import lombok.experimental.Accessors;
12 10
 
11
+import java.io.Serializable;
12
+import java.time.LocalDateTime;
13
+
13 14
 /**
14 15
  * <p>
15 16
  *  
@@ -70,6 +71,9 @@ public class TaChannel implements Serializable {
70 71
     @TableField(exist = false)
71 72
     private Integer inviteCount;
72 73
 
74
+    @TableField(exist = false)
75
+    private Integer customerNum;
76
+
73 77
     /**
74 78
      * 创建时间
75 79
      */

+ 14
- 0
src/main/java/com/huiju/estateagents/mapper/TaChannelMapper.java 查看文件

@@ -3,9 +3,11 @@ package com.huiju.estateagents.mapper;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.huiju.estateagents.entity.TaChannel;
6
+import com.huiju.estateagents.entity.TsActivityDaily;
6 7
 import org.apache.ibatis.annotations.Mapper;
7 8
 import org.apache.ibatis.annotations.Param;
8 9
 
10
+import java.time.LocalDate;
9 11
 import java.util.List;
10 12
 
11 13
 /**
@@ -39,4 +41,16 @@ public interface TaChannelMapper extends BaseMapper<TaChannel> {
39 41
     IPage<TaChannel> pageTaChannel(IPage<TaChannel> pg,@Param("orgId")Integer orgId,@Param("channelId")Integer channelId);
40 42
 
41 43
     List<TaChannel> recommendCount(@Param("orgId")Integer orgId,@Param("channelId")Integer channelId);
44
+
45
+    /**
46
+     * 渠道引进客户统计
47
+     * @param pg
48
+     * @param orgId
49
+     * @param startDate
50
+     * @param endDate
51
+     * @param channelType
52
+     * @param buildingId
53
+     * @return
54
+     */
55
+    IPage<TsActivityDaily> getChannelIntroductionList(IPage<TsActivityDaily> pg,@Param("orgId") Integer orgId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate,@Param("channelType") String channelType,@Param("buildingId") String buildingId,@Param("channelId") Integer channelId);
42 56
 }

+ 15
- 0
src/main/java/com/huiju/estateagents/service/TaChannelService.java 查看文件

@@ -1,7 +1,10 @@
1 1
 package com.huiju.estateagents.service;
2 2
 import com.baomidou.mybatisplus.extension.service.IService;
3
+import com.huiju.estateagents.base.ResponseBean;
3 4
 import com.huiju.estateagents.entity.TaChannel;
4 5
 
6
+import java.time.LocalDate;
7
+
5 8
 /**
6 9
  * <p>
7 10
  *   服务类
@@ -12,4 +15,16 @@ import com.huiju.estateagents.entity.TaChannel;
12 15
  */
13 16
 public interface TaChannelService extends IService<TaChannel> {
14 17
 
18
+    /**
19
+     * 渠道引进客户统计
20
+     * @param pageNum
21
+     * @param pageSize
22
+     * @param orgId
23
+     * @param startDate
24
+     * @param endDate
25
+     * @param channelType
26
+     * @param buildingId
27
+     * @return
28
+     */
29
+    ResponseBean getChannelIntroductionList(Integer pageNum, Integer pageSize, Integer orgId, LocalDate startDate, LocalDate endDate, String channelType, String buildingId, Integer channelId);
15 30
 }

+ 29
- 0
src/main/java/com/huiju/estateagents/service/impl/TaChannelServiceImpl.java 查看文件

@@ -1,10 +1,18 @@
1 1
 package com.huiju.estateagents.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
2 5
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6
+import com.huiju.estateagents.base.ResponseBean;
3 7
 import com.huiju.estateagents.entity.TaChannel;
8
+import com.huiju.estateagents.entity.TsActivityDaily;
4 9
 import com.huiju.estateagents.mapper.TaChannelMapper;
5 10
 import com.huiju.estateagents.service.TaChannelService;
11
+import org.springframework.beans.factory.annotation.Autowired;
6 12
 import org.springframework.stereotype.Service;
7 13
 
14
+import java.time.LocalDate;
15
+
8 16
 /**
9 17
  * <p>
10 18
  *   服务实现类
@@ -16,4 +24,25 @@ import org.springframework.stereotype.Service;
16 24
 @Service
17 25
 public class TaChannelServiceImpl extends ServiceImpl<TaChannelMapper, TaChannel> implements TaChannelService {
18 26
 
27
+    @Autowired
28
+    private TaChannelMapper taChannelMapper;
29
+
30
+    /**
31
+     * 渠道引进客户统计
32
+     *
33
+     * @param pageNum
34
+     * @param pageSize
35
+     * @param orgId
36
+     * @param startDate
37
+     * @param endDate
38
+     * @param channelType
39
+     * @param buildingId
40
+     * @return
41
+     */
42
+    @Override
43
+    public ResponseBean getChannelIntroductionList(Integer pageNum, Integer pageSize, Integer orgId, LocalDate startDate, LocalDate endDate, String channelType, String buildingId, Integer channelId) {
44
+        IPage<TsActivityDaily> pg = new Page<>(pageNum, pageSize);
45
+        IPage<TsActivityDaily> data = taChannelMapper.getChannelIntroductionList(pg, orgId,startDate,endDate,channelType,buildingId, channelId);
46
+        return ResponseBean.success(data);
47
+    }
19 48
 }

+ 22
- 0
src/main/resources/mapper/TaChannelMapper.xml 查看文件

@@ -33,11 +33,15 @@
33 33
         c.*,
34 34
         count(tp.person_id) AS brokerCount,
35 35
         (SELECT COUNT(p.recommend_agent ) from ta_person p WHERE cp.person_id = p.recommend_agent) AS inviteCount,
36
+        IFNULL(ts.customerNum,0) as customerNum,
36 37
         cp.person_id
37 38
         FROM
38 39
         ta_channel c
39 40
         LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id
40 41
         LEFT JOIN ta_person tp ON cp.person_id = tp.person_id 	AND tp.person_type = 'estate agent' 	AND cp.STATUS = 1
42
+        LEFT JOIN (SELECT sum(z.customerNum) as customerNum,z.qr_code_id,z.org_id,z.channel_id from (SELECT sum(new_customers) as customerNum,qr_code_id,channel_id,org_id from ts_activity_daily where channel_id is not null and org_id = #{orgId} GROUP BY channel_id
43
+        union all
44
+        SELECT sum(new_customers) as customerNum,qr_code_id,channel_id,org_id from ts_channel_daily where channel_id is not null and org_id = #{orgId} GROUP BY channel_id) z GROUP BY z.channel_id) ts on c.channel_id = ts.channel_id
41 45
         <where>
42 46
             <if test="channelId != null and channelId != ''">
43 47
                 c.channel_id = #{channelId}
@@ -65,4 +69,22 @@
65 69
         GROUP BY c.channel_id
66 70
     </select>
67 71
 
72
+    <select id="getChannelIntroductionList" resultType="com.huiju.estateagents.entity.TsActivityDaily">
73
+        SELECT
74
+            *
75
+        FROM
76
+            ts_activity_daily
77
+        WHERE
78
+            channel_id = #{channelId}
79
+        AND org_id = #{orgId}
80
+        UNION ALL
81
+        SELECT
82
+            *
83
+        FROM
84
+            ts_channel_daily
85
+        WHERE
86
+            channel_id = #{channelId}
87
+            AND org_id = #{orgId}
88
+    </select>
89
+
68 90
 </mapper>