|
@@ -1,15 +1,29 @@
|
|
|
package com.zhongzheng.modules.distribution.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.zhongzheng.common.constant.Constants;
|
|
|
+import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
+import com.zhongzheng.common.type.EncryptHandler;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
+import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.common.utils.ToolsUtils;
|
|
|
import com.zhongzheng.modules.distribution.bo.DistributionSellerAddBo;
|
|
|
import com.zhongzheng.modules.distribution.bo.DistributionSellerEditBo;
|
|
|
import com.zhongzheng.modules.distribution.bo.DistributionSellerQueryBo;
|
|
|
+import com.zhongzheng.modules.distribution.bo.SellerAppRegisterBo;
|
|
|
import com.zhongzheng.modules.distribution.domain.DistributionSeller;
|
|
|
import com.zhongzheng.modules.distribution.mapper.DistributionSellerMapper;
|
|
|
import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
|
|
|
import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
|
|
|
+import com.zhongzheng.modules.user.bo.UserAppRegisterBo;
|
|
|
+import com.zhongzheng.modules.user.domain.User;
|
|
|
+import com.zhongzheng.modules.user.service.IUserService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -30,6 +44,67 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSellerMapper, DistributionSeller> implements IDistributionSellerService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserService iUserService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean registerSeller(SellerAppRegisterBo bo) {
|
|
|
+ if(StringUtils.isBlank(bo.getIdcard())){
|
|
|
+ throw new CustomException("身份证不能为空");
|
|
|
+ }
|
|
|
+ if(bo.getTel()==null){
|
|
|
+ throw new CustomException("手机号不能为空");
|
|
|
+ }
|
|
|
+ if(bo.getPwd()==null){
|
|
|
+ throw new CustomException("密码不能为空");
|
|
|
+ }
|
|
|
+ if(Validator.isEmpty(bo.getRealname())){
|
|
|
+ throw new CustomException("姓名不能为空");
|
|
|
+ }
|
|
|
+ if(!ToolsUtils.verifPwd(bo.getPwd())){
|
|
|
+ throw new CustomException("密码应由8-16位数字、大小写字母、符号组成");
|
|
|
+ }
|
|
|
+ String key = Constants.REGISTER_SMS + bo.getTel();
|
|
|
+ String code = redisCache.getCacheObject(key);
|
|
|
+ if(code==null){
|
|
|
+ throw new CustomException("验证码错误");
|
|
|
+ }
|
|
|
+ if(!code.equals(bo.getCode())){
|
|
|
+ throw new CustomException("验证码错误");
|
|
|
+ }
|
|
|
+ DistributionSeller seller = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
+ .eq(DistributionSeller::getTelphone, EncryptHandler.encrypt(bo.getTel())).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();
|
|
|
+ inertData.setTelphone(bo.getTel());
|
|
|
+ inertData.setIdCard(bo.getIdcard());
|
|
|
+ inertData.setRealname(bo.getRealname());
|
|
|
+ inertData.setAvatar(Constants.DEFAULT_AVATAR);
|
|
|
+ inertData.setPassword(SecurityUtils.encryptPassword(bo.getPwd()));
|
|
|
+ inertData.setCode(ServletUtils.getEncoded(""));
|
|
|
+ inertData.setCreateTime(DateUtils.getNowTime());
|
|
|
+ inertData.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ 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(!save(inertData)){
|
|
|
+ throw new CustomException("注册失败");
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public DistributionSellerVo queryById(Long salerId){
|
|
|
DistributionSeller db = this.baseMapper.selectById(salerId);
|
|
@@ -105,4 +180,6 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|