解决维修开单新增客户、车辆信息ID不回填

This commit is contained in:
xiaofajia 2024-10-31 14:35:05 +08:00
parent c939fbe59b
commit c4d996a265

View File

@ -437,13 +437,28 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
userDTO.setUsername(customerAndCarVO.getUserInfo().getPhoneNumber()); userDTO.setUsername(customerAndCarVO.getUserInfo().getPhoneNumber());
userDTO.setPassword("123456"); userDTO.setPassword("123456");
adminUserApi.createUser(userDTO); adminUserApi.createUser(userDTO);
// 如果新增了数据id没有回填
if (ObjectUtil.isEmpty(userDTO.getId())){
AdminUserRespDTO byMobile = adminUserApi.getUserByMobile(userDTO.getMobile());
userDTO.setId(byMobile.getId());
}
customerAndCarVO.getUserInfo().setUserId(userDTO.getId()); customerAndCarVO.getUserInfo().setUserId(userDTO.getId());
} }
} }
// 客户信息 // 客户信息
if (ObjectUtil.isNotEmpty(customerAndCarVO.getUserInfo())) { if (ObjectUtil.isNotEmpty(customerAndCarVO.getUserInfo())) {
if (ObjectUtil.isEmpty(customerAndCarVO.getUserInfo().getId())) { if (ObjectUtil.isEmpty(customerAndCarVO.getUserInfo().getId())) {
// 新增之前判断一下电话号码是否重复
List<CustomerMain> list = customerService.list(new LambdaQueryWrapper<CustomerMain>().eq(CustomerMain::getPhoneNumber, customerAndCarVO.getUserInfo().getPhoneNumber()));
if (CollectionUtil.isNotEmpty(list)){
throw exception0(500, "电话号码重复");
}
customerService.save(customerAndCarVO.getUserInfo()); customerService.save(customerAndCarVO.getUserInfo());
// 如果新增了数据id没有回填
if (ObjectUtil.isEmpty(customerAndCarVO.getUserInfo().getId())){
CustomerMain byPhoneNumber = customerService.getOne(new LambdaQueryWrapper<CustomerMain>().eq(CustomerMain::getPhoneNumber, customerAndCarVO.getUserInfo().getPhoneNumber()));
customerAndCarVO.getUserInfo().setId(byPhoneNumber.getId());
}
} else { } else {
customerService.updateById(customerAndCarVO.getUserInfo()); customerService.updateById(customerAndCarVO.getUserInfo());
} }
@ -452,7 +467,17 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
if (ObjectUtil.isNotEmpty(customerAndCarVO.getCarInfo())) { if (ObjectUtil.isNotEmpty(customerAndCarVO.getCarInfo())) {
if (ObjectUtil.isEmpty(customerAndCarVO.getCarInfo().getId())) { if (ObjectUtil.isEmpty(customerAndCarVO.getCarInfo().getId())) {
customerAndCarVO.getCarInfo().setUserId(customerAndCarVO.getUserInfo().getUserId()); customerAndCarVO.getCarInfo().setUserId(customerAndCarVO.getUserInfo().getUserId());
// 新增之前判断一下车牌重复没
List<CarMain> list = carMainService.list(new LambdaQueryWrapper<CarMain>().eq(CarMain::getLicenseNumber, customerAndCarVO.getCarInfo().getLicenseNumber()));
if (CollectionUtil.isNotEmpty(list)){
throw exception0(500, "车牌重复");
}
carMainService.createCarMain(customerAndCarVO.getCarInfo()); carMainService.createCarMain(customerAndCarVO.getCarInfo());
// 如果新增了数据id没有回填
if (ObjectUtil.isEmpty(customerAndCarVO.getCarInfo().getId())){
CarMain byLicenseNumber = carMainService.getOne(new LambdaQueryWrapper<CarMain>().eq(CarMain::getLicenseNumber, customerAndCarVO.getCarInfo().getLicenseNumber()));
customerAndCarVO.getCarInfo().setId(byLicenseNumber.getId());
}
} else { } else {
carMainService.updateCarMain(customerAndCarVO.getCarInfo()); carMainService.updateCarMain(customerAndCarVO.getCarInfo());
} }