Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
b64c07c7
Commit
b64c07c7
authored
Jan 04, 2022
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into 'master'
Feature/optimize See merge request
!489
parents
2f5433fd
c17a2092
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
25 deletions
+28
-25
ArticleController.php
console/controllers/ArticleController.php
+28
-25
No files found.
console/controllers/ArticleController.php
View file @
b64c07c7
...
...
@@ -2,50 +2,53 @@
namespace
console\controllers
;
use
common\models\pwallet\Article
;
use
Yii
;
use
yii\console\Controller
;
use
common\components\Tools
;
use
common\models\pwallet\Article
;
use
common\service\bishijie\BishijieService
;
use
linslin\yii2\curl\Curl
;
class
ArticleController
extends
Controller
{
public
function
actionIndex
()
{
$page
=
1
;
$size
=
20
;
$bishijie
=
Yii
::
$app
->
params
[
'bishijie'
];
$appid
=
$bishijie
[
'Appid'
];
$appSecret
=
$bishijie
[
'AppSecret'
];
$bishijie_service
=
new
BishijieService
(
$appid
,
$appSecret
);
$resp
=
$bishijie_service
->
getArticleList
(
$page
,
$size
);
if
(
!
isset
(
$resp
[
'list'
]))
{
$coindog
=
Yii
::
$app
->
params
[
'coindog'
];
$httpParams
=
array
(
'access_key'
=>
$coindog
[
'accessKey'
],
'date'
=>
time
()
);
$signParams
=
array_merge
(
$httpParams
,
array
(
'secret_key'
=>
$coindog
[
'secretKey'
]));
ksort
(
$signParams
);
$signString
=
http_build_query
(
$signParams
);
$httpParams
[
'sign'
]
=
strtolower
(
md5
(
$signString
));
$url
=
$coindog
[
'article'
]
.
'?'
.
http_build_query
(
$httpParams
);
$curl
=
new
Curl
();
$resp
=
$curl
->
get
(
$url
,
false
);
if
(
empty
(
$resp
))
{
return
0
;
}
$create_time
=
Article
::
find
()
->
where
([
'platform_id'
=>
-
1
])
->
max
(
'create_time'
);
$list
=
$resp
[
'list'
];
if
(
$create_time
>=
$list
[
0
][
'issue_time'
])
{
$max_create_time
=
Article
::
find
()
->
where
([
'platform_id'
=>
-
1
])
->
max
(
'create_time'
);
if
(
$max_create_time
>=
strtotime
(
$resp
[
0
][
'published_time'
]))
{
return
0
;
}
$list
=
Tools
::
arraySort
(
$list
,
'issue_time'
,
SORT_ASC
);
$list
=
Tools
::
arraySort
(
$resp
,
'id'
,
SORT_ASC
);
$article
=
new
Article
();
foreach
(
$list
as
&
$item
)
{
go
(
function
()
use
(
$item
,
$article
,
$create_time
)
{
go
(
function
()
use
(
$item
,
$article
,
$
max_
create_time
)
{
\Co
::
sleep
(
0.5
);
if
(
$item
[
'issue_time'
]
>
$
create_time
)
{
if
(
strtotime
(
$item
[
'published_time'
])
>
$max_
create_time
)
{
$article
->
setIsNewRecord
(
true
);
$article
->
title
=
$item
[
'title'
];
$article
->
source
=
$item
[
'source
'
];
$article
->
content
=
$item
[
'id
'
];
$article
->
logo_pic
=
$item
[
'promulgator'
][
'logo_pic
'
];
$article
->
img_url
=
$item
[
'img_url
'
];
$article
->
content
=
$item
[
'content
'
];
$article
->
logo_pic
=
$item
[
'thumbnail
'
];
$article
->
img_url
=
$item
[
'thumbnail
'
];
$article
->
source
=
$item
[
'resource
'
];
$article
->
platform_id
=
-
1
;
$article
->
create_time
=
$item
[
'issue_time'
]
;
$article
->
create_time
=
strtotime
(
$item
[
'published_time'
])
;
$article
->
save
()
&&
$article
->
id
=
0
;;
}
});
...
...
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