|
|
@ -48,7 +48,7 @@ class QueryController extends ThinkController
|
|
|
|
$endTime = I('timeend', get_lastweek_name(1));
|
|
|
|
$endTime = I('timeend', get_lastweek_name(1));
|
|
|
|
$sortBy = I('sort_by', '');
|
|
|
|
$sortBy = I('sort_by', '');
|
|
|
|
$sortColumn = I('sort_column', '');
|
|
|
|
$sortColumn = I('sort_column', '');
|
|
|
|
$order = 'tab_spend.pay_time';
|
|
|
|
$order = 'day';
|
|
|
|
$orderType = 'desc';
|
|
|
|
$orderType = 'desc';
|
|
|
|
|
|
|
|
|
|
|
|
if (in_array($sortColumn, ['user_num', 'sum_amount'])) {
|
|
|
|
if (in_array($sortColumn, ['user_num', 'sum_amount'])) {
|
|
|
@ -66,7 +66,7 @@ class QueryController extends ThinkController
|
|
|
|
$spendMap['tab_spend.selle_status'] = 0;
|
|
|
|
$spendMap['tab_spend.selle_status'] = 0;
|
|
|
|
$spendMap['tab_spend.pay_time'] = ['between', [$beginTime, $endTime]];
|
|
|
|
$spendMap['tab_spend.pay_time'] = ['between', [$beginTime, $endTime]];
|
|
|
|
$spendMap['tab_spend.promote_id'] = ['in', $promoteIds];
|
|
|
|
$spendMap['tab_spend.promote_id'] = ['in', $promoteIds];
|
|
|
|
$spendField = 'tab_spend.promote_account, tab_spend.game_name, sum(tab_spend.pay_amount) as sum_amount, tab_spend.selle_ratio, sum(if(tab_spend.selle_ratio > 0, tab_spend.pay_amount * tab_spend.selle_ratio, 0)) as settlement_amount';
|
|
|
|
$spendField = "tab_spend.game_id, tab_spend.game_name, sum(tab_spend.pay_amount) as sum_amount, tab_spend.selle_ratio, sum(if(tab_spend.selle_ratio > 0, tab_spend.pay_amount * tab_spend.selle_ratio, 0)) as settlement_amount, FROM_UNIXTIME(tab_spend.`pay_time`, '%Y-%m-%d') as day";
|
|
|
|
$userMap['tab_user.promote_id'] = ['in', $promoteIds];
|
|
|
|
$userMap['tab_user.promote_id'] = ['in', $promoteIds];
|
|
|
|
$userMap['_string'] = 'tab_user.promote_id = tab_spend.promote_id';
|
|
|
|
$userMap['_string'] = 'tab_user.promote_id = tab_spend.promote_id';
|
|
|
|
$userField = M('user', 'tab_')->field('count(tab_user.id) as user_num')
|
|
|
|
$userField = M('user', 'tab_')->field('count(tab_user.id) as user_num')
|
|
|
@ -76,7 +76,7 @@ class QueryController extends ThinkController
|
|
|
|
|
|
|
|
|
|
|
|
$query = M('spend', 'tab_')->field($field)
|
|
|
|
$query = M('spend', 'tab_')->field($field)
|
|
|
|
->where($spendMap)
|
|
|
|
->where($spendMap)
|
|
|
|
->group('tab_spend.selle_ratio, tab_spend.game_id, tab_spend.promote_id')
|
|
|
|
->group('tab_spend.selle_ratio, tab_spend.game_id, day')
|
|
|
|
->order("{$order} {$orderType}");
|
|
|
|
->order("{$order} {$orderType}");
|
|
|
|
if(I('export', 0) != 1){
|
|
|
|
if(I('export', 0) != 1){
|
|
|
|
$query->page($page, $row);
|
|
|
|
$query->page($page, $row);
|
|
|
@ -85,9 +85,9 @@ class QueryController extends ThinkController
|
|
|
|
->alias('record')
|
|
|
|
->alias('record')
|
|
|
|
->select();
|
|
|
|
->select();
|
|
|
|
if(I('export', 0) != 1){
|
|
|
|
if(I('export', 0) != 1){
|
|
|
|
$countQuery = M('spend', 'tab_')->field('tab_spend.id')
|
|
|
|
$countQuery = M('spend', 'tab_')->field($spendField)
|
|
|
|
->where($spendMap)
|
|
|
|
->where($spendMap)
|
|
|
|
->group('tab_spend.selle_ratio, tab_spend.game_id, tab_spend.promote_id')
|
|
|
|
->group('tab_spend.selle_ratio, tab_spend.game_id, day')
|
|
|
|
->buildSql();
|
|
|
|
->buildSql();
|
|
|
|
$count = M()->table($countQuery)
|
|
|
|
$count = M()->table($countQuery)
|
|
|
|
->alias('tab_spend')
|
|
|
|
->alias('tab_spend')
|
|
|
@ -111,6 +111,7 @@ class QueryController extends ThinkController
|
|
|
|
$data = [];
|
|
|
|
$data = [];
|
|
|
|
foreach ($records as $value) {
|
|
|
|
foreach ($records as $value) {
|
|
|
|
$data[] = [
|
|
|
|
$data[] = [
|
|
|
|
|
|
|
|
'day' => $value['day'],
|
|
|
|
'promote_account' => $value['promote_account'],
|
|
|
|
'promote_account' => $value['promote_account'],
|
|
|
|
'game_name' => $value['game_name'],
|
|
|
|
'game_name' => $value['game_name'],
|
|
|
|
'sum_amount' => $value['sum_amount'],
|
|
|
|
'sum_amount' => $value['sum_amount'],
|
|
|
@ -122,7 +123,8 @@ class QueryController extends ThinkController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$field = [
|
|
|
|
$field = [
|
|
|
|
'promote_account' => '推广员账号',
|
|
|
|
'day' => '日期',
|
|
|
|
|
|
|
|
'promote_account' => '会长账号',
|
|
|
|
'game_name' => '游戏名称',
|
|
|
|
'game_name' => '游戏名称',
|
|
|
|
'sum_amount' => '总充值',
|
|
|
|
'sum_amount' => '总充值',
|
|
|
|
'user_num' => '总注册',
|
|
|
|
'user_num' => '总注册',
|
|
|
|