Bladeren bron

* 新需求

顾绍勇 5 jaren geleden
bovenliggende
commit
7a2f54e4ca

+ 8
- 8
src/main/java/com/huiju/estateagents/common/MiniAppPageEnum.java Bestand weergeven

@@ -11,42 +11,42 @@ public enum MiniAppPageEnum {
11 11
     /**
12 12
      * 项目
13 13
      */
14
-    PROJECT("project", "targetId=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/project/detail/index"),
14
+    PROJECT("project", "id=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/project/detail/index"),
15 15
 
16 16
     /**
17 17
      * 报名活动
18 18
      */
19
-    ACTIVITY("activity", "targetId=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/activity/detail/index"),
19
+    ACTIVITY("activity", "id=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/activity/detail/index"),
20 20
 
21 21
     /**
22 22
      * 助力活动
23 23
      */
24
-    HELP("help", "targetId=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/activity/detail/assistance"),
24
+    HELP("help", "id=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/activity/detail/assistance"),
25 25
 
26 26
     /**
27 27
      * 拼团活动
28 28
      */
29
-    GROUP("group", "targetId=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/activity/detail/assemble"),
29
+    GROUP("group", "id=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/activity/detail/assemble"),
30 30
 
31 31
     /**
32 32
      * h5活动
33 33
      */
34
-    H5("h5", "targetId=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/project/h5Page"),
34
+    H5("h5", "id=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/project/h5Page"),
35 35
 
36 36
     /**
37 37
      * 直播活动
38 38
      */
39
-    LIVE("live", "targetId=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "onlineSelling/pages/live/index"),
39
+    LIVE("live", "id=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "onlineSelling/pages/live/index"),
40 40
 
41 41
     /**
42 42
      * 资讯
43 43
      */
44
-    NEWS("news", "targetId=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/news/detail/index"),
44
+    NEWS("news", "id=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "pages/news/detail/index"),
45 45
 
46 46
     /**
47 47
      * 在线选房
48 48
      */
49
-    SALESBATCH("salesBatch", "targetId=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "onlineSelling/pages/houseList/index");
49
+    SALESBATCH("salesBatch", "id=%s&targetType=%S&channelId=%s&qrCodeId=%s&buildingId=%s", "onlineSelling/pages/houseList/index");
50 50
 
51 51
     private String type;
52 52
     private String scene;

+ 60
- 14
src/main/java/com/huiju/estateagents/controller/TaQrcodeController.java Bestand weergeven

@@ -1,26 +1,26 @@
1 1
 package com.huiju.estateagents.controller;
2 2
 
3
+import com.alibaba.excel.EasyExcel;
4
+import com.alibaba.excel.ExcelWriter;
5
+import com.alibaba.excel.support.ExcelTypeEnum;
3 6
 import com.alibaba.fastjson.JSONObject;
4
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
-import com.baomidou.mybatisplus.core.metadata.IPage;
6
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
-import com.google.gson.JsonObject;
8 7
 import com.huiju.estateagents.base.BaseController;
9 8
 import com.huiju.estateagents.base.ResponseBean;
10 9
 import com.huiju.estateagents.common.CommConstant;
11
-import com.huiju.estateagents.common.WxQrCodeUtils;
12
-import com.huiju.estateagents.entity.TaMiniapp;
13 10
 import com.huiju.estateagents.entity.TaQrcode;
11
+import com.huiju.estateagents.excel.ActivityStatistics.VisitPersonNum;
14 12
 import com.huiju.estateagents.service.IMiniAppService;
15 13
 import com.huiju.estateagents.service.ITaQrcodeService;
16
-import org.apache.commons.lang3.StringUtils;
14
+import org.apache.poi.sl.usermodel.Sheet;
17 15
 import org.slf4j.Logger;
18 16
 import org.slf4j.LoggerFactory;
19 17
 import org.springframework.beans.factory.annotation.Autowired;
20 18
 import org.springframework.web.bind.annotation.*;
21 19
 
22 20
 import javax.servlet.http.HttpServletRequest;
23
-import java.time.LocalDateTime;
21
+import javax.servlet.http.HttpServletResponse;
22
+import java.io.IOException;
23
+import java.io.OutputStream;
24 24
 import java.util.List;
25 25
 
26 26
 /**
@@ -53,14 +53,14 @@ public class TaQrcodeController extends BaseController {
53 53
      */
54 54
     @RequestMapping(value = "/admin/listQrCode", method = RequestMethod.GET)
55 55
     public ResponseBean listQrCodeByCondition(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
56
-                                     @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
57
-                                     String targetType, String targetName, Integer channelId, String buildingId,
58
-                                     HttpServletRequest request) {
56
+                                              @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
57
+                                              String targetType, String targetName, Integer channelId, String buildingId,
58
+                                              HttpServletRequest request) {
59 59
         logger.info("接收参数:targetType:{},targetName:{},channelId:{},buildingId:{}",
60 60
                 targetType, targetName, channelId, buildingId);
61 61
         ResponseBean responseBean = new ResponseBean();
62 62
         try {
63
-            responseBean = iTaQrcodeService.listQrCodeByCondition(pageNum,pageSize,targetType,targetName,channelId,buildingId,getOrgId(request));
63
+            responseBean = iTaQrcodeService.listQrCodeByCondition(pageNum, pageSize, targetType, targetName, channelId, buildingId, getOrgId(request));
64 64
         } catch (Exception e) {
65 65
             e.printStackTrace();
66 66
             logger.error("taQrcodeList -=- {}", e.toString());
@@ -116,7 +116,7 @@ public class TaQrcodeController extends BaseController {
116 116
      */
117 117
     @ResponseBody
118 118
     @RequestMapping(value = "/admin/qrCode/batchDelete", method = RequestMethod.DELETE)
119
-    public ResponseBean batchDelete(List<TaQrcode> taQrcodeList) {
119
+    public ResponseBean batchDelete(@RequestBody List<TaQrcode> taQrcodeList) {
120 120
         ResponseBean responseBean = new ResponseBean();
121 121
         try {
122 122
 
@@ -184,7 +184,7 @@ public class TaQrcodeController extends BaseController {
184 184
      * @param request
185 185
      * @return
186 186
      */
187
-    @RequestMapping("/admin/qrCode/getStatisticData")
187
+    @RequestMapping(value = "/admin/qrCode/getStatisticData", method = RequestMethod.GET)
188 188
     public ResponseBean getStatisticData(Integer qrCodeId, HttpServletRequest request) {
189 189
         logger.info("getStatisticData 接收参数:qrCodeId:{}", qrCodeId);
190 190
         ResponseBean responseBean = new ResponseBean();
@@ -197,4 +197,50 @@ public class TaQrcodeController extends BaseController {
197 197
         }
198 198
         return responseBean;
199 199
     }
200
+
201
+    /**
202
+     * 获取二维码统计信息记录
203
+     *
204
+     * @param pageNum
205
+     * @param pageSize
206
+     * @param qrCodeId
207
+     * @param type     1:访问人数,2:访问次数,3:新增注册用户数
208
+     * @param request
209
+     * @return
210
+     */
211
+    @RequestMapping(value = "/admin/getStatisticRecord", method = RequestMethod.GET)
212
+    public ResponseBean getStatisticRecord(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
213
+                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
214
+                                           Integer qrCodeId, Integer type, HttpServletRequest request) {
215
+        ResponseBean responseBean = new ResponseBean();
216
+        try {
217
+            responseBean = iTaQrcodeService.getStatisticRecord(type, pageNum, pageSize, qrCodeId, getOrgId(request));
218
+        } catch (Exception e) {
219
+            logger.error("getStatisticRecord 异常:", e);
220
+            responseBean.addError("fail");
221
+        }
222
+        return responseBean;
223
+    }
224
+
225
+    @RequestMapping(value = "/admin/getStatisticRecordExport", method = RequestMethod.GET)
226
+    public void getStatisticRecordExport(Integer qrCodeId, Integer type, HttpServletRequest request, HttpServletResponse response) {
227
+        ExcelWriter writer = null;
228
+        OutputStream outputStream = null;
229
+        try {
230
+            outputStream = response.getOutputStream();
231
+            iTaQrcodeService.getStatisticRecordExport(type,qrCodeId,getOrgId(request));
232
+            outputStream.flush();
233
+        } catch (Exception e) {
234
+            e.printStackTrace();
235
+        } finally {
236
+            try {
237
+                response.getOutputStream().close();
238
+            } catch (IOException e) {
239
+                e.printStackTrace();
240
+            }
241
+        }
242
+    }
243
+
200 244
 }
245
+
246
+

+ 12
- 0
src/main/java/com/huiju/estateagents/entity/TaPersonVisitRecord.java Bestand weergeven

@@ -202,4 +202,16 @@ public class TaPersonVisitRecord implements Serializable {
202 202
      */
203 203
     @TableField(exist = false)
204 204
     private String customerId;
205
+
206
+    /**
207
+     * 客户性别
208
+     */
209
+    @TableField(exist = false)
210
+    private Integer sex;
211
+
212
+    /**
213
+     * 客户归属地
214
+     */
215
+    @TableField(exist = false)
216
+    private String city;
205 217
 }

+ 43
- 0
src/main/java/com/huiju/estateagents/excel/QrCodeStatistics/QrCodeNewPersonNum.java Bestand weergeven

@@ -0,0 +1,43 @@
1
+package com.huiju.estateagents.excel.QrCodeStatistics;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
5
+import lombok.Data;
6
+
7
+@Data
8
+public class QrCodeNewPersonNum {
9
+    /**
10
+     * 姓名
11
+     */
12
+    @ColumnWidth(15)
13
+    @ExcelProperty(value = "姓名", index = 0)
14
+    private String nickName;
15
+
16
+    /**
17
+     * 电话
18
+     */
19
+    @ColumnWidth(15)
20
+    @ExcelProperty(value = "电话", index = 1)
21
+    private String phone;
22
+
23
+    /**
24
+     * 性别
25
+     */
26
+    @ColumnWidth(15)
27
+    @ExcelProperty(value = "性别", index = 2)
28
+    private String gender;
29
+
30
+    /**
31
+     * 归属地
32
+     */
33
+    @ColumnWidth(15)
34
+    @ExcelProperty(value = "归属地", index = 3)
35
+    private String province;
36
+
37
+    /**
38
+     * 访问次数
39
+     */
40
+    @ColumnWidth(15)
41
+    @ExcelProperty(value = "访问次数", index = 4)
42
+    private String visitNum;
43
+}

+ 45
- 0
src/main/java/com/huiju/estateagents/excel/QrCodeStatistics/QrCodeVisitNum.java Bestand weergeven

@@ -0,0 +1,45 @@
1
+package com.huiju.estateagents.excel.QrCodeStatistics;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
5
+import lombok.Data;
6
+
7
+import java.time.LocalDateTime;
8
+
9
+@Data
10
+public class QrCodeVisitNum {
11
+    /**
12
+     * 姓名
13
+     */
14
+    @ColumnWidth(15)
15
+    @ExcelProperty(value = "姓名", index = 0)
16
+    private String nickName;
17
+
18
+    /**
19
+     * 电话
20
+     */
21
+    @ColumnWidth(15)
22
+    @ExcelProperty(value = "电话", index = 1)
23
+    private String phone;
24
+
25
+    /**
26
+     * 性别
27
+     */
28
+    @ColumnWidth(15)
29
+    @ExcelProperty(value = "性别", index = 2)
30
+    private String gender;
31
+
32
+    /**
33
+     * 归属地
34
+     */
35
+    @ColumnWidth(15)
36
+    @ExcelProperty(value = "归属地", index = 3)
37
+    private String province;
38
+
39
+    /**
40
+     * 访问次数
41
+     */
42
+    @ColumnWidth(15)
43
+    @ExcelProperty(value = "访问时间", index = 4)
44
+    private LocalDateTime visitTime;
45
+}

+ 44
- 0
src/main/java/com/huiju/estateagents/excel/QrCodeStatistics/QrCodeVisitPersonNum.java Bestand weergeven

@@ -0,0 +1,44 @@
1
+package com.huiju.estateagents.excel.QrCodeStatistics;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
5
+import lombok.Data;
6
+
7
+@Data
8
+public class QrCodeVisitPersonNum {
9
+    /**
10
+     * 姓名
11
+     */
12
+    @ColumnWidth(15)
13
+    @ExcelProperty(value = "姓名", index = 0)
14
+    private String nickName;
15
+
16
+    /**
17
+     * 电话
18
+     */
19
+    @ColumnWidth(15)
20
+    @ExcelProperty(value = "电话", index = 1)
21
+    private String phone;
22
+
23
+    /**
24
+     * 性别
25
+     */
26
+    @ColumnWidth(15)
27
+    @ExcelProperty(value = "性别", index = 2)
28
+    private String gender;
29
+
30
+    /**
31
+     * 归属地
32
+     */
33
+    @ColumnWidth(15)
34
+    @ExcelProperty(value = "归属地", index = 3)
35
+    private String province;
36
+
37
+    /**
38
+     * 访问次数
39
+     */
40
+    @ColumnWidth(15)
41
+    @ExcelProperty(value = "访问次数", index = 4)
42
+    private String visitNum;
43
+
44
+}

+ 58
- 1
src/main/java/com/huiju/estateagents/mapper/TaQrcodeMapper.java Bestand weergeven

@@ -2,13 +2,18 @@ package com.huiju.estateagents.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 5
 import com.huiju.estateagents.bo.request.QrCodeStatisticResponseBO;
6
+import com.huiju.estateagents.entity.TaPersonVisitRecord;
7 7
 import com.huiju.estateagents.entity.TaQrcode;
8
+import com.huiju.estateagents.excel.QrCodeStatistics.QrCodeNewPersonNum;
9
+import com.huiju.estateagents.excel.QrCodeStatistics.QrCodeVisitNum;
10
+import com.huiju.estateagents.excel.QrCodeStatistics.QrCodeVisitPersonNum;
8 11
 import org.apache.ibatis.annotations.Mapper;
9 12
 import org.apache.ibatis.annotations.Param;
10 13
 import org.springframework.stereotype.Component;
11 14
 
15
+import java.util.List;
16
+
12 17
 /**
13 18
  * <p>
14 19
  * 二维码管理表 Mapper 接口
@@ -29,4 +34,56 @@ public interface TaQrcodeMapper extends BaseMapper<TaQrcode> {
29 34
                                           @Param("channelId") Integer channelId,
30 35
                                           @Param("buildingId") String buildingId,
31 36
                                           @Param("orgId") Integer orgId);
37
+
38
+    /**
39
+     * 获取访问用户人数
40
+     *
41
+     * @param qrCodeId
42
+     * @param orgId
43
+     * @return
44
+     */
45
+    Integer getVisitPersons(@Param("qrCodeId") Integer qrCodeId,
46
+                            @Param("orgId") Integer orgId);
47
+
48
+    /**
49
+     * 获取访问次数
50
+     *
51
+     * @param qrCodeId
52
+     * @param orgId
53
+     * @return
54
+     */
55
+    Integer getVisitNum(@Param("qrCodeId") Integer qrCodeId,
56
+                        @Param("orgId") Integer orgId);
57
+
58
+    /**
59
+     * 获取新增用户数
60
+     *
61
+     * @param qrCodeId
62
+     * @param orgId
63
+     * @return
64
+     */
65
+    Integer getNewPersons(@Param("qrCodeId") Integer qrCodeId,
66
+                          @Param("orgId") Integer orgId);
67
+
68
+    IPage<TaPersonVisitRecord> getVisitPersonsRecord(IPage<TaPersonVisitRecord> page,
69
+                                                     @Param("qrCodeId") Integer qrCodeId,
70
+                                                     @Param("orgId") Integer orgId);
71
+
72
+    IPage<TaPersonVisitRecord> getVisitNumRecord(IPage<TaPersonVisitRecord> page,
73
+                                                 @Param("qrCodeId") Integer qrCodeId,
74
+                                                 @Param("orgId") Integer orgId);
75
+
76
+    IPage<TaPersonVisitRecord> getNewPersonsRecord(IPage<TaPersonVisitRecord> page,
77
+                                                   @Param("qrCodeId") Integer qrCodeId,
78
+                                                   @Param("orgId") Integer orgId);
79
+
80
+    List<QrCodeVisitPersonNum> getVisitPersonsRecordExport(@Param("qrCodeId") Integer qrCodeId,
81
+                                                           @Param("orgId") Integer orgId);
82
+
83
+
84
+    List<QrCodeVisitNum> getVisitNumRecordExport(@Param("qrCodeId") Integer qrCodeId,
85
+                                                 @Param("orgId") Integer orgId);
86
+
87
+    List<QrCodeNewPersonNum> getNewPersonsRecordExport(@Param("qrCodeId") Integer qrCodeId,
88
+                                                       @Param("orgId") Integer orgId);
32 89
 }

+ 5
- 0
src/main/java/com/huiju/estateagents/service/ITaQrcodeService.java Bestand weergeven

@@ -1,6 +1,8 @@
1 1
 package com.huiju.estateagents.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.huiju.estateagents.base.ResponseBean;
5
+import com.huiju.estateagents.entity.TaPerson;
4 6
 import com.huiju.estateagents.entity.TaQrcode;
5 7
 import com.baomidou.mybatisplus.extension.service.IService;
6 8
 import org.springframework.web.bind.annotation.RequestParam;
@@ -23,4 +25,7 @@ public interface ITaQrcodeService extends IService<TaQrcode> {
23 25
 
24 26
     ResponseBean getStatisticData(Integer qrCodeId, Integer orgId);
25 27
 
28
+    ResponseBean getStatisticRecord(Integer type, Integer pageNum, Integer pageSize, Integer qrCodeId, Integer orgId);
29
+
30
+    void getStatisticRecordExport(Integer type, Integer qrCodeId, Integer orgId);
26 31
 }

+ 3
- 3
src/main/java/com/huiju/estateagents/service/impl/MiniAppServiceImpl.java Bestand weergeven

@@ -358,9 +358,9 @@ public class MiniAppServiceImpl implements IMiniAppService {
358 358
             taQrcode.setCreateDate(LocalDateTime.now());
359 359
             taQrcode.setExpireDate(LocalDateTime.now().plusDays(7));
360 360
             taQrcode.setQrParams(paramsStr);
361
-            JSONObject sceneObj = JSONObject.parseObject(scene);
362
-            if (!StringUtils.isEmpty(sceneObj.getString("qrCodeId"))) {
363
-                taQrcode.setTargetId(Integer.parseInt(sceneObj.getString("qrCodeId")));
361
+            if (scene.indexOf("&qrCodeId=") > -1) {
362
+                String str = scene.substring(scene.indexOf("&qrCodeId=") + 10);
363
+                taQrcode.setTargetId(Integer.parseInt(str.substring(0, str.indexOf("&"))));
364 364
             }
365 365
 
366 366
             boolean success = taMiniappQrcodeMapper.insert(taQrcode) > 0;

+ 73
- 6
src/main/java/com/huiju/estateagents/service/impl/TaQrcodeServiceImpl.java Bestand weergeven

@@ -1,27 +1,32 @@
1 1
 package com.huiju.estateagents.service.impl;
2 2
 
3
+import com.alibaba.excel.EasyExcel;
3 4
 import com.alibaba.fastjson.JSONObject;
4 5
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 6
 import com.baomidou.mybatisplus.core.metadata.IPage;
6 7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8 9
 import com.huiju.estateagents.base.ResponseBean;
9
-import com.huiju.estateagents.bo.request.QrCodeStatisticResponseBO;
10 10
 import com.huiju.estateagents.common.CommConstant;
11 11
 import com.huiju.estateagents.common.WxQrCodeUtils;
12 12
 import com.huiju.estateagents.entity.TaMiniapp;
13
+import com.huiju.estateagents.entity.TaPersonVisitRecord;
13 14
 import com.huiju.estateagents.entity.TaQrcode;
15
+import com.huiju.estateagents.excel.QrCodeStatistics.QrCodeNewPersonNum;
16
+import com.huiju.estateagents.excel.QrCodeStatistics.QrCodeVisitNum;
17
+import com.huiju.estateagents.excel.QrCodeStatistics.QrCodeVisitPersonNum;
14 18
 import com.huiju.estateagents.mapper.TaMiniappMapper;
15 19
 import com.huiju.estateagents.mapper.TaQrcodeMapper;
16 20
 import com.huiju.estateagents.service.IMiniAppService;
17 21
 import com.huiju.estateagents.service.ITaQrcodeService;
18
-import org.checkerframework.checker.units.qual.A;
22
+import org.apache.commons.lang3.StringUtils;
19 23
 import org.slf4j.Logger;
20 24
 import org.slf4j.LoggerFactory;
21 25
 import org.springframework.beans.factory.annotation.Autowired;
22 26
 import org.springframework.stereotype.Service;
23 27
 
24 28
 import java.time.LocalDateTime;
29
+import java.util.List;
25 30
 
26 31
 /**
27 32
  * <p>
@@ -77,6 +82,19 @@ public class TaQrcodeServiceImpl extends ServiceImpl<TaQrcodeMapper, TaQrcode> i
77 82
     public ResponseBean saveQrcode(TaQrcode taQrcode, Integer userId, Integer orgId) {
78 83
         ResponseBean responseBean = new ResponseBean();
79 84
 
85
+        // 校验是否已有相同的数据
86
+        QueryWrapper<TaQrcode> qrcodeQueryWrapper = new QueryWrapper<>();
87
+        qrcodeQueryWrapper.eq("org_id", orgId);
88
+        qrcodeQueryWrapper.eq(StringUtils.isNotBlank(taQrcode.getBuildingId()), "building_id", taQrcode.getBuildingId());
89
+        qrcodeQueryWrapper.eq(taQrcode.getChannelId() != null, "channel_id", taQrcode.getChannelId());
90
+        qrcodeQueryWrapper.eq("target_type", taQrcode.getTargetType());
91
+        qrcodeQueryWrapper.eq("target_id", taQrcode.getTargetId());
92
+        TaQrcode taQrCodeCheck = taQrcodeMapper.selectOne(qrcodeQueryWrapper);
93
+        if (taQrCodeCheck != null) {
94
+            responseBean.addError("请勿重复提交");
95
+            return responseBean;
96
+        }
97
+
80 98
         // 保存数据
81 99
         taQrcode.setOrgId(orgId);
82 100
         taQrcode.setCreateUser(userId);
@@ -98,7 +116,7 @@ public class TaQrcodeServiceImpl extends ServiceImpl<TaQrcodeMapper, TaQrcode> i
98 116
         ResponseBean qrCodeResult = iMiniAppService.getQrCode(paramsStr, taMiniapp.getMiniappId());
99 117
         if (qrCodeResult != null && ResponseBean.CODE_SUCCESS == qrCodeResult.getCode()) {
100 118
             // 更新数据
101
-            taQrcode.setQrCodeUrl(qrCodeResult.getCode() + "");
119
+            taQrcode.setQrCodeUrl((String) qrCodeResult.getData());
102 120
             if (updateById(taQrcode)) {
103 121
                 responseBean.addSuccess(taQrcode);
104 122
                 return responseBean;
@@ -127,14 +145,63 @@ public class TaQrcodeServiceImpl extends ServiceImpl<TaQrcodeMapper, TaQrcode> i
127 145
             return responseBean;
128 146
         }
129 147
 
130
-        // 获取统计数据
131
-        QrCodeStatisticResponseBO statisticData = taQrcodeMapper.getStatisticData(orgId);
148
+        // 查询访问总人数
149
+        Integer visitPersons = taQrcodeMapper.getVisitPersons(qrCodeId, orgId);
150
+
151
+        // 查询访问总次数
152
+        Integer visitNum = taQrcodeMapper.getVisitNum(qrCodeId, orgId);
153
+
154
+        // 查询新增用户数
155
+//        Integer newPersons = taQrcodeMapper.getNewPersons(qrCodeId, orgId);
132 156
 
133 157
         // 组装反参
134 158
         JSONObject resultObj = new JSONObject();
135
-        resultObj.put("statistic", statisticData);
159
+        resultObj.put("visitPersons", visitPersons);
160
+        resultObj.put("visitNum", visitNum);
161
+//        resultObj.put("newPersons", newPersons);
136 162
         resultObj.put("qrCodeInfo", taQrcode);
137 163
         responseBean.addSuccess(resultObj);
138 164
         return responseBean;
139 165
     }
166
+
167
+    @Override
168
+    public ResponseBean getStatisticRecord(Integer type, Integer pageNum, Integer pageSize, Integer qrCodeId, Integer orgId) {
169
+        ResponseBean responseBean = new ResponseBean();
170
+        IPage<TaPersonVisitRecord> pg = new Page<>(pageNum, pageSize);
171
+        switch (type) {
172
+            case 1:
173
+                responseBean.addSuccess(taQrcodeMapper.getVisitPersonsRecord(pg, qrCodeId, orgId));
174
+                break;
175
+            case 2:
176
+                responseBean.addSuccess(taQrcodeMapper.getVisitNumRecord(pg, qrCodeId, orgId));
177
+                break;
178
+            case 3:
179
+                responseBean.addSuccess(taQrcodeMapper.getNewPersonsRecord(pg, qrCodeId, orgId));
180
+                break;
181
+            default:
182
+                responseBean.addError("fail");
183
+                break;
184
+        }
185
+        return responseBean;
186
+    }
187
+
188
+    @Override
189
+    public void getStatisticRecordExport(Integer type, Integer qrCodeId, Integer orgId) {
190
+        switch (type) {
191
+            case 1:
192
+                List<QrCodeVisitPersonNum> records = taQrcodeMapper.getVisitPersonsRecordExport(qrCodeId,orgId);
193
+                EasyExcel.write("访问人数.xlsx", QrCodeVisitPersonNum.class).sheet("访问人数").doWrite(records);
194
+                break;
195
+            case 2:
196
+                List<QrCodeVisitNum> records2 = taQrcodeMapper.getVisitNumRecordExport(qrCodeId, orgId);
197
+                EasyExcel.write("访问次数.xlsx", QrCodeVisitNum.class).sheet("访问次数").doWrite(records2);
198
+                break;
199
+            case 3:
200
+                List<QrCodeNewPersonNum> records3 = taQrcodeMapper.getNewPersonsRecordExport(qrCodeId, orgId);
201
+                EasyExcel.write("新增注册用户.xlsx", QrCodeNewPersonNum.class).sheet("新增注册用户").doWrite(records3);
202
+                break;
203
+            default:
204
+                break;
205
+        }
206
+    }
140 207
 }

+ 101
- 5
src/main/resources/mapper/TaQrcodeMapper.xml Bestand weergeven

@@ -14,23 +14,119 @@
14 14
     WHERE
15 15
         t.`status` > - 1
16 16
         AND t.org_id = #{orgId}
17
-        <if test = "buildingId == '' or buildingId == null">
17
+        <if test = "buildingId != '' and buildingId != null">
18 18
             AND t.building_id = #{buildingId}
19 19
         </if>
20
-        <if test = "targetType == '' or targetType == null">
20
+        <if test = "targetType != '' and targetType != null">
21 21
             AND t.target_type = #{targetType}
22 22
         </if>
23
-        <if test = "targetName == '' or targetName == null">
23
+        <if test = "targetName != '' and targetName != null">
24 24
             AND t.target_name = #{targetName}
25 25
         </if>
26
-        <if test = "channelId == null">
26
+        <if test = "channelId != null">
27 27
             AND t.channel_id = #{channelId}
28 28
         </if>
29 29
       ORDER BY
30 30
         t.create_date DESC
31 31
     </select>
32 32
 
33
-    <select id="getStatisticData" resultType="com.huiju.estateagents.bo.request.QrCodeStatisticResponseBO">
33
+    <select id="getVisitPersons" resultType="java.lang.Integer">
34
+        SELECT
35
+            count( DISTINCT t.person_id )
36
+        FROM
37
+            ta_person_visit_record t
38
+        WHERE
39
+            t.org_id = #{orgId}
40
+            AND t.qrcode_id = #{qrCodeId}
41
+    </select>
42
+
43
+    <select id="getVisitNum" resultType="java.lang.Integer">
44
+        SELECT
45
+            count( * )
46
+        FROM
47
+            ta_person_visit_record t
48
+        WHERE
49
+            t.org_id = #{orgId}
50
+            AND t.qrcode_id = #{qrCodeId}
51
+    </select>
52
+
53
+    <select id="getNewPersons" resultType="java.lang.Integer">
54
+
55
+    </select>
56
+
57
+    <select id="getVisitPersonsRecord" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
58
+        SELECT
59
+            t.*,
60
+            IFNULL(t2.`name`,t2.nickname) userName,
61
+            t2.tel userTel,
62
+            t2.sex,
63
+            t2.city,
64
+            sum(t.record_id) accessCount
65
+        FROM
66
+            ta_person_visit_record t
67
+            left join ta_person t2
68
+            on t.person_id = t2.person_id
69
+        WHERE
70
+            t.org_id = #{orgId}
71
+            AND t.qrcode_id = #{qrCodeId}
72
+        GROUP BY
73
+	        t.person_id
74
+    </select>
75
+
76
+    <select id="getVisitPersonsRecordExport" resultType="com.huiju.estateagents.excel.QrCodeStatistics.QrCodeVisitPersonNum">
77
+        SELECT
78
+            IFNULL( t2.`name`, t2.nickname ) nickName,
79
+            t2.tel phone,
80
+            t2.sex gender,
81
+            t2.city province,
82
+            sum( t.record_id ) visitNum
83
+        FROM
84
+            ta_person_visit_record t
85
+            LEFT JOIN ta_person t2 ON t.person_id = t2.person_id
86
+        WHERE
87
+            t.org_id = #{orgId}
88
+
89
+            AND t.qrcode_id = #{qrCodeId}
90
+
91
+        GROUP BY
92
+            t.person_id
93
+    </select>
94
+
95
+    <select id="getVisitNumRecord" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
96
+        SELECT
97
+            t.*,
98
+            IFNULL( t2.`name`, t2.nickname ) userName,
99
+            t2.tel userTel,
100
+            t2.sex,
101
+            t2.city
102
+        FROM
103
+            ta_person_visit_record t
104
+            LEFT JOIN ta_person t2 ON t.person_id = t2.person_id
105
+        WHERE
106
+            t.org_id = #{orgId}
107
+            AND t.qrcode_id = #{qrCodeId}
108
+    </select>
109
+
110
+    <select id="getVisitPersonsRecordExport" resultType="com.huiju.estateagents.excel.QrCodeStatistics.QrCodeVisitNum">
111
+        SELECT
112
+            IFNULL( t2.`name`, t2.nickname ) nickName,
113
+            t2.tel phone,
114
+            t2.sex gender,
115
+            t2.city province,
116
+			t.visit_time visitTime
117
+        FROM
118
+            ta_person_visit_record t
119
+            LEFT JOIN ta_person t2 ON t.person_id = t2.person_id
120
+        WHERE
121
+            t.org_id = #{orgId}
122
+            AND t.qrcode_id = #{qrCodeId}
123
+    </select>
124
+
125
+    <select id="getNewPersonsRecord" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
126
+
127
+    </select>
128
+
129
+    <select id="getNewPersonsRecordExport" resultType="com.huiju.estateagents.excel.QrCodeStatistics.QrCodeNewPersonNum">
34 130
 
35 131
     </select>
36 132