master
ELF 4 years ago
parent 8c8d01a446
commit 34586b228e

@ -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);

@ -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 = [];

@ -85,6 +85,7 @@ class PromoteGradeController extends BaseController
$records = $promoteGradeService->searchGradeByPromotes($promotes, [
'month' => $month,
'base_game_id' => $baseGameId
], $setting);
if (I('p', 1) == 1) {

@ -105,7 +105,7 @@
</div>
<div class="pagenation clearfix">
<?php if ($loginer['level'] !== 4) :?>
<a id="sch-btn" href="{:U('download/promote_grade_export',array_merge(['parent_id'=>$parentId,'month'=>$month],I('post.')))}" class="ajax-get">导出</a>
<a id="sch-btn" href="{:U('download/promote_grade_export',array_merge(['parent_id'=>$parentId,'month'=>$month, 'base_game_id' => I('base_game_id', 0)],I('post.')))}" class="ajax-get">导出</a>
<?php endif ;?>
{$pagination}
</div>

Loading…
Cancel
Save