GameBetGameModel.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. const ACTION_TYPE_BET = 1; // 下注
  16. const ACTION_TYPE_RESULT = 2; // 结算
  17. // 状态常量
  18. const STATUS_PENDING = 0; // 待处理
  19. const STATUS_SUCCESS = 1; // 成功
  20. const STATUS_FAILED = 2; // 失败
  21. // 游戏类型常量
  22. const GAME_TYPE_SLOT = 1; // 老虎机
  23. const GAME_TYPE_TABLE = 2; // 桌面游戏
  24. const GAME_TYPE_LIVE = 3; // 真人游戏
  25. /**
  26. * 获取游戏记录列表(参考apiAdminBetGameList方法)
  27. */
  28. public static function getBetGameList($appId, $page = 1, $limit = 20, $filters = [])
  29. {
  30. $wheres = [];
  31. $wheres[] = ['action_type', '=', 1]; // 只查询下注记录
  32. $wheres[] = ['app_id', '=', $appId];
  33. // 时间筛选
  34. if (!empty($filters['start_time'])) {
  35. $startTime = strtotime($filters['start_time'] . ' 00:00:00');
  36. $wheres[] = ['create_time', '>=', $startTime];
  37. }
  38. if (!empty($filters['end_time'])) {
  39. $endTime = strtotime($filters['end_time'] . ' 23:59:59');
  40. $wheres[] = ['create_time', '<=', $endTime];
  41. }
  42. // 游戏ID筛选
  43. if (!empty($filters['game_id'])) {
  44. $wheres[] = ['game_id', '=', $filters['game_id']];
  45. }
  46. // 牌局编号筛选
  47. if (!empty($filters['third_round_id'])) {
  48. $wheres[] = ['third_round_id', '=', $filters['third_round_id']];
  49. }
  50. // 用户ID筛选
  51. if (!empty($filters['player_id'])) {
  52. $wheres[] = ['user_id', '=', $filters['user_id']];
  53. }
  54. // 游戏玩法类型筛选
  55. if (!empty($filters['bet_game_play_type'])) {
  56. if ($filters['bet_game_play_type'] == 2) {
  57. $wheres[] = ['bet_game_play_type', 'in', [1, 2]];
  58. } else {
  59. $wheres[] = ['bet_game_play_type', '=', $filters['bet_game_play_type']];
  60. }
  61. }
  62. $query = self::where($wheres);
  63. // 统计总数
  64. $total = $query->count();
  65. // 获取列表数据(不包含result字段)
  66. $list = $query->withoutField('result')
  67. ->order('id', 'desc')
  68. ->page($page, $limit)
  69. ->select()
  70. ->toArray();
  71. if (empty($list)) {
  72. return [
  73. 'list' => [],
  74. 'total' => $total,
  75. 'page' => $page,
  76. 'limit' => $limit
  77. ];
  78. }
  79. return [
  80. 'list' => $list,
  81. 'total' => $total,
  82. 'page' => $page,
  83. 'limit' => $limit
  84. ];
  85. }
  86. }