Commit 28da5c33 authored by huangcb's avatar huangcb

增加手机号唯一功能:承运商、司机、货主之间的手机号不能重复

parent 4f9a20eb
package com.esv.freight.customer.module.carrier.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -21,6 +22,10 @@ import com.esv.freight.customer.module.carrier.form.CarrierQueryForm;
import com.esv.freight.customer.module.carrier.service.CarrierAccountService;
import com.esv.freight.customer.module.carrier.service.CarrierInfoService;
import com.esv.freight.customer.module.carrier.vo.CarrierInfoListVO;
import com.esv.freight.customer.module.driver.entity.DriverAccountEntity;
import com.esv.freight.customer.module.driver.service.DriverAccountService;
import com.esv.freight.customer.module.goodsowner.entity.GoodsOwnerAccountEntity;
import com.esv.freight.customer.module.goodsowner.service.GoodsOwnerAccountService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
......@@ -35,16 +40,19 @@ import java.util.List;
public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, CarrierAccountEntity> implements CarrierAccountService {
private FeignBaseService feignBaseService;
private ErrorMessageComponent errorMessageComponent;
private PasswordComponent passwordComponent;
private CarrierInfoService carrierInfoService;
@Autowired
public CarrierAccountServiceImpl(FeignBaseService feignBaseService, ErrorMessageComponent errorMessageComponent,
PasswordComponent passwordComponent, CarrierInfoService carrierInfoService) {
private GoodsOwnerAccountService goodsOwnerAccountService;
@Autowired
private DriverAccountService driverAccountService;
@Autowired
public CarrierAccountServiceImpl(FeignBaseService feignBaseService, ErrorMessageComponent errorMessageComponent
, PasswordComponent passwordComponent, CarrierInfoService carrierInfoService) {
this.feignBaseService = feignBaseService;
this.errorMessageComponent = errorMessageComponent;
this.passwordComponent = passwordComponent;
......@@ -70,6 +78,16 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca
if (this.isAccountExit(carrierQueryForm)) {
throw new EException(1001, errorMessageComponent.getCarrierAccountAdd1001());
}
int goodsOwnerCount = goodsOwnerAccountService.getBaseMapper().selectCount(new LambdaQueryWrapper<GoodsOwnerAccountEntity>()
.eq(GoodsOwnerAccountEntity::getAccount, form.getAccount()));
if (0 < goodsOwnerCount) {
throw new EException(1001, errorMessageComponent.getCarrierAccountAdd1001());
}
int driverCount = driverAccountService.getBaseMapper().selectCount(new LambdaQueryWrapper<DriverAccountEntity>()
.eq(DriverAccountEntity::getAccount, form.getAccount()));
if (0 < driverCount) {
throw new EException(1001, errorMessageComponent.getCarrierAccountAdd1001());
}
// 1.2:校验道路运输经营许可证号是否已存在
carrierQueryForm = new CarrierQueryForm();
......
package com.esv.freight.customer.module.driver.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -28,6 +29,8 @@ import com.esv.freight.customer.module.driver.service.DriverAccountService;
import com.esv.freight.customer.module.driver.service.DriverAuditHistoryService;
import com.esv.freight.customer.module.driver.service.DriverInfoService;
import com.esv.freight.customer.module.driver.vo.DriverListVO;
import com.esv.freight.customer.module.goodsowner.entity.GoodsOwnerAccountEntity;
import com.esv.freight.customer.module.goodsowner.service.GoodsOwnerAccountService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
......@@ -44,26 +47,25 @@ import java.util.List;
public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, DriverAccountEntity> implements DriverAccountService {
private ErrorMessageComponent errorMessageComponent;
private PasswordComponent passwordComponent;
private DriverInfoService driverInfoService;
private DriverAuditHistoryService driverAuditHistoryService;
private FeignAppService feignAppService;
@Autowired
private CarrierAccountService carrierAccountService;
private FeignAppService feignAppService;
@Autowired
private GoodsOwnerAccountService goodsOwnerAccountService;
@Autowired
public DriverAccountServiceImpl(ErrorMessageComponent errorMessageComponent, PasswordComponent passwordComponent,
DriverInfoService driverInfoService, DriverAuditHistoryService driverAuditHistoryService,
CarrierAccountService carrierAccountService, FeignAppService feignAppService) {
FeignAppService feignAppService) {
this.errorMessageComponent = errorMessageComponent;
this.passwordComponent = passwordComponent;
this.driverInfoService = driverInfoService;
this.driverAuditHistoryService = driverAuditHistoryService;
this.carrierAccountService = carrierAccountService;
this.feignAppService = feignAppService;
}
......@@ -72,11 +74,22 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
public Long insertDriver(DriverInfoForm form) {
// 1:校验
// 1.1:校验账号是否已存在
Integer count = this.baseMapper.selectCount(new QueryWrapper<DriverAccountEntity>().lambda()
int count = this.baseMapper.selectCount(new LambdaQueryWrapper<DriverAccountEntity>()
.eq(DriverAccountEntity::getAccount, form.getAccount()));
if (0 < count) {
throw new EException(1001, errorMessageComponent.getCarrierDriverAdd1001());
}
int carrierCount = carrierAccountService.getBaseMapper().selectCount(new LambdaQueryWrapper<CarrierAccountEntity>()
.eq(CarrierAccountEntity::getAccount, form.getAccount()));
if (0 < carrierCount) {
throw new EException(1001, errorMessageComponent.getCarrierDriverAdd1001());
}
int goodsOwnerCount = goodsOwnerAccountService.getBaseMapper().selectCount(new LambdaQueryWrapper<GoodsOwnerAccountEntity>()
.eq(GoodsOwnerAccountEntity::getAccount, form.getAccount()));
if (0 < goodsOwnerCount) {
throw new EException(1001, errorMessageComponent.getCarrierDriverAdd1001());
}
// 1.2:校验身份证号码是否已存在
count = this.driverInfoService.getBaseMapper().selectCount(new QueryWrapper<DriverInfoEntity>().lambda()
.eq(DriverInfoEntity::getIdCard, form.getIdCard()));
......
......@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.goodsowner.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -14,6 +15,10 @@ import com.esv.freight.customer.common.util.FeignUtils;
import com.esv.freight.customer.common.util.ReqUtils;
import com.esv.freight.customer.common.vo.PageResultVO;
import com.esv.freight.customer.feign.FeignBaseService;
import com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity;
import com.esv.freight.customer.module.carrier.service.CarrierAccountService;
import com.esv.freight.customer.module.driver.entity.DriverAccountEntity;
import com.esv.freight.customer.module.driver.service.DriverAccountService;
import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants;
import com.esv.freight.customer.module.goodsowner.dao.AccountDao;
import com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto;
......@@ -46,18 +51,21 @@ import java.util.List;
public class GoodsOwnerAccountServiceImpl extends ServiceImpl<AccountDao, GoodsOwnerAccountEntity> implements GoodsOwnerAccountService {
private FeignBaseService feignBaseService;
private PasswordComponent passwordComponent;
private ErrorMessageComponent errorMessageComponent;
private GoodsOwnerInfoService goodsOwnerInfoService;
private AuditHistoryService auditHistoryService;
@Autowired
private DriverAccountService driverAccountService;
@Autowired
private CarrierAccountService carrierAccountService;
@Autowired
public GoodsOwnerAccountServiceImpl(FeignBaseService feignBaseService, PasswordComponent passwordComponent,
ErrorMessageComponent errorMessageComponent, GoodsOwnerInfoService goodsOwnerInfoService, AuditHistoryService auditHistoryService) {
ErrorMessageComponent errorMessageComponent, GoodsOwnerInfoService goodsOwnerInfoService,
AuditHistoryService auditHistoryService) {
this.feignBaseService = feignBaseService;
this.passwordComponent = passwordComponent;
this.errorMessageComponent = errorMessageComponent;
......@@ -91,6 +99,16 @@ public class GoodsOwnerAccountServiceImpl extends ServiceImpl<AccountDao, GoodsO
} else {
goodsOwnerAccountEntity = new GoodsOwnerAccountEntity();
}
int driverCount = driverAccountService.getBaseMapper().selectCount(new LambdaQueryWrapper<DriverAccountEntity>()
.eq(DriverAccountEntity::getAccount, form.getAccount()));
if (0 < driverCount) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountAdd1001());
}
int carrierCount = carrierAccountService.getBaseMapper().selectCount(new LambdaQueryWrapper<CarrierAccountEntity>()
.eq(CarrierAccountEntity::getAccount, form.getAccount()));
if (0 < carrierCount) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountAdd1001());
}
// 2.获取客户编码
JSONObject batchIdReqJson = new JSONObject();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment