张延森 преди 4 години
родител
ревизия
6f9fc62cf1
променени са 24 файла, в които са добавени 347 реда и са изтрити 27 реда
  1. 7
    0
      pom.xml
  2. 23
    0
      src/main/java/com/yunzhi/liyuanhui/common/ExcelCellWriteHandler.java
  3. 36
    0
      src/main/java/com/yunzhi/liyuanhui/common/ExcelUtils.java
  4. 7
    3
      src/main/java/com/yunzhi/liyuanhui/common/OssUtils.java
  5. 3
    12
      src/main/java/com/yunzhi/liyuanhui/common/ResponseBean.java
  6. 28
    1
      src/main/java/com/yunzhi/liyuanhui/controller/TaActivityController.java
  7. 25
    4
      src/main/java/com/yunzhi/liyuanhui/controller/TaPersonController.java
  8. 44
    4
      src/main/java/com/yunzhi/liyuanhui/controller/TaRecommenderController.java
  9. 34
    0
      src/main/java/com/yunzhi/liyuanhui/entity/RecommendExport.java
  10. 12
    0
      src/main/java/com/yunzhi/liyuanhui/entity/TaActivity.java
  11. 9
    1
      src/main/java/com/yunzhi/liyuanhui/entity/TaPerson.java
  12. 3
    0
      src/main/java/com/yunzhi/liyuanhui/mapper/TaActivityEnrollMapper.java
  13. 4
    0
      src/main/java/com/yunzhi/liyuanhui/mapper/TaRecommenderMapper.java
  14. 2
    0
      src/main/java/com/yunzhi/liyuanhui/service/ITaActivityEnrollService.java
  15. 2
    0
      src/main/java/com/yunzhi/liyuanhui/service/ITaActivityVoteService.java
  16. 4
    0
      src/main/java/com/yunzhi/liyuanhui/service/ITaPersonService.java
  17. 4
    0
      src/main/java/com/yunzhi/liyuanhui/service/ITaRecommenderService.java
  18. 11
    0
      src/main/java/com/yunzhi/liyuanhui/service/impl/TaActivityEnrollServiceImpl.java
  19. 8
    1
      src/main/java/com/yunzhi/liyuanhui/service/impl/TaActivityVoteServiceImpl.java
  20. 15
    0
      src/main/java/com/yunzhi/liyuanhui/service/impl/TaPersonServiceImpl.java
  21. 7
    0
      src/main/java/com/yunzhi/liyuanhui/service/impl/TaRecommenderServiceImpl.java
  22. 9
    1
      src/main/resources/application-prod.yml
  23. 15
    0
      src/main/resources/mapper/TaActivityEnrollMapper.xml
  24. 35
    0
      src/main/resources/mapper/TaRecommenderMapper.xml

+ 7
- 0
pom.xml Целия файл

@@ -75,6 +75,13 @@
75 75
 			<optional>true</optional>
76 76
 		</dependency>
77 77
 
78
+		<!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel -->
79
+		<dependency>
80
+			<groupId>com.alibaba</groupId>
81
+			<artifactId>easyexcel</artifactId>
82
+			<version>2.0.4</version>
83
+		</dependency>
84
+
78 85
 		<dependency>
79 86
 			<groupId>org.springframework.boot</groupId>
80 87
 			<artifactId>spring-boot-starter-test</artifactId>

+ 23
- 0
src/main/java/com/yunzhi/liyuanhui/common/ExcelCellWriteHandler.java Целия файл

@@ -0,0 +1,23 @@
1
+package com.yunzhi.liyuanhui.common;
2
+
3
+import com.alibaba.excel.metadata.CellData;
4
+import com.alibaba.excel.metadata.Head;
5
+import com.alibaba.excel.write.handler.CellWriteHandler;
6
+import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
7
+import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
8
+import lombok.extern.slf4j.Slf4j;
9
+import org.apache.poi.ss.usermodel.Cell;
10
+import org.apache.poi.ss.usermodel.Row;
11
+
12
+@Slf4j
13
+public class ExcelCellWriteHandler implements CellWriteHandler {
14
+    @Override
15
+    public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, int i, boolean b) {
16
+
17
+    }
18
+
19
+    @Override
20
+    public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, CellData cellData, Cell cell, Head head, int i, boolean b) {
21
+
22
+    }
23
+}

+ 36
- 0
src/main/java/com/yunzhi/liyuanhui/common/ExcelUtils.java Целия файл

