|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.github.rholder.retry.Retryer;
|
|
|
import com.github.rholder.retry.RetryerBuilder;
|
|
|
import com.github.rholder.retry.StopStrategies;
|
|
|
import com.google.common.base.Predicates;
|
|
|
import com.yoho.core.rest.client.ServiceCaller;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.message.sdk.utils.DateUtils;
|
|
|
import com.yoho.service.model.social.response.UserInfoRspBO;
|
|
|
import com.yohobuy.ufo.model.order.resp.InviteInfoResp;
|
|
|
import com.yohoufo.common.ApiResponse;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
...
|
...
|
@@ -19,10 +18,10 @@ import com.yohoufo.order.common.InviterType; |
|
|
import com.yohoufo.order.service.IInviteService;
|
|
|
import com.yohoufo.order.service.IStoredSellerService;
|
|
|
import com.yohoufo.order.service.proxy.UserProxyService;
|
|
|
import com.yohoufo.order.service.support.InviteCodeGenerator;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
...
|
...
|
@@ -31,7 +30,6 @@ import java.util.List; |
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
...
|
...
|
@@ -43,9 +41,6 @@ public class InviteServiceImpl implements IInviteService { |
|
|
IStoredSellerService storedSellerService;
|
|
|
|
|
|
@Autowired
|
|
|
InviteCodeSequenceMapper inviteCodeSequenceMapper;
|
|
|
|
|
|
@Autowired
|
|
|
InviterMapper inviterMapper;
|
|
|
|
|
|
@Autowired
|
...
|
...
|
@@ -60,9 +55,12 @@ public class InviteServiceImpl implements IInviteService { |
|
|
@Autowired
|
|
|
ServiceCaller serviceCaller;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
UserProxyService userProxyService;
|
|
|
|
|
|
@Autowired
|
|
|
InviteCodeGenerator inviteCodeGenerator;
|
|
|
|
|
|
/**
|
|
|
* 是否需要跳转到入驻页面
|
|
|
* @param uid
|
...
|
...
|
@@ -272,7 +270,7 @@ public class InviteServiceImpl implements IInviteService { |
|
|
|
|
|
// 已入驻
|
|
|
if (storedSeller){
|
|
|
Integer generateAInviteCode = generateInviteCodeSequence(uid);
|
|
|
Integer generateAInviteCode = saveInviteCode(uid);
|
|
|
|
|
|
lastShowInvite = generateAInviteCode != null ?
|
|
|
getShowInviteCode(InviterType.STORED_SELLER, generateAInviteCode)
|
...
|
...
|
@@ -288,7 +286,7 @@ public class InviteServiceImpl implements IInviteService { |
|
|
if (!storedSeller){
|
|
|
lastShowInvite = null;
|
|
|
}else{
|
|
|
Integer generateAInviteCode = generateInviteCodeSequence(uid);
|
|
|
Integer generateAInviteCode = saveInviteCode(uid);
|
|
|
|
|
|
lastShowInvite = generateAInviteCode != null ? getShowInviteCode(InviterType.STORED_SELLER, generateAInviteCode) : null;
|
|
|
}
|
...
|
...
|
@@ -318,7 +316,7 @@ public class InviteServiceImpl implements IInviteService { |
|
|
* @param uid
|
|
|
* @return
|
|
|
*/
|
|
|
private Integer generateInviteCodeSequence(int uid) {
|
|
|
private Integer saveInviteCode(int uid) {
|
|
|
|
|
|
// 是否存在A类邀请码,(即使是无效的也不会继续生成)
|
|
|
Inviter aClassInviter = inviterMapper.selectInviteCodeByUidType(uid, InviterType.STORED_SELLER.getType());
|
...
|
...
|
@@ -329,25 +327,25 @@ public class InviteServiceImpl implements IInviteService { |
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 生成邀请码
|
|
|
InviteCodeSequence inviteCodeSequence = new InviteCodeSequence();
|
|
|
inviteCodeSequence.setCreateTime(DateUtil.getCurrentTimeSecond());
|
|
|
inviteCodeSequenceMapper.insert(inviteCodeSequence);
|
|
|
Integer codeSequence = inviteCodeGenerator.generateCodeSequenceRandom();
|
|
|
|
|
|
// 插入邀请码
|
|
|
Inviter inviter = new Inviter();
|
|
|
inviter.setUid(uid);
|
|
|
inviter.setType(InviterType.STORED_SELLER.getType());
|
|
|
inviter.setInviteCode(inviteCodeSequence.getId());
|
|
|
inviter.setInviteCode(codeSequence);
|
|
|
int now = DateUtil.getCurrentTimeSecond();
|
|
|
inviter.setUpdateTime(now);
|
|
|
inviter.setCreateTime(now);
|
|
|
inviterMapper.insertSelective(inviter);
|
|
|
|
|
|
return inviteCodeSequence.getId();
|
|
|
return codeSequence;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 邀请者退驻则之前的所有绑定关系无效
|
|
|
* @param uid
|
...
|
...
|
|