瀏覽代碼

Merge branch 'develop' of http://git.ycjcjy.com/marketing/services into develop

张延森 3 年之前
父節點
當前提交
f028674041

+ 1
- 1
src/main/java/com/yunzhi/marketing/controller/TaRecommendCustomerController.java 查看文件

@@ -202,7 +202,7 @@ public class TaRecommendCustomerController extends BaseController {
202 202
      * @return
203 203
      */
204 204
     @PostMapping("/wx/channel/report")
205
-    public ResponseBean channelReportCust(@RequestBody ChannelReportDTO channelReportDTO, HttpServletRequest request) {
205
+    public ResponseBean channelReportCust(@RequestBody ChannelReportDTO channelReportDTO, HttpServletRequest request) throws Exception {
206 206
         String openid = getOpenId(request);
207 207
         Integer orgId = getOrgId(request);
208 208
         channelReportDTO.setOpenid(openid);

+ 1
- 1
src/main/java/com/yunzhi/marketing/service/ITaRecommendCustomerService.java 查看文件

@@ -195,5 +195,5 @@ public interface ITaRecommendCustomerService extends IService<TaRecommendCustome
195 195
      * @param channelReportDTO
196 196
      * @return
197 197
      */
198
-    ResponseBean channelReportCust(ChannelReportDTO channelReportDTO);
198
+    ResponseBean channelReportCust(ChannelReportDTO channelReportDTO) throws Exception;
199 199
 }

+ 54
- 3
src/main/java/com/yunzhi/marketing/service/impl/TaRecommendCustomerServiceImpl.java 查看文件

@@ -26,7 +26,9 @@ import com.yunzhi.marketing.statistic.entity.TaCustomerFollowUpRecord;
26 26
 import com.yunzhi.marketing.statistic.mapper.TaCustomerFollowUpRecordMapper;
27 27
 import com.yunzhi.marketing.entity.*;
28 28
 import com.yunzhi.marketing.mapper.*;
29
+import com.yunzhi.marketing.xlk.entity.BuildingChannel;
29 30
 import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
31
+import com.yunzhi.marketing.xlk.mapper.BuildingChannelMapper;
30 32
 import com.yunzhi.marketing.xlk.mapper.ChannelCustomerMapper;
31 33
 import org.apache.commons.collections.CollectionUtils;
32 34
 import org.slf4j.Logger;
@@ -118,6 +120,12 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
118 120
     @Autowired
119 121
     private ChannelCustomerMapper channelCustomerMapper;
120 122
 
123
+    @Autowired
124
+    private BuildingChannelMapper buildingChannelMapper;
125
+
126
+    @Autowired
127
+    private TaChannelPersonMapper channelPersonMapper;
128
+
121 129
     @Override
122 130
     public ResponseBean getMyCustList(String openid, String keywords, int pageNumber, int pageSize) {
123 131
         List<TaPerson> taPersons = getPersonsByOpenId(openid);
@@ -351,7 +359,15 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
351 359
      * @return
352 360
      */
353 361
     @Override
354
-    public ResponseBean channelReportCust(ChannelReportDTO channelReportDTO) {
362
+    public ResponseBean channelReportCust(ChannelReportDTO channelReportDTO) throws Exception {
363
+
364
+        // 当前人员
365
+        List<TaPerson> persons = getPersonsByOpenId(channelReportDTO.getOpenid());
366
+        if (null == persons || persons.size() != 1) {
367
+            throw new Exception("当前人员 openid 异常");
368
+        }
369
+        TaPerson person = persons.get(0);
370
+
355 371
         // 先查看在ta_recommend_customer 手机号是否存在
356 372
         LambdaQueryWrapper<TaRecommendCustomer> queryWrapper = new LambdaQueryWrapper<>();
357 373
         queryWrapper.eq(TaRecommendCustomer::getPhone,channelReportDTO.getPhone());
@@ -360,6 +376,40 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
360 376
         if (taRecommendCustomers.size() > 0) {
361 377
             return ResponseBean.error("已存在的客户报备失败", ResponseBean.ERROR_UNAVAILABLE);
362 378
         }
379
+        //查询此楼盘的渠道id
380
+        LambdaQueryWrapper<TaChannelPerson> channelPersonLambdaQueryWrapper = new LambdaQueryWrapper<>();
381
+        channelPersonLambdaQueryWrapper.eq(TaChannelPerson::getPersonId,person.getPersonId());
382
+        TaChannelPerson taChannelPeople = channelPersonMapper.selectOne(channelPersonLambdaQueryWrapper);
383
+        if (null == taChannelPeople) {
384
+            return ResponseBean.error("不是渠道用户请绑定", ResponseBean.ERROR_UNAVAILABLE);
385
+        }
386
+
387
+        // 查询这个楼盘的这个渠道的有效保护期
388
+        LambdaQueryWrapper<BuildingChannel> buildingChannelLambdaQueryWrapper = new LambdaQueryWrapper<>();
389
+        buildingChannelLambdaQueryWrapper.eq(BuildingChannel::getBuildingId,channelReportDTO.getBuildingId());
390
+        buildingChannelLambdaQueryWrapper.eq(BuildingChannel::getChannelId,taChannelPeople.getChannelId());
391
+        BuildingChannel buildingChannel = buildingChannelMapper.selectOne(buildingChannelLambdaQueryWrapper);
392
+
393
+        // 查询是否在渠道推荐表中
394
+        LambdaQueryWrapper<ChannelCustomer> channelCustomerLambdaQueryWrapper = new LambdaQueryWrapper<>();
395
+        channelCustomerLambdaQueryWrapper.eq(ChannelCustomer::getBuildingId,channelReportDTO.getBuildingId());
396
+        channelCustomerLambdaQueryWrapper.eq(ChannelCustomer::getChannelId,taChannelPeople.getChannelId());
397
+        channelCustomerLambdaQueryWrapper.ne(ChannelCustomer::getStatus,"3");
398
+        List<ChannelCustomer> channelCustomers = channelCustomerMapper.selectList(channelCustomerLambdaQueryWrapper);
399
+        List<ChannelCustomer> passCustomer = channelCustomers.stream().filter(e -> "2".equals(e.getStatus())).collect(Collectors.toList());
400
+        if (passCustomer.size() > 0) {
401
+            return ResponseBean.error("此用户已经被报备", ResponseBean.ERROR_UNAVAILABLE);
402
+        }
403
+
404
+        // 审核中的
405
+        for (ChannelCustomer customer : channelCustomers) {
406
+            // 过期时间
407
+            LocalDateTime expirDate = customer.getCreateDate().plusDays(buildingChannel.getExpirationDate());
408
+            LocalDateTime now = LocalDateTime.now();
409
+            if (now.isBefore(expirDate)) {
410
+                return ResponseBean.error("此用户已经被报备", ResponseBean.ERROR_UNAVAILABLE);
411
+            }
412
+        }
363 413
 
364 414
         // 入渠道推荐客户表
365 415
         ChannelCustomer channelCustomer = new ChannelCustomer();
@@ -370,10 +420,11 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
370 420
         channelCustomer.setSex(channelReportDTO.getSex());
371 421
         channelCustomer.setRecommendPerson(channelReportDTO.getRealtyChannel());
372 422
         channelCustomer.setCreateDate(LocalDateTime.now());
373
-        channelCustomer.setStatus("0");
423
+        channelCustomer.setStatus("1");
424
+        channelCustomer.setChannelId(taChannelPeople.getChannelId());
374 425
         channelCustomer.setOrgId(channelReportDTO.getOrgId());
375 426
         channelCustomerMapper.insert(channelCustomer);
376
-        return null;
427
+        return ResponseBean.success(channelCustomer);
377 428
     }
378 429
 
379 430
     private void fillSomeFieldsOfCustomer(TaRecommendCustomer customer, TaPerson recommender, LocalDateTime now) {

+ 18
- 66
src/main/java/com/yunzhi/marketing/xlk/controller/ChannelCustomerController.java 查看文件

@@ -1,12 +1,16 @@
1 1
 package com.yunzhi.marketing.xlk.controller;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
3 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 7
 import com.yunzhi.marketing.base.BaseController;
7 8
 import com.yunzhi.marketing.base.ResponseBean;
9
+import com.yunzhi.marketing.xlk.dto.ChannelCustomerDTO;
8 10
 import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
9 11
 import com.yunzhi.marketing.xlk.service.IChannelCustomerService;
12
+import io.swagger.annotations.Api;
13
+import io.swagger.annotations.ApiOperation;
10 14
 import org.slf4j.Logger;
11 15
 import org.slf4j.LoggerFactory;
12 16
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,7 +25,8 @@ import org.springframework.web.bind.annotation.*;
21 25
  * @since 2021-07-19
22 26
  */
23 27
 @RestController
24
-@RequestMapping("/")
28
+@RequestMapping("/api")
29
+@Api(value = "渠道报备客户表", tags = "xlk-渠道报备客户表")
25 30
 public class ChannelCustomerController extends BaseController {
26 31
 
27 32
     private final Logger logger = LoggerFactory.getLogger(ChannelCustomerController.class);
@@ -36,15 +41,17 @@ public class ChannelCustomerController extends BaseController {
36 41
      * @param pageSize
37 42
      * @return
38 43
      */
39
-    @RequestMapping(value="/channelCustomer",method= RequestMethod.GET)
44
+    @ApiOperation(value = "admin-渠道报备客户表", notes = "admin-渠道报备客户表")
45
+    @RequestMapping(value="/admin/channelCustomer",method= RequestMethod.GET)
40 46
     public ResponseBean channelCustomerList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
41 47
                                             @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
42 48
         ResponseBean responseBean = new ResponseBean();
43 49
         try {
44 50
             //使用分页插件
45 51
 		    IPage<ChannelCustomer> pg = new Page<>(pageNum, pageSize);
46
-            QueryWrapper<ChannelCustomer> queryWrapper = new QueryWrapper<>();
47
-            queryWrapper.orderByDesc("create_date");
52
+            LambdaQueryWrapper<ChannelCustomer> queryWrapper = new LambdaQueryWrapper<>();
53
+            queryWrapper.eq(ChannelCustomer::getStatus,"1");
54
+            queryWrapper.orderByDesc(ChannelCustomer::getCreateDate);
48 55
 
49 56
             IPage<ChannelCustomer> result = iChannelCustomerService.page(pg, queryWrapper);
50 57
             responseBean.addSuccess(result);
@@ -57,78 +64,23 @@ public class ChannelCustomerController extends BaseController {
57 64
     }
58 65
 
59 66
     /**
60
-     * 保存对象
61
-     * @param channelCustomer 实体对象
62
-     * @return
63
-     */
64
-    @RequestMapping(value="/channelCustomer",method= RequestMethod.POST)
65
-    public ResponseBean channelCustomerAdd(@RequestBody ChannelCustomer channelCustomer){
66
-        ResponseBean responseBean = new ResponseBean();
67
-        try {
68
-            if (iChannelCustomerService.save(channelCustomer)){
69
-                responseBean.addSuccess(channelCustomer);
70
-            }else {
71
-                responseBean.addError("fail");
72
-            }
73
-        }catch (Exception e){
74
-            e.printStackTrace();
75
-            logger.error("channelCustomerAdd -=- {}",e.toString());
76
-            responseBean.addError(e.getMessage());
77
-        }
78
-        return responseBean;
79
-    }
80
-
81
-    /**
82
-     * 根据id删除对象
83
-     * @param id  实体ID
84
-     */
85
-    @ResponseBody
86
-    @RequestMapping(value="/channelCustomer/{id}", method= RequestMethod.DELETE)
87
-    public ResponseBean channelCustomerDelete(@PathVariable Integer id){
88
-        ResponseBean responseBean = new ResponseBean();
89
-        try {
90
-            if(iChannelCustomerService.removeById(id)){
91
-                responseBean.addSuccess("success");
92
-            }else {
93
-                responseBean.addError("fail");
94
-            }
95
-        }catch (Exception e){
96
-            e.printStackTrace();
97
-            logger.error("channelCustomerDelete -=- {}",e.toString());
98
-            responseBean.addError(e.getMessage());
99
-        }
100
-        return responseBean;
101
-    }
102
-
103
-    /**
104
-     * 修改对象
67
+     * 审核
105 68
      * @param id  实体ID
106
-     * @param channelCustomer 实体对象
69
+     * @param channelCustomerDTO 实体对象
107 70
      * @return
108 71
      */
109
-    @RequestMapping(value="/channelCustomer/{id}",method= RequestMethod.PUT)
72
+    @ApiOperation(value = "admin-渠道报备客户审核", notes = "admin-渠道报备客户审核")
73
+    @RequestMapping(value="/admin/channelCustomer/{id}",method= RequestMethod.PUT)
110 74
     public ResponseBean channelCustomerUpdate(@PathVariable Integer id,
111
-                                        @RequestBody ChannelCustomer channelCustomer){
112
-        ResponseBean responseBean = new ResponseBean();
113
-        try {
114
-            if (iChannelCustomerService.updateById(channelCustomer)){
115
-                responseBean.addSuccess(channelCustomer);
116
-            }else {
117
-                responseBean.addError("fail");
118
-            }
119
-        }catch (Exception e){
120
-            e.printStackTrace();
121
-            logger.error("channelCustomerUpdate -=- {}",e.toString());
122
-            responseBean.addError(e.getMessage());
123
-        }
124
-        return responseBean;
75
+                                        @RequestBody ChannelCustomerDTO channelCustomerDTO){
76
+        return iChannelCustomerService.auditCustomer(id,channelCustomerDTO);
125 77
     }
126 78
 
127 79
     /**
128 80
      * 根据id查询对象
129 81
      * @param id  实体ID
130 82
      */
131
-    @RequestMapping(value="/channelCustomer/{id}",method= RequestMethod.GET)
83
+    @RequestMapping(value="/admin/channelCustomer/{id}",method= RequestMethod.GET)
132 84
     public ResponseBean channelCustomerGet(@PathVariable Integer id){
133 85
         ResponseBean responseBean = new ResponseBean();
134 86
         try {

+ 22
- 0
src/main/java/com/yunzhi/marketing/xlk/controller/CurriculumController.java 查看文件

@@ -253,4 +253,26 @@ public class CurriculumController extends BaseController {
253 253
         }
254 254
         return responseBean;
255 255
     }
256
+
257
+    /**
258
+     * 根据id查询对象
259
+     * @param id  实体ID
260
+     */
261
+    @ApiOperation(value = "wx-根据id查询课程表详情", notes = "wx-根据id查询课程表详情")
262
+    @RequestMapping(value="/wx/curriculum/{id}",method= RequestMethod.GET)
263
+    public ResponseBean curriculum(@PathVariable String id,
264
+                                      @RequestHeader("authorization") String token, HttpServletRequest request){
265
+        ResponseBean responseBean = new ResponseBean();
266
+        try {
267
+            Curriculum curriculum = iCurriculumService.getById(id);
268
+            curriculum.setLookNum(curriculum.getLookNum() + 1);
269
+            iCurriculumService.updateById(curriculum);
270
+            responseBean.addSuccess(curriculum);
271
+        }catch (Exception e){
272
+            e.printStackTrace();
273
+            logger.error("curriculumDelete -=- {}",e.toString());
274
+            responseBean.addError(e.getMessage());
275
+        }
276
+        return responseBean;
277
+    }
256 278
 }

+ 35
- 0
src/main/java/com/yunzhi/marketing/xlk/dto/ChannelCustomerDTO.java 查看文件

@@ -0,0 +1,35 @@
1
+package com.yunzhi.marketing.xlk.dto;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableName;
4
+import lombok.Data;
5
+import lombok.EqualsAndHashCode;
6
+import lombok.experimental.Accessors;
7
+
8
+import java.io.Serializable;
9
+import java.time.LocalDateTime;
10
+
11
+/**
12
+ * <p>
13
+ * 渠道报备客户表 
14
+ * </p>
15
+ *
16
+ * @author jobob
17
+ * @since 2021-07-19
18
+ */
19
+@Data
20
+@EqualsAndHashCode(callSuper = false)
21
+@Accessors(chain = true)
22
+@TableName("xlk_channel_customer")
23
+public class ChannelCustomerDTO implements Serializable {
24
+
25
+    /**
26
+     * 主键
27
+     */
28
+    private String channelCustomerId;
29
+
30
+    /**
31
+     * 审核结果 pass 通过  fail 失败
32
+     */
33
+    private String auditResult;
34
+
35
+}

+ 2
- 1
src/main/java/com/yunzhi/marketing/xlk/entity/ChannelCustomer.java 查看文件

@@ -1,6 +1,7 @@
1 1
 package com.yunzhi.marketing.xlk.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.TableName;
4
+import io.swagger.models.auth.In;
4 5
 import lombok.Data;
5 6
 import lombok.EqualsAndHashCode;
6 7
 import lombok.experimental.Accessors;
@@ -82,7 +83,7 @@ public class ChannelCustomer implements Serializable {
82 83
     /**
83 84
      * 渠道id
84 85
      */
85
-    private String channelId;
86
+    private Integer channelId;
86 87
 
87 88
 
88 89
 }

+ 9
- 0
src/main/java/com/yunzhi/marketing/xlk/service/IChannelCustomerService.java 查看文件

@@ -1,6 +1,8 @@
1 1
 package com.yunzhi.marketing.xlk.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.yunzhi.marketing.base.ResponseBean;
5
+import com.yunzhi.marketing.xlk.dto.ChannelCustomerDTO;
4 6
 import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
5 7
 
6 8
 /**
@@ -13,4 +15,11 @@ import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
13 15
  */
14 16
 public interface IChannelCustomerService extends IService<ChannelCustomer> {
15 17
 
18
+    /**
19
+     * 审核
20
+     * @param id
21
+     * @param channelCustomerDTO
22
+     * @return
23
+     */
24
+    ResponseBean auditCustomer(Integer id, ChannelCustomerDTO channelCustomerDTO);
16 25
 }

+ 54
- 0
src/main/java/com/yunzhi/marketing/xlk/service/impl/ChannelCustomerServiceImpl.java 查看文件

@@ -1,11 +1,20 @@
1 1
 package com.yunzhi.marketing.xlk.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
3 4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
+import com.yunzhi.marketing.base.ResponseBean;
6
+import com.yunzhi.marketing.common.StringUtils;
7
+import com.yunzhi.marketing.entity.TaRecommendCustomer;
8
+import com.yunzhi.marketing.mapper.TaRecommendCustomerMapper;
9
+import com.yunzhi.marketing.xlk.dto.ChannelCustomerDTO;
4 10
 import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
5 11
 import com.yunzhi.marketing.xlk.mapper.ChannelCustomerMapper;
6 12
 import com.yunzhi.marketing.xlk.service.IChannelCustomerService;
13
+import org.springframework.beans.factory.annotation.Autowired;
7 14
 import org.springframework.stereotype.Service;
8 15
 
16
+import java.util.List;
17
+
9 18
 /**
10 19
  * <p>
11 20
  * 渠道报备客户表  服务实现类
@@ -17,4 +26,49 @@ import org.springframework.stereotype.Service;
17 26
 @Service
18 27
 public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMapper, ChannelCustomer> implements IChannelCustomerService {
19 28
 
29
+    @Autowired
30
+    private ChannelCustomerMapper channelCustomerMapper;
31
+
32
+    @Autowired
33
+    private TaRecommendCustomerMapper taRecommendCustomerMapper;
34
+
35
+    /**
36
+     * 审核
37
+     *
38
+     * @param id
39
+     * @param channelCustomerDTO
40
+     * @return
41
+     */
42
+    @Override
43
+    public ResponseBean auditCustomer(Integer id, ChannelCustomerDTO channelCustomerDTO) {
44
+        ChannelCustomer customer = channelCustomerMapper.selectById(id);
45
+        if ("fail".equals(channelCustomerDTO.getAuditResult())){
46
+            // 审核不通过
47
+            customer.setStatus("3");
48
+            channelCustomerMapper.updateById(customer);
49
+            return ResponseBean.success("审核成功");
50
+        }
51
+
52
+        // 审核通过 先查看在ta_recommend_customer 手机号是否存在
53
+        LambdaQueryWrapper<TaRecommendCustomer> queryWrapper = new LambdaQueryWrapper<>();
54
+        queryWrapper.eq(TaRecommendCustomer::getPhone,customer.getPhone());
55
+        queryWrapper.eq(TaRecommendCustomer::getBuildingId,customer.getBuildingId());
56
+        TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.selectOne(queryWrapper);
57
+        if (null == taRecommendCustomer) {
58
+            // 审核通过
59
+            customer.setStatus("2");
60
+            channelCustomerMapper.updateById(customer);
61
+            return ResponseBean.success("审核成功");
62
+        }
63
+
64
+        if (StringUtils.isEmpty(taRecommendCustomer.getRealtyConsultant()) &&
65
+                (StringUtils.isEmpty(taRecommendCustomer.getRecommendPerson()) || taRecommendCustomer.getRecommendPerson().equals(customer.getRecommendPerson()))){
66
+            // 审核通过
67
+            customer.setStatus("2");
68
+            channelCustomerMapper.updateById(customer);
69
+            return ResponseBean.success("审核成功");
70
+        }
71
+
72
+        return ResponseBean.error("此客户是私客或已被报备", ResponseBean.ERROR_UNAVAILABLE);
73
+    }
20 74
 }