| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- declare (strict_types = 1);
- namespace app\model;
- use think\Model;
- use think\facade\Db;
- use app\model\GameModel;
- /**
- * 游戏订单模型 - 基于tp_game_bet_order表
- */
- class GameBetOrderModel extends Model
- {
- protected $name = 'game_bet_order';
- protected $connection = 'fortue_tiger';
- protected $pk = 'id';
-
- // 状态常量
- const STATUS_PENDING = 0; // 待处理
- const STATUS_SUCCESS = 1; // 成功
- const STATUS_FAILED = 2; // 失败
- const STATUS_CANCELLED = 3; // 已取消
-
- // 动作类型常量
- const ACTION_TYPE_BET = 1; // 下注
- const ACTION_TYPE_SETTLE = 2; // 结算
- const ACTION_TYPE_CANCEL = 3; // 取消
- const ACTION_TYPE_CHECK = 4; // 检查
- const ACTION_TYPE_RESULT = 5; // 结果
-
- // 游戏类型常量
- const GAME_TYPE_SLOT = 1; // 老虎机
- const GAME_TYPE_TABLE = 2; // 桌面游戏
- const GAME_TYPE_LIVE = 3; // 真人游戏
-
- /**
- * 获取下注订单列表(参考apiAdminBetOrderList方法)
- */
- public static function getBetOrderList($appId, $page = 1, $limit = 20, $filters = [])
- {
- $where = [
- ['app_id', '=', $appId]
- ];
-
- // 时间筛选
- if (!empty($filters['start_time'])) {
- $startTime = strtotime($filters['start_time'] . ' 00:00:00');
- $where[] = ['create_time', '>=', $startTime];
- }
-
- if (!empty($filters['end_time'])) {
- $endTime = strtotime($filters['end_time'] . ' 23:59:59');
- $where[] = ['create_time', '<=', $endTime];
- }
-
- // 游戏筛选
- if (!empty($filters['game_id'])) {
- $where[] = ['game_id', '=', $filters['game_id']];
- }
-
- // 订单原因筛选(动作类型)
- if (!empty($filters['order_reason'])) {
- $where[] = ['action_type', '=', $filters['order_reason']];
- }
-
- // 平台ID筛选
- if (!empty($filters['uname'])) {
- $where[] = ['uname', '=', $filters['uname']];
- }
- // 平台昵称筛选
- if (!empty($filters['nickname'])) {
- $where[] = ['nickname', 'like', '%' . $filters['nickname'] . '%'];
- }
-
- // 玩家id筛选
- if (!empty($filters['player_id'])) {
- $where[] = ['user_id', 'like', '%' . $filters['player_id'] . '%'];
- }
-
- // 订单状态筛选
- if ($filters['order_status'] !== '') {
- $where[] = ['status', '=', $filters['order_status']];
- }
-
- // 订单编号筛选
- if (!empty($filters['third_order_id'])) {
- $where[] = ['third_order_id', 'like', '%' . $filters['third_order_id'] . '%'];
- }
-
- // 母单号筛选
- if (!empty($filters['third_gid'])) {
- $where[] = ['third_gid', 'like', '%' . $filters['third_gid'] . '%'];
- }
-
- // 牌局编号筛选
- if (!empty($filters['third_round_id'])) {
- $where[] = ['third_round_id', 'like', '%' . $filters['third_round_id'] . '%'];
- }
-
- $query = self::where($where);
-
- // 统计总数
- $total = $query->count();
-
- // 获取列表数据
- $list = $query->field([
- 'id', 'user_id', 'app_id', 'uname', 'nickname',
- 'third_gid', 'third_order_id', 'third_round_id', 'parent_id',
- 'game_id', 'game_type', 'status', 'message',
- 'amount', 'bet', 'prev_amount', 'next_amount',
- 'action_type', 'ip', 'err_desc', 'create_time',
- 'total_win_amount', 'total_amount'
- ])
- ->order('id', 'desc')
- ->page($page, $limit)
- ->select()
- ->toArray();
-
- return [
- 'list' => $list,
- 'total' => $total,
- 'page' => $page,
- 'limit' => $limit
- ];
- }
- }
|