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
e7ff28aa
Commit
e7ff28aa
authored
Jul 28, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
b43f10dc
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
200 additions
and
41 deletions
+200
-41
ArticleController.php
api/controllers/ArticleController.php
+2
-2
CoinDogController.php
api/controllers/CoinDogController.php
+2
-2
SourceController.php
backend/controllers/SourceController.php
+5
-5
Article.php
common/models/pwallet/Article.php
+1
-1
News.php
common/models/pwallet/News.php
+104
-0
ArticleController.php
console/controllers/ArticleController.php
+18
-31
NewsController.php
console/controllers/NewsController.php
+68
-0
No files found.
api/controllers/ArticleController.php
View file @
e7ff28aa
...
@@ -10,7 +10,7 @@ namespace api\controllers;
...
@@ -10,7 +10,7 @@ namespace api\controllers;
use
Yii
;
use
Yii
;
use
api\base\BaseController
;
use
api\base\BaseController
;
use
common\models\pwallet\
Article
;
use
common\models\pwallet\
News
;
class
ArticleController
extends
BaseController
class
ArticleController
extends
BaseController
{
{
...
@@ -50,7 +50,7 @@ class ArticleController extends BaseController
...
@@ -50,7 +50,7 @@ class ArticleController extends BaseController
if
(
isset
(
$post
[
'update_at'
]))
{
if
(
isset
(
$post
[
'update_at'
]))
{
$condition
[]
=
[
'>='
,
'update_at'
,
$post
[
'update_at'
]];
$condition
[]
=
[
'>='
,
'update_at'
,
$post
[
'update_at'
]];
}
}
$data
=
Article
::
getList
(
$page
,
$limit
,
$condition
);
$data
=
News
::
getList
(
$page
,
$limit
,
$condition
);
return
$data
;
return
$data
;
}
}
...
...
api/controllers/CoinDogController.php
View file @
e7ff28aa
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
backend\models\coin\ArticleForm
;
use
backend\models\coin\ArticleForm
;
use
common\models\pwallet\
Article
;
use
common\models\pwallet\
News
;
use
common\service\bishijie\BishijieService
;
use
common\service\bishijie\BishijieService
;
use
linslin\yii2\curl\Curl
;
use
linslin\yii2\curl\Curl
;
use
Yii
;
use
Yii
;
...
@@ -127,7 +127,7 @@ class CoinDogController extends BaseController
...
@@ -127,7 +127,7 @@ class CoinDogController extends BaseController
public
function
actionArticleBanner
()
public
function
actionArticleBanner
()
{
{
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
1
);
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
1
);
$data
=
Article
::
find
()
$data
=
News
::
find
()
->
select
(
'id, image_url ,title, url'
)
->
select
(
'id, image_url ,title, url'
)
->
where
([
'type'
=>
$type
])
->
where
([
'type'
=>
$type
])
->
orderBy
(
'update_at desc'
)
->
orderBy
(
'update_at desc'
)
...
...
backend/controllers/SourceController.php
View file @
e7ff28aa
...
@@ -11,7 +11,7 @@ namespace backend\controllers;
...
@@ -11,7 +11,7 @@ namespace backend\controllers;
use
backend\models\coin\ArticleForm
;
use
backend\models\coin\ArticleForm
;
use
backend\models\coin\NoticeForm
;
use
backend\models\coin\NoticeForm
;
use
Yii
;
use
Yii
;
use
common\models\pwallet\
Article
;
use
common\models\pwallet\
News
;
use
common\models\pwallet\Notice
;
use
common\models\pwallet\Notice
;
use
common\models\pwallet\Feedback
;
use
common\models\pwallet\Feedback
;
use
yii\db\Exception
;
use
yii\db\Exception
;
...
@@ -37,7 +37,7 @@ class SourceController extends BaseController
...
@@ -37,7 +37,7 @@ class SourceController extends BaseController
if
(
$status
!=
'all'
)
{
if
(
$status
!=
'all'
)
{
$condition
[]
=
[
'status'
=>
$status
];
$condition
[]
=
[
'status'
=>
$status
];
}
}
$results
=
Article
::
getList
(
$page
,
$limit
,
$condition
);
$results
=
News
::
getList
(
$page
,
$limit
,
$condition
);
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
data
=
$results
;
Yii
::
$app
->
response
->
data
=
$results
;
Yii
::
$app
->
response
->
send
();
Yii
::
$app
->
response
->
send
();
...
@@ -56,7 +56,7 @@ class SourceController extends BaseController
...
@@ -56,7 +56,7 @@ class SourceController extends BaseController
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
$request
=
Yii
::
$app
->
request
;
$request
=
Yii
::
$app
->
request
;
if
(
$model
->
load
(
$request
->
post
())
&&
$model
->
validate
())
{
if
(
$model
->
load
(
$request
->
post
())
&&
$model
->
validate
())
{
$article
=
new
Article
();
$article
=
new
News
();
$res
=
$article
->
addOne
(
$request
->
post
());
$res
=
$article
->
addOne
(
$request
->
post
());
if
(
$res
===
true
)
{
if
(
$res
===
true
)
{
$this
->
success
(
'添加成功'
,
'/admin/source/article'
);
$this
->
success
(
'添加成功'
,
'/admin/source/article'
);
...
@@ -85,7 +85,7 @@ class SourceController extends BaseController
...
@@ -85,7 +85,7 @@ class SourceController extends BaseController
$model
->
scenario
=
'edit'
;
$model
->
scenario
=
'edit'
;
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
null
);
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
null
);
if
(
$id
)
{
if
(
$id
)
{
$article
=
Article
::
findOne
([
'id'
=>
$id
]);
$article
=
News
::
findOne
([
'id'
=>
$id
]);
if
(
$article
)
{
if
(
$article
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
validate
())
{
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
validate
())
{
...
@@ -118,7 +118,7 @@ class SourceController extends BaseController
...
@@ -118,7 +118,7 @@ class SourceController extends BaseController
{
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
null
);
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
null
);
if
(
$id
)
{
if
(
$id
)
{
$article
=
Article
::
findOne
([
'id'
=>
$id
]);
$article
=
News
::
findOne
([
'id'
=>
$id
]);
if
(
$article
)
{
if
(
$article
)
{
try
{
try
{
$article
->
delete
();
$article
->
delete
();
...
...
common/models/pwallet/Article.php
View file @
e7ff28aa
...
@@ -87,7 +87,7 @@ class Article extends BaseActiveRecord
...
@@ -87,7 +87,7 @@ class Article extends BaseActiveRecord
unset
(
$params
[
'id'
]);
unset
(
$params
[
'id'
]);
}
else
{
}
else
{
$article
=
$this
;
$article
=
$this
;
$params
=
array_merge
(
$params
,
[
'create_at'
=>
date
(
'Y-m-d H:i:s'
)]);
$params
=
array_merge
(
$params
,
[
'create_at'
=>
date
(
'Y-m-d H:i:s'
)]);
}
}
$params
=
array_merge
(
$params
,
[
'update_at'
=>
date
(
'Y-m-d H:i:s'
,
time
())]);
$params
=
array_merge
(
$params
,
[
'update_at'
=>
date
(
'Y-m-d H:i:s'
,
time
())]);
if
(
!
isset
(
$params
[
'status'
]))
{
if
(
!
isset
(
$params
[
'status'
]))
{
...
...
common/models/pwallet/News.php
0 → 100644
View file @
e7ff28aa
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-4
* Time: 上午9:53
*/
namespace
common\models\pwallet
;
use
common\base\Exception
;
use
common\core\BaseActiveRecord
;
use
Yii
;
class
News
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'db_pwallet'
);
}
public
static
function
tableName
()
{
return
'{{%news}}'
;
}
/**
* 获取文章列表
* @param int $page
* @param int $limit
* @param array $condition
* @return array
*/
public
static
function
getList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
{
$query
=
self
::
find
();
foreach
(
$condition
as
$item
)
{
$query
=
$query
->
andWhere
(
$item
);
}
$count
=
$query
->
count
();
if
(
$count
)
{
$data
=
$query
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
return
[
'code'
=>
0
,
'count'
=>
$count
,
'data'
=>
$data
];
}
return
[
'code'
=>
1
,
'msg'
=>
'数据为空'
];
}
/**
* 添加文章
* @param $params
* @return bool|array
*/
public
function
addOne
(
$params
)
{
return
$this
->
realWrite
(
$params
);
}
/**
* 更新文章
* @param $params
* @return bool|array
*/
public
function
updateOne
(
$params
)
{
return
$this
->
realWrite
(
$params
);
}
/**
* 实际操作数据方法
*/
private
function
realWrite
(
$params
)
{
if
(
!
is_array
(
$params
))
{
$params
=
[
$params
];
}
$params
=
array_filter
(
$params
,
function
(
$value
,
$key
)
{
if
(
ctype_digit
(
$key
)
||
empty
(
$value
))
{
return
false
;
}
return
true
;
},
ARRAY_FILTER_USE_BOTH
);
if
(
isset
(
$params
[
'id'
]))
{
$article
=
self
::
findOne
(
$params
[
'id'
]);
if
(
$article
===
null
)
{
return
[
'code'
=>
1
,
'msg'
=>
'文章不存在'
];
}
unset
(
$params
[
'id'
]);
}
else
{
$article
=
$this
;
$params
=
array_merge
(
$params
,
[
'create_at'
=>
date
(
'Y-m-d H:i:s'
)]);
}
$params
=
array_merge
(
$params
,
[
'update_at'
=>
date
(
'Y-m-d H:i:s'
,
time
())]);
if
(
!
isset
(
$params
[
'status'
]))
{
$params
[
'status'
]
=
0
;
}
$article
->
setAttributes
(
$params
,
false
);
try
{
return
(
bool
)
$article
->
save
();
}
catch
(
Exception
$exception
)
{
return
[
'code'
=>
$exception
->
getCode
(),
'msg'
=>
$exception
->
getMessage
()];
}
}
}
\ No newline at end of file
console/controllers/ArticleController.php
View file @
e7ff28aa
...
@@ -4,61 +4,48 @@ namespace console\controllers;
...
@@ -4,61 +4,48 @@ namespace console\controllers;
use
Yii
;
use
Yii
;
use
yii\console\Controller
;
use
yii\console\Controller
;
use
linslin\yii2\curl\Curl
;
use
common\components\Tools
;
use
common\components\Tools
;
use
common\models\pwallet\Article
;
use
common\models\pwallet\Article
;
use
common\service\bishijie\BishijieService
;
class
ArticleController
extends
Controller
class
ArticleController
extends
Controller
{
{
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$coindog
=
Yii
::
$app
->
params
[
'coindog'
];
$page
=
1
;
$size
=
20
;
$accessKey
=
$coindog
[
'accessKey'
];
$bishijie
=
Yii
::
$app
->
params
[
'bishijie'
];
$secretKey
=
$coindog
[
'secretKey'
];
$appid
=
$bishijie
[
'Appid'
];
$httpParams
=
array
(
$appSecret
=
$bishijie
[
'AppSecret'
];
'access_key'
=>
$accessKey
,
$bishijie_service
=
new
BishijieService
(
$appid
,
$appSecret
);
'date'
=>
time
()
$resp
=
$bishijie_service
->
getArticleList
(
$page
,
$size
);
);
$signParams
=
array_merge
(
$httpParams
,
array
(
'secret_key'
=>
$secretKey
));
ksort
(
$signParams
);
$signString
=
http_build_query
(
$signParams
);
$httpParams
=
[
'sign'
=>
strtolower
(
md5
(
$signString
)),
];
$url
=
$coindog
[
'live'
]
.
'?'
.
http_build_query
(
$httpParams
);
$curl
=
new
Curl
();
$resp
=
$curl
->
get
(
$url
,
false
);
if
(
!
isset
(
$resp
[
'list'
]))
{
if
(
!
isset
(
$resp
[
'list'
]))
{
return
0
;
return
0
;
}
}
$create_time
=
Article
::
find
()
->
where
([
'platform_id'
=>
-
1
])
->
max
(
'create_time'
);
$create_time
=
Article
::
find
()
->
where
([
'platform_id'
=>
-
1
])
->
max
(
'create_time'
);
$list
=
$resp
[
'list'
]
[
0
][
'lives'
]
;
$list
=
$resp
[
'list'
];
if
(
$create_time
>=
$list
[
0
][
'
created_at
'
])
{
if
(
$create_time
>=
$list
[
0
][
'
issue_time
'
])
{
return
0
;
return
0
;
}
}
$list
=
Tools
::
arraySort
(
$list
,
'
created_at
'
,
SORT_ASC
);
$list
=
Tools
::
arraySort
(
$list
,
'
issue_time
'
,
SORT_ASC
);
$article
=
new
Article
();
$article
=
new
Article
();
foreach
(
$list
as
&
$item
)
{
foreach
(
$list
as
&
$item
)
{
go
(
function
()
use
(
$item
,
$article
,
$create_time
)
{
go
(
function
()
use
(
$item
,
$article
,
$create_time
)
{
\Co
::
sleep
(
0.5
);
\Co
::
sleep
(
0.5
);
if
(
$item
[
'created_at'
]
>
$create_time
)
{
if
(
$item
[
'issue_time'
]
>
$create_time
)
{
preg_match_all
(
"/\【(.+?)\】/"
,
$item
[
'content'
],
$match
);
$title
=
$match
[
1
][
0
];
$content
=
str_replace
(
'【'
.
$title
.
'】'
,
''
,
$item
[
'content'
]);
$article
->
setIsNewRecord
(
true
);
$article
->
setIsNewRecord
(
true
);
$article
->
title
=
$title
;
$article
->
title
=
$item
[
'title'
];
$article
->
content
=
$content
;
$article
->
source
=
$item
[
'source'
];
$article
->
content
=
$item
[
'id'
];
$article
->
logo_pic
=
$item
[
'promulgator'
][
'logo_pic'
];
$article
->
img_url
=
$item
[
'img_url'
];
$article
->
platform_id
=
-
1
;
$article
->
platform_id
=
-
1
;
$article
->
create_time
=
$item
[
'
created_at
'
];
$article
->
create_time
=
$item
[
'
issue_time
'
];
$article
->
save
()
&&
$article
->
id
=
0
;;
$article
->
save
()
&&
$article
->
id
=
0
;;
}
}
});
});
...
...
console/controllers/NewsController.php
0 → 100644
View file @
e7ff28aa
<?php
namespace
console\controllers
;
use
Yii
;
use
yii\console\Controller
;
use
linslin\yii2\curl\Curl
;
use
common\components\Tools
;
use
common\models\pwallet\News
;
class
NewsController
extends
Controller
{
public
function
actionIndex
()
{
$coindog
=
Yii
::
$app
->
params
[
'coindog'
];
$accessKey
=
$coindog
[
'accessKey'
];
$secretKey
=
$coindog
[
'secretKey'
];
$httpParams
=
array
(
'access_key'
=>
$accessKey
,
'date'
=>
time
()
);
$signParams
=
array_merge
(
$httpParams
,
array
(
'secret_key'
=>
$secretKey
));
ksort
(
$signParams
);
$signString
=
http_build_query
(
$signParams
);
$httpParams
=
[
'sign'
=>
strtolower
(
md5
(
$signString
)),
];
$url
=
$coindog
[
'live'
]
.
'?'
.
http_build_query
(
$httpParams
);
$curl
=
new
Curl
();
$resp
=
$curl
->
get
(
$url
,
false
);
if
(
!
isset
(
$resp
[
'list'
]))
{
return
0
;
}
$create_time
=
News
::
find
()
->
where
([
'platform_id'
=>
-
1
])
->
max
(
'create_time'
);
$list
=
$resp
[
'list'
][
0
][
'lives'
];
if
(
$create_time
>=
$list
[
0
][
'created_at'
])
{
return
0
;
}
$list
=
Tools
::
arraySort
(
$list
,
'created_at'
,
SORT_ASC
);
$article
=
new
News
();
foreach
(
$list
as
&
$item
)
{
go
(
function
()
use
(
$item
,
$article
,
$create_time
)
{
\Co
::
sleep
(
0.5
);
if
(
$item
[
'created_at'
]
>
$create_time
)
{
preg_match_all
(
"/\【(.+?)\】/"
,
$item
[
'content'
],
$match
);
$title
=
$match
[
1
][
0
];
$content
=
str_replace
(
'【'
.
$title
.
'】'
,
''
,
$item
[
'content'
]);
$article
->
setIsNewRecord
(
true
);
$article
->
title
=
$title
;
$article
->
content
=
$content
;
$article
->
platform_id
=
-
1
;
$article
->
create_time
=
$item
[
'created_at'
];
$article
->
save
()
&&
$article
->
id
=
0
;;
}
});
}
return
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