推广员重复校验
parent
9bef9b0cc3
commit
6d93d5ca16
|
@ -15,6 +15,8 @@ public interface ErrorCodeConstants {
|
|||
ErrorCode PROMOTER_NOT_EXISTS = new ErrorCode(1004001002, "推广员不存在");
|
||||
|
||||
ErrorCode PROMOTER_EXISTS = new ErrorCode(1004001003, "推广员存在");
|
||||
|
||||
ErrorCode PROMOTER_EXISTS_OTHER = new ErrorCode(1004001003, "推广员信息存在于其他商户");
|
||||
ErrorCode PROMOTER_IMPORT_LIST_IS_EMPTY = new ErrorCode(1002003004, "导入推广员数据不能为空!");
|
||||
// ========== AUTH 模块 1004003000 ==========
|
||||
ErrorCode AUTH_LOGIN_BAD_CREDENTIALS = new ErrorCode(1004003000, "登录失败,账号密码不正确");
|
||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
|
|||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.enums.ErrorCodeConstants;
|
||||
|
@ -76,11 +77,13 @@ public class PromoterServiceImpl implements PromoterService {
|
|||
memberUserDO.setPassword(createReqVO.getMobile().substring(createReqVO.getMobile().length() - 6));
|
||||
memberUserDO = memberUserService.createUserIfAbsent(createReqVO.getMobile(), createReqVO.getNickname(), getClientIP());
|
||||
}
|
||||
if(!TenantContextHolder.getTenantId().equals(memberUserDO.getTenantId())){
|
||||
throw new ServiceException(PROMOTER_EXISTS_OTHER);
|
||||
}
|
||||
// 插入
|
||||
PromoterDO promoter = PromoterConvert.INSTANCE.convert(createReqVO);
|
||||
promoter.setTenantId(TenantContextHolder.getTenantId());
|
||||
Long count = promoterMapper.selectCount(Wrappers.lambdaQuery(PromoterDO.class).eq(PromoterDO::getUserId, memberUserDO.getId()));
|
||||
if (count > 0) {
|
||||
if (checkIsPromoterByUserId(memberUserDO.getId())) {
|
||||
throw new ServiceException(PROMOTER_EXISTS);
|
||||
}
|
||||
promoter.setUserId(memberUserDO.getId());
|
||||
|
@ -135,6 +138,7 @@ public class PromoterServiceImpl implements PromoterService {
|
|||
* @param userId@return 推广员
|
||||
*/
|
||||
@Override
|
||||
@TenantIgnore
|
||||
public Boolean checkIsPromoterByUserId(Long userId) {
|
||||
Long count = this.promoterMapper.selectCount(Wrappers.lambdaQuery(PromoterDO.class).eq(PromoterDO::getUserId, userId));
|
||||
return count > 0;
|
||||
|
|
|
@ -56,6 +56,7 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
@Override
|
||||
@TenantIgnore
|
||||
public MemberUserDO getUserByMobile(String mobile) {
|
||||
return memberUserMapper.selectByMobile(mobile);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue