|
@@ -11,7 +11,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
import com.zhongzheng.common.constant.Constants;
|
|
import com.zhongzheng.common.constant.Constants;
|
|
-import com.zhongzheng.common.core.domain.AjaxResult;
|
|
|
|
import com.zhongzheng.common.core.domain.entity.SysRole;
|
|
import com.zhongzheng.common.core.domain.entity.SysRole;
|
|
import com.zhongzheng.common.core.domain.entity.SysUser;
|
|
import com.zhongzheng.common.core.domain.entity.SysUser;
|
|
import com.zhongzheng.common.core.domain.model.LoginUser;
|
|
import com.zhongzheng.common.core.domain.model.LoginUser;
|
|
@@ -21,6 +20,7 @@ import com.zhongzheng.common.exception.BaseException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.type.EncryptHandler;
|
|
import com.zhongzheng.common.type.EncryptHandler;
|
|
import com.zhongzheng.common.utils.*;
|
|
import com.zhongzheng.common.utils.*;
|
|
|
|
+import com.zhongzheng.common.utils.ip.IpUtils;
|
|
import com.zhongzheng.modules.distribution.bo.*;
|
|
import com.zhongzheng.modules.distribution.bo.*;
|
|
import com.zhongzheng.modules.distribution.domain.DistributionSeller;
|
|
import com.zhongzheng.modules.distribution.domain.DistributionSeller;
|
|
import com.zhongzheng.modules.distribution.mapper.DistributionSellerMapper;
|
|
import com.zhongzheng.modules.distribution.mapper.DistributionSellerMapper;
|
|
@@ -30,7 +30,7 @@ import com.zhongzheng.modules.system.service.ISysRoleService;
|
|
import com.zhongzheng.modules.system.service.ISysUserService;
|
|
import com.zhongzheng.modules.system.service.ISysUserService;
|
|
import com.zhongzheng.modules.top.distribution.bo.DistributionSellerQuery;
|
|
import com.zhongzheng.modules.top.distribution.bo.DistributionSellerQuery;
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
-import com.zhongzheng.modules.user.entity.ClientLoginSeller;
|
|
|
|
|
|
+import com.zhongzheng.modules.user.entity.ClientLoginUser;
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -112,6 +112,7 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
inertData.setCreateTime(DateUtils.getNowTime());
|
|
inertData.setCreateTime(DateUtils.getNowTime());
|
|
inertData.setUpdateTime(DateUtils.getNowTime());
|
|
inertData.setUpdateTime(DateUtils.getNowTime());
|
|
inertData.setShareCode(ToolsUtils.getRandomString(8));
|
|
inertData.setShareCode(ToolsUtils.getRandomString(8));
|
|
|
|
+ inertData.setRegisterFrom(1);
|
|
if(Validator.isNotEmpty(bo.getShareCode())){
|
|
if(Validator.isNotEmpty(bo.getShareCode())){
|
|
DistributionSeller sellerShare = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
DistributionSeller sellerShare = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
.eq(DistributionSeller::getShareCode,bo.getShareCode()).last("limit 1"));
|
|
.eq(DistributionSeller::getShareCode,bo.getShareCode()).last("limit 1"));
|
|
@@ -129,6 +130,7 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
SysUser sysUser = new SysUser();
|
|
SysUser sysUser = new SysUser();
|
|
sysUser.setUserName(bo.getTel());
|
|
sysUser.setUserName(bo.getTel());
|
|
sysUser.setPhonenumber(bo.getTel());
|
|
sysUser.setPhonenumber(bo.getTel());
|
|
|
|
+ sysUser.setIdCard(bo.getIdcard());
|
|
sysUser.setAvatar(bo.getAvatar());
|
|
sysUser.setAvatar(bo.getAvatar());
|
|
sysUser.setPassword(SecurityUtils.encryptPassword(bo.getPwd()));
|
|
sysUser.setPassword(SecurityUtils.encryptPassword(bo.getPwd()));
|
|
sysUser.setPwdTime(DateUtils.getNowTime());
|
|
sysUser.setPwdTime(DateUtils.getNowTime());
|
|
@@ -339,40 +341,62 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public Boolean insertByAddBo(DistributionSellerAddBo bo) {
|
|
public Boolean insertByAddBo(DistributionSellerAddBo bo) {
|
|
-
|
|
|
|
- /* DistributionSeller add = BeanUtil.toBean(bo, DistributionSeller.class);
|
|
|
|
|
|
+ if(Validator.isEmpty(bo.getIdCard())){
|
|
|
|
+ throw new CustomException("没有身份证信息");
|
|
|
|
+ }
|
|
|
|
+ if(Validator.isEmpty(bo.getPhonenumber())){
|
|
|
|
+ throw new CustomException("没有手机号码");
|
|
|
|
+ }
|
|
|
|
+ if(Validator.isEmpty(bo.getRealname())){
|
|
|
|
+ throw new CustomException("没有真实姓名");
|
|
|
|
+ }
|
|
|
|
+ SysUser sellerIdCard = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>()
|
|
|
|
+ .eq(SysUser::getIdCard,bo.getIdCard()));
|
|
|
|
+ if(Validator.isNotNull(sellerIdCard)){
|
|
|
|
+ if(Validator.isNotEmpty(sellerIdCard.getSellerId())){
|
|
|
|
+ throw new CustomException("该身份证已注册业务员");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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());
|
|
|
|
|
|
DistributionSeller inertData = new DistributionSeller();
|
|
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.setRealname(bo.getRealname());
|
|
- inertData.setAvatar(Constants.DEFAULT_AVATAR);
|
|
|
|
inertData.setUserAccount(ServletUtils.getEncoded("YW"));
|
|
inertData.setUserAccount(ServletUtils.getEncoded("YW"));
|
|
inertData.setCreateTime(DateUtils.getNowTime());
|
|
inertData.setCreateTime(DateUtils.getNowTime());
|
|
inertData.setUpdateTime(DateUtils.getNowTime());
|
|
inertData.setUpdateTime(DateUtils.getNowTime());
|
|
inertData.setShareCode(ToolsUtils.getRandomString(8));
|
|
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());
|
|
|
|
|
|
+ inertData.setRegisterFrom(2);
|
|
|
|
+ if(!save(inertData)){
|
|
|
|
+ throw new CustomException("注册失败");
|
|
}
|
|
}
|
|
- 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(Validator.isNotEmpty(sellerIdCard)){
|
|
|
|
+ sellerIdCard.setSellerId(inertData.getSellerId());
|
|
|
|
+ iSysUserService.updateById(sellerIdCard);
|
|
|
|
+ }else{
|
|
|
|
+ SysUser sysUser = new SysUser();
|
|
|
|
+ sysUser.setUserName(bo.getPhonenumber());
|
|
|
|
+ sysUser.setPhonenumber(bo.getPhonenumber());
|
|
|
|
+ sysUser.setIdCard(bo.getIdCard());
|
|
|
|
+ //密码身份证后六位
|
|
|
|
+ String pwd = bo.getIdCard().substring(bo.getIdCard().length() - 6);
|
|
|
|
+ sysUser.setPassword(SecurityUtils.encryptPassword(pwd));
|
|
|
|
+ sysUser.setPwdTime(DateUtils.getNowTime());
|
|
|
|
+ sysUser.setSellerId(inertData.getSellerId());
|
|
|
|
+ SysRole role = iSysRoleService.getOne(new LambdaQueryWrapper<SysRole>()
|
|
|
|
+ .eq(SysRole::getRoleKey, "seller")
|
|
|
|
+ .eq(SysRole::getStatus, 1).last("limit 1"));
|
|
|
|
+ if(Validator.isNotEmpty(role)){
|
|
|
|
+ sysUser.setRoleIds(new Long[]{role.getRoleId()});
|
|
}
|
|
}
|
|
|
|
+ iSysUserService.insertUser(sysUser);
|
|
}
|
|
}
|
|
- return this.save(inertData);*/
|
|
|
|
- return null;
|
|
|
|
|
|
+
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -398,6 +422,7 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
inertData.setCreateTime(DateUtils.getNowTime());
|
|
inertData.setCreateTime(DateUtils.getNowTime());
|
|
inertData.setUpdateTime(DateUtils.getNowTime());
|
|
inertData.setUpdateTime(DateUtils.getNowTime());
|
|
inertData.setShareCode(ToolsUtils.getRandomString(8));
|
|
inertData.setShareCode(ToolsUtils.getRandomString(8));
|
|
|
|
+ inertData.setRegisterFrom(3);
|
|
if(this.save(inertData)){
|
|
if(this.save(inertData)){
|
|
user.setSellerId(inertData.getSellerId());
|
|
user.setSellerId(inertData.getSellerId());
|
|
}
|
|
}
|
|
@@ -407,10 +432,11 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Boolean updateByEditBo(DistributionSellerEditBo bo) {
|
|
public Boolean updateByEditBo(DistributionSellerEditBo bo) {
|
|
- DistributionSeller update = BeanUtil.toBean(bo, DistributionSeller.class);
|
|
|
|
- validEntityBeforeSave(update);
|
|
|
|
- update.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
- return this.updateById(update);
|
|
|
|
|
|
+ SysUser user = new SysUser();
|
|
|
|
+ user.setAvatar(bo.getAvatar());
|
|
|
|
+ user.setUserId(bo.getSysUserId());
|
|
|
|
+ user.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
+ return iSysUserService.updateById(user);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -429,6 +455,21 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
}
|
|
}
|
|
return this.removeByIds(ids);
|
|
return this.removeByIds(ids);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String refreshSellerToken(String userAccount) {
|
|
|
|
+ DistributionSeller seller = getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
|
+ .eq(DistributionSeller::getUserAccount, userAccount).last("limit 1"));
|
|
|
|
+ if (seller == null) {
|
|
|
|
+ throw new CustomException("userAccount不存在");
|
|
|
|
+ }
|
|
|
|
+ SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>()
|
|
|
|
+ .eq(SysUser::getSellerId, seller.getSellerId()).last("limit 1"));
|
|
|
|
+ if(Validator.isEmpty(sysUser)){
|
|
|
|
+ throw new CustomException("非法账号");
|
|
|
|
+ }
|
|
|
|
+ LoginUser loginSeller = new LoginUser();
|
|
|
|
+ loginSeller.setUser(sysUser);
|
|
|
|
+ return tokenService.createToken(loginSeller);
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|