...
|
...
|
@@ -37,7 +37,7 @@ import java.util.stream.Collectors; |
|
|
@Service
|
|
|
public class InviteServiceImpl implements IInviteService {
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(AppraiseService.class);
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(InviteServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
IStoredSellerService storedSellerService;
|
...
|
...
|
@@ -127,11 +127,7 @@ public class InviteServiceImpl implements IInviteService { |
|
|
throw new ServiceException(ServiceError.INVITE_CODE_NOT_EXIST);
|
|
|
}
|
|
|
|
|
|
String inviteCode = showInviteCode.replaceFirst(inviterType.getAlphabet(), "");
|
|
|
if (!inviteCode.matches("\\d+")){
|
|
|
LOGGER.warn("invite invalidate, showInviteCode is {}", showInviteCode);
|
|
|
throw new ServiceException(ServiceError.INVITE_CODE_NOT_EXIST);
|
|
|
}
|
|
|
String inviteCode = inviterType.getValue();
|
|
|
|
|
|
// 未开始
|
|
|
InviteActivity inviteActivity = inviteActivityMapper.selectLastActivtiy();
|
...
|
...
|
@@ -151,7 +147,7 @@ public class InviteServiceImpl implements IInviteService { |
|
|
// 不能自己邀请自己
|
|
|
if (inviter.getUid() == uid){
|
|
|
LOGGER.info("can not invite self, uid is {}, showInviteCode is {}", uid, showInviteCode);
|
|
|
throw new ServiceException(ServiceError.INVITE_CODE_NOT_EXIST);
|
|
|
throw new ServiceException(ServiceError.CAN_NOT_INVITE_SELF);
|
|
|
}
|
|
|
|
|
|
// 校验是否已经有绑定关系
|
...
|
...
|
@@ -169,6 +165,11 @@ public class InviteServiceImpl implements IInviteService { |
|
|
throw new ServiceException(ServiceError.INVITE_ACTIVITY_HAS_END);
|
|
|
}
|
|
|
|
|
|
if (!storedSellerService.isStoredSeller(inviter.getUid())){
|
|
|
LOGGER.warn("inviter has quit, showInviteCode is {}, uid is {}", showInviteCode, uid);
|
|
|
throw new ServiceException(ServiceError.INVITE_CODE_INVALIDATE);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -217,7 +218,7 @@ public class InviteServiceImpl implements IInviteService { |
|
|
.uid(uid)
|
|
|
.showInviteCode(showInviteCode)
|
|
|
.inviteeUidNum(inviteeUidList.size())
|
|
|
.finishedOrderNum(orderNumMap.keySet().stream().collect(Collectors.summingInt(Integer::intValue)))
|
|
|
.finishedOrderNum(orderNumMap.values().stream().collect(Collectors.summingInt(Integer::intValue)))
|
|
|
.inviteRecordList(getInviteRecordList(inviteRecords, storedSellerMap, orderNumMap, nickNameMap))
|
|
|
.build();
|
|
|
|
...
|
...
|
@@ -234,7 +235,7 @@ public class InviteServiceImpl implements IInviteService { |
|
|
return inviteRecords.stream().map(x ->{
|
|
|
return InviteInfoResp.InviteRecord.builder()
|
|
|
.inviteeUid(x.getInviteeUid())
|
|
|
.nikeName(Objects.isNull(nickNameMap.get(x.getInviteeUid())) ? "" : nickNameMap.get(x.getInviteeUid()))
|
|
|
.nickName(Objects.isNull(nickNameMap.get(x.getInviteeUid())) ? "" : nickNameMap.get(x.getInviteeUid()))
|
|
|
.enterTime(storedSellerMap.get(x.getInviteeUid()) == null ? "" : DateUtil.getDateFormatLong(storedSellerMap.get(x.getInviteeUid())))
|
|
|
.orderNum(Objects.isNull(orderNumMap.get(x.getInviteeUid())) ? 0 : orderNumMap.get(x.getInviteeUid()))
|
|
|
.build();
|
...
|
...
|
@@ -356,7 +357,7 @@ public class InviteServiceImpl implements IInviteService { |
|
|
*/
|
|
|
public int quitInviter(int uid){
|
|
|
|
|
|
// 检查该退驻的商户是否是邀请人,则之前的所有绑定关系无效
|
|
|
// 检查该退驻的商户是否邀请人,将使用A类邀请码的绑定关系设置成无效
|
|
|
InviteRecord inviteRecord = new InviteRecord();
|
|
|
inviteRecord.setInviterUid(uid);
|
|
|
inviteRecord.setStatus(InviteRecordStatusEnum.INVALID.getCode());
|
...
|
...
|
@@ -385,11 +386,7 @@ public class InviteServiceImpl implements IInviteService { |
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
String inviteCode = showInviteCode.replaceFirst(inviterType.getAlphabet(),"");
|
|
|
if (!inviteCode.matches("\\d+")){
|
|
|
LOGGER.warn("[{}] [{}] [{}]. invite code invaliate.", showInviteCode, uid, orderCode);
|
|
|
return 0 ;
|
|
|
}
|
|
|
String inviteCode = inviterType.getValue();
|
|
|
|
|
|
Inviter inviter = inviterMapper.selectValidateInviter(inviterType.getType(), Integer.parseInt(inviteCode));
|
|
|
// 无有效的邀请信息
|
...
|
...
|
@@ -416,9 +413,12 @@ public class InviteServiceImpl implements IInviteService { |
|
|
record.setInviterUid(inviter.getUid());
|
|
|
record.setInviteeUid(uid);
|
|
|
record.setInviterId(inviter.getId());
|
|
|
record.setInviteActivityId(inviteActivity.getId());
|
|
|
record.setCreateTime(DateUtils.getCurrentTimeSeconds());
|
|
|
inviteRecordMapper.insert(record);
|
|
|
record.setStatus(InviterStatus.VALID.getCode());
|
|
|
record.setInviteActivityId(inviterType == InviterType.STORED_SELLER ? inviteActivity.getId() : 0);
|
|
|
int now = DateUtils.getCurrentTimeSeconds();
|
|
|
record.setCreateTime(now);
|
|
|
record.setUpdateTime(now);
|
|
|
inviteRecordMapper.insertSelective(record);
|
|
|
|
|
|
return 1;
|
|
|
}
|
...
|
...
|
|