Merge branch 'hotfix/agg_data' of wmtx/platform into master

聚合数据统计优化
master
廖金灵 4 years ago committed by Gogs
commit 67960a1cd5

@ -8279,11 +8279,14 @@ class ExportController extends Controller
$map = [];
$searchGameIds = null;
$game_ids = array_column(getGameByName(I("game_name"), I("sdk_type")), 'id');
if ($game_ids) {
$map['s.game_id'] = ['in', $game_ids];
$searchGameIds = $game_ids;
}
if (!empty(I('partner_id'))) {
$map['g.partner_id'] = I('partner_id');
}
@ -8303,20 +8306,39 @@ class ExportController extends Controller
if (!empty(I('game_type_id'))) {
$map['g.game_type_id'] = I('game_type_id');
$searchGameIds = M('game', 'tab_')->where(['game_type_id' => I('game_type_id', 0)])->getField('id', true);
}
$xlsData = D("spend")->gameStatistics($map);
$uniqueCodes = array_column($xlsData, 'unique_code');
$gameIds = array_column($data, 'game_id');
$uniqueCodes = array_filter($uniqueCodes, function($value) {
if ($value) {
return true;
}
return false;
});
$gameSets = [];
if (count($gameIds) > 0) {
$gameSets = M('game_set', 'tab_')->field(['game_id', 'pay_notify_url'])->where(['game_id' => ['in', $gameIds]])->select();
$gameSets = index_by_column('game_id', $gameSets);
}
$searchGameCodes = [];
if (count($searchGameIds) > 0) {
$searchGameCodes = M('game', 'tab_')->where(['id' => ['in', $searchGameIds], 'unique_code' => ['neq', '']])->getField('unique_code', true);
$searchGameCodes = array_unique($searchGameCodes);
}
$client = new AggregateClient();
$result = $client->api('game-data', ['unique_codes' => $uniqueCodes, 'started_at' => I('timestart', ''), 'ended_at' => I('timeend', '')]);
$result = $client->api('game-data', [
'unique_codes' => $uniqueCodes,
'started_at' => I('timestart', ''),
'ended_at' => I('timeend', ''),
'search_games' => $searchGameCodes,
]);
$aggData = [];
$aggTotal = '0.00';
if ($result['code'] == '0000') {
@ -8332,7 +8354,7 @@ class ExportController extends Controller
$aggAmount = number_format($aggData[$value['unique_code']][$deviceType], 2, '.', '');
}
$xlsData[$key]['agg_amount'] = $aggAmount;
if ($aggAmount != '0.00') {
if (isset($gameSets[$value['game_id']]) && isAggGame($gameSets[$value['game_id']]['pay_notify_url'])) {
$value['cash_count'] = 0;
$value['balance_coin_count'] = 0;
$value['inside_cash_count'] = 0;

@ -707,9 +707,11 @@ class FinanceController extends ThinkController
$map = [];
$searchGameIds = null;
$game_ids = array_column(getGameByName(I("game_name"), I("sdk_type")), 'id');
if ($game_ids) {
$map['s.game_id'] = ['in', $game_ids];
$searchGameIds = $game_ids;
}
if (!empty(I('partner_id'))) {
@ -731,10 +733,13 @@ class FinanceController extends ThinkController
if (!empty(I('game_type_id'))) {
$map['g.game_type_id'] = I('game_type_id');
$searchGameIds = M('game', 'tab_')->where(['game_type_id' => I('game_type_id', 0)])->getField('id', true);
}
$startTime = time();
//游戏统计列表
$data = D("spend")->gameStatistics($map, $row, $p);
$gameIds = array_column($data, 'game_id');
$uniqueCodes = array_column($data, 'unique_code');
$uniqueCodes = array_filter($uniqueCodes, function($value) {
if ($value) {
@ -743,8 +748,32 @@ class FinanceController extends ThinkController
return false;
});
$gameSets = [];
if (count($gameIds) > 0) {
$gameSets = M('game_set', 'tab_')->field(['game_id', 'pay_notify_url'])->where(['game_id' => ['in', $gameIds]])->select();
$gameSets = index_by_column('game_id', $gameSets);
}
$searchGameCodes = [];
if (count($searchGameIds) > 0) {
$searchGameCodes = M('game', 'tab_')->where(['id' => ['in', $searchGameIds], 'unique_code' => ['neq', '']])->getField('unique_code', true);
$searchGameCodes = array_unique($searchGameCodes);
}
var_dump([
'unique_codes' => $uniqueCodes,
'started_at' => I('timestart', ''),
'ended_at' => I('timeend', ''),
'search_games' => $searchGameCodes,
]);
$client = new AggregateClient();
$result = $client->api('game-data', ['unique_codes' => $uniqueCodes, 'started_at' => I('timestart', ''), 'ended_at' => I('timeend', '')]);
$result = $client->api('game-data', [
'unique_codes' => $uniqueCodes,
'started_at' => I('timestart', ''),
'ended_at' => I('timeend', ''),
'search_games' => $searchGameCodes,
]);
$aggData = [];
$aggTotal = '0.00';
if ($result['code'] == '0000') {
@ -760,7 +789,8 @@ class FinanceController extends ThinkController
if ($value['unique_code'] && isset($aggData[$value['unique_code']]) && isset($aggData[$value['unique_code']][$deviceType])) {
$aggAmount = number_format($aggData[$value['unique_code']][$deviceType], 2, '.', '');
}
if ($aggAmount != '0.00') {
// if ($aggAmount != '0.00') {
if (isset($gameSets[$value['game_id']]) && isAggGame($gameSets[$value['game_id']]['pay_notify_url'])) {
$data[$key]['cash_count'] = $value['cash_count'] = 0;
$data[$key]['balance_coin_count'] = $value['balance_coin_count'] = 0;
$data[$key]['inside_cash_count'] = $value['inside_cash_count'] = 0;

@ -3029,4 +3029,12 @@ function db2csv(&$data,$title,$header=false){
function hideRealName($realName)
{
return mb_strlen($realName,'utf-8') == 2 ? mb_substr($realName,0,1,'utf-8').'*':mb_substr($realName,0,1,'utf-8').'**';
}
function isAggGame($payUrl)
{
if (strpos($payUrl, 'sdk-pay-a.wmtxkj') !== false || strpos($payUrl, 'sdk-pay-i.wmtxkj') !== false ) {
return true;
}
return false;
}
Loading…
Cancel
Save