|
@@ -8,11 +8,15 @@ import com.huiju.estateagents.base.ResponseBean;
|
8
|
8
|
import com.huiju.estateagents.common.CommConstant;
|
9
|
9
|
import com.huiju.estateagents.common.JWTUtils;
|
10
|
10
|
import com.huiju.estateagents.common.StringUtils;
|
|
11
|
+import com.huiju.estateagents.entity.TaChannel;
|
|
12
|
+import com.huiju.estateagents.entity.TaChannelPerson;
|
11
|
13
|
import com.huiju.estateagents.entity.TaPerson;
|
12
|
14
|
import com.huiju.estateagents.entity.TaRecommendCustomer;
|
13
|
15
|
import com.huiju.estateagents.event.EventBus;
|
14
|
16
|
import com.huiju.estateagents.service.ITaPersonService;
|
15
|
17
|
import com.huiju.estateagents.service.ITaRecommendCustomerService;
|
|
18
|
+import com.huiju.estateagents.service.TaChannelPersonService;
|
|
19
|
+import com.huiju.estateagents.service.TaChannelService;
|
16
|
20
|
import org.springframework.beans.factory.annotation.Autowired;
|
17
|
21
|
import org.springframework.context.ApplicationContext;
|
18
|
22
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -21,6 +25,7 @@ import com.huiju.estateagents.base.BaseController;
|
21
|
25
|
|
22
|
26
|
import javax.annotation.Resource;
|
23
|
27
|
import javax.servlet.http.HttpServletRequest;
|
|
28
|
+import java.time.LocalDateTime;
|
24
|
29
|
import java.util.List;
|
25
|
30
|
|
26
|
31
|
/**
|
|
@@ -44,6 +49,12 @@ public class TaRecommendCustomerController extends BaseController {
|
44
|
49
|
@Resource
|
45
|
50
|
private ApplicationContext applicationContext;
|
46
|
51
|
|
|
52
|
+ @Autowired
|
|
53
|
+ private TaChannelService taChannelService;
|
|
54
|
+
|
|
55
|
+ @Autowired
|
|
56
|
+ private TaChannelPersonService taChannelPersonService;
|
|
57
|
+
|
47
|
58
|
/**
|
48
|
59
|
* 我的客户列表
|
49
|
60
|
* @param pageNumber
|
|
@@ -132,9 +143,61 @@ public class TaRecommendCustomerController extends BaseController {
|
132
|
143
|
}
|
133
|
144
|
|
134
|
145
|
@GetMapping("/wx/customer/myReport")
|
135
|
|
- public ResponseBean getCustomerIReport (@RequestParam(value ="personId") String personId,
|
|
146
|
+ public ResponseBean getCustomerIReport (HttpServletRequest request,
|
136
|
147
|
@RequestParam(value ="pageNumber",defaultValue = "1") Integer pageNumber,
|
137
|
148
|
@RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
|
149
|
+ String openid = JWTUtils.getSubject(request);
|
|
150
|
+ List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
|
151
|
+ if (null == taPersons || taPersons.size() != 1) {
|
|
152
|
+ return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
153
|
+ }
|
|
154
|
+ TaPerson person = taPersons.get(0);
|
|
155
|
+ try{
|
|
156
|
+ IPage<TaRecommendCustomer>pg = new Page<>(pageNumber,pageSize);
|
|
157
|
+ QueryWrapper<TaRecommendCustomer>queryWrapper = new QueryWrapper<>();
|
|
158
|
+ queryWrapper.eq("realty_consultant",person.getPersonId());
|
|
159
|
+ queryWrapper.eq("report_recommend_status",CommConstant.REPORTED);
|
|
160
|
+ queryWrapper.eq("status",CommConstant.CUSTOMER_REPORT);
|
|
161
|
+ queryWrapper.orderByDesc("create_date");
|
|
162
|
+ IPage<TaRecommendCustomer>result = taRecommendCustomerService.page(pg,queryWrapper);
|
|
163
|
+ return ResponseBean.success(result);
|
|
164
|
+ }catch (Exception e){
|
|
165
|
+ e.printStackTrace();
|
|
166
|
+ return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
|
|
167
|
+ }
|
|
168
|
+ }
|
|
169
|
+
|
|
170
|
+ @GetMapping("/wx/customer/myCustomer")
|
|
171
|
+ public ResponseBean getMyCustomer ( @RequestParam(value ="pageNumber",defaultValue = "1") Integer pageNumber,
|
|
172
|
+ @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
173
|
+ HttpServletRequest request){
|
|
174
|
+ String openid = JWTUtils.getSubject(request);
|
|
175
|
+ List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
|
176
|
+ if (null == taPersons || taPersons.size() != 1) {
|
|
177
|
+ return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
178
|
+ }
|
|
179
|
+ TaPerson person = taPersons.get(0);
|
|
180
|
+
|
|
181
|
+ try{
|
|
182
|
+ IPage<TaRecommendCustomer>pg = new Page<>(pageNumber,pageSize);
|
|
183
|
+ QueryWrapper<TaRecommendCustomer>queryWrapper = new QueryWrapper<>();
|
|
184
|
+ queryWrapper.eq("realty_consultant",person.getPersonId());
|
|
185
|
+ queryWrapper.eq("report_recommend_status",CommConstant.REPORTED);
|
|
186
|
+ queryWrapper.gt("status",CommConstant.CUSTOMER_REPORT);
|
|
187
|
+ queryWrapper.orderByDesc("create_date");
|
|
188
|
+ IPage<TaRecommendCustomer>result = taRecommendCustomerService.page(pg,queryWrapper);
|
|
189
|
+ return ResponseBean.success(result);
|
|
190
|
+ }catch (Exception e){
|
|
191
|
+ e.printStackTrace();
|
|
192
|
+ return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
|
|
193
|
+ }
|
|
194
|
+ }
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+ @GetMapping("/wx/customer/myInviteAgent")
|
|
198
|
+ public ResponseBean getMyInviteAgent (@RequestParam(value ="personId") String personId,
|
|
199
|
+ @RequestParam(value ="pageNumber",defaultValue = "1") Integer pageNumber,
|
|
200
|
+ @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
138
|
201
|
try{
|
139
|
202
|
IPage<TaRecommendCustomer>pg = new Page<>(pageNumber,pageSize);
|
140
|
203
|
QueryWrapper<TaRecommendCustomer>queryWrapper = new QueryWrapper<>();
|
|
@@ -149,6 +212,7 @@ public class TaRecommendCustomerController extends BaseController {
|
149
|
212
|
}
|
150
|
213
|
}
|
151
|
214
|
|
|
215
|
+
|
152
|
216
|
// 客户列表 公客/私客
|
153
|
217
|
@GetMapping("/admin/customer/recommend")
|
154
|
218
|
public ResponseBean getCustomerList (@RequestParam(value ="name",required = false) String name,
|
|
@@ -237,16 +301,88 @@ public class TaRecommendCustomerController extends BaseController {
|
237
|
301
|
|
238
|
302
|
|
239
|
303
|
@GetMapping("/admin/customer/recommend/{customerId}")
|
240
|
|
- public ResponseBean getCustomersIRecommended (@RequestParam int pageNumber, @RequestParam int pageSize, @PathVariable String customerId){
|
241
|
|
- String buildingId="";
|
|
304
|
+ public ResponseBean getCustomersIRecommended (@RequestParam int pageNumber, @RequestParam int pageSize, @PathVariable String customerId,HttpServletRequest request){
|
|
305
|
+ Integer orgId = getOrgId(request);
|
|
306
|
+ try{
|
|
307
|
+ return ResponseBean.success(taRecommendCustomerService.getCustomersIRecommended(pageNumber,pageSize,customerId,orgId));
|
|
308
|
+ }catch (Exception e){
|
|
309
|
+ e.printStackTrace();
|
|
310
|
+ return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
|
|
311
|
+ }
|
|
312
|
+ }
|
|
313
|
+
|
|
314
|
+ @GetMapping("/wx/customer/recommend/{customerId}")
|
|
315
|
+ public ResponseBean getWxCustomersIRecommended (@RequestParam int pageNumber, @RequestParam int pageSize,HttpServletRequest request){
|
|
316
|
+ Integer orgId =getOrgId(request);
|
|
317
|
+ String openid = JWTUtils.getSubject(request);
|
|
318
|
+ List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
|
319
|
+ if (null == taPersons || taPersons.size() != 1) {
|
|
320
|
+ return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
321
|
+ }
|
|
322
|
+ TaPerson person = taPersons.get(0);
|
242
|
323
|
try{
|
243
|
|
- return ResponseBean.success(taRecommendCustomerService.getCustomersIRecommended(pageNumber,pageSize,customerId,buildingId));
|
|
324
|
+ return ResponseBean.success(taRecommendCustomerService.getCustomersIRecommended(pageNumber,pageSize,person.getPersonId(),orgId));
|
244
|
325
|
}catch (Exception e){
|
245
|
326
|
e.printStackTrace();
|
246
|
327
|
return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
|
247
|
328
|
}
|
248
|
329
|
}
|
249
|
330
|
|
|
331
|
+ /**
|
|
332
|
+ * 修改对象
|
|
333
|
+ * @param channelCode 渠道码
|
|
334
|
+ * @return
|
|
335
|
+ */
|
|
336
|
+ @RequestMapping(value="/wx/customer/recommend/beComeChannel/{channelCode}",method= RequestMethod.PUT)
|
|
337
|
+ public ResponseBean taRecommendAgentBecomeChannel(@PathVariable String channelCode,HttpServletRequest request,@RequestParam("personType")String personType){
|
|
338
|
+ ResponseBean responseBean = new ResponseBean();
|
|
339
|
+ String openid = JWTUtils.getSubject(request);
|
|
340
|
+ List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
|
341
|
+ if (null == taPersons || taPersons.size() != 1) {
|
|
342
|
+ return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
343
|
+ }
|
|
344
|
+ TaPerson person = taPersons.get(0);
|
|
345
|
+ try {
|
|
346
|
+ if(CommConstant.PERSON_ESTATE_CHANNEL.equals(personType)){
|
|
347
|
+ QueryWrapper<TaChannel>channelQueryWrapper = new QueryWrapper<>();
|
|
348
|
+ channelQueryWrapper.eq("channel_code",channelCode);
|
|
349
|
+ QueryWrapper<TaChannelPerson>channelPersonQueryWrapper = new QueryWrapper<>();
|
|
350
|
+ TaChannel channel = taChannelService.getOne(channelQueryWrapper);
|
|
351
|
+ channelPersonQueryWrapper.eq("person_id",person.getPersonId());
|
|
352
|
+ channelPersonQueryWrapper.eq("channel_id",channel.getChannelId());
|
|
353
|
+ Integer count = taChannelPersonService.count(channelPersonQueryWrapper);
|
|
354
|
+ if(count >0){
|
|
355
|
+ return ResponseBean.error("您已绑定过渠道",ResponseBean.ERROR_UNAVAILABLE);
|
|
356
|
+ }
|
|
357
|
+ TaChannelPerson channelPerson = new TaChannelPerson();
|
|
358
|
+ channelPerson.setCreateDate(LocalDateTime.now());
|
|
359
|
+ channelPerson.setPersonId(person.getPersonId());
|
|
360
|
+ channelPerson.setChannelId(channel.getChannelId());
|
|
361
|
+ taChannelPersonService.save(channelPerson);
|
|
362
|
+ }else {
|
|
363
|
+ QueryWrapper<TaChannelPerson>channelPersonQueryWrapper = new QueryWrapper<>();
|
|
364
|
+ channelPersonQueryWrapper.eq("person_id",person.getPersonId());
|
|
365
|
+ List<TaChannelPerson> taChannelPerson = taChannelPersonService.list(channelPersonQueryWrapper);
|
|
366
|
+ if (taChannelPerson.size()>0){
|
|
367
|
+ for(int i=0;i<taChannelPerson.size();i++){
|
|
368
|
+ taChannelPerson.get(i).setStatus(CommConstant.STATUS_DELETE);
|
|
369
|
+ }
|
|
370
|
+ taChannelPersonService.updateBatchById(taChannelPerson);
|
|
371
|
+ }
|
|
372
|
+ }
|
|
373
|
+ person.setPersonType(personType);
|
|
374
|
+ if (taPersonService.updateById(person)){
|
|
375
|
+ responseBean.addSuccess(person);
|
|
376
|
+ }else {
|
|
377
|
+ responseBean.addError("fail");
|
|
378
|
+ }
|
|
379
|
+ }catch (Exception e){
|
|
380
|
+ e.printStackTrace();
|
|
381
|
+ responseBean.addError(e.getMessage());
|
|
382
|
+ }
|
|
383
|
+ return responseBean;
|
|
384
|
+ }
|
|
385
|
+
|
250
|
386
|
/**
|
251
|
387
|
* 修改对象
|
252
|
388
|
* @param taRecommendCustomer 实体对象
|