Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
addcpm-json
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Александр Чаплыгин
addcpm-json
Commits
d56f3815
Commit
d56f3815
authored
Feb 07, 2019
by
Александр Чаплыгин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Проброс в запрос фида, обработка исключения для запроса API
parent
1f62ca14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
19 deletions
+10
-19
Statistics.php
src/src/App/Model/Statistics.php
+9
-11
cabinet-feed.phtml
src/templates/app/user/cabinet-feed.phtml
+1
-8
No files found.
src/src/App/Model/Statistics.php
View file @
d56f3815
...
@@ -58,7 +58,7 @@ class Statistics
...
@@ -58,7 +58,7 @@ class Statistics
$dataRequest
=
array
(
$dataRequest
=
array
(
'method'
=>
$type
,
'method'
=>
$type
,
'data'
=>
array
(
'data'
=>
array
(
'feed_id'
=>
10003
,
'feed_id'
=>
$feed_id_list
[
0
]
,
'start_date'
=>
$dates
[
'start'
],
'start_date'
=>
$dates
[
'start'
],
'end_date'
=>
$dates
[
'end'
],
'end_date'
=>
$dates
[
'end'
],
)
)
...
@@ -66,8 +66,14 @@ class Statistics
...
@@ -66,8 +66,14 @@ class Statistics
}
}
//return $dataRequest;
//return $dataRequest;
$stats
=
$this
->
apiRequest
(
$dataRequest
);
//$stats = $this->apiRequest($dataRequest);
try
{
$stats
=
$this
->
apiRequest
(
$dataRequest
);
}
catch
(
\Exception
$e
)
{
$stats
[
'status'
]
=
'Error'
;
}
//return $stats;
//return $stats;
// В запросе ошибка или отсутствуют данные для статистики:
// В запросе ошибка или отсутствуют данные для статистики:
if
(
$stats
[
'status'
]
==
'Error'
)
{
if
(
$stats
[
'status'
]
==
'Error'
)
{
...
@@ -77,7 +83,6 @@ class Statistics
...
@@ -77,7 +83,6 @@ class Statistics
return
null
;
return
null
;
}
}
$dataStats
=
array
();
$dataStats
=
array
();
$dataStats
[
'report'
]
=
$report_type
;
$dataStats
[
'report'
]
=
$report_type
;
...
@@ -233,12 +238,6 @@ class Statistics
...
@@ -233,12 +238,6 @@ class Statistics
// Данные для отчета 'transaction':
// Данные для отчета 'transaction':
if
(
$report_type
==
'transaction'
)
{
if
(
$report_type
==
'transaction'
)
{
$dataStats
[
'period'
]
=
[];
$dataStats
[
'Timestamp'
]
=
[];
$dataStats
[
'OrderSum'
]
=
[];
$dataStats
[
'Basket'
]
=
[];
foreach
(
$stats
[
'data'
]
as
$item
)
{
foreach
(
$stats
[
'data'
]
as
$item
)
{
$dataStats
[
'period'
][]
=
$item
[
'ForeignID'
];
$dataStats
[
'period'
][]
=
$item
[
'ForeignID'
];
$dataStats
[
'Timestamp'
][]
=
$item
[
'Timestamp'
];
$dataStats
[
'Timestamp'
][]
=
$item
[
'Timestamp'
];
...
@@ -257,7 +256,7 @@ class Statistics
...
@@ -257,7 +256,7 @@ class Statistics
// Запрос к API:
// Запрос к API:
private
function
apiRequest
(
$data
)
private
function
apiRequest
(
$data
)
{
{
//return $data;
$playload
=
json_encode
(
$data
);
$playload
=
json_encode
(
$data
);
$url
=
'http://stat.instraroam.net/json/'
.
md5
(
$playload
.
$this
->
hashSolt
);
$url
=
'http://stat.instraroam.net/json/'
.
md5
(
$playload
.
$this
->
hashSolt
);
...
@@ -278,7 +277,6 @@ class Statistics
...
@@ -278,7 +277,6 @@ class Statistics
if
(
$info
[
'http_code'
]
!=
200
)
{
if
(
$info
[
'http_code'
]
!=
200
)
{
throw
new
\Exception
(
'Error. '
.
$info
[
'http_code'
]);
throw
new
\Exception
(
'Error. '
.
$info
[
'http_code'
]);
//throw new \Exception('Error. ' . $info['http_code'] . ' json-data: '. json_encode($data)); // для передачи данных json-запроса
}
}
return
json_decode
(
$result
,
1
);
return
json_decode
(
$result
,
1
);
...
...
src/templates/app/user/cabinet-feed.phtml
View file @
d56f3815
...
@@ -36,7 +36,7 @@ $this->headScript()
...
@@ -36,7 +36,7 @@ $this->headScript()
->
appendFile
(
'/js/script-feeds-stat-table.js'
)
->
appendFile
(
'/js/script-feeds-stat-table.js'
)
->
appendFile
(
'/js/script-feeds-stat.js'
)
->
appendFile
(
'/js/script-feeds-stat.js'
)
->
appendFile
(
'/js/adm/service-actions.js'
)
->
appendFile
(
'/js/adm/service-actions.js'
)
//->appendFile('/js/script-canvas.js')
;
;
$this
->
headLink
()
$this
->
headLink
()
...
@@ -158,13 +158,6 @@ if (!$error) {
...
@@ -158,13 +158,6 @@ if (!$error) {
<div
class=
"message"
></div>
<div
class=
"message"
></div>
</div>
</div>
<?php
/* ?>
<div>
<img id="scream" src="/img/canvas/image-test5.jpg" alt="The Scream" width="200" height="200">
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;"></canvas>
</div>
<?php */
?>
<?php
/* График */
?>
<?php
/* График */
?>
<?php
if
(
$current_report
==
'common'
)
:
?>
<?php
if
(
$current_report
==
'common'
)
:
?>
<div
id=
"chart-graph-stat"
style=
"height: 370px;"
data-colors=
<?=
(
$colors_active_lines
?
json_encode
(
$colors_active_lines
)
:
''
)
?>
>
</div
>
<div
id=
"chart-graph-stat"
style=
"height: 370px;"
data-colors=
<?=
(
$colors_active_lines
?
json_encode
(
$colors_active_lines
)
:
''
)
?>
>
</div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment