diff --git a/Application/Callback/Controller/Notify3Controller.class.php b/Application/Callback/Controller/Notify3Controller.class.php
index 6c3c0e9e6..33d7e65eb 100644
--- a/Application/Callback/Controller/Notify3Controller.class.php
+++ b/Application/Callback/Controller/Notify3Controller.class.php
@@ -194,6 +194,7 @@ class Notify3Controller extends BaseController
$data['type'] = 1;
$data['sub_type'] = 1;
$data['target_id'] = $promote['id'];
+ $data['promote_id'] = $promote['id'];
$data['target_level'] = $promote['level'];
$data['target_type'] = 1;
$data['ref_id'] = $order['id'];
diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php
index 255b4d206..2529f6bd4 100644
--- a/Application/Home/Controller/QueryController.class.php
+++ b/Application/Home/Controller/QueryController.class.php
@@ -1709,118 +1709,132 @@ class QueryController extends BaseController
$isSelf = I('is_self', 0);
$roleName = I('role_name', '');
$userAccount = I('user_account', '');
- $promoteId = I('promote_id', 0);
$sdkVersion = I('sdk_version', 0);
$costBegin = I('cost_begin', '');
$costEnd = I('cost_end', '');
+ $sortName = trim(I('sort_name', ''));
+ $sort = intval(I('sort', 1));
+ $nowTime = date('Y-m-d');
+ $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
+ $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime');
+ $initEndTime = $nowTime;
+ $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime');
+ $begTime = strtotime($initBegTime);
+ $endTime = strtotime($initEndTime);
+ $endTime += 3600 * 24;
$promote = $this->getLoginPromote();
$levelPromote = $this->getLevelPromote();
$queryPromote = $this->getQueryPromote($levelPromote);
- $map[] = [
- '_logic' => 'or',
- 'id' => $queryPromote['id'],
- 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']
- ];
- $ids = M('promote', 'tab_')->where($map)->getField('id', true);
+ $records = [];
+ $pagination = '';
+ $count = 0;
+ if (intval($endTime - $begTime) / (24 * 3600) <= 31) {
+ $map[] = [
+ '_logic' => 'or',
+ 'id' => $queryPromote['id'],
+ 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']
+ ];
+ $ids = M('promote', 'tab_')->where($map)->getField('id', true);
- $map = [];
- if (count($ids) > 0) {
- $map = ['promote_id' => ['in', $ids]];
- } else {
- $map['_string'] = '1<>1';
- }
+ $map = [];
+ if (count($ids) > 0) {
+ $map = ['promote_id' => ['in', $ids]];
+ } else {
+ $map['_string'] = '1<>1';
+ }
- $spendMap = $map;
- if ($gameId != 0) {
- $map['game_id'] = $gameId;
- }
- if ($serverId != 0) {
- $map['server_id'] = $serverId;
- }
- if ($roleName != '') {
- $map['role_name'] = ['like', '%' . $roleName . '%'];
- }
- if ($userAccount != '') {
- $map['user_account'] = ['like', '%' . $userAccount . '%'];
- }
- if ($sdkVersion != 0) {
- $map['sdk_version'] = $sdkVersion;
- }
- if ($isSelf) {
- $map['promote_id'] = $queryPromote['id'];
- $spendMap['promote_id'] = $queryPromote['id'];
- }
- if ($costBegin != '' || $costEnd != '') {
- $having = '';
- if ($costBegin != '' && $costEnd != '') {
- $having = 'sum(cost) between ' . $costBegin . ' and ' . $costEnd;
- } elseif ($costBegin != '' && $costEnd == '') {
- $having = 'sum(cost) >= ' . $costBegin;
- } elseif ($costBegin == '' && $costEnd != '') {
- $having = 'sum(cost) <= ' . $costEnd;
+ $subMap = [];
+ if ($gameId != 0) {
+ $map['game_id'] = $gameId;
+ $subMap['game_id'] = $gameId;
+ }
+ if ($serverId != 0) {
+ $map['server_id'] = $serverId;
+ $subMap['server_id'] = $serverId;
+ }
+ if ($roleName != '') {
+ $map['role_name'] = ['like', '%' . $roleName . '%'];
+ }
+ if ($userAccount != '') {
+ $map['user_account'] = ['like', '%' . $userAccount . '%'];
+ }
+ if ($sdkVersion != 0) {
+ $map['sdk_version'] = $sdkVersion;
+ }
+ if ($isSelf) {
+ $map['promote_id'] = $queryPromote['id'];
}
- $subMap = $map;
- $subMap['pay_status'] = 1;
- $subMap['pay_game_status'] = 1;
- $subQuery = M('spend', 'tab_')->field('game_player_id')->where($subMap)->group('game_player_id')->having($having)->buildSql();
- $map['_string'] = 'role_id in (' . $subQuery . ')';
- }
- $query = M('user_play_info', 'tab_')->where($map)->order('play_time desc');
- list($roles, $pagination, $count) = $this->paginate($query);
- $roleIds = array_column($roles, 'role_id');
-
- $spendMap['pay_status'] = 1;
- $spendMap['pay_game_status'] = 1;
- if (count($roleIds) > 0) {
- $spendMap['game_player_id'] = ['in', $roleIds];
- } else {
- $spendMap['_string'] = '1<>1';
- }
- $allRecharges = M('spend', 'tab_')->field('count(*) count, sum(cost) cost, game_player_id')->where($spendMap)->group('game_player_id')->select();
- $allRecords = [];
- foreach ($allRecharges as $recharge) {
- $allRecords[$recharge['game_player_id']] = $recharge;
- }
- $spendMap['pay_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]];
- $todayRecharges = M('spend', 'tab_')->field('sum(cost) cost, game_player_id')->where($spendMap)->group('game_player_id')->select();
- $todayRecords = [];
- foreach ($todayRecharges as $recharge) {
- $todayRecords[$recharge['game_player_id']] = $recharge;
- }
+ $subMap['create_time'] = ['between', [$begTime, $endTime - 1]];
+ if ($costBegin != '' || $costEnd != '') {
+ $having = '';
+ if ($costBegin != '' && $costEnd != '') {
+ $having = 'sum(recharge_cost) between ' . $costBegin . ' and ' . $costEnd;
+ } elseif ($costBegin != '' && $costEnd == '') {
+ $having = 'sum(recharge_cost) >= ' . $costBegin;
+ } elseif ($costBegin == '' && $costEnd != '') {
+ $having = 'sum(recharge_cost) <= ' . $costEnd;
+ }
+ $subQuery = M('user_play_data_count', 'tab_')->field('role_id')
+ ->where($subMap)
+ ->group('game_id,server_id,role_id')
+ ->having($having)
+ ->buildSql();
+ $map['_string'] = 'role_id in (' . $subQuery . ')';
+ }
+ $spendMap['uc.create_time'] = ['between', [$begTime, $endTime - 1]];
+ $spendMap['_string'] = 'uc.game_id = game_id and uc.server_id = server_id and uc.role_id = role_id';
+ $sqlCost = M('user_play_data_count', 'tab_')->alias('uc')
+ ->field('sum(uc.recharge_cost) cost')
+ ->where($spendMap)
+ ->buildSql();
+ $sqlCount = M('user_play_data_count', 'tab_')->alias('uc')
+ ->field('sum(uc.recharge_count) count')
+ ->where($spendMap)
+ ->buildSql();
+ $spendMap['uc.create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]];
+ $sqlTodayCost = M('user_play_data_count', 'tab_')->alias('uc')
+ ->field('sum(uc.recharge_count) count')
+ ->where($spendMap)
+ ->buildSql();
+ $query = M('user_play_info', 'tab_')
+ ->field("*,$sqlCost as cost,$sqlCount as count,$sqlTodayCost as today_cost")
+ ->where($map)
+ ->order('play_time desc');
+ list($roles, $pagination, $count) = $this->paginate($query);
- $records = [];
- foreach ($roles as $role) {
- $records[] = [
- 'user_account' => encryption($role['user_account']),
- 'game_name' => $role['game_name'],
- 'role_name' => $role['role_name'],
- 'role_id' => $role['role_id'],
- 'role_level' => $role['role_level'],
- 'server_id' => $role['server_id'],
- 'server_name' => $role['server_name'],
- 'recharge_cost' => isset($allRecords[$role['role_id']]) ? round(floatval($allRecords[$role['role_id']]['cost']), 2) : 0,
- 'recharge_count' => isset($allRecords[$role['role_id']]) ? $allRecords[$role['role_id']]['count'] : 0,
- 'recharge_cost_today' => isset($todayRecords[$role['role_id']]) ? round(floatval($todayRecords[$role['role_id']]['cost']), 2) : 0,
- 'play_time' => $role['play_time'],
- 'play_ip' => $role['play_ip'],
- 'promote_id' => $role['promote_id'],
- 'promote_account' => $role['promote_account'],
- 'sdk_version' => $role['sdk_version'],
- 'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600))
- ];
+ foreach ($roles as $role) {
+ $records[] = [
+ 'user_account' => encryption($role['user_account']),
+ 'game_name' => $role['game_name'],
+ 'role_name' => $role['role_name'],
+ 'role_id' => $role['role_id'],
+ 'role_level' => $role['role_level'],
+ 'server_id' => $role['server_id'],
+ 'server_name' => $role['server_name'],
+ 'recharge_cost' => $role['cost'],
+ 'recharge_count' => $role['count'],
+ 'recharge_cost_today' => $role['cost_today'],
+ 'play_time' => $role['play_time'],
+ 'play_ip' => $role['play_ip'],
+ 'promote_id' => $role['promote_id'],
+ 'promote_account' => $role['promote_account'],
+ 'sdk_version' => $role['sdk_version'],
+ 'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600))
+ ];
+ }
}
$games = $this->getGamesByPromote($promote);
$this->assign('games', $games);
- $this->assign('promotes', $promotes);
- $this->assign('groupPromotes', $groupPromotes);
$this->assign('records', $records);
$this->assign('pagination', $pagination);
$this->assign('count', $count);
+ $this->assign('initBegTime', $initBegTime);
+ $this->assign('initEndTime', $initEndTime);
$this->display('userRecharges');
}
@@ -1906,10 +1920,10 @@ class QueryController extends BaseController
public function achievement()
{
$time = I('time', date('Y-m-d'));
- if(!empty($time)) {
- $defaultTime = $time ;
- }else {
- $defaultTime = date('Y-m-d',time());
+ if (!empty($time)) {
+ $defaultTime = $time;
+ } else {
+ $defaultTime = date('Y-m-d', time());
}
$sdkVersion = I('sdk_version', 0);
$gameId = I('game_id', 0);
@@ -2000,7 +2014,7 @@ class QueryController extends BaseController
$rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params);
$rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params);
$rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params);
-
+
if (I('p', 1) == 1) {
$selfParams = $params;
$selfParams['isContainSubs'] = false;
@@ -2013,7 +2027,7 @@ class QueryController extends BaseController
$selfRechargeCountList = $promoteRepository->getRechargeCountByIds([$parent['id']], $selfParams);
$selfRechargeUserCountList = $promoteRepository->getRechargeUserCountByIds([$parent['id']], $selfParams);
$selfRechargeAmountList = $promoteRepository->getRechargeAmountByIds([$parent['id']], $selfParams);
-
+
$records[] = [
'id' => $parent['id'],
'account' => $parent['account'],
@@ -2070,7 +2084,7 @@ class QueryController extends BaseController
$this->assign('parentid', $parentId);
$this->assign('count', $count);
$this->assign('timeout', $timeout);
- $this->assign('time',$defaultTime);
+ $this->assign('time', $defaultTime);
$this->display();
}
diff --git a/Application/Home/View/default/Query/userRecharges.html b/Application/Home/View/default/Query/userRecharges.html
index 29dd264db..06dce4616 100644
--- a/Application/Home/View/default/Query/userRecharges.html
+++ b/Application/Home/View/default/Query/userRecharges.html
@@ -1,6 +1,7 @@