@@ -0,0 +1,36 @@
1
+package com.yunzhi.liyuanhui.common;
2
+
3
+import com.alibaba.excel.EasyExcel;
4
+import com.alibaba.excel.ExcelWriter;
5
+import com.alibaba.excel.write.metadata.WriteSheet;
6
+
7
+import javax.servlet.http.HttpServletResponse;
8
+import java.io.IOException;
9
+import java.util.List;
10
+
11
+public class ExcelUtils {
12
+
13
+    /**
14
+     * 发送 excel 到客户端
15
+     * 暂时只支持单 sheet 页
16
+     * @param response
17
+     * @param data
18
+     * @param fileName
19
+     * @throws IOException
20
+     */
21
+    public static void flush(HttpServletResponse response, Class dataClass, List data, String fileName) throws IOException {
22
+        response.setContentType("application/vnd.ms-excel");
23
+        response.setCharacterEncoding("utf-8");
24
+        response.setHeader("Content-disposition", "attachment;filename="+StringUtils.urlEncode(fileName)+".xlsx");
25
+
26
+        EasyExcel.write(response.getOutputStream(), dataClass).sheet("sheet1").doWrite(data);
27
+
28
+//        ParameterizedType type = (ParameterizedType) data.getClass().getGenericSuperclass();
29
+//        Class dataClass = (Class) type.getActualTypeArguments()[0];
30
+
31
+//        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), dataClass).registerWriteHandler(new ExcelCellWriteHandler()).build();
32
+//        WriteSheet sheet1 = EasyExcel.writerSheet("sheet1").build();
33
+//        excelWriter.write(data, sheet1);
34
+//        excelWriter.finish();
35
+    }
36
+}

+ 7
- 3
src/main/java/com/yunzhi/liyuanhui/common/OssUtils.java Целия файл

