|
@@ -3,6 +3,7 @@ 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.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.zhongzheng.common.constant.Constants;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
@@ -91,14 +92,22 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
inertData.setRealname(bo.getRealname());
|
|
|
inertData.setAvatar(Constants.DEFAULT_AVATAR);
|
|
|
inertData.setPassword(SecurityUtils.encryptPassword(bo.getPwd()));
|
|
|
- inertData.setCode(ServletUtils.getEncoded(""));
|
|
|
+ inertData.setCode(ServletUtils.getEncoded("YW"));
|
|
|
inertData.setCreateTime(DateUtils.getNowTime());
|
|
|
inertData.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ inertData.setShareCode(ToolsUtils.getRandomString(8));
|
|
|
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());
|
|
|
+ }
|
|
|
+ }
|
|
|
if(!save(inertData)){
|
|
|
throw new CustomException("注册失败");
|
|
|
}
|
|
@@ -106,8 +115,78 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public DistributionSellerVo queryById(Long salerId){
|
|
|
- DistributionSeller db = this.baseMapper.selectById(salerId);
|
|
|
+ public Boolean forgetUser(SellerAppRegisterBo bo) {
|
|
|
+ if(bo.getTel()==null){
|
|
|
+ throw new CustomException("手机号不能为空");
|
|
|
+ }
|
|
|
+ if(bo.getPwd()==null){
|
|
|
+ throw new CustomException("密码不能为空");
|
|
|
+ }
|
|
|
+ String key = Constants.FORGET_SMS + bo.getTel();
|
|
|
+ String code = redisCache.getCacheObject(key);
|
|
|
+ if(code==null){
|
|
|
+ throw new CustomException("验证码错误");
|
|
|
+ }
|
|
|
+ if(!code.equals(bo.getCode())){
|
|
|
+ throw new CustomException("验证码错误");
|
|
|
+ }
|
|
|
+ redisCache.deleteObject(key);
|
|
|
+ DistributionSeller seller = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
+ .eq(DistributionSeller::getTelphone,EncryptHandler.encrypt(bo.getTel())).last("limit 1"));
|
|
|
+ if(Validator.isEmpty(seller)){
|
|
|
+ throw new CustomException("该手机号未注册");
|
|
|
+ }
|
|
|
+ seller.setPassword(SecurityUtils.encryptPassword(bo.getPwd()));
|
|
|
+ seller.setUpdateTime(DateUtils.getNowTime());
|
|
|
+
|
|
|
+ DistributionSeller sellerSync = new DistributionSeller();
|
|
|
+ sellerSync.setUserId(seller.getUserId());
|
|
|
+ sellerSync.setPassword(seller.getPassword());
|
|
|
+ syncSellerToUser(sellerSync,null,1);
|
|
|
+ return updateById(seller);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param seller
|
|
|
+ * @param user
|
|
|
+ * @param type 1业务员更新到用户 2用户更新到业务员
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean syncSellerToUser(DistributionSeller seller, User user, Integer type) {
|
|
|
+ if(type==1){
|
|
|
+ if(Validator.isNotEmpty(seller.getUserId())){
|
|
|
+ iUserService.update(new LambdaUpdateWrapper<User>()
|
|
|
+ .eq(User::getUserId,seller.getUserId())
|
|
|
+ .set(User::getUpdateTime,DateUtils.getNowTime())
|
|
|
+ .set(Validator.isNotEmpty(seller.getTelphone()),User::getTelphone,seller.getTelphone())
|
|
|
+ .set(Validator.isNotEmpty(seller.getIdCard()),User::getIdCard,seller.getIdCard())
|
|
|
+ .set(Validator.isNotEmpty(seller.getAvatar()),User::getAvatar,seller.getAvatar())
|
|
|
+ .set(Validator.isNotEmpty(seller.getRealname()),User::getRealname,seller.getRealname())
|
|
|
+ .set(Validator.isNotEmpty(seller.getPassword()),User::getPassword,seller.getPassword()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(type==2){
|
|
|
+ DistributionSeller sellerUser = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
+ .eq(DistributionSeller::getUserId,user.getUserId()).last("limit 1"));
|
|
|
+ if(Validator.isNotEmpty(sellerUser)){
|
|
|
+ update(new LambdaUpdateWrapper<DistributionSeller>()
|
|
|
+ .eq(DistributionSeller::getSellerId,sellerUser.getSellerId())
|
|
|
+ .set(DistributionSeller::getUpdateTime,DateUtils.getNowTime())
|
|
|
+ .set(Validator.isNotEmpty(user.getTelphone()),DistributionSeller::getTelphone,user.getTelphone())
|
|
|
+ .set(Validator.isNotEmpty(user.getIdCard()),DistributionSeller::getIdCard,user.getIdCard())
|
|
|
+ .set(Validator.isNotEmpty(user.getAvatar()),DistributionSeller::getAvatar,user.getAvatar())
|
|
|
+ .set(Validator.isNotEmpty(user.getRealname()),DistributionSeller::getRealname,user.getRealname())
|
|
|
+ .set(Validator.isNotEmpty(user.getPassword()),DistributionSeller::getPassword,user.getPassword()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public DistributionSellerVo queryById(Long sellerId){
|
|
|
+ DistributionSeller db = this.baseMapper.selectById(sellerId);
|
|
|
return BeanUtil.toBean(db, DistributionSellerVo.class);
|
|
|
}
|
|
|
|