|
@@ -11,6 +11,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.zhongzheng.common.constant.Constants;
|
|
|
+import com.zhongzheng.common.core.domain.AjaxResult;
|
|
|
+import com.zhongzheng.common.core.domain.entity.SysUser;
|
|
|
+import com.zhongzheng.common.core.domain.model.LoginUser;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.enums.UserStatus;
|
|
|
import com.zhongzheng.common.exception.BaseException;
|
|
@@ -22,6 +25,7 @@ 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.system.service.ISysUserService;
|
|
|
import com.zhongzheng.modules.top.distribution.bo.DistributionSellerQuery;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
import com.zhongzheng.modules.user.entity.ClientLoginSeller;
|
|
@@ -53,7 +57,10 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
private IUserService iUserService;
|
|
|
|
|
|
@Autowired
|
|
|
- private SellerTokenService sellerTokenService;
|
|
|
+ private ISysUserService iSysUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
|
|
|
@Override
|
|
|
public Boolean registerSeller(SellerAppRegisterBo bo) {
|
|
@@ -80,32 +87,22 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
if(!code.equals(bo.getCode())){
|
|
|
throw new CustomException("验证码错误");
|
|
|
}
|
|
|
- DistributionSeller seller = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
- .eq(DistributionSeller::getTelphone, EncryptHandler.encrypt(bo.getTel())).last("limit 1"));
|
|
|
+ SysUser seller = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>()
|
|
|
+ .eq(SysUser::getPhonenumber, 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"));
|
|
|
+ SysUser sellerIdCard = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>()
|
|
|
+ .eq(SysUser::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.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"));
|
|
@@ -116,6 +113,14 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
if(!save(inertData)){
|
|
|
throw new CustomException("注册失败");
|
|
|
}
|
|
|
+ SysUser sysUser = new SysUser();
|
|
|
+ sysUser.setUserName(bo.getTel());
|
|
|
+ sysUser.setPhonenumber(bo.getTel());
|
|
|
+ sysUser.setAvatar(bo.getAvatar());
|
|
|
+ sysUser.setPassword(SecurityUtils.encryptPassword(bo.getPwd()));
|
|
|
+ sysUser.setPwdTime(DateUtils.getNowTime());
|
|
|
+ sysUser.setSellerId(inertData.getSellerId());
|
|
|
+ iSysUserService.insertUser(sysUser);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -136,19 +141,16 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
throw new CustomException("验证码错误");
|
|
|
}
|
|
|
redisCache.deleteObject(key);
|
|
|
- DistributionSeller seller = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
- .eq(DistributionSeller::getTelphone,EncryptHandler.encrypt(bo.getTel())).last("limit 1"));
|
|
|
+ SysUser seller = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>()
|
|
|
+ .eq(SysUser::getPhonenumber,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);
|
|
|
+ return iSysUserService.update(null,
|
|
|
+ new LambdaUpdateWrapper<SysUser>()
|
|
|
+ .set(SysUser::getPassword,SecurityUtils.encryptPassword(bo.getPwd()))
|
|
|
+ .set(SysUser::getPwdTime,DateUtils.getNowTime())
|
|
|
+ .eq(SysUser::getUserId,seller.getUserId()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -160,38 +162,13 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
*/
|
|
|
@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 Map<String, Object> accountLogin(SellerAppAccountLoginBo bo) {
|
|
|
- if(Validator.isEmpty(bo.getAccount())){
|
|
|
+/* if(Validator.isEmpty(bo.getAccount())){
|
|
|
throw new CustomException("账号不能为空");
|
|
|
}
|
|
|
LambdaQueryWrapper<DistributionSeller> queryWrapper =new LambdaQueryWrapper<DistributionSeller>();
|
|
@@ -231,7 +208,8 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
map.put(Constants.TOKEN,sellerTokenService.createToken(loginSeller));
|
|
|
map.put("user_account",seller.getUserAccount());
|
|
|
map.put("full_info",Validator.isEmpty(seller.getIdCard())?false:true); //是否完善身份信息
|
|
|
- return map;
|
|
|
+ return map;*/
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -248,18 +226,22 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
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)) {
|
|
|
+ SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>()
|
|
|
+ .eq(SysUser::getPhonenumber, bo.getTel()).last("limit 1"));
|
|
|
+ if (Validator.isEmpty(sysUser)) {
|
|
|
throw new CustomException("该手机号未注册");
|
|
|
}
|
|
|
-
|
|
|
- ClientLoginSeller loginSeller = new ClientLoginSeller();
|
|
|
- loginSeller.setSeller(seller);
|
|
|
+ if(Validator.isEmpty(sysUser.getSellerId())){
|
|
|
+ throw new CustomException("非业务员账号");
|
|
|
+ }
|
|
|
+ DistributionSeller seller = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
+ .eq(DistributionSeller::getSellerId, sysUser.getSellerId()));
|
|
|
+ LoginUser loginSeller = new LoginUser();
|
|
|
+ loginSeller.setUser(sysUser);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- map.put(Constants.TOKEN, sellerTokenService.createToken(loginSeller));
|
|
|
+ map.put(Constants.TOKEN, tokenService.createToken(loginSeller));
|
|
|
map.put("user_account", seller.getUserAccount());
|
|
|
- map.put("full_info", Validator.isEmpty(seller.getIdCard()) ? false : true); //是否完善身份信息
|
|
|
+ map.put("full_info", Validator.isEmpty(sysUser.getIdCard()) ? false : true); //是否完善身份信息
|
|
|
return map;
|
|
|
}
|
|
|
public List<DistributionSellerVo> getSellerListByTenant(DistributionSellerQuery query) {
|
|
@@ -283,15 +265,11 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
public List<DistributionSellerVo> queryList(DistributionSellerQueryBo bo) {
|
|
|
LambdaQueryWrapper<DistributionSeller> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.like(StrUtil.isNotBlank(bo.getRealname()), DistributionSeller::getRealname, bo.getRealname());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getIdCard()), DistributionSeller::getIdCard, bo.getIdCard());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getTelphone()), DistributionSeller::getTelphone, bo.getTelphone());
|
|
|
lqw.eq(bo.getStatus() != null, DistributionSeller::getStatus, bo.getStatus());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getAvatar()), DistributionSeller::getAvatar, bo.getAvatar());
|
|
|
lqw.eq(bo.getUserId() != null, DistributionSeller::getUserId, bo.getUserId());
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getUserAccount()), DistributionSeller::getUserAccount, bo.getUserAccount());
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getGzhOpenId()), DistributionSeller::getGzhOpenId, bo.getGzhOpenId());
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getUnionId()), DistributionSeller::getUnionId, bo.getUnionId());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getPassword()), DistributionSeller::getPassword, bo.getPassword());
|
|
|
return entity2Vo(this.list(lqw));
|
|
|
}
|
|
|
|
|
@@ -322,7 +300,7 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean insertByAddBo(DistributionSellerAddBo bo) {
|
|
|
- if(StringUtils.isBlank(bo.getIdCard())){
|
|
|
+ /* if(StringUtils.isBlank(bo.getIdCard())){
|
|
|
throw new CustomException("身份证不能为空");
|
|
|
}
|
|
|
if(bo.getTelphone()==null){
|
|
@@ -370,12 +348,13 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
inertData.setParentId(sellerShare.getSellerId());
|
|
|
}
|
|
|
}
|
|
|
- return this.save(inertData);
|
|
|
+ return this.save(inertData);*/
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean insertBatchByAddBo(DistributionSellerAddBo bo) {
|
|
|
- for(Long userId:bo.getUserIds()){
|
|
|
+ /* for(Long userId:bo.getUserIds()){
|
|
|
User user = iUserService.getOne(new LambdaQueryWrapper<User>()
|
|
|
.eq(User::getUserId,userId));
|
|
|
if(Validator.isEmpty(user.getIdCard())){
|
|
@@ -397,7 +376,7 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
insertByAddBo(bo1);
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ }*/
|
|
|
return true;
|
|
|
}
|
|
|
|