|
|
<?php
|
|
|
// +----------------------------------------------------------------------
|
|
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
|
|
// +----------------------------------------------------------------------
|
|
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
|
|
// | 开源版本可自由商用,可去除界面版权logo
|
|
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
|
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
|
|
// | 访问官网:https://www.likeadmin.cn
|
|
|
// | likeadmin团队 版权所有 拥有最终解释权
|
|
|
// +----------------------------------------------------------------------
|
|
|
// | author: likeadminTeam
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
namespace app\adminapi\lists\game;
|
|
|
|
|
|
use think\facade\Db;
|
|
|
use app\common\model\game\UserTroops;
|
|
|
use app\common\model\game\Heroes;
|
|
|
use app\adminapi\lists\BaseAdminDataLists;
|
|
|
use app\common\model\game\UserRoles;
|
|
|
use app\common\model\game\UserAccount;
|
|
|
use app\common\model\log\UserPayOrder;
|
|
|
use app\common\lists\ListsExcelInterface;
|
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
use app\common\model\user\UserAuth;
|
|
|
use app\adminapi\service\GameService;
|
|
|
|
|
|
/**
|
|
|
* UserRoles列表
|
|
|
* Class UserRolesLists
|
|
|
* @package app\adminapi\listsgame
|
|
|
*/
|
|
|
class UserRolesLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
|
|
{
|
|
|
/**
|
|
|
* @notes 设置导出字段
|
|
|
* @return string[]
|
|
|
* @author 段誉
|
|
|
* @date 2021/12/29 10:08
|
|
|
*/
|
|
|
public function setExcelFields(): array
|
|
|
{
|
|
|
return [
|
|
|
'uid' => '用户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();
|
|
|
}
|
|
|
}
|