|
|
@@ -1,6 +1,7 @@ |
|
|
|
package com.iformall.service.sm.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.common.ResultData; |
|
|
@@ -8,11 +9,16 @@ import com.iformall.domain.po.WxCUserBasicInfo; |
|
|
|
import com.iformall.domain.po.sm.InviteCode; |
|
|
|
import com.iformall.domain.po.sm.InviteCodeInfo; |
|
|
|
import com.iformall.mapper.InviteCodeInfoMapper; |
|
|
|
import com.iformall.service.WxCUserBasicInfoService; |
|
|
|
import com.iformall.service.sm.InviteCodeInfoService; |
|
|
|
import com.iformall.service.sm.InviteCodeService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class InviteCodeInfoServiceImpl implements InviteCodeInfoService { |
|
|
@@ -23,6 +29,9 @@ public class InviteCodeInfoServiceImpl implements InviteCodeInfoService { |
|
|
|
@Autowired |
|
|
|
private InviteCodeService inviteCodeService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCUserBasicInfoService wxCUserBasicInfoService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 使用邀请码 |
|
|
|
* |
|
|
@@ -34,7 +43,7 @@ public class InviteCodeInfoServiceImpl implements InviteCodeInfoService { |
|
|
|
@Override |
|
|
|
public ResultData useCode(WxCUserBasicInfo cUser, String code) { |
|
|
|
//查询code 是否存在,存在再去进行操作 |
|
|
|
InviteCode info = inviteCodeService.getCodeInfo(code,null); |
|
|
|
InviteCode info = inviteCodeService.getCodeInfo(code, null); |
|
|
|
if (!ObjectUtils.isEmpty(info)) { |
|
|
|
if (cUser.getId().equals(info.getUserId())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, "不能使用自己的邀请码"); |
|
|
@@ -78,4 +87,23 @@ public class InviteCodeInfoServiceImpl implements InviteCodeInfoService { |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<InviteCodeInfo> getUseCodeUser(WxCUserBasicInfo cUser) { |
|
|
|
List<InviteCodeInfo> codeInfos = inviteCodeInfoMapper.selectList(new LambdaQueryWrapper<InviteCodeInfo>() |
|
|
|
.eq(InviteCodeInfo::getIsDel, 0) |
|
|
|
.eq(InviteCodeInfo::getUserId, cUser.getId()) |
|
|
|
.select(InviteCodeInfo::getEmail, InviteCodeInfo::getPhone, InviteCodeInfo::getUserId, InviteCodeInfo::getCreateDate)); |
|
|
|
if (CollectionUtils.isEmpty(codeInfos)) { |
|
|
|
return Lists.newArrayList(); |
|
|
|
} |
|
|
|
for (InviteCodeInfo info : codeInfos) { |
|
|
|
WxCUserBasicInfo userBasicInfo = wxCUserBasicInfoService.getById(info.getUserId()); |
|
|
|
if (!ObjectUtils.isEmpty(userBasicInfo)) { |
|
|
|
info.setName(StringUtils.isEmpty(userBasicInfo.getName()) ? null : userBasicInfo.getName()); |
|
|
|
info.setAvatarUrl(StringUtils.isEmpty(userBasicInfo.getAvatarUrl()) ? null : userBasicInfo.getAvatarUrl()); |
|
|
|
} |
|
|
|
} |
|
|
|
return codeInfos; |
|
|
|
} |
|
|
|
} |