| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\model;
- use think\Model;
- class PlayerControlModel extends Model
- {
- // 设置表名
- protected $name = 'player_control';
- protected $connection = 'fortue_tiger';
- // 设置主键
- protected $pk = 'control_id';
- // 设置自动时间戳
- protected $autoWriteTimestamp = 'int';
- // 设置字段类型
- protected $type = [
- 'control_id' => 'int',
- 'app_id' => 'int', // 商户ID
- 'user_id' => 'int', // 用户ID
- 'player_id' => 'int', // 玩家ID
- 'game_id' => 'string', // 游戏ID
- 'control_rpt' => 'int', // 设置的RTP值
- 'auto_cancel_rtp' => 'int', // 达到此RTP解除点控
- 'max_win_multi' => 'int', // 赢取倍数限制
- 'control_balance' => 'decimal', // 设置时点控那刻当前余额
- 'create_time' => 'int',
- 'update_time' => 'int',
- ];
- /**
- * 获取点控详情
- * @param $merchantId
- * @param $uname
- * @param $game_id
- * @return mixed
- */
- public static function getPlayerControlInfo($merchantId, $player_id, $game_id)
- {
- return self::where(['app_id' => $merchantId, 'player_id' => $player_id, 'game_id' => $game_id])->find();
- }
- /**
- * 根据商户ID获取玩家列表
- */
- public static function getPlayerControlList($merchantId, $page = 1, $limit = 10, $filters = [])
- {
- $wheres = [];
- $wheres[] = ['app_id', '=', $merchantId];
- // 应用过滤条件
- if (!empty($filters['uname'])) {
- $wheres[] = ['uname', 'like', '%' . $filters['uname'] . '%'];
- }
- if (!empty($filters['nickname'])) {
- $wheres[] = ['nickname', 'like', '%' . $filters['nickname'] . '%'];
- }
- if (!empty($filters['user_id'])) {
- $wheres[] = ['user_id', '=', $filters['user_id']];
- }
- if(!empty($filters['game_id'])) {
- $wheres[] = ['game_id', 'in', $filters['game_id']];
- }
- $query = self::where($wheres);
- $order = $filters['order'] ?? 'create_time';
- $sort = $filters['sort'] ?? 'desc';
- $query->order($order, $sort);
- // 获取总数
- $total = $query->count();
- // 获取列表
- $list = $query->page($page, $limit)->select()->toArray();
- return [
- 'list' => $list,
- 'total' => $total,
- 'page' => $page,
- 'limit' => $limit
- ];
- }
- /**
- * 创建角色
- * @param array $data 角色数据
- */
- public static function updatePlayerControl(array $data)
- {
- self:create($data);
- }
- }
|