|
|
@@ -8,6 +8,7 @@ import com.iformall.mapper.InviteCodeMapper; |
|
|
|
import com.iformall.service.sm.InviteCodeService; |
|
|
|
import com.iformall.utils.sign.AppUtils; |
|
|
|
import io.swagger.models.auth.In; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
@@ -22,11 +23,17 @@ public class InviteCodeServiceImpl implements InviteCodeService { |
|
|
|
public String inviteCode(Long memberId) { |
|
|
|
//生成了邀请码 查一下是否重复 |
|
|
|
String inviteCode = AppUtils.getInviteCode(); |
|
|
|
InviteCode info = getCodeInfo(inviteCode); |
|
|
|
if (!ObjectUtils.isEmpty(info)){ |
|
|
|
InviteCode info = getCodeInfo(inviteCode, null); |
|
|
|
if (!ObjectUtils.isEmpty(info)) { |
|
|
|
inviteCode = AppUtils.getInviteCode(); |
|
|
|
} |
|
|
|
|
|
|
|
//如果用户已经生成过邀请码 就直接返回 |
|
|
|
InviteCode userInfo = getCodeInfo(null, memberId); |
|
|
|
if (!ObjectUtils.isEmpty(userInfo)) { |
|
|
|
return userInfo.getCode(); |
|
|
|
} |
|
|
|
|
|
|
|
InviteCode code = new InviteCode(); |
|
|
|
code.setId(IdWorker.get().nextId()); |
|
|
|
code.setCode(inviteCode); |
|
|
@@ -37,8 +44,11 @@ public class InviteCodeServiceImpl implements InviteCodeService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public InviteCode getCodeInfo(String code) { |
|
|
|
return inviteCodeMapper.selectOne(new LambdaQueryWrapper<InviteCode>().eq(InviteCode::getIsDel, 0).eq(InviteCode::getCode, code)); |
|
|
|
public InviteCode getCodeInfo(String code, Long userId) { |
|
|
|
return inviteCodeMapper.selectOne(new LambdaQueryWrapper<InviteCode>() |
|
|
|
.eq(InviteCode::getIsDel, 0) |
|
|
|
.eq(StringUtils.isNotEmpty(code), InviteCode::getCode, code) |
|
|
|
.eq(userId != null, InviteCode::getUserId, userId)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|