TdCCarServiceImpl.java
11.3 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
package com.zteits.pay.biz;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.clouds.common.constants.ExamineStateEnum;
import com.github.pagehelper.PageInfo;
import com.zteits.clouds.api.apibase.bean.PageBean;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.apibase.constants.ErrorType;
import com.zteits.clouds.api.apibase.exception.BizException;
import com.zteits.clouds.api.dto.pay.TdCCustPersonDTO;
import com.zteits.clouds.api.dto.pay.car.dto.CustCarInfoDTO;
import com.zteits.clouds.api.dto.pay.car.param.CustCarInfoCheckStatusUpdateReq;
import com.zteits.clouds.api.dto.pay.car.param.CustCarInfoQueryReq;
import com.zteits.clouds.api.dto.pay.car.param.UserCarInfoQueryForPageReq;
import com.zteits.clouds.api.dto.pay.param.AppIDcardReviewRequest;
import com.zteits.pay.dao.TdCCustPersonDao;
import com.zteits.pay.domain.TdCCarCheckRecord;
import com.zteits.pay.domain.TdCCustPerson;
import com.zteits.pay.pagepager.PageBeanUtil;
import com.zteits.pay.service.carcheckrecord.oper.TdCCarCheckRecordOperInnerService;
import com.zteits.pay.util.CredentialsReviewService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import com.clouds.common.utils.ListCopyUtil;
import com.zteits.clouds.api.apibase.bean.BizResult;
import com.zteits.clouds.api.dto.pay.TdCCarDTO;
import com.zteits.clouds.api.dto.pay.param.QueryTdCCarInfoByCustIdOrCarNumReq;
import com.zteits.clouds.api.dto.pay.param.TdCCarEditRequest;
import com.zteits.clouds.api.dto.pay.param.TdCCarRequest;
import com.zteits.clouds.api.service.pay.TdCCarService;
import com.zteits.pay.dao.TdCCarDao;
import com.zteits.pay.domain.TdCCar;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;
@Service("com.zteits.pay.biz.TdCCarServiceImpl")
public class TdCCarServiceImpl implements TdCCarService {
@Autowired
private TdCCarDao tdCCarDao;
@Autowired
private TdCCustPersonDao tdCCustPersonDao;
@Autowired
private CredentialsReviewService credentialsReviewService;
@Autowired
private TdCCarCheckRecordOperInnerService tdCCarCheckRecordOperInnerService;
@Override
public BizResult<List<TdCCarDTO>> selectCustInfoBycustId(TdCCarRequest request) {
List<TdCCarDTO> carlistdto = new ArrayList<TdCCarDTO>();
List<TdCCar> carlist = tdCCarDao.selectCustInfoBycustId(request);
if(CollectionUtils.isNotEmpty(carlist)){
for(TdCCar car :carlist){
TdCCarDTO dto = new TdCCarDTO();
BeanUtils.copyProperties(car, dto);
carlistdto.add(dto);
}
}
return new BizResult<List<TdCCarDTO>>(carlistdto);
}
@Override
public BizResult<Integer> updateCars(TdCCarEditRequest request) {
TdCCar car = new TdCCar();
BeanUtils.copyProperties(request, car);
Integer i = tdCCarDao.updateCars(car);
return new BizResult<Integer>(i);
}
@Override
public BizResult<Integer> insertCars(TdCCarEditRequest request) {
TdCCar car = new TdCCar();
BeanUtils.copyProperties(request, car);
car.setDataState(1);
Integer i = tdCCarDao.insertCars(car);
return new BizResult<Integer>(i);
}
@Override
public BizResult<Integer> deleteCars(TdCCarEditRequest request) {
TdCCar car = new TdCCar();
BeanUtils.copyProperties(request, car);
Integer i = tdCCarDao.deleteCars(car);
return new BizResult<Integer>(i);
}
@Override
public BizResult<List<TdCCarDTO>> selectCustInfo(TdCCarRequest request) {
List<TdCCarDTO> carlistdto = new ArrayList<TdCCarDTO>();
TdCCar reqcar = new TdCCar();
BeanUtils.copyProperties(request, reqcar);
List<TdCCar> carlist = tdCCarDao.selectCustInfo(reqcar);
if(CollectionUtils.isNotEmpty(carlist)){
for(TdCCar car :carlist){
TdCCarDTO dto = new TdCCarDTO();
BeanUtils.copyProperties(car, dto);
carlistdto.add(dto);
}
}
return new BizResult<List<TdCCarDTO>>(carlistdto);
}
@Override
public BizResult<PageBean<TdCCarDTO>> queryUserCarInfoForPage(UserCarInfoQueryForPageReq req) {
PageBean<TdCCarDTO> pageBean = new PageBean<>();
PageInfo<TdCCarDTO> pageInfo = tdCCarDao.queryUserCarInfoForPageAndPN(req);
PageBeanUtil.copyProperties(pageInfo,pageBean,TdCCarDTO.class);
return new BizResult<>(pageBean);
}
@Override
public BizResult<List<TdCCarDTO>> queryCustCarInfoByPhone(UserCarInfoQueryForPageReq req) {
List<TdCCarDTO> list = tdCCarDao.queryCustCarInfoByPhone(req);
return new BizResult<>(list);
}
@Override
public BizResult<CustCarInfoDTO> queryCustCarInfo(CustCarInfoQueryReq request) {
if(StringUtils.isEmpty(request.getCustId())){
throw new BizException(ErrorType.PAY_TYPE_ERROR,"客户ID");
}
/**
* 1、 查询 custPersonDTO
*/
TdCCustPerson person = tdCCustPersonDao.queryPersonByCustId(request.getCustId());
TdCCustPersonDTO personDTO = null;
if(null != person){
personDTO = new TdCCustPersonDTO();
BeanUtils.copyProperties(person,personDTO);
}
/**
* 2、查询 carDTOS
*/
TdCCar queryCar = new TdCCar();
queryCar.setCustId(request.getCustId());
queryCar.setCarNumber(request.getCarNumber());
List<TdCCar> carList = tdCCarDao.selectCustInfo(queryCar);
List<TdCCarDTO> carDTOS = null;
if(CollectionUtils.isNotEmpty(carList)){
carDTOS = new ArrayList<>();
ListCopyUtil.listCopyProperties(carList,carDTOS,TdCCarDTO.class);
}
/**
* 3、赋值
*/
CustCarInfoDTO custCarInfoDTO = new CustCarInfoDTO();
custCarInfoDTO.setCustPersonDTO(personDTO);
custCarInfoDTO.setCarDTOS(carDTOS);
return new BizResult<>(custCarInfoDTO);
}
@Override
@Transactional
public BizResult<Boolean> updateCustCarInfoCheckStatus(CustCarInfoCheckStatusUpdateReq req) {
if(null == req.getId()){
throw new BizException(ErrorType.PARAMM_NULL,"主键信息");
}
if(null == req.getCheckStatus()){
throw new BizException(ErrorType.PARAMM_NULL,"审核状态");
}
if(StringUtils.isEmpty(req.getRemark())){
throw new BizException(ErrorType.PARAMM_NULL,"备注信息");
}
//推送消息时用
int checkStatus = req.getCheckStatus();
//审核被撤销时,入参传入0,保存时为3
if(req.getCheckStatus().equals(0)){
req.setCheckStatus(3);
}
/**
* 1、根据主键查询车辆信息
*/
TdCCar car = tdCCarDao.selectCustCarInfoById(req.getId());
if(null == car){
throw new BizException(ErrorType.BIZ_ERROR,"查找不到车辆信息");
}
/**
* 2、更新车辆信息审核状态
*/
TdCCar updateCar = new TdCCar();
updateCar.setId(car.getId());
updateCar.setExamineState(req.getCheckStatus());
int num = tdCCarDao.updateCars(updateCar);
if(num < 1){
throw new BizException(ErrorType.BIZ_ERROR,"更新审核状态失败");
}
/**
* 3、记录操作流水
*/
TdCCarCheckRecord record = new TdCCarCheckRecord();
BeanUtils.copyProperties(car,record);
record.setId(null);
record.setCarShelfNum(car.getCarShelfNum());
record.setCarEngineNum(car.getCarEngineNum());
record.setPhoneNum(car.getPhoneNumber());
record.setOperId(req.getsOpId().intValue());
record.setOperName(req.getsOpName());
record.setDataStatus(DataStatusEnum.DATA_STATUS_VALID.value());
record.setCheckRemark(req.getRemark());
record.setOperTime(new Date());
record.setCheckState(req.getCheckStatus());
record.setCheckRemark(req.getRemark());
num = tdCCarCheckRecordOperInnerService.saveTdCCarCheckRecord(record);
if(num < 1){
throw new BizException(ErrorType.BIZ_ERROR,"保存车辆审核操作流水失败");
}
/**向车主推送车牌审核信息*/
record.setCheckState(checkStatus);
sendMsg(num,record);
return new BizResult<>(true);
}
private void sendMsg(int num, TdCCarCheckRecord record) {
if (TransactionSynchronizationManager.isActualTransactionActive()) {
//存在事物
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
//成功后推送,否则不推送
if(num > 0) {
credentialsReviewService.driverLicenseResPush(record);
}
}
});
} else {
if(num > 0) {
credentialsReviewService.driverLicenseResPush(record);
}
}
}
/**
* 通过个人客户id或车牌查询车牌信息.<br/>
* @param custId
* @return
* @author wangfs
*/
@Override
public BizResult<List<TdCCarDTO>> queryTdCCarInfoByCustIdOrCarNum(QueryTdCCarInfoByCustIdOrCarNumReq request) {
List<TdCCarDTO> list = new ArrayList<>();
TdCCar reqcar = new TdCCar();
reqcar.setCarNumber(request.getCarNumber());
reqcar.setCustId(request.getCustId());
List<TdCCar> selectCustInfo = tdCCarDao.selectCustInfo(reqcar);
ListCopyUtil.listCopyProperties(selectCustInfo, list, TdCCarDTO.class);
return new BizResult<>(list);
}
@Override
public BizResult<CustCarInfoDTO> queryCustCarInfoByCarNumber(CustCarInfoQueryReq request) {
CustCarInfoDTO dto = new CustCarInfoDTO();
List<TdCCarDTO> carDTOS = new ArrayList<>();
TdCCustPersonDTO personDTO = new TdCCustPersonDTO();
//查询车辆信息
List<TdCCar> list = tdCCarDao.selectCustInfoByCarNumber(request);
if(CollectionUtils.isEmpty(list)){
return new BizResult<>(dto);
}
ListCopyUtil.listCopyProperties(list, carDTOS, TdCCarDTO.class);
dto.setCarDTOS(carDTOS);
//查询用户信息
String custId = list.get(0).getCustId();
TdCCustPerson person = tdCCustPersonDao.queryPersonByCustId(custId);
if(null != person){
personDTO = new TdCCustPersonDTO();
BeanUtils.copyProperties(person,personDTO);
dto.setCustPersonDTO(personDTO);
}
return new BizResult<>(dto);
}
@Transactional(rollbackFor = Exception.class)
@Override
public BizResult<Boolean> DriverLicenseReview(TdCCarEditRequest request) {
/**主表车辆表保存驾驶证图片并更新审核状态信息*/
TdCCar car = new TdCCar();
BeanUtils.copyProperties(request, car);
Integer i = tdCCarDao.updateCars(car);
/**审核记录表新增审核记录,状态为待审核*/
TdCCar tdCCar = tdCCarDao.selectCustCarInfoById(request.getId());
TdCCarCheckRecord tdCCarCheckRecord = new TdCCarCheckRecord();
BeanUtils.copyProperties(tdCCar,tdCCarCheckRecord);
tdCCarCheckRecord.setId(null);
tdCCarCheckRecord.setCarCheckType(1);
tdCCarCheckRecord.setCheckState(ExamineStateEnum.NoAudit.getValue());
int j = tdCCarCheckRecordOperInnerService.saveTdCCarCheckRecord(tdCCarCheckRecord);
return new BizResult<>(i>0 & j>0);
}
@Override
public BizResult<Boolean> IDcardReview(AppIDcardReviewRequest request) {
/**主表车辆表更新车主审核状态信息*/
TdCCar car = new TdCCar();
BeanUtils.copyProperties(request,car);
car.setCardCheckState(ExamineStateEnum.NoAudit.getValue());
Integer i = tdCCarDao.updateCars(car);
/**审核记录表新增车主身份审核记录,状态为未审核*/
TdCCar tdCCar = tdCCarDao.selectCustCarInfoById(request.getId());
TdCCarCheckRecord tdCCarCheckRecord = new TdCCarCheckRecord();
BeanUtils.copyProperties(tdCCar,tdCCarCheckRecord);
BeanUtils.copyProperties(request,tdCCarCheckRecord);
tdCCarCheckRecord.setId(null);
tdCCarCheckRecord.setCarCheckType(2);
tdCCarCheckRecord.setCheckState(ExamineStateEnum.NoAudit.getValue());
int j = tdCCarCheckRecordOperInnerService.saveTdCCarCheckRecord(tdCCarCheckRecord);
return new BizResult<>(i>0 & j>0);
}
}