This commit is contained in:
wells
2026-08-05 15:43:04 +08:00
parent 50005dd439
commit ce7a619791
8 changed files with 283 additions and 35 deletions
@@ -3,6 +3,7 @@ package com.tailbet.service;
import com.tailbet.model.entity.GameRound;
import com.tailbet.model.entity.DrawRecord;
import com.tailbet.model.entity.BetOrder;
import com.tailbet.model.vo.GroupStatVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tailbet.model.vo.DigitTrialVo;
import lombok.Data;
@@ -80,4 +81,9 @@ public interface IGameService {
* 获取开奖历史
*/
Page<DrawRecord> getHistory(Long groupId, Integer pageNum, Integer pageSize);
/**
* 获取群统计信息
*/
GroupStatVo getGroupStat(Long groupId);
}
@@ -59,4 +59,9 @@ public interface IGroupService {
* 检查用户是否是管理员
*/
boolean isAdmin(Long groupId, Long userId);
/**
* 根据OpenIM群ID获取群信息
*/
Group getByOpenimGroupId(String openimGroupId);
}
@@ -11,6 +11,7 @@ import com.tailbet.model.entity.DrawRecord;
import com.tailbet.model.entity.GameRound;
import com.tailbet.model.entity.Group;
import com.tailbet.model.vo.DigitTrialVo;
import com.tailbet.model.vo.GroupStatVo;
import com.tailbet.service.IGameService;
import com.tailbet.service.IPointsService;
import com.tailbet.service.IAuditService;
@@ -334,4 +335,34 @@ public class GameServiceImpl implements IGameService {
.orderByDesc(DrawRecord::getCreateTime);
return drawRecordMapper.selectPage(page, wrapper);
}
/**
* 获取群统计信息
*/
@Override
public GroupStatVo getGroupStat(Long groupId) {
GroupStatVo stat = new GroupStatVo();
stat.setGroupId(groupId);
// 统计局数
List<GameRound> allRounds = gameRoundMapper.selectList(new LambdaQueryWrapper<GameRound>()
.eq(GameRound::getGroupId, groupId));
stat.setTotalRounds(allRounds.size());
stat.setOngoingRounds((int) allRounds.stream().filter(r -> r.getStatus() == STATUS_ONGOING).count());
// 统计注单
List<BetOrder> allBets = betOrderMapper.selectList(new LambdaQueryWrapper<BetOrder>()
.eq(BetOrder::getGroupId, groupId)
.eq(BetOrder::getIsFake, 0));
stat.setTotalBetCount(allBets.size());
stat.setTotalBetAmount(allBets.stream().mapToLong(BetOrder::getBetAmount).sum());
// 统计派奖
List<DrawRecord> records = drawRecordMapper.selectList(new LambdaQueryWrapper<DrawRecord>()
.eq(DrawRecord::getGroupId, groupId));
stat.setTotalAwardAmount(records.stream().mapToLong(DrawRecord::getTotalAward).sum());
stat.setTotalProfit(records.stream().mapToLong(DrawRecord::getProfit).sum());
return stat;
}
}
@@ -211,4 +211,13 @@ public class GroupServiceImpl implements IGroupService {
.eq(GroupMember::getUserId, userId));
return member != null && (member.getRole() == ROLE_ADMIN || member.getRole() == ROLE_OWNER);
}
/**
* 根据OpenIM群ID获取群信息
*/
@Override
public Group getByOpenimGroupId(String openimGroupId) {
return groupMapper.selectOne(new LambdaQueryWrapper<Group>()
.eq(Group::getOpenimGroupId, openimGroupId));
}
}
@@ -93,11 +93,7 @@ public class PushServiceImpl implements IPushService {
return;
}
// TODO: 根据实际推送通道实现
// 1. 如果用户在线,通过OpenIM发送即时消息
// 2. 如果用户离线,通过FCM/APNs发送离线推送
// 通过OpenIM单聊发送
// 通过OpenIM单聊发送(生产环境可扩展FCM/APNs离线推送)
openIMClient.sendUserMessage(String.valueOf(user.getId()),
message.getTitle() + " - " + message.getContent());