傅行帆 5 vuotta sitten
vanhempi
commit
e99e4f07f9

+ 20
- 18
src/main/java/com/huiju/estateagents/controller/TaChannelController.java Näytä tiedosto

1
 package com.huiju.estateagents.controller;
1
 package com.huiju.estateagents.controller;
2
 
2
 
3
-import com.alibaba.fastjson.JSONObject;
4
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
4
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.huiju.estateagents.base.BaseController;
5
 import com.huiju.estateagents.base.BaseController;
8
 import com.huiju.estateagents.base.ResponseBean;
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
 import com.huiju.estateagents.entity.TaChannel;
7
 import com.huiju.estateagents.entity.TaChannel;
14
-import com.huiju.estateagents.entity.TaPerson;
15
 import com.huiju.estateagents.mapper.TaChannelMapper;
8
 import com.huiju.estateagents.mapper.TaChannelMapper;
16
 import com.huiju.estateagents.service.ITaPersonService;
9
 import com.huiju.estateagents.service.ITaPersonService;
17
 import com.huiju.estateagents.service.TaChannelService;
10
 import com.huiju.estateagents.service.TaChannelService;
18
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.Api;
19
 import io.swagger.annotations.ApiImplicitParam;
12
 import io.swagger.annotations.ApiImplicitParam;
20
 import io.swagger.annotations.ApiImplicitParams;
13
 import io.swagger.annotations.ApiImplicitParams;
21
-import org.apache.http.HttpRequest;
14
+import io.swagger.annotations.ApiOperation;
22
 import org.slf4j.Logger;
15
 import org.slf4j.Logger;
23
 import org.slf4j.LoggerFactory;
16
 import org.slf4j.LoggerFactory;
24
 import org.springframework.beans.factory.annotation.Autowired;
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
 import javax.servlet.http.HttpServletRequest;
21
 import javax.servlet.http.HttpServletRequest;
34
-
35
-import java.time.LocalDateTime;
22
+import java.time.LocalDate;
36
 import java.util.HashMap;
23
 import java.util.HashMap;
37
 import java.util.List;
24
 import java.util.List;
38
-import java.util.stream.Collectors;
39
 
25
 
40
 
26
 
41
 /**
27
 /**
260
         ResponseBean taPerson =  taPersonService.InviteClientsList(id,phone,pageNum,pageSize);
246
         ResponseBean taPerson =  taPersonService.InviteClientsList(id,phone,pageNum,pageSize);
261
         return taPerson;
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 Näytä tiedosto

1
 package com.huiju.estateagents.entity;
1
 package com.huiju.estateagents.entity;
2
 
2
 
3
-import com.baomidou.mybatisplus.annotation.TableField;
4
-import com.baomidou.mybatisplus.annotation.TableName;
5
 import com.baomidou.mybatisplus.annotation.IdType;
3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
6
 import com.baomidou.mybatisplus.annotation.TableId;
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
 import lombok.Data;
7
 import lombok.Data;
10
 import lombok.EqualsAndHashCode;
8
 import lombok.EqualsAndHashCode;
11
 import lombok.experimental.Accessors;
9
 import lombok.experimental.Accessors;
12
 
10
 
11
+import java.io.Serializable;
12
+import java.time.LocalDateTime;
13
+
13
 /**
14
 /**
14
  * <p>
15
  * <p>
15
  *  
16
  *  
70
     @TableField(exist = false)
71
     @TableField(exist = false)
71
     private Integer inviteCount;
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 Näytä tiedosto

3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.huiju.estateagents.entity.TaChannel;
5
 import com.huiju.estateagents.entity.TaChannel;
6
+import com.huiju.estateagents.entity.TsActivityDaily;
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.time.LocalDate;
9
 import java.util.List;
11
 import java.util.List;
10
 
12
 
11
 /**
13
 /**
39
     IPage<TaChannel> pageTaChannel(IPage<TaChannel> pg,@Param("orgId")Integer orgId,@Param("channelId")Integer channelId);
41
     IPage<TaChannel> pageTaChannel(IPage<TaChannel> pg,@Param("orgId")Integer orgId,@Param("channelId")Integer channelId);
40
 
42
 
41
     List<TaChannel> recommendCount(@Param("orgId")Integer orgId,@Param("channelId")Integer channelId);
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 Näytä tiedosto

1
 package com.huiju.estateagents.service;
1
 package com.huiju.estateagents.service;
2
 import com.baomidou.mybatisplus.extension.service.IService;
2
 import com.baomidou.mybatisplus.extension.service.IService;
3
+import com.huiju.estateagents.base.ResponseBean;
3
 import com.huiju.estateagents.entity.TaChannel;
4
 import com.huiju.estateagents.entity.TaChannel;
4
 
5
 
6
+import java.time.LocalDate;
7
+
5
 /**
8
 /**
6
  * <p>
9
  * <p>
7
  *   服务类
10
  *   服务类
12
  */
15
  */
13
 public interface TaChannelService extends IService<TaChannel> {
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 Näytä tiedosto

1
 package com.huiju.estateagents.service.impl;
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
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6
+import com.huiju.estateagents.base.ResponseBean;
3
 import com.huiju.estateagents.entity.TaChannel;
7
 import com.huiju.estateagents.entity.TaChannel;
8
+import com.huiju.estateagents.entity.TsActivityDaily;
4
 import com.huiju.estateagents.mapper.TaChannelMapper;
9
 import com.huiju.estateagents.mapper.TaChannelMapper;
5
 import com.huiju.estateagents.service.TaChannelService;
10
 import com.huiju.estateagents.service.TaChannelService;
11
+import org.springframework.beans.factory.annotation.Autowired;
6
 import org.springframework.stereotype.Service;
12
 import org.springframework.stereotype.Service;
7
 
13
 
14
+import java.time.LocalDate;
15
+
8
 /**
16
 /**
9
  * <p>
17
  * <p>
10
  *   服务实现类
18
  *   服务实现类
16
 @Service
24
 @Service
17
 public class TaChannelServiceImpl extends ServiceImpl<TaChannelMapper, TaChannel> implements TaChannelService {
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 Näytä tiedosto

33
         c.*,
33
         c.*,
34
         count(tp.person_id) AS brokerCount,
34
         count(tp.person_id) AS brokerCount,
35
         (SELECT COUNT(p.recommend_agent ) from ta_person p WHERE cp.person_id = p.recommend_agent) AS inviteCount,
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
         cp.person_id
37
         cp.person_id
37
         FROM
38
         FROM
38
         ta_channel c
39
         ta_channel c
39
         LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id
40
         LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id
40
         LEFT JOIN ta_person tp ON cp.person_id = tp.person_id 	AND tp.person_type = 'estate agent' 	AND cp.STATUS = 1
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
         <where>
45
         <where>
42
             <if test="channelId != null and channelId != ''">
46
             <if test="channelId != null and channelId != ''">
43
                 c.channel_id = #{channelId}
47
                 c.channel_id = #{channelId}
65
         GROUP BY c.channel_id
69
         GROUP BY c.channel_id
66
     </select>
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
 </mapper>
90
 </mapper>