You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
6.2 KiB
PHTML

5 years ago
<?php
namespace Home\Controller;
/**
* 前台首页控制器
* 主要获取首页聚合数据
*/
class PlayersController extends BaseController {
//玩家行为日志
public function playAction() {
$page = intval(I('p', 1));
$row = intval(I('row', 10));
$relationGameId = intval(I('relation_game_id', 0));
$sdkVersion = intval(I('sdk_version', 0));
$serverId = trim(I('server_id', ''));
$gamePlayerName = trim(I('game_player_name', ''));
$userAccount = trim(I('user_account', ''));
$userId = trim(I('user_id', ''));
$extend = trim(I('extend', '')); //cp订单号
$begTime = strtotime(I('begtime'));
$endTime = strtotime(I('endtime'));
$levelPromote = $this->getLevelPromote();
$queryPromote = $this->getQueryPromote($levelPromote);
// $loginPromote = $this->getLoginPromote();
$map = [];
$map['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'];
$ids = M('promote', 'tab_')->where($map)->getField('id', true);
$ids[] = $queryPromote['id'];
$map = [];
$map['tab_pay_info.promote_id'] = ['in', $ids];
if ($relationGameId != 0 || $sdkVersion != 0) {
if ($relationGameId != 0) {
$gameMap['relation_game_id'] = $relationGameId;
}
if ($sdkVersion != 0) {
$gameMap['sdk_version'] = $sdkVersion;
}
$gameId = M('game', 'tab_')->where($gameMap)->getField('id', true);
$map['game_id'] = ['in', $gameId];
5 years ago
}
if (!empty($serverId)) {
$map['tab_pay_info.server_id'] = $serverId;
}
if (!empty($gamePlayerName)) {
$map['tab_pay_info.game_player_name'] = $gamePlayerName;
}
if (!empty($userAccount)) {
$map['tab_pay_info.user_account'] = $userAccount;
}
if (!empty($extend)) {
$map['tab_pay_info.extend'] = $extend;
}
if (!empty($userId)) {
$map['tab_pay_info.user_id'] = $userId;
}
if (!empty($begTime) && !empty($endTime)) {
$map['tab_pay_info.create_time'] = ['between', [$begTime, $endTime - 1]];
}else if (empty($begTime) && !empty($endTime)) {
$map['tab_pay_info.create_time'] = ['elt',$endTime];
}else if (!empty($begTime) && empty($endTime)) {
$map['tab_pay_info.create_time'] = ['EGT',$begTime];
}
$page = intval(I('get.p', 1));
$page = $page ? $page : 1; //默认显示第一页数据arraypage
$row=10;
$rs = M('pay_info','tab_')->where($map)->order('tab_pay_info.create_time desc')
->page($page, $row)->select();
foreach($rs as $key => $v) {
$rs[$key]['extend'] = encryption($v['extend']);
$rs[$key]['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
$promoteInfo = M('promote','tab_')->field("nickname")->where(['id' => intval($v['promote_id'])])->find();
$rs[$key]['promote_id']= $promoteInfo['nickname'];
}
$count = M('pay_info', 'tab_')
->field('tab_pay_info.id')
->where($map)
->select();
$count = count($count);
//分页
$parameter['p'] = $page;
$parameter['row'] = $row;
$parameter['begtime'] = $initBegTime;
$parameter['endtime'] = $initEndTime;
$parameter['relation_game_id'] = $relationGameId;
$parameter['sdk_version'] = $sdkVersion;
$parameter['server_id'] = $serverId;
$parameter['game_player_name'] = $gamePlayerName;
$parameter['user_account'] = $userAccount;
$parameter['extend'] = $extend;
$parameter['user_id'] = $user_id;
$parameter['level_promote_2'] = $levelPromote[0];
$parameter['level_promote_3'] = $levelPromote[1];
$parameter['level_promote_4'] = $levelPromote[2];
5 years ago
$serverData = $this->getServer(I('relation_game_id'), I('sdk_version'));
5 years ago
$page = set_pagination($count, $row, $parameter);
if ($page) {
$this->assign('_page', $page);
}
$this->assign('listData',$rs);
5 years ago
$this->assign('serverData', $serverData['data']);
5 years ago
$this->assign('initBegTime', I('begtime'));
$this->assign('initEndTime', I('endtime'));
$this->display();
}
private function getLevelPromote()
{
$levelPromote = [];
$levelPromote[] = I('level_promote_2', 0);
$levelPromote[] = I('level_promote_3', 0);
$levelPromote[] = I('level_promote_4', 0);
return $levelPromote;
}
private function getQueryPromote($levelPromote)
{
$queryPromote = null;
$promote = $this->getLoginPromote();
$queryPromoteId = 0;
foreach ($levelPromote as $item) {
if ($item != 0) {
$queryPromoteId = $item;
}
}
if ($queryPromoteId == 0) {
$queryPromote = $this->getLoginPromote();
} else {
$queryPromote = M('promote', 'tab_')->where(['id' => $queryPromoteId])->find();
}
return $queryPromote;
}
5 years ago
public function getServer($relationGameId, $sdkVersion)
{
$result['status'] = 0;
$result['data'] = [];
if (empty($relationGameId)) {
return $result;
}
$map['relation_game_id'] = intval($relationGameId);
empty($sdkVersion) || $map['sdk_version'] = intval($sdkVersion);
$gameIds = M('Game', 'tab_')
->where($map)
->getField('id', true);
if (empty($gameIds)) {
return $result;
}
$gameIds = implode(',', $gameIds);
$where['game_id'] = ['in', $gameIds];
$where['show_status'] = 1;
$serverData = M('Server', 'tab_')
->field('server_id,server_name')
->where($where)
->order('server_version,start_time desc')
->select();
$result['status'] = 1;
$result['data'] = $serverData;
return $result;
}
5 years ago
public function getServerAjax()
{
$serverData = $this->getServer(I('relation_game_id'), I('sdk_version'));
$this->ajaxReturn($serverData);
}
5 years ago
}