|
|
@ -3,12 +3,11 @@ package awesome.group.game.service; |
|
|
|
|
|
|
|
import awesome.group.game.dao.bean.GameApp; |
|
|
|
import awesome.group.game.dao.bean.InviteRecord; |
|
|
|
import awesome.group.game.dao.mapper.InviteRecordMapper; |
|
|
|
import awesome.group.game.service.bo.*; |
|
|
|
import awesome.group.game.dao.bean.WeGameUser; |
|
|
|
import awesome.group.game.service.bo.WxUserInfo; |
|
|
|
import awesome.group.game.dao.mapper.GameAppMapper; |
|
|
|
import awesome.group.game.dao.mapper.InviteRecordMapper; |
|
|
|
import awesome.group.game.dao.mapper.WeGameUserMapper; |
|
|
|
import awesome.group.game.service.bo.*; |
|
|
|
import awesome.group.game.service.common.exception.PaganiException; |
|
|
|
import awesome.group.game.service.common.exception.PaganiExceptionCode; |
|
|
|
import awesome.group.game.service.util.EncryptUtil; |
|
|
@ -24,10 +23,12 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import java.sql.Timestamp; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class WxService { |
|
|
@ -58,15 +59,23 @@ public class WxService { |
|
|
|
inviteRecordMapper.insert(record); |
|
|
|
} |
|
|
|
|
|
|
|
public List<UserInfo> myInviteRecord(Integer userId) { |
|
|
|
List<Integer> list = inviteRecordMapper.query(userId); |
|
|
|
public InviteInfo myInviteRecord(Integer userId) { |
|
|
|
List<InviteRecord> list = inviteRecordMapper.query(userId); |
|
|
|
WeGameUser u = weGameUserMapper.selectById(userId); |
|
|
|
InviteInfo info = new InviteInfo(); |
|
|
|
info.inviteCnt = u.getInviteCnt(); |
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
return info; |
|
|
|
} |
|
|
|
List<Integer> uids = list.stream().map(InviteRecord::getInvitedUserId).toList(); |
|
|
|
LambdaQueryWrapper<WeGameUser> query = Wrappers.lambdaQuery(); |
|
|
|
query.in(WeGameUser::getId, list); |
|
|
|
query.in(WeGameUser::getId, uids); |
|
|
|
List<WeGameUser> data = weGameUserMapper.selectList(query); |
|
|
|
return data.stream().map(UserInfo::new).toList(); |
|
|
|
Map<Integer, WeGameUser> map = data.stream().collect(Collectors.toMap(WeGameUser::getId, x -> x)); |
|
|
|
for (InviteRecord x : list) { |
|
|
|
info.addInviteUser(map.get(x.invitedUserId),x); |
|
|
|
} |
|
|
|
return info; |
|
|
|
} |
|
|
|
|
|
|
|
public WeGameUser login(String code, String appId) { |
|
|
@ -111,13 +120,21 @@ public class WxService { |
|
|
|
|
|
|
|
LambdaQueryWrapper<InviteRecord> inviteQuery = Wrappers.lambdaQuery(); |
|
|
|
inviteQuery.eq(InviteRecord::getInvitedUserId, u.getId()); |
|
|
|
if (inviteRecordMapper.selectOne(inviteQuery) != null) { |
|
|
|
InviteRecord record = inviteRecordMapper.selectOne(inviteQuery); |
|
|
|
if (record != null && record.lastTime.getTime() + 3600_000 < System.currentTimeMillis()) { |
|
|
|
return res; |
|
|
|
} |
|
|
|
InviteRecord record = new InviteRecord(); |
|
|
|
record.userId = user.getId(); |
|
|
|
record.invitedUserId = u.getId(); |
|
|
|
inviteRecordMapper.insert(record); |
|
|
|
if (record == null) { |
|
|
|
record = new InviteRecord(); |
|
|
|
record.userId = user.getId(); |
|
|
|
record.invitedUserId = u.getId(); |
|
|
|
record.lastTime = new Timestamp(System.currentTimeMillis()); |
|
|
|
inviteRecordMapper.insert(record); |
|
|
|
} else { |
|
|
|
record.lastTime = new Timestamp(System.currentTimeMillis()); |
|
|
|
inviteRecordMapper.updateById(record); |
|
|
|
} |
|
|
|
weGameUserMapper.addInviteCnt(user.getId()); |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|