diff --git a/Application/Base/Service/PromoteGradeService.class.php b/Application/Base/Service/PromoteGradeService.class.php index 6636aff96..f15d088d6 100644 --- a/Application/Base/Service/PromoteGradeService.class.php +++ b/Application/Base/Service/PromoteGradeService.class.php @@ -128,6 +128,7 @@ class PromoteGradeService $config = json_decode($setting['config'], true); $settingLevel = $config['reach_level']; $month = $params['month'] ?? date('Y-m'); + $baseGameId = $params['base_game_id'] ?? 0; $promoteIds = array_column($promotes, 'id'); $beginTime = strtotime($month . '-01 00:00:00'); $endDate = date('Y-m-01 00:00:00', strtotime($month . '-01' . ' +1 month')); @@ -140,26 +141,44 @@ class PromoteGradeService ->where(['register_time' => ['between', $betweenTime], 'promote_id' => ['in', $promoteIds]]) ->group('promote_id') ->select(false); + + $baseGame = null; + if ($baseGameId > 0) { + $baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find(); + } + + $roleMap = [ + 'role_level' => ['egt', $settingLevel], + 'create_time' => ['between', $betweenTime], + 'promote_id' => ['in', $promoteIds], + '_string' => 'user_id in (' . $userSubSql . ')' + ]; + $spendMap = [ + 'pay_time' => ['between', $betweenTime], + 'pay_status' => 1, + 'promote_id' => ['in', $promoteIds], + '_string' => 'user_id in (' . $userSubSql . ')' + ]; + + if ($baseGame) { + $roleMap['game_id'] = ['in', [$baseGame['android_game_id'], $baseGame['ios_game_id']]]; + $spendMap['game_id'] = ['in', [$baseGame['android_game_id'], $baseGame['ios_game_id']]]; + } else { + $roleMap['_string'] .= ' and 1=0'; + $spendMap['_string'] .= ' and 1=0'; + } + $accountItems = M('user_play_info', 'tab_') ->field(['promote_id', 'count(DISTINCT user_id) num']) - ->where([ - 'role_level' => ['egt', $settingLevel], - 'create_time' => ['between', $betweenTime], - 'promote_id' => ['in', $promoteIds], - '_string' => 'user_id in (' . $userSubSql . ')' - ]) + ->where($roleMap) ->group('promote_id') ->select(); $accountItems = index_by_column('promote_id', $accountItems); - + $amountItems = M('spend', 'tab_') ->field(['promote_id', 'sum(pay_amount) amount']) - ->where([ - 'pay_time' => ['between', $betweenTime], - 'pay_status' => 1, 'promote_id' => ['in', $promoteIds], - '_string' => 'user_id in (' . $userSubSql . ')' - ]) + ->where($spendMap) ->group('promote_id') ->select(); $amountItems = index_by_column('promote_id', $amountItems); diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 4d72a450c..8500853e4 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -1894,12 +1894,18 @@ class DownloadController extends BaseController { public function promote_grade_export() { $month = I('month', date('Y-m')); + $month = $month ? $month : date('Y-m'); + $baseGameId = I('base_game_id', 0); $loginPromote = $this->getLoginPromote(); + if ($baseGameId == 0) { + return $this->error('未选择游戏'); + } $promoteGradeService = new PromoteGradeService(); - $setting = $promoteGradeService->getCurrentSetting($loginPromote); + $monthNumber = date('Ym', strtotime($month . '-01')); + $setting = $promoteGradeService->getCurrentSetting($loginPromote, $baseGameId, $monthNumber); if (is_null($setting)) { - return $this->error('未设置评级规则'); + return $this->error('该游戏在此月份未设置评级规则'); } $parentId = I('parent_id', 0); @@ -1931,7 +1937,7 @@ class DownloadController extends BaseController { $promotes = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map)->select(); array_unshift($promotes, $parent); - $conditions = json_encode(['promotes' => $promotes, 'setting' => $setting, 'month' => $month], true); + $conditions = json_encode(['promotes' => $promotes, 'setting' => $setting, 'month' => $month, 'base_game_id' => $baseGameId], true); $addtime = time(); $data1 = [ 'logid' => 'pg_'.time(), @@ -4217,6 +4223,7 @@ public function iosDetailExcelInfo($id,$map) { $promoteGradeService = new PromoteGradeService(); $records = $promoteGradeService->searchGradeByPromotes($map['promotes'], [ 'month' => $map['month'], + 'base_game_id' => $map['base_game_id'] ], $map['setting']); $xlsData = []; diff --git a/Application/Home/Controller/PromoteGradeController.class.php b/Application/Home/Controller/PromoteGradeController.class.php index d3d178b95..e09435d2b 100644 --- a/Application/Home/Controller/PromoteGradeController.class.php +++ b/Application/Home/Controller/PromoteGradeController.class.php @@ -85,6 +85,7 @@ class PromoteGradeController extends BaseController $records = $promoteGradeService->searchGradeByPromotes($promotes, [ 'month' => $month, + 'base_game_id' => $baseGameId ], $setting); if (I('p', 1) == 1) { diff --git a/Application/Home/View/default/PromoteGrade/index.html b/Application/Home/View/default/PromoteGrade/index.html index 35013ba1d..889c8cb7e 100644 --- a/Application/Home/View/default/PromoteGrade/index.html +++ b/Application/Home/View/default/PromoteGrade/index.html @@ -105,7 +105,7 @@