| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?php
- /**
- * 玩家游戏账号控制器
- *
- * Created by PhpStorm.
- * User: Admin
- * Date: 2018/5/10
- * Time: 10:27
- */
- namespace app\admin\controller;
- use think\Db;
- use app\common\model\Game as GameModel;
- use app\common\model\GameInfo;
- use app\common\model\Logininfo;
- use app\common\model\AndroidSdk;
- use app\common\model\AutoPackage;
- use app\common\library\ValidateExtend;
- class Subaccount extends Admin
- {
- protected $gameModel;
- protected $sdkgamelistModel;
- protected $gameList;
- protected function _initialize()
- {
- parent::_initialize();
- $this->gameModel = new GameModel;
- $this->sdkgamelistModel = $this->cyModel('sdkgamelist');
- $this->gameList = $gameList = model('Common/Game')->getAllByCondition('id,name');
- $tmpSelfGameList = model('Common/Game')->getAllByCondition('id,name', [],'','self');
- $selfGameList = array();
- foreach ($tmpSelfGameList as $game) {
- $selfGameList[ $game['id']] = $game;
- }
- $this->selfGameList = $selfGameList;
- }
- /**
- * 换绑记录列表
- * @return mixed
- */
- public function index()
- {
- $game_id = input('game_id',0,'intval');
- $account = input('account','','trim');
- $start_time = input('start_time','','trim');
- $end_time = input('end_time','','trim');
- $sub_username = input('sub_username','','trim');
- $action = input('action','','trim');
- // 验证日期格式
- if (!empty($start_time) && !preg_match('/^\d{4}-\d{2}-\d{2}$/', $start_time)) {
- $start_time = '';
- }
- if (!empty($end_time) && !preg_match('/^\d{4}-\d{2}-\d{2}$/', $end_time)) {
- $end_time = '';
- }
- // 日期最多选择到今天(包含今天)
- if (!empty($start_time) && $start_time > date('Y-m-d')) {
- $start_time = date('Y-m-d');
- }
- if (!empty($end_time) && $end_time > date('Y-m-d')) {
- $end_time = date('Y-m-d');
- }
- // 开始时间不能大于结束时间
- if (!empty($start_time) && !empty($end_time) && $start_time > $end_time) {
- $start_time = $end_time;
- }
- // 非搜索(首次进入页面)时,默认查最近一个月的数据
- if (empty($action) && empty($start_time) && empty($end_time)) {
- $start_time = date('Y-m-d', strtotime('-30 days'));
- $end_time = date('Y-m-d');
- }
- $condition = [];
- if(input('account')){
- $condition['m.username'] = $account;
- }
- if(input('sub_username')){
- $condition['s.sub_username'] = $sub_username;
- }
- if(input('game_id') <> ''){
- $condition['s.game_id'] = $game_id;
- }
- // 日期不为空时才处理日期条件
- if ($start_time != '' && $end_time != '') {
- $condition['s.create_time'] = [
- ['>=', strtotime($start_time)],
- ['<=', strtotime($end_time . ' 23:59:59')],
- ];
- } elseif ($start_time != '') {
- $condition['s.create_time'] = ['>=', strtotime($start_time)];
- } elseif ($end_time != '') {
- $condition['s.create_time'] = ['<=', strtotime($end_time . ' 23:59:59')];
- }
- //查询参数
- $param = input('get.');
- $subaccountList = model('Subaccount')->alias('s')
- ->join('cy_members m', 's.member_id = m.id')
- ->join('cy_game g', 's.game_id = g.id')
- ->where($condition)
- ->field("s.id,s.member_id as userid,m.username,s.sub_username,s.game_id,g.name as game_name,s.create_time as create_time_value,s.auth_type,s.real_name,s.idcard_num,s.last_auth_time as last_auth_time_value,s.auth_pi,s.auth_status")
- ->order("id desc")
- ->paginate(10, false, ['query' => $param]);
- // PDO 可能将时间戳返回为数字字符串,同时兼容历史日期字符串。
- $formatTime = function ($value, $format) {
- if (empty($value)) {
- return '-';
- }
- $timestamp = is_numeric($value) ? (int) $value : strtotime($value);
- return $timestamp ? date($format, $timestamp) : '-';
- };
- $subaccountList->each(function (&$item) use ($formatTime) {
- $item['create_time_text'] = $formatTime($item['create_time_value'], 'Y-m-d H:i:s');
- $item['last_auth_date'] = $formatTime($item['last_auth_time_value'], 'Y-m-d');
- return $item;
- });
- // 获取分页显示
- $page = $subaccountList->render();
- // dump($subaccountList);
- $this->assign('game_list', $this->selfGameList);
- $this->assign('page', $page);
- $this->assign('subaccountList', $subaccountList);
- $this->assign('start_time', $start_time);
- $this->assign('end_time', $end_time);
- return $this->fetch();
- }
- }
|