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
6edafced
Commit
6edafced
authored
Nov 03, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into 'master'
Feature/optimize See merge request
!402
parents
674d2bf9
1b728e04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
RecommendCoinController.php
api/controllers/RecommendCoinController.php
+76
-0
WalletRecommendCoin.php
common/models/psources/WalletRecommendCoin.php
+3
-0
No files found.
api/controllers/RecommendCoinController.php
View file @
6edafced
...
...
@@ -3,6 +3,7 @@
namespace
api\controllers
;
use
common\business\ExchangeBusiness
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinSupportedChain
;
use
Yii
;
use
api\base\BaseController
;
...
...
@@ -122,4 +123,78 @@ class RecommendCoinController extends BaseController
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
public
function
actionTrusteeship
()
{
$platform_id
=
$this
->
platform_id
;
if
(
false
==
$platform_id
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
}
$recommend
=
Yii
::
$app
->
request
->
get
(
'recommend'
,
1
);
if
(
$recommend
!=
1
)
{
$this
->
code
=
1
;
$this
->
msg
=
'数据为空'
;
goto
doEnd
;
}
$coin_trusteeship
=
WalletRecommendCoin
::
find
()
->
select
(
'cid'
)
->
where
([
'type'
=>
WalletRecommendCoin
::
TYPE_TRUSTEESHIP
,
'platform_id'
=>
$platform_id
])
->
asArray
()
->
all
();
$select
=
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'introduce'
,
'optional_name'
,
'nickname'
,
'platform'
,
'chain'
,
'treaty'
];
$coin_ids
=
array_column
(
$coin_trusteeship
,
'cid'
);
if
(
false
==
$coin_ids
)
{
$this
->
code
=
1
;
$this
->
msg
=
'数据为空'
;
goto
doEnd
;
}
$coin_infos
=
Coin
::
getCoinInfoByIds
(
$coin_ids
,
$select
,
'id'
);
foreach
(
$coin_infos
as
$key
=>
&
$val
)
{
$nickname
=
json_decode
(
$val
[
'nickname'
],
true
);
$val
[
'nickname'
]
=
isset
(
$nickname
[
$this
->
lang
])
?
$nickname
[
$this
->
lang
]
:
''
;
$introduce
=
json_decode
(
$val
[
'introduce'
],
true
);
$val
[
'introduce'
]
=
isset
(
$introduce
[
$this
->
lang
])
?
$introduce
[
$this
->
lang
]
:
''
;
}
//获取行情信息
$coin_names
=
array_column
(
$coin_infos
,
'name'
);
$coin_names
=
array_merge
(
$coin_names
,
array_column
(
$coin_infos
,
'chain'
));
$coin_quotations
=
ExchangeBusiness
::
getQuatationByNames
(
$coin_names
);
if
(
$coin_infos
)
{
array_shift
(
$select
);
foreach
(
$coin_trusteeship
as
$key
=>
&
$value
)
{
$temp_key
=
$coin_infos
[
$value
[
'cid'
]][
'name'
];
foreach
(
$select
as
$item
)
{
$value
[
$item
]
=
$coin_infos
[
$value
[
'cid'
]][
$item
];
if
(
$platform_id
!=
2
)
{
//国盾币不需要行情
$value
[
'low'
]
=
$coin_quotations
[
$temp_key
][
'low'
];
$value
[
'high'
]
=
$coin_quotations
[
$temp_key
][
'high'
];
$value
[
'last'
]
=
$coin_quotations
[
$temp_key
][
'last'
];
$value
[
'rmb'
]
=
$coin_quotations
[
$temp_key
][
'rmb'
];
$value
[
'usd'
]
=
$coin_quotations
[
$temp_key
][
'usd'
]
??
0
;
}
else
{
$value
[
'low'
]
=
0
;
$value
[
'high'
]
=
0
;
$value
[
'last'
]
=
0
;
$value
[
'rmb'
]
=
0
;
$value
[
'usd'
]
=
0
;
}
}
$value
[
'id'
]
=
$value
[
'cid'
];
$value
[
'sid'
]
=
ucfirst
(
$value
[
'sid'
]);
$value
[
'chain_quotation'
]
=
$coin_quotations
[
$coin_infos
[
$value
[
'cid'
]][
'chain'
]];
$value
[
'chain_rmb'
]
=
isset
(
$coin_quotations
[
$coin_infos
[
$value
[
'cid'
]][
'chain'
]][
'rmb'
])
?
$coin_quotations
[
$coin_infos
[
$value
[
'cid'
]][
'chain'
]][
'rmb'
]
:
0
;
$value
[
'chain_usd'
]
=
isset
(
$coin_quotations
[
$coin_infos
[
$value
[
'cid'
]][
'chain'
]][
'usd'
])
?
$coin_quotations
[
$coin_infos
[
$value
[
'cid'
]][
'chain'
]][
'usd'
]
:
0
;
unset
(
$value
[
'create_time'
],
$value
[
'update_time'
],
$value
[
'cid'
]);
$value
[
'type'
]
=
WalletRecommendCoin
::
TYPE_TRUSTEESHIP
;
$value
[
'platform_id'
]
=
$platform_id
;
$value
[
'sort'
]
=
$value
[
'recommend'
]
=
1
;
$value
[
'coin'
]
=
$value
[
'name'
];
}
unset
(
$key
,
$value
);
}
$this
->
data
=
$coin_trusteeship
;
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
,
'count'
=>
empty
(
$this
->
data
)
?
0
:
count
(
$this
->
data
)];
}
}
\ No newline at end of file
common/models/psources/WalletRecommendCoin.php
View file @
6edafced
...
...
@@ -7,6 +7,9 @@ use common\core\BaseActiveRecord;
class
WalletRecommendCoin
extends
BaseActiveRecord
{
const
TYPE_COMMON
=
1
;
//去中心化
const
TYPE_TRUSTEESHIP
=
2
;
//托管钱包
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
...
...
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