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
9060f31c
Commit
9060f31c
authored
Jan 10, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into develop
parents
07d48b97
735bdb8a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
0 deletions
+82
-0
BaseController.php
api/base/BaseController.php
+4
-0
RecommendCoinController.php
api/controllers/RecommendCoinController.php
+51
-0
RecommendCoin.php
common/models/psources/RecommendCoin.php
+27
-0
No files found.
api/base/BaseController.php
View file @
9060f31c
...
@@ -22,6 +22,10 @@ class BaseController extends Controller
...
@@ -22,6 +22,10 @@ class BaseController extends Controller
public
$currency_id
;
public
$currency_id
;
public
$platform_id
;
public
$platform_id
;
public
$code
=
0
;
public
$msg
=
'success'
;
public
$data
=
null
;
private
static
$default_header_list
=
[];
private
static
$default_header_list
=
[];
public
function
init
()
public
function
init
()
...
...
api/controllers/RecommendCoinController.php
0 → 100644
View file @
9060f31c
<?php
namespace
api\controllers
;
use
Yii
;
use
api\base\BaseController
;
use
common\business\ExchangeBusiness
;
use
common\models\psources\RecommendCoin
;
class
RecommendCoinController
extends
BaseController
{
public
function
actionIndex
()
{
$recommend
=
Yii
::
$app
->
request
->
post
(
'recommend'
,
0
);
$platform_id
=
Yii
::
$app
->
request
->
post
(
'platform_id'
,
0
);
if
(
false
==
$recommend
||
false
==
$platform_id
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
}
$recommend_coins
=
RecommendCoin
::
find
()
->
where
([
'platform_id'
=>
(
int
)
$platform_id
])
->
all
();
if
(
empty
(
$recommend_coins
))
{
goto
doEnd
;
}
$this
->
data
=
[];
foreach
(
$recommend_coins
as
$coin
)
{
//$this->data[$coin->coin[0]['chain']] = $coin->coin;
$this
->
data
=
array_merge
(
$this
->
data
,
$coin
->
coin
);
}
$chains
=
array_column
(
$this
->
data
,
'chain'
);
$coin_quotations
=
ExchangeBusiness
::
getQuatationByNames
(
$chains
);
$i
=
0
;
foreach
(
$coin_quotations
as
$key
=>
$val
)
{
$nickname
=
json_decode
(
$this
->
data
[
$i
][
'nickname'
],
true
);
$this
->
data
[
$i
][
'nickname'
]
=
isset
(
$nickname
[
$this
->
lang
])
?
$nickname
[
$this
->
lang
]
:
''
;
$introduce
=
json_decode
(
$this
->
data
[
$i
][
'introduce'
],
true
);
$this
->
data
[
$i
][
'introduce'
]
=
isset
(
$introduce
[
$this
->
lang
])
?
$introduce
[
$this
->
lang
]
:
''
;
$this
->
data
[
$i
][
'chain_quotation'
]
=
$val
;
foreach
(
$val
as
$key
=>
$cloumn
)
{
$this
->
data
[
$i
][
$key
]
=
$cloumn
;
}
$i
++
;
}
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
}
\ No newline at end of file
common/models/psources/RecommendCoin.php
0 → 100644
View file @
9060f31c
<?php
namespace
common\models\psources
;
use
Yii
;
use
yii\db\Expression
;
use
common\core\BaseActiveRecord
;
use
yii\behaviors\TimestampBehavior
;
class
RecommendCoin
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{wallet_recommend_coin}}'
;
}
public
function
getCoin
()
{
return
$this
->
hasOne
(
Coin
::
className
(),
[
'id'
=>
'cid'
])
->
select
([
'id'
,
'sid'
,
'icon'
,
'name'
,
'introduce'
,
'optional_name'
,
'nickname'
,
'platform'
,
'chain'
,
'treaty'
])
->
asArray
()
->
all
();
}
}
\ No newline at end of file
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