Отчет по статистике по транзакциям

parent d72eff0c
......@@ -41,14 +41,12 @@ return [
],
'transaction' => [
'title' => 'Транзакции',
'type' => 'feed_stat',
'type' => 'feed_transactions',
'fields' => ['Views','Clicks','Orders','OrderSum'],
'cats' => [
'Views' => 'Показы',
'Clicks' => 'Клики',
'Orders' => 'Заказы',
'OrderSum' => 'Заказы на сумму',
'AdMoney' => 'Комиссия AddCPM'
'Timestamp' => 'Дата и время',
'OrderSum' => 'Сумма',
'BasketCount' => 'Количество товаров'
]
/*
$cats => [
......
......@@ -12,10 +12,16 @@ $(document).ready(function(){
{
var
currencyFields = ['admoney', 'salemoney', 'usdollarmoney', 'localmoney', 'AdMoney', 'OrderSum'],
nonFormatFields = ['Timestamp'],
isCurrencyValue = currencyFields.indexOf(currentActiveLine) > -1,
isNonFormatValue = nonFormatFields.indexOf(currentActiveLine) > -1,
//format = (isCurrencyValue) ? d3.format(',.2f') : d3.format(',.0f');
format = (isCurrencyValue) ? d3.format(',.0f') : d3.format(',.0f');
if (isNonFormatValue) {
return value;
}
if (isCurrencyValue) {
return format(value) + ' грн.';
} else {
......@@ -28,6 +34,9 @@ $(document).ready(function(){
{
var dataPeriod = dataLineChartStat['period'];
var notSumFields = ['Timestamp'];
dataTable = dataLineChartStat;
// Добавляем строку "Итого":
......@@ -36,10 +45,16 @@ $(document).ready(function(){
activeLines.forEach(function(item){
currentActiveLine = item;
var isNotSumValue = notSumFields.indexOf(currentActiveLine) > -1;
if (!isNotSumValue) {
var totalValue = 0;
for(var i = dataPeriod.length-1; i >= 0; i--) {
totalValue += dataTable[item][i];
}
} else {
totalValue = '';
}
$row.append($('<td>').html(valueFormat(totalValue)));
});
......@@ -129,7 +144,7 @@ $(document).ready(function(){
});
console.log('AAA TableStat render: ', dataLineChartStat);
//console.log('AAA activeLines: ', activeLines);
console.log('AAA activeLines: ', activeLines);
dataTable = {};
activeLines.forEach(function(item){
......@@ -140,6 +155,10 @@ $(document).ready(function(){
RenderInterval(dataLineChartStat);
}
if (dataLineChartStat.report == 'transaction') {
RenderInterval(dataLineChartStat);
}
$tableBody.html('').append($tableContent.children());
},
......
......@@ -36,18 +36,11 @@ class Statistics
);
// Параметры запроса по типу отчета:
switch ($report_type) {
case 'common':
$type = $report_conf['type'];
$fields = $report_conf['fields'];
break;
case 'transaction':
$type = $report_conf['type'];
$fields = $report_conf['fields'];
break;
}
// Данные для запроса:
if ($report_type == 'common') {
$dataRequest = array(
'method' => "reports",
'data' => array(
......@@ -59,6 +52,19 @@ class Statistics
'dates' => $dates,
)
);
}
if ($report_type == 'transaction') {
$dataRequest = array(
'method' => $type,
'data' => array(
'feed_id' => 10003,
'start_date' => $dates['start'],
'end_date' => $dates['end'],
)
);
}
//return $dataRequest;
$stats = $this->apiRequest($dataRequest);
......@@ -72,7 +78,12 @@ class Statistics
return null;
}
$dataStats = array();
$dataStats['report'] = $report_type;
if ($report_type == 'common') {
$period = array();
// Формируем данные для временного промежутка
......@@ -207,7 +218,6 @@ class Statistics
}
}
/*
foreach ($stats['data']['Day'] as $day=>$value_day) {
$period[] = $day;
......@@ -216,7 +226,35 @@ class Statistics
*/
$dataStats['period'] = $period;
$dataStats['report'] = $report_type;
}
if ($report_type == 'transaction') {
$period = array();
//$data = [];
$dataStats['Timestamp'] = [];
$dataStats['OrderSum'] = [];
$dataStats['BasketCount'] = [];
foreach ($stats['data'] as $item) {
$period[] = $item['TransactionID'];
$dataStats['Timestamp'][] = $item['Timestamp'];
$dataStats['OrderSum'][] = $item['OrderSum'];
$dataStats['BasketCount'][] = count($item['Basket']);
/*
$data[] = array(
'Timestamp' => $item['Timestamp'],
'OrderSum' => $item['OrderSum'],
'BasketCount' => count($item['Basket']),
);
*/
}
$dataStats['period'] = $period;
//$dataStats['data'] = $data;
}
$stats = $dataStats;
return $stats;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment