GameBetOrderModel.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\model;
  4. use think\Model;
  5. use think\facade\Db;
  6. use app\model\GameModel;
  7. /**
  8. * 游戏订单模型 - 基于tp_game_bet_order表
  9. */
  10. class GameBetOrderModel extends Model
  11. {
  12. protected $name = 'game_bet_order';
  13. protected $connection = 'fortue_tiger';
  14. protected $pk = 'id';
  15. // 状态常量
  16. const STATUS_PENDING = 0; // 待处理
  17. const STATUS_SUCCESS = 1; // 成功
  18. const STATUS_FAILED = 2; // 失败
  19. const STATUS_CANCELLED = 3; // 已取消
  20. // 动作类型常量
  21. const ACTION_TYPE_BET = 1; // 下注
  22. const ACTION_TYPE_SETTLE = 2; // 结算
  23. const ACTION_TYPE_CANCEL = 3; // 取消
  24. const ACTION_TYPE_CHECK = 4; // 检查
  25. const ACTION_TYPE_RESULT = 5; // 结果
  26. // 游戏类型常量
  27. const GAME_TYPE_SLOT = 1; // 老虎机
  28. const GAME_TYPE_TABLE = 2; // 桌面游戏
  29. const GAME_TYPE_LIVE = 3; // 真人游戏
  30. /**
  31. * 获取下注订单列表(参考apiAdminBetOrderList方法)
  32. */
  33. public static function getBetOrderList($appId, $page = 1, $limit = 20, $filters = [])
  34. {
  35. $where = [
  36. ['app_id', '=', $appId]
  37. ];
  38. // 时间筛选
  39. if (!empty($filters['start_time'])) {
  40. $startTime = strtotime($filters['start_time'] . ' 00:00:00');
  41. $where[] = ['create_time', '>=', $startTime];
  42. }
  43. if (!empty($filters['end_time'])) {
  44. $endTime = strtotime($filters['end_time'] . ' 23:59:59');
  45. $where[] = ['create_time', '<=', $endTime];
  46. }
  47. // 游戏筛选
  48. if (!empty($filters['game_id'])) {
  49. $where[] = ['game_id', '=', $filters['game_id']];
  50. }
  51. // 订单原因筛选(动作类型)
  52. if (!empty($filters['order_reason'])) {
  53. $where[] = ['action_type', '=', $filters['order_reason']];
  54. }
  55. // 平台ID筛选
  56. if (!empty($filters['uname'])) {
  57. $where[] = ['uname', '=', $filters['uname']];
  58. }
  59. // 平台昵称筛选
  60. if (!empty($filters['nickname'])) {
  61. $where[] = ['nickname', 'like', '%' . $filters['nickname'] . '%'];
  62. }
  63. // 玩家id筛选
  64. if (!empty($filters['player_id'])) {
  65. $where[] = ['user_id', 'like', '%' . $filters['player_id'] . '%'];
  66. }
  67. // 订单状态筛选
  68. if ($filters['order_status'] !== '') {
  69. $where[] = ['status', '=', $filters['order_status']];
  70. }
  71. // 订单编号筛选
  72. if (!empty($filters['third_order_id'])) {
  73. $where[] = ['third_order_id', 'like', '%' . $filters['third_order_id'] . '%'];
  74. }
  75. // 母单号筛选
  76. if (!empty($filters['third_gid'])) {
  77. $where[] = ['third_gid', 'like', '%' . $filters['third_gid'] . '%'];
  78. }
  79. // 牌局编号筛选
  80. if (!empty($filters['third_round_id'])) {
  81. $where[] = ['third_round_id', 'like', '%' . $filters['third_round_id'] . '%'];
  82. }
  83. $query = self::where($where);
  84. // 统计总数
  85. $total = $query->count();
  86. // 获取列表数据
  87. $list = $query->field([
  88. 'id', 'user_id', 'app_id', 'uname', 'nickname',
  89. 'third_gid', 'third_order_id', 'third_round_id', 'parent_id',
  90. 'game_id', 'game_type', 'status', 'message',
  91. 'amount', 'bet', 'prev_amount', 'next_amount',
  92. 'action_type', 'ip', 'err_desc', 'create_time',
  93. 'total_win_amount', 'total_amount'
  94. ])
  95. ->order('id', 'desc')
  96. ->page($page, $limit)
  97. ->select()
  98. ->toArray();
  99. return [
  100. 'list' => $list,
  101. 'total' => $total,
  102. 'page' => $page,
  103. 'limit' => $limit
  104. ];
  105. }
  106. }