Your Name 3 年之前
父節點
當前提交
6dd3f377c6

+ 6
- 0
src/main/java/com/yunzhi/marketing/entity/TaBuilding.java 查看文件

@@ -77,6 +77,12 @@ public class TaBuilding implements Serializable {
77 77
      */
78 78
     private String dynamic;
79 79
 
80
+    /**
81
+     * 有效期
82
+     */
83
+    private Integer expirationDate;
84
+
85
+
80 86
     /**
81 87
      * 电话
82 88
      */

+ 21
- 0
src/main/java/com/yunzhi/marketing/po/MineRecommendCustomerPO.java 查看文件

@@ -0,0 +1,21 @@
1
+package com.yunzhi.marketing.po;
2
+
3
+import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
4
+import lombok.Data;
5
+
6
+import java.time.LocalDateTime;
7
+
8
+@Data
9
+public class MineRecommendCustomerPO extends ChannelCustomer {
10
+
11
+    private String avatarurl;
12
+
13
+    private String type;
14
+
15
+    private String customerStatus;
16
+
17
+    /**
18
+     * 过了保护期的时间
19
+     */
20
+    private Integer expirationDate;
21
+}

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

@@ -3,7 +3,9 @@ package com.yunzhi.marketing.xlk.controller;
3 3
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4 4
 import com.yunzhi.marketing.base.BaseController;
5 5
 import com.yunzhi.marketing.base.ResponseBean;
6
+import com.yunzhi.marketing.entity.TaBuilding;
6 7
 import com.yunzhi.marketing.entity.TaPerson;
8
+import com.yunzhi.marketing.service.ITaBuildingService;
7 9
 import com.yunzhi.marketing.service.ITaPersonService;
8 10
 import com.yunzhi.marketing.xlk.dto.BuildingChannelDTO;
9 11
 import com.yunzhi.marketing.xlk.dto.MarkingChannelCustomerDTO;
@@ -44,6 +46,9 @@ public class BuildingChannelController extends BaseController {
44 46
     @Autowired
45 47
     ITaPersonService iTaPersonService;
46 48
 
49
+    @Autowired
50
+    private ITaBuildingService taBuildingService;
51
+
47 52
     /**
48 53
      * 保存对象
49 54
      * @param buildingChannelDTO 实体对象
@@ -113,6 +118,11 @@ public class BuildingChannelController extends BaseController {
113 118
             buildingChannelList.add(buildingChannel);
114 119
         });
115 120
 
121
+        // 楼盘中冗余一份
122
+        TaBuilding building = taBuildingService.getById(buildingChannelDTO.getBuildingId());
123
+        building.setExpirationDate(buildingChannelDTO.getExpirationDate());
124
+        taBuildingService.updateById(building);
125
+
116 126
         return iBuildingChannelService.saveBatch(buildingChannelList);
117 127
     }
118 128
 

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

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
6 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7 7
 import com.yunzhi.marketing.base.BaseController;
8 8
 import com.yunzhi.marketing.base.ResponseBean;
9
+import com.yunzhi.marketing.entity.TaPerson;
10
+import com.yunzhi.marketing.service.ITaPersonService;
9 11
 import com.yunzhi.marketing.xlk.dto.*;
10 12
 import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
11 13
 import com.yunzhi.marketing.xlk.service.IChannelCustomerService;
@@ -14,9 +16,11 @@ import io.swagger.annotations.ApiOperation;
14 16
 import org.slf4j.Logger;
15 17
 import org.slf4j.LoggerFactory;
16 18
 import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.format.annotation.DateTimeFormat;
17 20
 import org.springframework.web.bind.annotation.*;
18 21
 
19 22
 import javax.servlet.http.HttpServletRequest;
23
+import java.time.LocalDateTime;
20 24
 
21 25
 /**
22 26
  * <p>
@@ -36,6 +40,9 @@ public class ChannelCustomerController extends BaseController {
36 40
     @Autowired
37 41
     public IChannelCustomerService iChannelCustomerService;
38 42
 
43
+    @Autowired
44
+    private ITaPersonService taPersonService;
45
+
39 46
 
40 47
     /**
41 48
      * 分页查询列表
@@ -170,20 +177,48 @@ public class ChannelCustomerController extends BaseController {
170 177
         return responseBean;
171 178
     }
172 179
 
180
+
173 181
     /**
174 182
      * 根据id查询对象
175 183
      * @param id  实体ID
176 184
      */
177 185
     @RequestMapping(value="/wx/channelCustomer/{id}",method= RequestMethod.GET)
178
-    public ResponseBean wxGetCust(@PathVariable String id){
186
+    public ResponseBean wxGetCust(@PathVariable String id) {
179 187
         ResponseBean responseBean = new ResponseBean();
180 188
         try {
181 189
             responseBean.addSuccess(iChannelCustomerService.getById(id));
182
-        }catch (Exception e){
190
+        } catch (Exception e) {
183 191
             e.printStackTrace();
184
-            logger.error("channelCustomerDelete -=- {}",e.toString());
192
+            logger.error("channelCustomerDelete -=- {}", e.toString());
185 193
             responseBean.addError(e.getMessage());
186 194
         }
187 195
         return responseBean;
188 196
     }
197
+
198
+
199
+    @ApiOperation(value = "森哥看这里-wx-查询经纪人的我的客户列表", notes = "森哥看这里-wx-查询经纪人的我的客户列表")
200
+    @GetMapping("/wx/channelCustomer/recommend/mine")
201
+    public ResponseBean getWxCustomersIRecommended(@RequestParam int pageNumber, @RequestParam int pageSize,
202
+                                                   @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startDate,
203
+                                                   @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime endDate,
204
+                                                   @RequestParam(value = "status", required = false) Integer status,
205
+                                                   @RequestParam(value = "name", required = false) String name,
206
+                                                   HttpServletRequest request) {
207
+        Integer orgId = getOrgId(request);
208
+        String personId = getPersonId(request);
209
+        TaPerson person = taPersonService.getById(personId);
210
+        try {
211
+            RecommendCustomerDTO recommendCustomerDTO = new RecommendCustomerDTO();
212
+            recommendCustomerDTO.setEndDate(endDate);
213
+            recommendCustomerDTO.setStartDate(startDate);
214
+            recommendCustomerDTO.setOrgId(orgId);
215
+            recommendCustomerDTO.setPersonId(personId);
216
+            recommendCustomerDTO.setStatus(status);
217
+            recommendCustomerDTO.setName(name);
218
+            return iChannelCustomerService.getCustomersIRecommended(pageNumber, pageSize, recommendCustomerDTO);
219
+        } catch (Exception e) {
220
+            e.printStackTrace();
221
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
222
+        }
223
+    }
189 224
 }

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

@@ -49,6 +49,7 @@ public class ChannelCustomerStatisticsController extends BaseController {
49 49
         statisticsDTo.setBuildingId(buildingId);
50 50
         statisticsDTo.setStartDate(startDate);
51 51
         statisticsDTo.setEndDate(endDate);
52
+        statisticsDTo.setOrgId(orgId);
52 53
         statisticsDTo.setPersonId(person.getPersonId());
53 54
         return  channelCustomerStatisticsService.getRanklist(statisticsDTo);
54 55
     }

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

@@ -0,0 +1,21 @@
1
+package com.yunzhi.marketing.xlk.dto;
2
+
3
+import lombok.Data;
4
+
5
+import java.time.LocalDateTime;
6
+
7
+@Data
8
+public class RecommendCustomerDTO {
9
+
10
+    private String personId;
11
+
12
+    private Integer orgId;
13
+
14
+    private LocalDateTime startDate;
15
+
16
+    private LocalDateTime endDate;
17
+
18
+    private Integer status;
19
+
20
+    private String name;
21
+}

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

@@ -34,11 +34,27 @@ public class ChannelCustomer implements Serializable {
34 34
     @TableId(value = "channel_customer_id", type = IdType.UUID)
35 35
     private String channelCustomerId;
36 36
 
37
+    /**
38
+     * 客户id
39
+     */
40
+    private String customerId;
41
+
37 42
     /**
38 43
      * 创建时间
39 44
      */
40 45
     private LocalDateTime createDate;
41 46
 
47
+    /**
48
+     * 到访时间
49
+     */
50
+    private LocalDateTime visitDate ;
51
+    /** 认筹时间 */
52
+    private LocalDateTime preparatoryDate ;
53
+    /** 签约时间 */
54
+    private LocalDateTime signedDate ;
55
+    /** 结佣时间 */
56
+    private LocalDateTime commissionDate ;
57
+
42 58
     /**
43 59
      * 公司id
44 60
      */
@@ -96,6 +112,16 @@ public class ChannelCustomer implements Serializable {
96 112
      */
97 113
     private Integer channelId;
98 114
 
115
+    /**
116
+     * 置业顾问
117
+     */
118
+    private String realtyConsultant;
119
+
120
+    /**
121
+     * 备注
122
+     */
123
+    private String remark;
124
+
99 125
     /**
100 126
      * 推荐人姓名
101 127
      */

+ 5
- 0
src/main/java/com/yunzhi/marketing/xlk/mapper/ChannelCustomerMapper.java 查看文件

@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.yunzhi.marketing.dto.StatisticsDTO;
6 6
 import com.yunzhi.marketing.po.CustomerRankListVO;
7
+import com.yunzhi.marketing.po.MineRecommendCustomerPO;
8
+import com.yunzhi.marketing.po.TaRecommendCustomerPO;
9
+import com.yunzhi.marketing.xlk.dto.RecommendCustomerDTO;
7 10
 import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
8 11
 import org.apache.ibatis.annotations.Mapper;
9 12
 import org.apache.ibatis.annotations.Param;
@@ -31,4 +34,6 @@ public interface ChannelCustomerMapper extends BaseMapper<ChannelCustomer> {
31 34
                                           @Param("status") String status,@Param("type") String type);
32 35
 
33 36
     List<CustomerRankListVO> getRanklist(@Param("params") StatisticsDTO statisticsDTo);
37
+
38
+    IPage<MineRecommendCustomerPO>  getCustomersIRecommended(IPage<MineRecommendCustomerPO> page,@Param("params") RecommendCustomerDTO recommendCustomerDTO);
34 39
 }

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

@@ -69,4 +69,13 @@ public interface IChannelCustomerService extends IService<ChannelCustomer> {
69 69
      * @return
70 70
      */
71 71
     ResponseBean signatoryCustomer(MarkingSignatoryCustomerDTO params);
72
+
73
+    /**
74
+     * 查询经纪人的我的客户列表
75
+     * @param pageNumber
76
+     * @param pageSize
77
+     * @param recommendCustomerDTO
78
+     * @return
79
+     */
80
+    ResponseBean getCustomersIRecommended(int pageNumber, int pageSize, RecommendCustomerDTO recommendCustomerDTO);
72 81
 }

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

@@ -2,12 +2,15 @@ package com.yunzhi.marketing.xlk.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6 7
 import com.yunzhi.marketing.base.ResponseBean;
7 8
 import com.yunzhi.marketing.common.CommConstant;
8 9
 import com.yunzhi.marketing.common.StringUtils;
9 10
 import com.yunzhi.marketing.entity.TaRecommendCustomer;
10 11
 import com.yunzhi.marketing.mapper.TaRecommendCustomerMapper;
12
+import com.yunzhi.marketing.po.MineRecommendCustomerPO;
13
+import com.yunzhi.marketing.po.TaRecommendCustomerPO;
11 14
 import com.yunzhi.marketing.xlk.dto.*;
12 15
 import com.yunzhi.marketing.xlk.entity.*;
13 16
 import com.yunzhi.marketing.xlk.mapper.*;
@@ -65,9 +68,6 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
65 68
         queryWrapper.eq(TaRecommendCustomer::getBuildingId,customer.getBuildingId());
66 69
         TaRecommendCustomer recommendCustomer = taRecommendCustomerMapper.selectOne(queryWrapper);
67 70
         if (null == recommendCustomer) {
68
-            // 审核通过
69
-            customer.setStatus("2");
70
-            channelCustomerMapper.updateById(customer);
71 71
             // 进业务客户表
72 72
             TaRecommendCustomer taRecommendCustomer = new TaRecommendCustomer();
73 73
             taRecommendCustomer.setName(customer.getName());
@@ -87,6 +87,11 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
87 87
             taRecommendCustomer.setRealtyConsultant(channelCustomerDTO.getRealtyConsultant());
88 88
             taRecommendCustomer.setCirculationTime(LocalDateTime.now());
89 89
             taRecommendCustomerMapper.insert(taRecommendCustomer);
90
+            // 审核通过
91
+            customer.setStatus("2");
92
+            customer.setCustomerId(taRecommendCustomer.getCustomerId());
93
+            customer.setVisitDate(LocalDateTime.now());
94
+            channelCustomerMapper.updateById(customer);
90 95
             return ResponseBean.success("审核成功");
91 96
         }
92 97
 
@@ -94,6 +99,8 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
94 99
                 (StringUtils.isEmpty(recommendCustomer.getRecommendPerson()) || recommendCustomer.getRecommendPerson().equals(customer.getRecommendPerson()))){
95 100
             // 审核通过
96 101
             customer.setStatus("2");
102
+            customer.setCustomerId(recommendCustomer.getCustomerId());
103
+            customer.setVisitDate(LocalDateTime.now());
97 104
             channelCustomerMapper.updateById(customer);
98 105
             return ResponseBean.success("审核成功");
99 106
         }
@@ -119,9 +126,6 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
119 126
             queryWrapper.eq(TaRecommendCustomer::getBuildingId,customer.getBuildingId());
120 127
             TaRecommendCustomer recommendCustomer = taRecommendCustomerMapper.selectOne(queryWrapper);
121 128
             if (null == recommendCustomer) {
122
-                // 审核通过
123
-                customer.setStatus("2");
124
-                channelCustomerMapper.updateById(customer);
125 129
                 // 进业务客户表
126 130
                 TaRecommendCustomer taRecommendCustomer = new TaRecommendCustomer();
127 131
                 taRecommendCustomer.setName(customer.getName());
@@ -141,10 +145,18 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
141 145
                 taRecommendCustomer.setRealtyConsultant(params.getRealtyConsultant());
142 146
                 taRecommendCustomer.setCirculationTime(LocalDateTime.now());
143 147
                 taRecommendCustomerMapper.insert(taRecommendCustomer);
148
+
149
+                // 审核通过
150
+                customer.setStatus("2");
151
+                customer.setVisitDate(LocalDateTime.now());
152
+                customer.setCustomerId(taRecommendCustomer.getCustomerId());
153
+                channelCustomerMapper.updateById(customer);
144 154
             }else if (StringUtils.isEmpty(recommendCustomer.getRealtyConsultant()) &&
145 155
                     (StringUtils.isEmpty(recommendCustomer.getRecommendPerson()) || recommendCustomer.getRecommendPerson().equals(customer.getRecommendPerson()))){
146 156
                 // 审核通过
147 157
                 customer.setStatus("2");
158
+                customer.setVisitDate(LocalDateTime.now());
159
+                customer.setCustomerId(recommendCustomer.getCustomerId());
148 160
                 channelCustomerMapper.updateById(customer);
149 161
 
150 162
                 // 修改状态为确认到访状态
@@ -234,6 +246,11 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
234 246
         taRecommendCustomer.setStatus(CommConstant.CUSTOMER_PREPARATORY);
235 247
         taRecommendCustomerMapper.updateById(taRecommendCustomer);
236 248
 
249
+        LambdaQueryWrapper<ChannelCustomer> channelCustomerLambdaQueryWrapper = new LambdaQueryWrapper<>();
250
+        channelCustomerLambdaQueryWrapper.eq(ChannelCustomer::getCustomerId,params.getCustomerId());
251
+        ChannelCustomer customer = channelCustomerMapper.selectOne(channelCustomerLambdaQueryWrapper);
252
+        customer.setPreparatoryDate(LocalDateTime.now());
253
+
237 254
         CustomerPreparatory customerPreparatory = params.getCustomerPreparatory();
238 255
         customerPreparatory.setCreateDate(LocalDateTime.now());
239 256
         customerPreparatoryMapper.insert(customerPreparatory);
@@ -251,6 +268,12 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
251 268
         TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.selectById(params.getCustomerId());
252 269
         taRecommendCustomer.setStatus(CommConstant.CUSTOMER_COMMISSION);
253 270
         taRecommendCustomerMapper.updateById(taRecommendCustomer);
271
+
272
+        LambdaQueryWrapper<ChannelCustomer> channelCustomerLambdaQueryWrapper = new LambdaQueryWrapper<>();
273
+        channelCustomerLambdaQueryWrapper.eq(ChannelCustomer::getCustomerId,params.getCustomerId());
274
+        ChannelCustomer customer = channelCustomerMapper.selectOne(channelCustomerLambdaQueryWrapper);
275
+        customer.setCommissionDate(LocalDateTime.now());
276
+
254 277
         return ResponseBean.success("审核成功");
255 278
     }
256 279
 
@@ -266,9 +289,29 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
266 289
         taRecommendCustomer.setStatus(CommConstant.CUSTOMER_SIGNED);
267 290
         taRecommendCustomerMapper.updateById(taRecommendCustomer);
268 291
 
292
+        LambdaQueryWrapper<ChannelCustomer> channelCustomerLambdaQueryWrapper = new LambdaQueryWrapper<>();
293
+        channelCustomerLambdaQueryWrapper.eq(ChannelCustomer::getCustomerId,params.getCustomerId());
294
+        ChannelCustomer customer = channelCustomerMapper.selectOne(channelCustomerLambdaQueryWrapper);
295
+        customer.setSignedDate(LocalDateTime.now());
296
+
269 297
         CustomerSignatory customerSignatory = params.getCustomerSignatory();
270 298
         customerSignatory.setCreateDate(LocalDateTime.now());
271 299
         customerSignatoryMapper.insert(customerSignatory);
272 300
         return ResponseBean.success("审核成功");
273 301
     }
302
+
303
+    /**
304
+     * 查询经纪人的我的客户列表
305
+     *
306
+     * @param pageNumber
307
+     * @param pageSize
308
+     * @param recommendCustomerDTO
309
+     * @return
310
+     */
311
+    @Override
312
+    public ResponseBean getCustomersIRecommended(int pageNumber, int pageSize, RecommendCustomerDTO recommendCustomerDTO) {
313
+        IPage<MineRecommendCustomerPO> page = new Page<MineRecommendCustomerPO>(pageNumber, pageSize);
314
+        IPage<MineRecommendCustomerPO> customersIRecommended = channelCustomerMapper.getCustomersIRecommended(page, recommendCustomerDTO);
315
+        return ResponseBean.success(customersIRecommended);
316
+    }
274 317
 }

