fix
This commit is contained in:
@@ -90,7 +90,7 @@ public class GameController {
|
|||||||
@GetMapping("/bet/trial")
|
@GetMapping("/bet/trial")
|
||||||
public R<?> trialDigit(Long groupId, Long roundId) {
|
public R<?> trialDigit(Long groupId, Long roundId) {
|
||||||
try {
|
try {
|
||||||
List<GameService.DigitTrial> trials = gameService.trialDigit(groupId, roundId);
|
List<IGameService.DigitTrial> trials = gameService.trialDigit(groupId, roundId);
|
||||||
return R.ok(trials);
|
return R.ok(trials);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
return R.fail(e.getMessage());
|
return R.fail(e.getMessage());
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import com.tailbet.mapper.RedPacketMapper;
|
|||||||
import com.tailbet.mapper.UserMapper;
|
import com.tailbet.mapper.UserMapper;
|
||||||
import com.tailbet.mapper.DigitWhiteMapper;
|
import com.tailbet.mapper.DigitWhiteMapper;
|
||||||
import com.tailbet.model.entity.DigitWhite;
|
import com.tailbet.model.entity.DigitWhite;
|
||||||
import com.tailbet.service.GameService;
|
import com.tailbet.service.IGameService;
|
||||||
import com.tailbet.service.RedPacketService;
|
import com.tailbet.service.IRedPacketService;
|
||||||
import com.tailbet.service.FakeUserService;
|
import com.tailbet.service.IFakeUserService;
|
||||||
import com.tailbet.openim.OpenIMClient;
|
import com.tailbet.openim.OpenIMClient;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -36,9 +36,9 @@ public class GameJob {
|
|||||||
private final RedPacketMapper redPacketMapper;
|
private final RedPacketMapper redPacketMapper;
|
||||||
private final UserMapper userMapper;
|
private final UserMapper userMapper;
|
||||||
private final DigitWhiteMapper digitWhiteMapper;
|
private final DigitWhiteMapper digitWhiteMapper;
|
||||||
private final GameService gameService;
|
private final IGameService gameService;
|
||||||
private final RedPacketService redPacketService;
|
private final IRedPacketService redPacketService;
|
||||||
private final FakeUserService fakeUserService;
|
private final IFakeUserService fakeUserService;
|
||||||
private final OpenIMClient openIMClient;
|
private final OpenIMClient openIMClient;
|
||||||
|
|
||||||
// 局状态监控(使用内存缓存,实际生产应使用Redis)
|
// 局状态监控(使用内存缓存,实际生产应使用Redis)
|
||||||
@@ -52,7 +52,7 @@ public class GameJob {
|
|||||||
// 查找进行中的游戏红包
|
// 查找进行中的游戏红包
|
||||||
List<RedPacket> ongoingRps = redPacketMapper.selectList(new LambdaQueryWrapper<RedPacket>()
|
List<RedPacket> ongoingRps = redPacketMapper.selectList(new LambdaQueryWrapper<RedPacket>()
|
||||||
.eq(RedPacket::getStatus, 0)
|
.eq(RedPacket::getStatus, 0)
|
||||||
.eq(RedPacket::getType, RedPacketService.TYPE_GAME)
|
.eq(RedPacket::getType, IRedPacketService.TYPE_GAME)
|
||||||
.isNotNull(RedPacket::getRoundId));
|
.isNotNull(RedPacket::getRoundId));
|
||||||
|
|
||||||
for (RedPacket rp : ongoingRps) {
|
for (RedPacket rp : ongoingRps) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.tailbet.service;
|
package com.tailbet.service;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送服务接口
|
* 推送服务接口
|
||||||
*/
|
*/
|
||||||
@@ -11,6 +13,21 @@ public interface IPushService {
|
|||||||
String PUSH_TYPE_GAME_END = "game_end"; // 游戏结束
|
String PUSH_TYPE_GAME_END = "game_end"; // 游戏结束
|
||||||
String PUSH_TYPE_RESULT = "result"; // 开奖结果
|
String PUSH_TYPE_RESULT = "result"; // 开奖结果
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送消息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
class PushMessage {
|
||||||
|
private String type;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private Long userId;
|
||||||
|
private Long groupId;
|
||||||
|
private Long roundId;
|
||||||
|
private String roundNo;
|
||||||
|
private Integer digit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送尾数试算完成通知给白名单用户
|
* 推送尾数试算完成通知给白名单用户
|
||||||
*/
|
*/
|
||||||
@@ -29,10 +46,10 @@ public interface IPushService {
|
|||||||
/**
|
/**
|
||||||
* 发送单用户推送
|
* 发送单用户推送
|
||||||
*/
|
*/
|
||||||
void sendPush(PushService.PushMessage message);
|
void sendPush(PushMessage message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 广播推送消息给群成员
|
* 广播推送消息给群成员
|
||||||
*/
|
*/
|
||||||
void broadcastToGroup(Long groupId, PushService.PushMessage message);
|
void broadcastToGroup(Long groupId, PushMessage message);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.tailbet.service;
|
package com.tailbet.service;
|
||||||
|
|
||||||
import com.tailbet.model.entity.User;
|
import com.tailbet.model.entity.User;
|
||||||
|
import com.tailbet.model.dto.UpdateUserDTO;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,4 +28,9 @@ public interface IUserService extends IService<User> {
|
|||||||
* 获取当前登录用户
|
* 获取当前登录用户
|
||||||
*/
|
*/
|
||||||
User getCurrentUser();
|
User getCurrentUser();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户信息
|
||||||
|
*/
|
||||||
|
void updateUserInfo(Long userId, UpdateUserDTO dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.tailbet.service.impl;
|
package com.tailbet.service.impl;
|
||||||
|
|
||||||
import com.tailbet.entity.GameRound;
|
|
||||||
import com.tailbet.entity.DrawRecord;
|
|
||||||
import com.tailbet.entity.BetOrder;
|
|
||||||
import com.tailbet.entity.Group;
|
|
||||||
import com.tailbet.entity.User;
|
|
||||||
import com.tailbet.mapper.GameRoundMapper;
|
import com.tailbet.mapper.GameRoundMapper;
|
||||||
import com.tailbet.mapper.DrawRecordMapper;
|
import com.tailbet.mapper.DrawRecordMapper;
|
||||||
import com.tailbet.mapper.BetOrderMapper;
|
import com.tailbet.mapper.BetOrderMapper;
|
||||||
import com.tailbet.mapper.GroupMapper;
|
import com.tailbet.mapper.GroupMapper;
|
||||||
import com.tailbet.mapper.UserMapper;
|
import com.tailbet.mapper.UserMapper;
|
||||||
|
import com.tailbet.model.entity.BetOrder;
|
||||||
|
import com.tailbet.model.entity.DrawRecord;
|
||||||
|
import com.tailbet.model.entity.GameRound;
|
||||||
|
import com.tailbet.model.entity.Group;
|
||||||
import com.tailbet.service.IGameService;
|
import com.tailbet.service.IGameService;
|
||||||
import com.tailbet.service.IPointsService;
|
import com.tailbet.service.IPointsService;
|
||||||
import com.tailbet.service.IAuditService;
|
import com.tailbet.service.IAuditService;
|
||||||
@@ -333,4 +333,4 @@ public class GameServiceImpl implements IGameService {
|
|||||||
.orderByDesc(DrawRecord::getCreateTime);
|
.orderByDesc(DrawRecord::getCreateTime);
|
||||||
return drawRecordMapper.selectPage(page, wrapper);
|
return drawRecordMapper.selectPage(page, wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package com.tailbet.service.impl;
|
package com.tailbet.service.impl;
|
||||||
|
|
||||||
import com.tailbet.entity.User;
|
|
||||||
import com.tailbet.entity.DigitWhite;
|
|
||||||
import com.tailbet.mapper.UserMapper;
|
import com.tailbet.mapper.UserMapper;
|
||||||
import com.tailbet.mapper.DigitWhiteMapper;
|
import com.tailbet.mapper.DigitWhiteMapper;
|
||||||
|
import com.tailbet.model.entity.DigitWhite;
|
||||||
|
import com.tailbet.model.entity.User;
|
||||||
import com.tailbet.openim.OpenIMClient;
|
import com.tailbet.openim.OpenIMClient;
|
||||||
import com.tailbet.service.IPushService;
|
import com.tailbet.service.IPushService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@@ -34,7 +35,7 @@ public class PushServiceImpl implements IPushService {
|
|||||||
for (DigitWhite white : whites) {
|
for (DigitWhite white : whites) {
|
||||||
User user = userMapper.selectById(white.getUserId());
|
User user = userMapper.selectById(white.getUserId());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
PushService.PushMessage message = new PushService.PushMessage();
|
IPushService.PushMessage message = new IPushService.PushMessage();
|
||||||
message.setType(PUSH_TYPE_DIGIT_TRIAL);
|
message.setType(PUSH_TYPE_DIGIT_TRIAL);
|
||||||
message.setTitle("尾数试算完成");
|
message.setTitle("尾数试算完成");
|
||||||
message.setContent("可前往修改尾数");
|
message.setContent("可前往修改尾数");
|
||||||
@@ -52,7 +53,7 @@ public class PushServiceImpl implements IPushService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void pushGameStart(Long groupId, String roundNo) {
|
public void pushGameStart(Long groupId, String roundNo) {
|
||||||
PushService.PushMessage message = new PushService.PushMessage();
|
IPushService.PushMessage message = new IPushService.PushMessage();
|
||||||
message.setType(PUSH_TYPE_GAME_START);
|
message.setType(PUSH_TYPE_GAME_START);
|
||||||
message.setTitle("游戏开始");
|
message.setTitle("游戏开始");
|
||||||
message.setContent(roundNo + "期已开始下注");
|
message.setContent(roundNo + "期已开始下注");
|
||||||
@@ -68,7 +69,7 @@ public class PushServiceImpl implements IPushService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void pushGameResult(Long groupId, String roundNo, int digit, String playWins) {
|
public void pushGameResult(Long groupId, String roundNo, int digit, String playWins) {
|
||||||
PushService.PushMessage message = new PushService.PushMessage();
|
IPushService.PushMessage message = new IPushService.PushMessage();
|
||||||
message.setType(PUSH_TYPE_RESULT);
|
message.setType(PUSH_TYPE_RESULT);
|
||||||
message.setTitle("开奖结果");
|
message.setTitle("开奖结果");
|
||||||
message.setContent(roundNo + "期开奖\n尾数: " + digit + "\n中奖玩法: " + playWins);
|
message.setContent(roundNo + "期开奖\n尾数: " + digit + "\n中奖玩法: " + playWins);
|
||||||
@@ -84,7 +85,7 @@ public class PushServiceImpl implements IPushService {
|
|||||||
* 发送单用户推送
|
* 发送单用户推送
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sendPush(PushService.PushMessage message) {
|
public void sendPush(IPushService.PushMessage message) {
|
||||||
try {
|
try {
|
||||||
User user = userMapper.selectById(message.getUserId());
|
User user = userMapper.selectById(message.getUserId());
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
@@ -111,7 +112,7 @@ public class PushServiceImpl implements IPushService {
|
|||||||
* 广播推送消息给群成员
|
* 广播推送消息给群成员
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void broadcastToGroup(Long groupId, PushService.PushMessage message) {
|
public void broadcastToGroup(Long groupId, IPushService.PushMessage message) {
|
||||||
try {
|
try {
|
||||||
// 通过OpenIM群消息发送
|
// 通过OpenIM群消息发送
|
||||||
openIMClient.sendGroupMessage(String.valueOf(groupId),
|
openIMClient.sendGroupMessage(String.valueOf(groupId),
|
||||||
@@ -122,4 +123,4 @@ public class PushServiceImpl implements IPushService {
|
|||||||
groupId, message.getType(), e.getMessage());
|
groupId, message.getType(), e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.tailbet.service.impl;
|
package com.tailbet.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.tailbet.model.entity.User;
|
import com.tailbet.model.entity.User;
|
||||||
import com.tailbet.mapper.UserMapper;
|
import com.tailbet.mapper.UserMapper;
|
||||||
import com.tailbet.model.dto.UpdateUserDTO;
|
import com.tailbet.model.dto.UpdateUserDTO;
|
||||||
@@ -19,16 +20,12 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class UserServiceImpl implements IUserService {
|
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements IUserService {
|
||||||
|
|
||||||
private final UserMapper userMapper;
|
private final UserMapper userMapper;
|
||||||
private final PasswordUtil passwordUtil;
|
private final PasswordUtil passwordUtil;
|
||||||
private final JwtUtil jwtUtil;
|
private final JwtUtil jwtUtil;
|
||||||
|
|
||||||
@Override
|
|
||||||
public User getById(Long id) {
|
|
||||||
return userMapper.selectById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户名查询用户
|
* 根据用户名查询用户
|
||||||
@@ -81,13 +78,7 @@ public class UserServiceImpl implements IUserService {
|
|||||||
return jwtUtil.generateToken(user.getId(), user.getUsername());
|
return jwtUtil.generateToken(user.getId(), user.getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean updateUser(User user) {
|
|
||||||
return userMapper.updateById(user) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户信息
|
* 更新用户信息
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ spring:
|
|||||||
min-idle: 0
|
min-idle: 0
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 8080
|
port: 9080
|
||||||
|
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
mapper-locations: classpath:mapper/**/*.xml
|
mapper-locations: classpath:mapper/**/*.xml
|
||||||
|
|||||||
Reference in New Issue
Block a user