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