+ 33
- 1
src/main/resources/mapper/xlk/ChannelCustomerMapper.xml 查看文件

@@ -53,7 +53,7 @@
53 53
             xlk_channel_customer t
54 54
         LEFT JOIN ta_person p on t.recommend_person = p.person_id
55 55
         WHERE t.channel_id  = #{params.channelId}
56
-        and `status` = 2
56
+        and `status` != 3
57 57
         <if test="params.startDate != null or params.endDate != null">
58 58
             AND t.create_date BETWEEN #{params.startDate} and #{params.endDate}
59 59
         </if>
@@ -64,4 +64,36 @@
64 64
         ORDER BY number desc
65 65
         LIMIT 3
66 66
     </select>
67
+
68
+    <select id="getCustomersIRecommended" resultType="com.yunzhi.marketing.po.MineRecommendCustomerPO">
69
+        SELECT
70
+            a.*,
71
+            b.avatarurl ,
72
+            ifnull(c.`status`, 1) as customer_status,
73
+            if(c.customer_id is null, "report", "customer") as type,
74
+            d.expiration_date
75
+        FROM
76
+            xlk_channel_customer a
77
+        LEFT JOIN ta_person b ON a.person_id = b.person_id
78
+        left join ta_recommend_customer c on a.customer_id = c.customer_id
79
+        LEFT JOIN ta_building d on a.building_id = d.building_id
80
+        WHERE
81
+        a.recommend_person = #{params.personId}
82
+        and a.`status` != 3
83
+        and a.org_id = #{params.orgId}
84
+        <if test="params.status != null and params.status !=''">
85
+            and c.status = #{params.status}
86
+        </if>
87
+        <if test="params.name != null and params.name !=''">
88
+            and a.name like CONCAT('%',#{params.name}, '%')
89
+        </if>
90
+        <if test="params.startDate != null and params.startDate != null">
91
+            AND a.create_date >= #{params.startDate}
92
+        </if>
93
+        <if test="params.endDate != null and params.endDate != null">
94
+            AND (a.visit_date &lt;= #{params.endDate} or a.preparatory_date &lt;= #{params.endDate} or a.signed_date &lt;= #{params.endDate} or a.commission_date &lt;= #{params.endDate})
95
+        </if>
96
+        ORDER BY
97
+        a.create_date desc
98
+    </select>
67 99
 </mapper>