|
@@ -301,13 +301,63 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
return voList;
|
|
return voList;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 后台注册
|
|
|
|
+ * @param bo 分销业务员新增业务对象
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public Boolean insertByAddBo(DistributionSellerAddBo bo) {
|
|
public Boolean insertByAddBo(DistributionSellerAddBo bo) {
|
|
|
|
+ if(StringUtils.isBlank(bo.getIdCard())){
|
|
|
|
+ throw new CustomException("身份证不能为空");
|
|
|
|
+ }
|
|
|
|
+ if(bo.getTelphone()==null){
|
|
|
|
+ throw new CustomException("手机号不能为空");
|
|
|
|
+ }
|
|
|
|
+ if(Validator.isEmpty(bo.getRealname())){
|
|
|
|
+ throw new CustomException("姓名不能为空");
|
|
|
|
+ }
|
|
DistributionSeller add = BeanUtil.toBean(bo, DistributionSeller.class);
|
|
DistributionSeller add = BeanUtil.toBean(bo, DistributionSeller.class);
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
- return this.save(add);
|
|
|
|
|
|
+ DistributionSeller seller = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
|
+ .eq(DistributionSeller::getTelphone, EncryptHandler.encrypt(bo.getTelphone())).last("limit 1"));
|
|
|
|
+ if(Validator.isNotNull(seller)){
|
|
|
|
+ throw new CustomException("该手机号已注册");
|
|
|
|
+ }
|
|
|
|
+ DistributionSeller sellerIdCard = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
|
+ .eq(DistributionSeller::getIdCard,EncryptHandler.encrypt(bo.getIdCard())).last("limit 1"));
|
|
|
|
+ if(Validator.isNotNull(sellerIdCard)){
|
|
|
|
+ throw new CustomException("该身份证已注册");
|
|
|
|
+ }
|
|
|
|
+ DistributionSeller inertData = new DistributionSeller();
|
|
|
|
+ //密码身份证后六位
|
|
|
|
+ String pwd = bo.getIdCard().substring(bo.getIdCard().length() - 6);
|
|
|
|
+ inertData.setPassword(SecurityUtils.encryptPassword(pwd));
|
|
|
|
+ inertData.setTelphone(bo.getTelphone());
|
|
|
|
+ inertData.setIdCard(bo.getIdCard());
|
|
|
|
+ inertData.setRealname(bo.getRealname());
|
|
|
|
+ inertData.setAvatar(Constants.DEFAULT_AVATAR);
|
|
|
|
+ inertData.setPassword(SecurityUtils.encryptPassword(bo.getPassword()));
|
|
|
|
+ inertData.setUserAccount(ServletUtils.getEncoded("YW"));
|
|
|
|
+ inertData.setCreateTime(DateUtils.getNowTime());
|
|
|
|
+ inertData.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ inertData.setShareCode(ToolsUtils.getRandomString(8));
|
|
|
|
+ inertData.setAvatar(bo.getAvatar());
|
|
|
|
+ User userIdCard = iUserService.getOne(new LambdaQueryWrapper<User>()
|
|
|
|
+ .eq(User::getIdCard,EncryptHandler.encrypt(bo.getIdCard())).last("limit 1"));
|
|
|
|
+ if(Validator.isNotEmpty(userIdCard)){
|
|
|
|
+ inertData.setUserId(userIdCard.getUserId());
|
|
|
|
+ }
|
|
|
|
+ if(Validator.isNotEmpty(bo.getShareCode())){
|
|
|
|
+ DistributionSeller sellerShare = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
|
+ .eq(DistributionSeller::getShareCode,bo.getShareCode()).last("limit 1"));
|
|
|
|
+ if(Validator.isNotEmpty(sellerShare)){
|
|
|
|
+ inertData.setParentId(sellerShare.getSellerId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return this.save(inertData);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|