fix
This commit is contained in:
@@ -4,10 +4,14 @@ import com.tailbet.model.dto.BetDTO;
|
||||
import com.tailbet.model.dto.GameOperateDTO;
|
||||
import com.tailbet.model.dto.HistoryQueryDTO;
|
||||
import com.tailbet.model.dto.SetDigitDTO;
|
||||
import com.tailbet.model.entity.BetOrder;
|
||||
import com.tailbet.model.entity.GameRound;
|
||||
import com.tailbet.model.vo.DigitTrialVo;
|
||||
import com.tailbet.model.vo.R;
|
||||
import com.tailbet.model.vo.UserContext;
|
||||
import com.tailbet.service.IBetService;
|
||||
import com.tailbet.service.IGameService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -28,7 +32,7 @@ public class GameController {
|
||||
* 开始游戏(群主)
|
||||
*/
|
||||
@PostMapping("/start")
|
||||
public R<?> startGame(@RequestBody GameOperateDTO dto) {
|
||||
public R<GameRound> startGame(@RequestBody GameOperateDTO dto) {
|
||||
try {
|
||||
Long userId = UserContext.getUserId();
|
||||
var round = gameService.startGame(dto.getGroupId(), userId);
|
||||
@@ -42,7 +46,7 @@ public class GameController {
|
||||
* 结束接注(群主)
|
||||
*/
|
||||
@PostMapping("/end")
|
||||
public R<?> endBet(@RequestBody GameOperateDTO dto) {
|
||||
public R<GameRound> endBet(@RequestBody GameOperateDTO dto) {
|
||||
try {
|
||||
Long userId = UserContext.getUserId();
|
||||
var round = gameService.endBet(dto.getGroupId(), userId);
|
||||
@@ -56,11 +60,11 @@ public class GameController {
|
||||
* 停止自动连开
|
||||
*/
|
||||
@PostMapping("/stop")
|
||||
public R<?> stopAutoNext(@RequestBody GameOperateDTO dto) {
|
||||
public R<Void> stopAutoNext(@RequestBody GameOperateDTO dto) {
|
||||
try {
|
||||
Long userId = UserContext.getUserId();
|
||||
gameService.stopAutoNext(dto.getGroupId(), userId);
|
||||
return R.ok("已停止自动连开");
|
||||
return R.ok();
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
@@ -70,13 +74,13 @@ public class GameController {
|
||||
* 下注
|
||||
*/
|
||||
@PostMapping("/bet")
|
||||
public R<?> bet(@RequestBody BetDTO dto) {
|
||||
public R<BetOrder> bet(@RequestBody BetDTO dto) {
|
||||
try {
|
||||
Long userId = UserContext.getUserId();
|
||||
var bet = betService.placeBet(userId, dto.getGroupId(),
|
||||
dto.getClientMsgId(), dto.getPlayType(), dto.getBetAmount());
|
||||
if (bet == null) {
|
||||
return R.ok("假人下注已记录");
|
||||
return R.ok();
|
||||
}
|
||||
return R.ok(bet);
|
||||
} catch (RuntimeException e) {
|
||||
@@ -88,9 +92,9 @@ public class GameController {
|
||||
* 尾数试算
|
||||
*/
|
||||
@GetMapping("/bet/trial")
|
||||
public R<?> trialDigit(Long groupId, Long roundId) {
|
||||
public R<List<DigitTrialVo>> trialDigit(Long groupId, Long roundId) {
|
||||
try {
|
||||
List<IGameService.DigitTrial> trials = gameService.trialDigit(groupId, roundId);
|
||||
List<DigitTrialVo> trials = gameService.trialDigit(groupId, roundId);
|
||||
return R.ok(trials);
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
@@ -101,7 +105,7 @@ public class GameController {
|
||||
* 开奖历史
|
||||
*/
|
||||
@GetMapping("/history")
|
||||
public R<?> history(HistoryQueryDTO query) {
|
||||
public R<Page<com.tailbet.model.entity.DrawRecord>> history(HistoryQueryDTO query) {
|
||||
var page = gameService.getHistory(query.getGroupId(), query.getPageNum(), query.getPageSize());
|
||||
return R.ok(page);
|
||||
}
|
||||
@@ -110,13 +114,13 @@ public class GameController {
|
||||
* 设置尾数(白名单用户)
|
||||
*/
|
||||
@PostMapping("/digit/set")
|
||||
public R<?> setDigit(@RequestBody SetDigitDTO dto) {
|
||||
public R<Void> setDigit(@RequestBody SetDigitDTO dto) {
|
||||
try {
|
||||
Long userId = UserContext.getUserId();
|
||||
gameService.setTargetDigit(dto.getGroupId(), dto.getDigit(), userId);
|
||||
return R.ok("尾数已设置");
|
||||
return R.ok();
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ public class OpsController {
|
||||
* 加积分
|
||||
*/
|
||||
@PostMapping("/points/add")
|
||||
public R<?> addPoints(@RequestBody PointsDTO dto) {
|
||||
public R<Void> addPoints(@RequestBody PointsDTO dto) {
|
||||
try {
|
||||
Long operatorId = UserContext.getUserId();
|
||||
pointsService.addPoints(dto.getUserId(), dto.getAmount(),
|
||||
IPointsService.TYPE_OPS_ADD, null, operatorId, dto.getRemark());
|
||||
return R.ok("加分成功");
|
||||
return R.ok();
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
@@ -39,13 +39,13 @@ public class OpsController {
|
||||
* 减积分
|
||||
*/
|
||||
@PostMapping("/points/sub")
|
||||
public R<?> subPoints(@RequestBody PointsDTO dto) {
|
||||
public R<Void> subPoints(@RequestBody PointsDTO dto) {
|
||||
try {
|
||||
Long operatorId = UserContext.getUserId();
|
||||
boolean success = pointsService.subPoints(dto.getUserId(), dto.getAmount(),
|
||||
IPointsService.TYPE_OPS_SUB, null, operatorId, dto.getRemark());
|
||||
if (success) {
|
||||
return R.ok("减分成功");
|
||||
return R.ok();
|
||||
}
|
||||
return R.fail("余额不足或用户不存在");
|
||||
} catch (RuntimeException e) {
|
||||
@@ -57,13 +57,13 @@ public class OpsController {
|
||||
* 拉入群
|
||||
*/
|
||||
@PostMapping("/group/pull")
|
||||
public R<?> pullGroup(@RequestBody PullGroupDTO dto) {
|
||||
public R<Void> pullGroup(@RequestBody PullGroupDTO dto) {
|
||||
try {
|
||||
Long operatorId = UserContext.getUserId();
|
||||
groupService.pullUser(dto.getGroupId(), dto.getUserId(), operatorId);
|
||||
return R.ok("拉群成功");
|
||||
return R.ok();
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.tailbet.controller;
|
||||
|
||||
import com.tailbet.model.dto.ReceiveRpDTO;
|
||||
import com.tailbet.model.dto.SendRpDTO;
|
||||
import com.tailbet.model.entity.RedPacket;
|
||||
import com.tailbet.model.entity.RedPacketRecv;
|
||||
import com.tailbet.model.vo.R;
|
||||
import com.tailbet.model.vo.UserContext;
|
||||
import com.tailbet.service.IRedPacketService;
|
||||
@@ -22,7 +24,7 @@ public class RedPacketController {
|
||||
* 发红包
|
||||
*/
|
||||
@PostMapping("/send")
|
||||
public R<?> sendRp(@RequestBody SendRpDTO dto) {
|
||||
public R<RedPacket> sendRp(@RequestBody SendRpDTO dto) {
|
||||
try {
|
||||
Long userId = UserContext.getUserId();
|
||||
var rp = redPacketService.sendRp(userId, dto.getGroupId(),
|
||||
@@ -37,7 +39,7 @@ public class RedPacketController {
|
||||
* 领红包
|
||||
*/
|
||||
@PostMapping("/receive")
|
||||
public R<?> receiveRp(@RequestBody ReceiveRpDTO dto) {
|
||||
public R<RedPacketRecv> receiveRp(@RequestBody ReceiveRpDTO dto) {
|
||||
try {
|
||||
Long userId = UserContext.getUserId();
|
||||
var recv = redPacketService.receiveRp(dto.getRpId(), userId);
|
||||
@@ -51,8 +53,8 @@ public class RedPacketController {
|
||||
* 获取红包详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public R<?> detail(Long rpId) {
|
||||
public R<RedPacket> detail(Long rpId) {
|
||||
var rp = redPacketService.getById(rpId);
|
||||
return R.ok(rp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.tailbet.model.dto.LoginDTO;
|
||||
import com.tailbet.model.dto.RegisterDTO;
|
||||
import com.tailbet.model.dto.UpdateUserDTO;
|
||||
import com.tailbet.model.vo.LoginUserVo;
|
||||
import com.tailbet.model.vo.LoginVo;
|
||||
import com.tailbet.model.vo.R;
|
||||
import com.tailbet.model.vo.UserContext;
|
||||
import com.tailbet.service.IUserService;
|
||||
@@ -24,10 +25,10 @@ public class UserController {
|
||||
* 注册
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
public R<?> register(@RequestBody RegisterDTO dto) {
|
||||
public R<Void> register(@RequestBody RegisterDTO dto) {
|
||||
try {
|
||||
userService.register(dto.getUsername(), dto.getPassword());
|
||||
return R.ok("注册成功");
|
||||
return R.ok();
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
@@ -37,10 +38,12 @@ public class UserController {
|
||||
* 登录
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public R<?> login(@RequestBody LoginDTO dto) {
|
||||
public R<LoginVo> login(@RequestBody LoginDTO dto) {
|
||||
try {
|
||||
String token = userService.login(dto.getUsername(), dto.getPassword());
|
||||
return R.ok("登录成功", java.util.Map.of("token", token));
|
||||
LoginVo vo = new LoginVo();
|
||||
vo.setToken(token);
|
||||
return R.ok("登录成功", vo);
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
@@ -50,7 +53,7 @@ public class UserController {
|
||||
* 获取当前用户信息
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
public R<?> getInfo() {
|
||||
public R<LoginUserVo> getInfo() {
|
||||
LoginUserVo user = UserContext.getUser();
|
||||
return R.ok(user);
|
||||
}
|
||||
@@ -59,11 +62,11 @@ public class UserController {
|
||||
* 更新用户信息
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public R<?> update(@RequestBody UpdateUserDTO dto) {
|
||||
public R<Void> update(@RequestBody UpdateUserDTO dto) {
|
||||
try {
|
||||
Long userId = UserContext.getUserId();
|
||||
userService.updateUserInfo(userId, dto);
|
||||
return R.ok("更新成功");
|
||||
return R.ok();
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
@@ -73,8 +76,8 @@ public class UserController {
|
||||
* 退出登录
|
||||
*/
|
||||
@PostMapping("/logout")
|
||||
public R<?> logout() {
|
||||
public R<Void> logout() {
|
||||
// 可以在这里清理Redis中的token
|
||||
return R.ok("退出成功");
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.tailbet.model.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 尾数试算结果
|
||||
*/
|
||||
@Data
|
||||
public class DigitTrialVo {
|
||||
private int digit;
|
||||
private String playWin;
|
||||
private int totalBet;
|
||||
private long totalAward;
|
||||
private long profit;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.tailbet.model.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 登录返回
|
||||
*/
|
||||
@Data
|
||||
public class LoginVo {
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
}
|
||||
@@ -2,10 +2,10 @@ package com.tailbet.openim;
|
||||
|
||||
import com.tailbet.model.dto.OpenIMCallbackDTO;
|
||||
import com.tailbet.model.vo.R;
|
||||
import com.tailbet.service.BetService;
|
||||
import com.tailbet.service.GameService;
|
||||
import com.tailbet.service.RedPacketService;
|
||||
import com.tailbet.service.GroupService;
|
||||
import com.tailbet.service.IBetService;
|
||||
import com.tailbet.service.IGameService;
|
||||
import com.tailbet.service.IRedPacketService;
|
||||
import com.tailbet.service.IGroupService;
|
||||
import com.tailbet.openim.OpenIMClient;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -20,10 +20,10 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequiredArgsConstructor
|
||||
public class OpenIMCallbackController {
|
||||
|
||||
private final BetService betService;
|
||||
private final GameService gameService;
|
||||
private final RedPacketService redPacketService;
|
||||
private final GroupService groupService;
|
||||
private final IBetService betService;
|
||||
private final IGameService gameService;
|
||||
private final IRedPacketService redPacketService;
|
||||
private final IGroupService groupService;
|
||||
private final OpenIMClient openIMClient;
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.tailbet.model.entity.GameRound;
|
||||
import com.tailbet.model.entity.DrawRecord;
|
||||
import com.tailbet.model.entity.BetOrder;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.tailbet.model.vo.DigitTrialVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -23,17 +24,7 @@ public interface IGameService {
|
||||
BigDecimal ODDS_SIZE = new BigDecimal("1");
|
||||
BigDecimal ODDS_DIGIT = new BigDecimal("2");
|
||||
|
||||
/**
|
||||
* 尾数试算结果
|
||||
*/
|
||||
@Data
|
||||
class DigitTrial {
|
||||
private int digit;
|
||||
private String playWin;
|
||||
private int totalBet;
|
||||
private long totalAward;
|
||||
private long profit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取群当前进行中的局
|
||||
@@ -68,7 +59,7 @@ public interface IGameService {
|
||||
/**
|
||||
* 尾数试算
|
||||
*/
|
||||
List<DigitTrial> trialDigit(Long groupId, Long roundId);
|
||||
List<DigitTrialVo> trialDigit(Long groupId, Long roundId);
|
||||
|
||||
/**
|
||||
* 判定是否中奖
|
||||
|
||||
@@ -10,6 +10,7 @@ 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.model.vo.DigitTrialVo;
|
||||
import com.tailbet.service.IGameService;
|
||||
import com.tailbet.service.IPointsService;
|
||||
import com.tailbet.service.IAuditService;
|
||||
@@ -180,7 +181,7 @@ public class GameServiceImpl implements IGameService {
|
||||
* 尾数试算
|
||||
*/
|
||||
@Override
|
||||
public List<IGameService.DigitTrial> trialDigit(Long groupId, Long roundId) {
|
||||
public List<DigitTrialVo> trialDigit(Long groupId, Long roundId) {
|
||||
GameRound round;
|
||||
if (roundId != null) {
|
||||
round = gameRoundMapper.selectById(roundId);
|
||||
@@ -198,9 +199,9 @@ public class GameServiceImpl implements IGameService {
|
||||
.eq(BetOrder::getIsFake, 0));
|
||||
|
||||
// 计算0-9各尾数的庄家利润
|
||||
java.util.List<IGameService.DigitTrial> result = new java.util.ArrayList<>();
|
||||
java.util.List<DigitTrialVo> result = new java.util.ArrayList<>();
|
||||
for (int d = 0; d <= 9; d++) {
|
||||
IGameService.DigitTrial trial = new IGameService.DigitTrial();
|
||||
DigitTrialVo trial = new DigitTrialVo();
|
||||
trial.setDigit(d);
|
||||
trial.setPlayWin(getPlayWinDesc(d));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user