CustomerController.java
13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
package cn.fw.valhalla.controller.app;
import cn.fw.common.page.AppPage;
import cn.fw.common.web.auth.LoginAuthBean;
import cn.fw.common.web.auth.annotation.CurrentUser;
import cn.fw.data.base.domain.common.Message;
import cn.fw.security.auth.client.annotation.Authorization;
import cn.fw.security.auth.client.annotation.IgnoreAuth;
import cn.fw.security.auth.client.enums.AuthType;
import cn.fw.valhalla.domain.dto.CustomerChangeDto;
import cn.fw.valhalla.domain.query.CustomerQueryVO;
import cn.fw.valhalla.domain.vo.customer.*;
import cn.fw.valhalla.service.bus.CommonService;
import cn.fw.valhalla.service.bus.cust.ContactBizService;
import cn.fw.valhalla.service.bus.cust.CustomerBizService;
import cn.fw.valhalla.service.bus.cust.CustomerChangeBizService;
import cn.fw.valhalla.service.bus.cust.PickUpCustomerService;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
import static cn.fw.common.web.util.ExceptionHandler.handleException;
import static cn.fw.common.web.util.ResultBuilder.failureWithMessage;
import static cn.fw.common.web.util.ResultBuilder.success;
import static cn.fw.valhalla.common.constant.MessageStr.QUERY_FAILURE;
import static cn.fw.valhalla.common.constant.MessageStr.SAVE_FAILURE;
/**
* @author : kurisu
* @className : CustomerController
* @description : 档案控制器
* @date: 2020-08-12 15:30
*/
@Slf4j
@Validated
@RestController
@Authorization(AuthType.APP)
@RequestMapping("/app/customer")
public class CustomerController {
private final CustomerBizService customerBizService;
private final PickUpCustomerService pickUpCustomerService;
private final CustomerChangeBizService customerChangeBiz;
private final ContactBizService contactBizService;
private final CommonService commonService;
@Autowired
public CustomerController(final CustomerBizService customerBizService,
final PickUpCustomerService pickUpCustomerService,
final CustomerChangeBizService customerChangeBiz,
final ContactBizService contactBizService,
final CommonService commonService) {
this.customerBizService = customerBizService;
this.pickUpCustomerService = pickUpCustomerService;
this.customerChangeBiz = customerChangeBiz;
this.contactBizService = contactBizService;
this.commonService = commonService;
}
/**
* 分页查询客户信息列表 (管理人员)
*
* @param queryVO 查询条件
*/
@GetMapping("/page")
@IgnoreAuth
public Message<AppPage<CustomerListVO>> customerList(@CurrentUser LoginAuthBean currentUser,
final CustomerQueryVO queryVO) {
final String msg = "分页查询 客户列表(管理人员)[page]";
try {
log.info("{}: param[{}]", msg, queryVO);
AppPage<CustomerListVO> page = customerBizService.getList(currentUser, queryVO);
return success(page, data -> log.info("dataSize: {}", CollectionUtils.isEmpty(data.getData()) ? 0 : data.getData().size()));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, queryVO, e));
return failureWithMessage(QUERY_FAILURE);
}
}
/**
* 分页查询客户信息列表 (服务顾问自己的)
*
* @param currentUser
* @param queryVO
* @return
*/
@GetMapping("/page/own")
public Message<AppPage<CustomerListVO>> customerOwnList(@CurrentUser LoginAuthBean currentUser,
final CustomerQueryVO queryVO) {
final String msg = "分页查询 客户列表(自己的)[page/own]";
try {
queryVO.setConsultantId(currentUser.getUserId());
log.info("{}: param[{}]", msg, queryVO);
AppPage<CustomerListVO> page = customerBizService.getList(currentUser, queryVO);
return success(page, data -> log.info("dataSize: {}", CollectionUtils.isEmpty(data.getData()) ? 0 : data.getData().size()));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, queryVO, e));
return failureWithMessage(QUERY_FAILURE);
}
}
/**
* 根据ID查询档案信息
*
* @param cusId 档案ID
*/
@GetMapping("/detailById")
@IgnoreAuth
public Message<CustomerDetailVO> getDetailById(@NotNull(message = "档案ID不能为空") final Long cusId) {
final String msg = "根据ID查询档案信息[detail]";
log.info("{}: param[{}]", msg, cusId);
try {
return success(customerBizService.getDetailById(cusId));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, cusId, e));
return failureWithMessage(QUERY_FAILURE);
}
}
/**
* 根据车牌号查询档案信息
*
* @param plateNo 车牌号
*/
@GetMapping("/detailByPlate")
@IgnoreAuth
public Message<PickUpCustomerDetailVO> getDetailByPlate(@CurrentUser LoginAuthBean currentUser, @NotBlank(message = "车牌号不能为空") final String plateNo) {
final String msg = "根据车牌号查询档案信息[detail]";
log.info("{}: param[{}]", msg, plateNo);
try {
return success(pickUpCustomerService.getDetailByPlateNo(currentUser, plateNo));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, plateNo, e));
return failureWithMessage(QUERY_FAILURE);
}
}
/**
* 通过智能通话拨打电话
*
* @param currentUser
* @param id
* @param accidentCar
* @return
*/
@GetMapping("/call")
public Message<String> call(@CurrentUser LoginAuthBean currentUser,
@NotNull(message = "档案ID不能为空") final Long id,
final Boolean accidentCar
) {
final String msg = "通过智能通话拨打电话[call]";
log.info("{}: param[cusId:{} accidentCar:{}]", msg, id, accidentCar);
try {
return success(commonService.call(currentUser.getUserId(), id, accidentCar));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{} accidentCar:{}]", msg, id, accidentCar, e));
return failureWithMessage(QUERY_FAILURE);
}
}
/**
* 根据车架号查询档案信息
* 如果发现档案是临牌则修改车牌为现在的
*
* @param frameNo 车架号
*/
@GetMapping("/detailByFrameNo")
public Message<PickUpCustomerDetailVO> getDetailByFrameNo(@CurrentUser LoginAuthBean currentUser, @NotBlank(message = "车架号不能为空") final String frameNo) {
final String msg = "根据车架号号查询档案信息[detail]";
log.info("{}: param[{}]", msg, frameNo);
try {
return success(pickUpCustomerService.getDetailByFrameNo(currentUser, frameNo));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, frameNo, e));
return failureWithMessage(QUERY_FAILURE);
}
}
/**
* 根据车架号修改档案车牌号
*
* @param frameNo
* @param plateNo
* @return
*/
@PostMapping("/fixPlateNo")
public Message<Long> fixPlateNo(@CurrentUser LoginAuthBean currentUser, @NotBlank(message = "车架号不能为空") final String frameNo, @NotBlank(message = "车牌号不能为空") final String plateNo) {
final String msg = "根据车架号修改档案车牌号[fixPlateNo]";
log.info("{}: param[{} {}]", msg, frameNo, plateNo);
try {
return success(pickUpCustomerService.fixPlateNo(frameNo, plateNo, currentUser));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, frameNo, e));
return failureWithMessage(SAVE_FAILURE);
}
}
/**
* 根据ID查询客户信息
*
* @param cusId 客户ID
*/
@GetMapping("/vehicle")
public Message<VehicleRecordVO> getCarInfoById(@NotNull(message = "档案ID不能为空") final Long cusId) {
final String msg = "根据ID查询车辆信息[vehicle]";
log.info("{}: param[{}]", msg, cusId);
try {
return success(customerBizService.getCarInfoById(cusId));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, cusId, e));
return failureWithMessage(QUERY_FAILURE);
}
}
/**
* 根据ID查询客户信息
*
* @param cusId 客户ID
*/
@GetMapping("/owner")
public Message<OwnerVO> getOwnerInfo(@NotNull(message = "档案ID不能为空") final Long cusId) {
final String msg = "根据ID查询所有人信息[owner]";
log.info("{}: param[{}]", msg, cusId);
try {
return success(customerBizService.getOwnerInfo(cusId));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, cusId, e));
return failureWithMessage(QUERY_FAILURE);
}
}
/**
* 根据ID查询客户信息
*
* @param cusId 客户ID
*/
@GetMapping("/getMore")
public Message<List<MoreVehicleVO>> getMore(@NotNull(message = "客户ID不能为空") final Long cusId, @CurrentUser LoginAuthBean currentUser) {
final String msg = "根据ID查询档案信息[getMore]";
log.info("{}: param[{}]", msg, cusId);
try {
return success(customerBizService.getMoreArchive(cusId, currentUser.getGroupId()));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, cusId, e));
return failureWithMessage(QUERY_FAILURE);
}
}
/**
* 修改档案标签
*
* @param tags 标签枚举
*/
@PostMapping("/updateTagById")
public Message<Integer> updateTagById(@NotBlank(message = "标签不能为空") final String tags,
@NotNull(message = "id不能为空") final Long cusId) {
final String msg = "修改档案标签[updateTagById]";
log.info("{}: param[{}、{}]", msg, tags, cusId);
try {
return success(customerChangeBiz.updateTagById(cusId, tags));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}、{}]", msg, tags, cusId, e));
return failureWithMessage(SAVE_FAILURE);
}
}
/**
* 查询送修人、同行人等信息
*
* @param cusId 档案id
*/
@GetMapping("/contact/list")
public Message<List<CustomerContactVO>> contactList(@NotNull(message = "档案ID不能为空") final Long cusId) {
final String msg = "查询送修人、同行人等信息[save]";
log.info("{}: param[{}]", msg, cusId);
try {
return success(contactBizService.contactList(cusId));
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, cusId, e));
return failureWithMessage(QUERY_FAILURE);
}
}
/**
* 获取档案变更二维码
*
* @param currentUser
* @param customerChangeDto
* @return
*/
@PostMapping("/change/qrcode")
public Message<CustomerChangeQrCodeVO> getQrCode(@CurrentUser LoginAuthBean currentUser,
@Validated @RequestBody CustomerChangeDto customerChangeDto) {
final String msg = "获取档案变更二维码";
log.info("{}: param[{}]", msg, customerChangeDto);
try {
CustomerChangeQrCodeVO qrCode = customerChangeBiz.createQrCode(currentUser, customerChangeDto);
log.info("生成成功");
return success(qrCode);
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}]", msg, customerChangeDto, e));
return failureWithMessage(SAVE_FAILURE);
}
}
/**
* 主动放弃
*
* @param cusId
*/
@PostMapping("/abandon")
public Message<Void> abandon(@NotNull(message = "id不能为空") final Long cusId, final String reason) {
final String msg = "主动放弃客户[abandon]";
log.info("{}: param[{}、{}]", msg, cusId, reason);
try {
customerBizService.abandon(cusId, reason);
return success();
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}、{}]", msg, cusId, reason, e));
return failureWithMessage(SAVE_FAILURE);
}
}
/**
* 继续跟进
*
* @param cusId
*/
@PostMapping("/continue")
public Message<Void> continueFollow(@CurrentUser LoginAuthBean currentUser, @NotNull(message = "id不能为空") final Long cusId) {
final String msg = "继续跟进客户[continue]";
log.info("{}: param[{}]", msg, cusId);
try {
customerBizService.continueFollow(currentUser, cusId);
return success();
} catch (Exception ex) {
handleException(ex, e -> log.error("{}失败:param[{}、{}]", msg, cusId, e));
return failureWithMessage(SAVE_FAILURE);
}
}
}