'用户ID', 'nickname' => '昵称', 'lv' => '等级', 'zone' => '区服ID', 'barrierId' => '主战场ID', 'missionId' => '任务ID', 'storey' => '王者之塔层级', 'online' => '在线时长(秒)', 'arenaAllWinCount' => '竞技场连胜次数', 'create' => '创建账号时间', 'logoutTime' => '登出时间', ]; } /** * @notes 设置导出文件名 * @return string * @author 段誉 * @date 2021/12/29 10:08 */ public function setFileName(): string { return '用户角色列表'; } /** * @notes 设置搜索条件 * @return \string[][] * @author likeadmin * @date 2024/03/13 10:53 */ public function setSearch(): array { return [ '=' => ['zone', 'barrierId', 'uid', 'storey'], 'between_time' => ['create'], ]; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/03/13 10:53 */ public function lists(): array { $list = UserRoles::where($this->searchWhere) ->field(['uid', 'zone', 'token', 'mergeZone', 'barrierId', 'full', 'missionId', 'storey', 'online', 'arenaAllWinCount', 'starUpTip', 'create', 'logoutTime', 'permission', 'isOnline']) ->limit($this->limitOffset, $this->limitLength) ->order(['isOnline' => 'desc', 'create' => 'desc']) ->select() ->toArray(); if ($list) { $uids = array_column($list, 'uid'); $appid = env('app.appid', 'daodao'); $accounts = UserAccount::where('Uid', 'in', $uids) ->where('AppId', $appid) ->column('Nickname,Lv,Inner', 'Uid'); // $troops = UserTroops::where('uid', 'in', $uids) // ->where('type', 1) // ->where('sort', 1) // ->column('uuids', 'uid'); // $power = []; // foreach ($troops as $uid => $uuids) { // $uuids = json_decode($uuids, true); // if (!$uuids || !is_array($uuids)) { // continue; // } // $power[$uid] = Heroes::where('uid', $uid) // ->where('uuid', 'in', $uuids) // ->sum('power'); // } $money = UserPayOrder::where('status', 4) ->whereIn('uid', $uids) ->group('uid') ->column('SUM(commodityPrice) as s', 'uid'); foreach ($list as $k => $l) { // $limitKey = ['ExpHardLv', 'FragmentHardLv', 'GlyphsHardLv']; // $limits = Db::connect('game') // ->table('userLimit_' . $l['zone']) // ->where('uid', $l['uid']) // ->where('limitKey', 'in', $limitKey) // ->column('limitNum', 'limitKey'); // foreach ($limitKey as $v) { // $list[$k][$v] = isset($limits[$v]) ? $limits[$v] : 0; // } $list[$k]['create'] = date('Y-m-d H:i:s', $l['create']); $list[$k]['nickname'] = ''; $list[$k]['permissionText'] = GameService::getPermission($l['permission']); $list[$k]['lv'] = ''; $list[$k]['money'] = 0; // $list[$k]['power'] = 0; $list[$k]['online'] = intval($l['online'] / 60); if (isset($accounts[$l['uid']])) { $list[$k]['nickname'] = $accounts[$l['uid']]['Nickname']; $list[$k]['lv'] = $accounts[$l['uid']]['Lv']; $list[$k]['inner'] = $accounts[$l['uid']]['Inner']; } if (isset($money[$l['uid']])) { $list[$k]['money'] = round($money[$l['uid']], 2); } // if (isset($power[$l['uid']])) { // $list[$k]['power'] = round($power[$l['uid']] / 1000, 1) . 'k'; // } if ($l['logoutTime'] > 0) { $list[$k]['logoutTime'] = date('Y-m-d H:i:s', $l['logoutTime']); } } } return $list; } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2024/03/13 10:53 */ public function count(): int { return UserRoles::where($this->searchWhere)->count(); } }