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