@@ -21,7 +21,7 @@ public class OssUtils {
21 21
      * @return
22 22
      */
23 23
     public String putObject(MultipartFile mf, String ... toDirs) throws IOException {
24
-        String fName = StringUtils.ifNull(mf.getOriginalFilename(), StringUtils.random(16) + ".png");
24
+        String fName = formatFileName(mf.getOriginalFilename());
25 25
         String preFix = String.valueOf(System.currentTimeMillis());
26 26
         String toDir = "/";
27 27
         if (null != toDirs && toDirs.length > 0) {
@@ -34,7 +34,7 @@ public class OssUtils {
34 34
     }
35 35
 
36 36
     public String putObject(File f, String ... toDirs) throws FileNotFoundException {
37
-        String fName = StringUtils.ifNull(f.getName(), StringUtils.random(16) + ".png");
37
+        String fName = formatFileName(f.getName());
38 38
         String preFix = String.valueOf(System.currentTimeMillis());
39 39
         String toDir = "/";
40 40
         if (null != toDirs && toDirs.length > 0) {
@@ -47,6 +47,10 @@ public class OssUtils {
47 47
         return putFile(nwFName, inputStream);
48 48
     }
49 49
 
50
+    private String formatFileName(String fName) {
51
+        return StringUtils.ifNull(fName, StringUtils.random(16) + ".png");
52
+    }
53
+
50 54
     private String putFile(String fname, InputStream input) {
51 55
         OSSClient ossClient = new OSSClient(aliyunConfig.getOss().getEndpoint(), aliyunConfig.getAccessKeyId(), aliyunConfig.getAccessKeySecret());
52 56
         ossClient.putObject(aliyunConfig.getOss().getBucketName(), fname, input);
@@ -59,6 +63,6 @@ public class OssUtils {
59 63
             preURL += "/";
60 64
         }
61 65
 
62
-        return preURL + fname;
66
+        return preURL + fname.replaceAll("\\ ", "%20");
63 67
     }
64 68
 }

+ 3
- 12
src/main/java/com/yunzhi/liyuanhui/common/ResponseBean.java Целия файл

@@ -1,10 +1,13 @@
1 1
 package com.yunzhi.liyuanhui.common;
2 2
 
3
+import lombok.Data;
4
+
3 5
 import java.io.Serializable;
4 6
 
5 7
 /**
6 8
  * 接口统一状态返回BEAN.
7 9
  */
10
+@Data
8 11
 public class ResponseBean<T> implements Serializable {
9 12
 
10 13
     private static final long serialVersionUID = 3593827217136880822L;
@@ -47,18 +50,6 @@ public class ResponseBean<T> implements Serializable {
47 50
 
48 51
         return responseBean;
49 52
     }
50
-
51
-    public int getCode() {
52
-        return code;
53
-    }
54
-
55
-    public String getMessage() {
56
-        return message;
57
-    }
58
-
59
-    public T getData() {
60
-        return data;
61
-    }
62 53
     
63 54
     @Override
64 55
     public String toString() {

+ 28
- 1
src/main/java/com/yunzhi/liyuanhui/controller/TaActivityController.java Целия файл

@@ -6,6 +6,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.liyuanhui.common.BaseController;
7 7
 import com.yunzhi.liyuanhui.common.ResponseBean;
8 8
 import com.yunzhi.liyuanhui.common.StringUtils;
9
+import com.yunzhi.liyuanhui.entity.TaPerson;
10
+import com.yunzhi.liyuanhui.service.ITaActivityEnrollService;
11
+import com.yunzhi.liyuanhui.service.ITaActivityVoteService;
12
+import org.bouncycastle.cms.PasswordRecipient;
9 13
 import org.slf4j.Logger;
10 14
 import org.slf4j.LoggerFactory;
11 15
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +17,8 @@ import org.springframework.web.bind.annotation.*;
13 17
 import com.yunzhi.liyuanhui.service.ITaActivityService;
14 18
 import com.yunzhi.liyuanhui.entity.TaActivity;
15 19
 
20
+import javax.servlet.http.HttpServletRequest;
21
+
16 22
 /**
17 23
  * <p>
18 24
     * 活动 前端控制器
@@ -30,6 +36,11 @@ public class TaActivityController extends BaseController {
30 36
     @Autowired
31 37
     public ITaActivityService iTaActivityService;
32 38
 
39
+    @Autowired
40
+    private ITaActivityVoteService iTaActivityVoteService;
41
+
42
+    @Autowired
43
+    private ITaActivityEnrollService iTaActivityEnrollService;
33 44
 
34 45
     /**
35 46
      * 分页查询列表
@@ -121,8 +132,24 @@ public class TaActivityController extends BaseController {
121 132
      */
122 133
     @RequestMapping(value="/{client}/activity/{id}",method= RequestMethod.GET)
123 134
     public ResponseBean taActivityGet(@PathVariable String client,
124
-                                      @PathVariable Integer id) throws Exception{
135
+                                      @PathVariable Integer id,
136
+                                      HttpServletRequest request) throws Exception{
125 137
         TaActivity result = iTaActivityService.getActivityProfile(id);
138
+
139
+        if ("wx".equals(client)) {
140
+            TaPerson taPerson = getPerson(request);
141
+            // 是否参与投票
142
+            if (null != result.getIsVote() && result.getIsVote()) {
143
+                boolean isVoted = iTaActivityVoteService.isVotedBy(result.getActivityId(), taPerson.getPersonId());
144
+                result.setIsSelfVoted(isVoted);
145
+            }
146
+            // 是否参与报名
147
+            if (null != result.getIsEnroll() && result.getIsEnroll()) {
148
+                boolean isSelfEnrolled = iTaActivityEnrollService.isEnrolledBy(result.getActivityId(), taPerson);
149
+                result.setIsSelfEnrolled(isSelfEnrolled);
150
+            }
151
+        }
152
+
126 153
         return ResponseBean.success(result);
127 154
     }
128 155
 }

+ 25
- 4
src/main/java/com/yunzhi/liyuanhui/controller/TaPersonController.java Целия файл

@@ -4,10 +4,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
4 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
-import com.yunzhi.liyuanhui.common.BaseController;
8
-import com.yunzhi.liyuanhui.common.ResponseBean;
9
-import com.yunzhi.liyuanhui.common.StringUtils;
10
-import com.yunzhi.liyuanhui.common.WxUtils;
7
+import com.yunzhi.liyuanhui.common.*;
11 8
 import com.yunzhi.liyuanhui.enums.StatusEnum;
12 9
 import org.slf4j.Logger;
13 10
 import org.slf4j.LoggerFactory;
@@ -16,6 +13,8 @@ import org.springframework.web.bind.annotation.*;
16 13
 import com.yunzhi.liyuanhui.service.ITaPersonService;
17 14
 import com.yunzhi.liyuanhui.entity.TaPerson;
18 15
 
16
+import javax.servlet.http.HttpServletResponse;
17
+import java.util.List;
19 18
 import java.util.Map;
20 19
 
21 20
 /**
@@ -64,6 +63,25 @@ public class TaPersonController extends BaseController {
64 63
         return ResponseBean.success(result);
65 64
     }
66 65
 
66
+    @GetMapping("/admin/person/export")
67
+    public void exportPerson(@RequestParam(value ="phone", required = false) String phone,
68
+                             @RequestParam(value ="name", required = false) String name,
69
+                             HttpServletResponse response) throws Exception {
70
+         List<TaPerson> personList = iTaPersonService.getListBy(phone, name);
71
+         for (TaPerson person: personList) {
72
+             // 设置性别
73
+             if (1 == person.getSex()) {
74
+                 person.setGender("男");
75
+             } else if (2 == person.getSex()) {
76
+                 person.setGender("女");
77
+             } else {
78
+                 person.setGender("未知");
79
+             }
80
+         }
81
+
82
+        ExcelUtils.flush(response, TaPerson.class, personList, "会员信息统计");
83
+    }
84
+
67 85
     /**
68 86
      * 保存对象
69 87
      * @param taPerson 实体对象
@@ -103,6 +121,9 @@ public class TaPersonController extends BaseController {
103 121
     @RequestMapping(value="/wx/person/{id}",method= RequestMethod.POST)
104 122
     public ResponseBean taPersonUpdate(@PathVariable Integer id,
105 123
                                         @RequestBody TaPerson taPerson) throws Exception{
124
+        if (null == taPerson.getPersonId()) {
125
+            taPerson.setPersonId(id);
126
+        }
106 127
 
107 128
         if (iTaPersonService.updateById(taPerson)){
108 129
             return ResponseBean.success(taPerson);

+ 44
- 4
src/main/java/com/yunzhi/liyuanhui/controller/TaRecommenderController.java Целия файл

@@ -3,10 +3,8 @@ package com.yunzhi.liyuanhui.controller;
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
-import com.yunzhi.liyuanhui.common.BaseController;
7
-import com.yunzhi.liyuanhui.common.DateUtils;
8
-import com.yunzhi.liyuanhui.common.ResponseBean;
9
-import com.yunzhi.liyuanhui.common.StringUtils;
6
+import com.yunzhi.liyuanhui.common.*;
7
+import com.yunzhi.liyuanhui.entity.RecommendExport;
10 8
 import com.yunzhi.liyuanhui.entity.TaPerson;
11 9
 import com.yunzhi.liyuanhui.enums.StatusEnum;
12 10
 import org.slf4j.Logger;
@@ -17,7 +15,9 @@ import com.yunzhi.liyuanhui.service.ITaRecommenderService;
17 15
 import com.yunzhi.liyuanhui.entity.TaRecommender;
18 16
 
19 17
 import javax.servlet.http.HttpServletRequest;
18
+import javax.servlet.http.HttpServletResponse;
20 19
 import java.util.Date;
20
+import java.util.List;
21 21
 import java.util.Map;
22 22
 
23 23
 /**
@@ -76,6 +76,46 @@ public class TaRecommenderController extends BaseController {
76 76
         return ResponseBean.success(result);
77 77
     }
78 78
 
79
+    @GetMapping("/admin/recommender/export")
80
+    public void taRecommenderList(@RequestParam(value ="startDate", required = false) String startDate,
81
+                                          @RequestParam(value ="endDate", required = false) String endDate,
82
+                                          @RequestParam(value ="recName", required = false) String recName,
83
+                                          @RequestParam(value ="recPhone", required = false) String recPhone,
84
+                                          @RequestParam(value ="name", required = false) String name,
85
+                                          @RequestParam(value ="phone", required = false) String phone,
86
+                                          @RequestParam(value ="status", required = false) Integer status,
87
+                                          HttpServletResponse response) throws Exception{
88
+        if (!StringUtils.isEmpty(startDate)) {
89
+            startDate += " 00:00:00";
90
+        }
91
+        if (!StringUtils.isEmpty(endDate)) {
92
+            endDate += " 23:59:59";
93
+        }
94
+
95
+        List<RecommendExport> result = iTaRecommenderService.getListBy(startDate, endDate, recName, recPhone, name, phone, status);
96
+        for (RecommendExport item: result) {
97
+            // 转换性别
98
+            if ("1".equals(item.getSex())) {
99
+                item.setSex("男");
100
+            } else if ("2".equals(item.getSex())) {
101
+                item.setSex("女");
102
+            } else {
103
+                item.setSex("未知");
104
+            }
105
+
106
+            // 转换审核状态
107
+            if ("1".equals(item.getStatus())) {
108
+                item.setStatus("审核通过");
109
+            } else if ("2".equals(item.getStatus())) {
110
+                item.setStatus("审核未通过");
111
+            } else {
112
+                item.setStatus("未审核");
113
+            }
114
+        }
115
+
116
+        ExcelUtils.flush(response, RecommendExport.class, result, StringUtils.strToUnicode("推荐用户"));
117
+    }
118
+
79 119
     @GetMapping("/wx/person/{personId}/recommender")
80 120
     public ResponseBean getRecommenderOf(@PathVariable Integer personId,
81 121
                                          @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,

+ 34
- 0
src/main/java/com/yunzhi/liyuanhui/entity/RecommendExport.java Целия файл

@@ -0,0 +1,34 @@
1
+package com.yunzhi.liyuanhui.entity;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import lombok.Data;
5
+
6
+import java.util.Date;
7
+
8
+@Data
9
+public class RecommendExport {
10
+
11
+    @ExcelProperty(value = "时间", index = 1)
12
+    private Date createDate;
13
+
14
+    @ExcelProperty(value = "手机", index = 2)
15
+    private String phone;
16
+
17
+    @ExcelProperty(value = "名称", index = 3)
18
+    private String name;
19
+
20
+    @ExcelProperty(value = "性别", index = 4)
21
+    private String sex;
22
+
23
+    @ExcelProperty(value = "备注", index = 5)
24
+    private String remark;
25
+
26
+    @ExcelProperty(value = "推荐人手机", index = 6)
27
+    private String recPhone;
28
+
29
+    @ExcelProperty(value = "推荐人名称", index = 7)
30
+    private String recName;
31
+
32
+    @ExcelProperty(value = "审核状态", index = 8)
33
+    private String status;
34
+}

+ 12
- 0
src/main/java/com/yunzhi/liyuanhui/entity/TaActivity.java Целия файл

@@ -157,4 +157,16 @@ public class TaActivity implements Serializable {
157 157
      */
158 158
     @TableField(exist = false)
159 159
     List<TaActivityVoteItem> voteItemList;
160
+
161
+    /**
162
+     * 是否参与投票
163
+     */
164
+    @TableField(exist = false)
165
+    Boolean isSelfVoted;
166
+
167
+    /**
168
+     * 是否参与报名
169
+     */
170
+    @TableField(exist = false)
171
+    Boolean isSelfEnrolled;
160 172
 }

+ 9
- 1
src/main/java/com/yunzhi/liyuanhui/entity/TaPerson.java Целия файл

@@ -1,6 +1,8 @@
1 1
 package com.yunzhi.liyuanhui.entity;
2 2
 
3
+import com.alibaba.excel.annotation.ExcelProperty;
3 4
 import com.baomidou.mybatisplus.annotation.IdType;
5
+import com.baomidou.mybatisplus.annotation.TableField;
4 6
 import com.baomidou.mybatisplus.annotation.TableId;
5 7
 import java.time.LocalDateTime;
6 8
 import java.io.Serializable;
@@ -37,11 +39,13 @@ public class TaPerson implements Serializable {
37 39
     /**
38 40
      * 姓名
39 41
      */
42
+    @ExcelProperty(value = "名称", index = 3)
40 43
     private String name;
41 44
 
42 45
     /**
43 46
      * 昵称
44 47
      */
48
+    @ExcelProperty(value = "昵称", index = 4)
45 49
     private String nickname;
46 50
 
47 51
     /**
@@ -52,6 +56,7 @@ public class TaPerson implements Serializable {
52 56
     /**
53 57
      * 电话
54 58
      */
59
+    @ExcelProperty(value = "手机", index = 2)
55 60
     private String phone;
56 61
 
57 62
     /**
@@ -62,6 +67,7 @@ public class TaPerson implements Serializable {
62 67
     /**
63 68
      * 创建时间
64 69
      */
70
+    @ExcelProperty(value = "时间", index = 1)
65 71
     private LocalDateTime createDate;
66 72
 
67 73
     /**
@@ -79,5 +85,7 @@ public class TaPerson implements Serializable {
79 85
      */
80 86
     private Integer status;
81 87
 
82
-
88
+    @ExcelProperty(value = "性别", index = 5)
89
+    @TableField(exist = false)
90
+    private String gender;
83 91
 }

+ 3
- 0
src/main/java/com/yunzhi/liyuanhui/mapper/TaActivityEnrollMapper.java Целия файл

@@ -4,6 +4,8 @@ import com.yunzhi.liyuanhui.entity.TaActivityEnroll;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import org.apache.ibatis.annotations.Mapper;
6 6
 
7
+import java.util.List;
8
+
7 9
 /**
8 10
  * <p>
9 11
  * 活动报名 Mapper 接口
@@ -15,4 +17,5 @@ import org.apache.ibatis.annotations.Mapper;
15 17
 @Mapper
16 18
 public interface TaActivityEnrollMapper extends BaseMapper<TaActivityEnroll> {
17 19
 
20
+    List<TaActivityEnroll> getEnrolledBy(Integer activityId, Integer personId, String phone);
18 21
 }

+ 4
- 0
src/main/java/com/yunzhi/liyuanhui/mapper/TaRecommenderMapper.java Целия файл

@@ -1,10 +1,12 @@
1 1
 package com.yunzhi.liyuanhui.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.liyuanhui.entity.RecommendExport;
4 5
 import com.yunzhi.liyuanhui.entity.TaRecommender;
5 6
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6 7
 import org.apache.ibatis.annotations.Mapper;
7 8
 
9
+import java.util.List;
8 10
 import java.util.Map;
9 11
 
10 12
 /**
@@ -19,4 +21,6 @@ import java.util.Map;
19 21
 public interface TaRecommenderMapper extends BaseMapper<TaRecommender> {
20 22
 
21 23
     IPage<Map<String, Object>> getListBy(IPage<Map<String, Object>> pg, String start, String end, String recName, String recPhone, String name, String phone, Integer status);
24
+
25
+    List<RecommendExport> getListNoPage(String start, String end, String recName, String recPhone, String name, String phone, Integer status);
22 26
 }

+ 2
- 0
src/main/java/com/yunzhi/liyuanhui/service/ITaActivityEnrollService.java Целия файл

@@ -15,4 +15,6 @@ import com.yunzhi.liyuanhui.entity.TaPerson;
15 15
 public interface ITaActivityEnrollService extends IService<TaActivityEnroll> {
16 16
 
17 17
     boolean enroll(TaActivityEnroll taActivityEnroll, TaPerson taPerson) throws Exception;
18
+
19
+    boolean isEnrolledBy(Integer activityId, TaPerson taPerson) throws Exception;
18 20
 }

+ 2
- 0
src/main/java/com/yunzhi/liyuanhui/service/ITaActivityVoteService.java Целия файл

@@ -17,4 +17,6 @@ import com.yunzhi.liyuanhui.entity.TaPerson;
17 17
 public interface ITaActivityVoteService extends IService<TaActivityVote> {
18 18
 
19 19
     boolean vote(TaActivity taActivity, TaActivityVoteItem taActivityVoteItem, TaPerson taPerson) throws Exception;
20
+
21
+    boolean isVotedBy(Integer activityId, Integer personId) throws Exception;
20 22
 }

+ 4
- 0
src/main/java/com/yunzhi/liyuanhui/service/ITaPersonService.java Целия файл

@@ -3,6 +3,8 @@ package com.yunzhi.liyuanhui.service;
3 3
 import com.yunzhi.liyuanhui.entity.TaPerson;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5 5
 
6
+import java.util.List;
7
+
6 8
 /**
7 9
  * <p>
8 10
  * 用户 服务类
@@ -29,4 +31,6 @@ public interface ITaPersonService extends IService<TaPerson> {
29 31
      * @throws Exception
30 32
      */
31 33
     TaPerson updatePersonPhone(Integer personId, String phone) throws Exception;
34
+
35
+    List<TaPerson> getListBy(String phone, String name) throws Exception;
32 36
 }

+ 4
- 0
src/main/java/com/yunzhi/liyuanhui/service/ITaRecommenderService.java Целия файл

@@ -1,9 +1,11 @@
1 1
 package com.yunzhi.liyuanhui.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.liyuanhui.entity.RecommendExport;
4 5
 import com.yunzhi.liyuanhui.entity.TaRecommender;
5 6
 import com.baomidou.mybatisplus.extension.service.IService;
6 7
 
8
+import java.util.List;
7 9
 import java.util.Map;
8 10
 
9 11
 /**
@@ -30,4 +32,6 @@ public interface ITaRecommenderService extends IService<TaRecommender> {
30 32
      * @throws Exception
31 33
      */
32 34
     IPage<Map<String, Object>> getListBy(IPage<Map<String, Object>> pg, String start, String end, String recName, String recPhone, String name, String phone, Integer status) throws Exception;
35
+
36
+    List<RecommendExport> getListBy(String startDate, String endDate, String recName, String recPhone, String name, String phone, Integer status) throws Exception;
33 37
 }

+ 11
- 0
src/main/java/com/yunzhi/liyuanhui/service/impl/TaActivityEnrollServiceImpl.java Целия файл

@@ -15,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
15 15
 import org.springframework.stereotype.Service;
16 16
 import org.springframework.transaction.annotation.Transactional;
17 17
 
18
+import java.util.List;
19
+
18 20
 /**
19 21
  * <p>
20 22
  * 活动报名 服务实现类
@@ -29,6 +31,9 @@ public class TaActivityEnrollServiceImpl extends ServiceImpl<TaActivityEnrollMap
29 31
     @Autowired
30 32
     ITaActivityService iTaActivityService;
31 33
 
34
+    @Autowired
35
+    TaActivityEnrollMapper taActivityEnrollMapper;
36
+
32 37
     @Transactional
33 38
     @Override
34 39
     public boolean enroll(TaActivityEnroll taActivityEnroll, TaPerson taPerson) throws Exception {
@@ -85,4 +90,10 @@ public class TaActivityEnrollServiceImpl extends ServiceImpl<TaActivityEnrollMap
85 90
 
86 91
         return true;
87 92
     }
93
+
94
+    @Override
95
+    public boolean isEnrolledBy(Integer activityId, TaPerson taPerson) throws Exception {
96
+        List<TaActivityEnroll> list = taActivityEnrollMapper.getEnrolledBy(activityId, taPerson.getPersonId(), taPerson.getPhone());
97
+        return null != list && list.size() > 0;
98
+    }
88 99
 }

+ 8
- 1
src/main/java/com/yunzhi/liyuanhui/service/impl/TaActivityVoteServiceImpl.java Целия файл

@@ -8,7 +8,6 @@ import com.yunzhi.liyuanhui.entity.TaActivityVote;
8 8
 import com.yunzhi.liyuanhui.entity.TaActivityVoteItem;
9 9
 import com.yunzhi.liyuanhui.entity.TaPerson;
10 10
 import com.yunzhi.liyuanhui.enums.StatusEnum;
11
-import com.yunzhi.liyuanhui.mapper.TaActivityVoteItemMapper;
12 11
 import com.yunzhi.liyuanhui.mapper.TaActivityVoteMapper;
13 12
 import com.yunzhi.liyuanhui.service.ITaActivityVoteItemService;
14 13
 import com.yunzhi.liyuanhui.service.ITaActivityVoteService;
@@ -91,4 +90,12 @@ public class TaActivityVoteServiceImpl extends ServiceImpl<TaActivityVoteMapper,
91 90
 
92 91
         return true;
93 92
     }
93
+
94
+    @Override
95
+    public boolean isVotedBy(Integer activityId, Integer personId) throws Exception {
96
+        QueryWrapper<TaActivityVote> queryWrapper = new QueryWrapper<>();
97
+        queryWrapper.eq("activity_id", activityId);
98
+        queryWrapper.eq("person_id", personId);
99
+        return this.count(queryWrapper) > 0;
100
+    }
94 101
 }

+ 15
- 0
src/main/java/com/yunzhi/liyuanhui/service/impl/TaPersonServiceImpl.java Целия файл

@@ -1,12 +1,16 @@
1 1
 package com.yunzhi.liyuanhui.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.liyuanhui.common.StringUtils;
4 5
 import com.yunzhi.liyuanhui.entity.TaPerson;
6
+import com.yunzhi.liyuanhui.enums.StatusEnum;
5 7
 import com.yunzhi.liyuanhui.mapper.TaPersonMapper;
6 8
 import com.yunzhi.liyuanhui.service.ITaPersonService;
7 9
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8 10
 import org.springframework.stereotype.Service;
9 11
 
12
+import java.util.List;
13
+
10 14
 /**
11 15
  * <p>
12 16
  * 用户 服务实现类
@@ -47,4 +51,15 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
47 51
         updateById(taPerson);
48 52
         return taPerson;
49 53
     }
54
+
55
+    @Override
56
+    public List<TaPerson> getListBy(String phone, String name) throws Exception {
57
+        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
58
+        queryWrapper.like(!StringUtils.isEmpty(phone), "phone", phone);
59
+        queryWrapper.nested(!StringUtils.isEmpty(name), q -> q.like("name", name).or().like("nickname", name));
60
+        queryWrapper.like(!StringUtils.isEmpty(name), "name", name);
61
+        queryWrapper.eq("status", StatusEnum.NORMAL.getCode());
62
+        queryWrapper.orderByDesc("create_date");
63
+        return this.list(queryWrapper);
64
+    }
50 65
 }

+ 7
- 0
src/main/java/com/yunzhi/liyuanhui/service/impl/TaRecommenderServiceImpl.java Целия файл

@@ -1,6 +1,7 @@
1 1
 package com.yunzhi.liyuanhui.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.liyuanhui.entity.RecommendExport;
4 5
 import com.yunzhi.liyuanhui.entity.TaRecommender;
5 6
 import com.yunzhi.liyuanhui.mapper.TaRecommenderMapper;
6 7
 import com.yunzhi.liyuanhui.service.ITaRecommenderService;
@@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8 9
 import org.springframework.beans.factory.annotation.Autowired;
9 10
 import org.springframework.stereotype.Service;
10 11
 
12
+import java.util.List;
11 13
 import java.util.Map;
12 14
 
13 15
 /**
@@ -27,4 +29,9 @@ public class TaRecommenderServiceImpl extends ServiceImpl<TaRecommenderMapper, T
27 29
     public IPage<Map<String, Object>> getListBy(IPage<Map<String, Object>> pg, String start, String end, String recName, String recPhone, String name, String phone, Integer status) throws Exception {
28 30
         return taRecommenderMapper.getListBy(pg, start, end, recName, recPhone, name, phone, status);
29 31
     }
32
+
33
+    @Override
34
+    public List<RecommendExport> getListBy(String startDate, String endDate, String recName, String recPhone, String name, String phone, Integer status) throws Exception {
35
+        return taRecommenderMapper.getListNoPage(startDate, endDate, recName, recPhone, name, phone, status);
36
+    }
30 37
 }

+ 9
- 1
src/main/resources/application-prod.yml Целия файл

@@ -5,4 +5,12 @@ spring:
5 5
   datasource:
6 6
     url: jdbc:mysql://rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com:3306/liyuanhui?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
7 7
     username: liyuanhui
8
-    password: abcd@123456
8
+    password: abcd@123456
9
+
10
+#weixin:
11
+#  miniapp:
12
+#    appid: wx842b0af4df4552a5
13
+#    secret: 602601def4b83277e6add96a82be937b
14
+#    token:
15
+#    aesKey:
16
+#    msgDataFormat: JSON

+ 15
- 0
src/main/resources/mapper/TaActivityEnrollMapper.xml Целия файл

@@ -2,4 +2,19 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.liyuanhui.mapper.TaActivityEnrollMapper">
4 4
 
5
+    <select id="getEnrolledBy" resultType="com.yunzhi.liyuanhui.entity.TaActivityEnroll">
6
+        SELECT
7
+            *
8
+        FROM
9
+            ta_activity_enroll t
10
+        WHERE
11
+            t.activity_id = #{activityId}
12
+        AND ( t.person_id = #{personId}
13
+        <if test="phone!=null and phone!=''">
14
+            OR t.person_phone = #{phone} OR t.enroll_phone = #{phone}
15
+        </if>
16
+        )
17
+        ORDER BY
18
+        t.create_date DESC
19
+    </select>
5 20
 </mapper>

+ 35
- 0
src/main/resources/mapper/TaRecommenderMapper.xml Целия файл

@@ -34,5 +34,40 @@
34 34
                 AND (s.`name` LIKE CONCAT( '%', #{recName}, '%' ) OR s.nickname LIKE CONCAT( '%', #{recName}, '%' ))
35 35
             </if>
36 36
         </where>
37
+        order by t.create_date desc
38
+    </select>
39
+    <select id="getListNoPage" resultType="com.yunzhi.liyuanhui.entity.RecommendExport">
40
+        SELECT
41
+        t.*,
42
+        s.`name` AS rec_name,
43
+        s.nickname AS rec_nickname,
44
+        s.phone AS rec_phone
45
+        FROM
46
+        ta_recommender t
47
+        LEFT JOIN ta_person s ON t.person_id = s.person_id
48
+        <where>
49
+            <if test="status != null">
50
+                t.`status` = #{status}
51
+            </if>
52
+            <if test="start!=null and start!=''">
53
+                AND t.create_date &gt;= STR_TO_DATE(#{start}, '%Y-%m-%d %H:%i:%s')
54
+            </if>
55
+            <if test="end!=null and end!=''">
56
+                AND t.create_date &lt;= STR_TO_DATE(#{end}, '%Y-%m-%d %H:%i:%s')
57
+            </if>
58
+            <if test="phone!=null and phone!=''">
59
+                AND t.phone LIKE CONCAT( '%', #{phone}, '%' )
60
+            </if>
61
+            <if test="name!=null and name!=''">
62
+                AND t.`name` LIKE CONCAT( '%', #{name}, '%' )
63
+            </if>
64
+            <if test="recPhone!=null and recPhone!=''">
65
+                AND s.phone LIKE CONCAT( '%', #{recPhone}, '%' )
66
+            </if>
67
+            <if test="recName!=null and recName!=''">
68
+                AND (s.`name` LIKE CONCAT( '%', #{recName}, '%' ) OR s.nickname LIKE CONCAT( '%', #{recName}, '%' ))
69
+            </if>
70
+        </where>
71
+        order by t.create_date desc
37 72
     </select>
38 73
 </mapper>