GameBetGameModel.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\model;
  4. use think\Model;
  5. use think\facade\Db;
  6. /**
  7. * 游戏记录模型 - 基于tp_game_bet_game表
  8. */
  9. class GameBetGameModel extends Model
  10. {
  11. protected $name = 'game_bet_game';
  12. protected $connection = 'fortue_tiger';
  13. protected $pk = 'id';
  14. /**
  15. * 获取游戏记录列表(参考apiAdminBetGameList方法)
  16. */
  17. public static function getBetGameList($appId, $page = 1, $limit = 20, $filters = [])
  18. {
  19. $wheres = [];
  20. $wheres[] = ['action_type', '=', 1]; // 只查询下注记录
  21. $wheres[] = ['app_id', '=', $appId];
  22. // 时间筛选
  23. if (!empty($filters['start_time'])) {
  24. $startTime = strtotime($filters['start_time']);
  25. $wheres[] = ['create_time', '>=', $startTime];
  26. }
  27. if (!empty($filters['end_time'])) {
  28. $endTime = strtotime($filters['end_time']);
  29. $wheres[] = ['create_time', '<=', $endTime];
  30. }
  31. // 游戏ID筛选
  32. if (!empty($filters['game_id'])) {
  33. $wheres[] = ['game_id', '=', $filters['game_id']];
  34. }
  35. // 牌局编号筛选
  36. if (!empty($filters['third_round_id'])) {
  37. $wheres[] = ['third_round_id', '=', $filters['third_round_id']];
  38. }
  39. // 用户ID筛选
  40. if (!empty($filters['player_id'])) {
  41. $wheres[] = ['user_id', '=', $filters['user_id']];
  42. }
  43. // 游戏玩法类型筛选
  44. if (!empty($filters['bet_game_play_type'])) {
  45. if ($filters['bet_game_play_type'] == 2) {
  46. $wheres[] = ['bet_game_play_type', 'in', [1, 2]];
  47. } else {
  48. $wheres[] = ['bet_game_play_type', '=', $filters['bet_game_play_type']];
  49. }
  50. }
  51. $query = self::where($wheres);
  52. // 统计总数
  53. $total = $query->count();
  54. // 获取列表数据(不包含result字段)
  55. $list = $query->withoutField('result')
  56. ->order('id', 'desc')
  57. ->page($page, $limit)
  58. ->select()
  59. ->toArray();
  60. if (empty($list)) {
  61. return [
  62. 'list' => [],
  63. 'total' => $total,
  64. 'page' => $page,
  65. 'limit' => $limit
  66. ];
  67. }
  68. return [
  69. 'list' => $list,
  70. 'total' => $total,
  71. 'page' => $page,
  72. 'limit' => $limit
  73. ];
  74. }
  75. }