| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- declare (strict_types = 1);
- namespace app\model;
- use think\Model;
- use think\facade\Db;
- /**
- * 游戏记录模型 - 基于tp_game_bet_game表
- */
- class GameBetGameModel extends Model
- {
- protected $name = 'game_bet_game';
- protected $connection = 'fortue_tiger';
- protected $pk = 'id';
-
- // 动作类型常量
- const ACTION_TYPE_BET = 1; // 下注
- const ACTION_TYPE_RESULT = 2; // 结算
-
- // 状态常量
- const STATUS_PENDING = 0; // 待处理
- const STATUS_SUCCESS = 1; // 成功
- const STATUS_FAILED = 2; // 失败
-
- // 游戏类型常量
- const GAME_TYPE_SLOT = 1; // 老虎机
- const GAME_TYPE_TABLE = 2; // 桌面游戏
- const GAME_TYPE_LIVE = 3; // 真人游戏
-
- /**
- * 获取游戏记录列表(参考apiAdminBetGameList方法)
- */
- public static function getBetGameList($appId, $page = 1, $limit = 20, $filters = [])
- {
- $wheres = [];
- $wheres[] = ['action_type', '=', 1]; // 只查询下注记录
- $wheres[] = ['app_id', '=', $appId];
-
- // 时间筛选
- if (!empty($filters['start_time'])) {
- $startTime = strtotime($filters['start_time'] . ' 00:00:00');
- $wheres[] = ['create_time', '>=', $startTime];
- }
-
- if (!empty($filters['end_time'])) {
- $endTime = strtotime($filters['end_time'] . ' 23:59:59');
- $wheres[] = ['create_time', '<=', $endTime];
- }
-
- // 游戏ID筛选
- if (!empty($filters['game_id'])) {
- $wheres[] = ['game_id', '=', $filters['game_id']];
- }
-
- // 牌局编号筛选
- if (!empty($filters['third_round_id'])) {
- $wheres[] = ['third_round_id', '=', $filters['third_round_id']];
- }
-
- // 用户ID筛选
- if (!empty($filters['player_id'])) {
- $wheres[] = ['user_id', '=', $filters['user_id']];
- }
-
- // 游戏玩法类型筛选
- if (!empty($filters['bet_game_play_type'])) {
- if ($filters['bet_game_play_type'] == 2) {
- $wheres[] = ['bet_game_play_type', 'in', [1, 2]];
- } else {
- $wheres[] = ['bet_game_play_type', '=', $filters['bet_game_play_type']];
- }
- }
-
- $query = self::where($wheres);
-
- // 统计总数
- $total = $query->count();
-
- // 获取列表数据(不包含result字段)
- $list = $query->withoutField('result')
- ->order('id', 'desc')
- ->page($page, $limit)
- ->select()
- ->toArray();
-
- if (empty($list)) {
- return [
- 'list' => [],
- 'total' => $total,
- 'page' => $page,
- 'limit' => $limit
- ];
- }
-
- return [
- 'list' => $list,
- 'total' => $total,
- 'page' => $page,
- 'limit' => $limit
- ];
- }
- }
|