PlayerControlModel.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class PlayerControlModel extends Model
  5. {
  6. // 设置表名
  7. protected $name = 'player_control';
  8. protected $connection = 'fortue_tiger';
  9. // 设置主键
  10. protected $pk = 'control_id';
  11. // 设置自动时间戳
  12. protected $autoWriteTimestamp = 'int';
  13. // 设置字段类型
  14. protected $type = [
  15. 'control_id' => 'int',
  16. 'app_id' => 'int', // 商户ID
  17. 'user_id' => 'int', // 用户ID
  18. 'player_id' => 'int', // 玩家ID
  19. 'game_id' => 'string', // 游戏ID
  20. 'control_rpt' => 'int', // 设置的RTP值
  21. 'auto_cancel_rtp' => 'int', // 达到此RTP解除点控
  22. 'max_win_multi' => 'int', // 赢取倍数限制
  23. 'control_balance' => 'decimal', // 设置时点控那刻当前余额
  24. 'create_time' => 'int',
  25. 'update_time' => 'int',
  26. ];
  27. /**
  28. * 获取点控详情
  29. * @param $merchantId
  30. * @param $uname
  31. * @param $game_id
  32. * @return mixed
  33. */
  34. public static function getPlayerControlInfo($merchantId, $player_id, $game_id)
  35. {
  36. return self::where(['app_id' => $merchantId, 'player_id' => $player_id, 'game_id' => $game_id])->find();
  37. }
  38. /**
  39. * 根据商户ID获取玩家列表
  40. */
  41. public static function getPlayerControlList($merchantId, $page = 1, $limit = 10, $filters = [])
  42. {
  43. $wheres = [];
  44. $wheres[] = ['app_id', '=', $merchantId];
  45. // 应用过滤条件
  46. if (!empty($filters['uname'])) {
  47. $wheres[] = ['uname', 'like', '%' . $filters['uname'] . '%'];
  48. }
  49. if (!empty($filters['nickname'])) {
  50. $wheres[] = ['nickname', 'like', '%' . $filters['nickname'] . '%'];
  51. }
  52. if (!empty($filters['user_id'])) {
  53. $wheres[] = ['user_id', '=', $filters['user_id']];
  54. }
  55. if(!empty($filters['game_id'])) {
  56. $wheres[] = ['game_id', 'in', $filters['game_id']];
  57. }
  58. $query = self::where($wheres);
  59. $order = $filters['order'] ?? 'create_time';
  60. $sort = $filters['sort'] ?? 'desc';
  61. $query->order($order, $sort);
  62. // 获取总数
  63. $total = $query->count();
  64. // 获取列表
  65. $list = $query->page($page, $limit)->select()->toArray();
  66. return [
  67. 'list' => $list,
  68. 'total' => $total,
  69. 'page' => $page,
  70. 'limit' => $limit
  71. ];
  72. }
  73. /**
  74. * 创建角色
  75. * @param array $data 角色数据
  76. */
  77. public static function updatePlayerControl(array $data)
  78. {
  79. self:create($data);
  80. }
  81. }