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
6ea75fa7
Commit
6ea75fa7
authored
Feb 12, 2020
by
shajiaming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into develop
parents
0c8563f2
a15680b8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
15 deletions
+77
-15
MarketController.php
api/controllers/MarketController.php
+12
-0
WalletCoinController.php
api/controllers/WalletCoinController.php
+32
-15
WalletCoin.php
common/models/psources/WalletCoin.php
+6
-0
WalletCoinRelation.php
common/models/psources/WalletCoinRelation.php
+27
-0
No files found.
api/controllers/MarketController.php
View file @
6ea75fa7
...
...
@@ -59,6 +59,18 @@ class MarketController extends BaseController
}
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
if
(
'USDT'
==
strtoupper
(
$base_currency
))
{
$currency_ticker
=
$exchange
->
getTicker
(
$currency
,
'USDT'
);
if
(
empty
(
$currency_ticker
)){
$this
->
code
=
-
1
;
$this
->
msg
=
'此交易所暂不支持所选币种!'
;
goto
doEnd
;
}
$this
->
data
=
rtrim
(
sprintf
(
'%.6f'
,
$currency_ticker
[
'last'
]),
'0'
);
goto
doEnd
;
}
$currency_ticker
=
$exchange
->
getTicker
(
$currency
,
'USDT'
);
$base_currency_ticker
=
$exchange
->
getTicker
(
$base_currency
,
'USDT'
);
if
(
empty
(
$currency_ticker
)
||
empty
(
$base_currency_ticker
))
{
...
...
api/controllers/WalletCoinController.php
View file @
6ea75fa7
...
...
@@ -7,6 +7,7 @@ use api\base\BaseController;
use
common\business\ExchangeBusiness
;
use
common\models\psources\WalletCoin
;
use
common\models\psources\CoinCurrency
;
use
common\models\psources\WalletCoinRelation
;
class
WalletCoinController
extends
BaseController
{
...
...
@@ -39,18 +40,26 @@ class WalletCoinController extends BaseController
}
}
$this
->
data
=
[];
$relation_model
=
WalletCoinRelation
::
find
()
->
select
(
'coin_id'
)
->
where
([
'platform_id'
=>
(
int
)
$platform_id
])
->
asArray
()
->
all
();
if
(
empty
(
$relation_model
))
{
goto
doEnd
;
}
$relation_ids
=
array_column
(
$relation_model
,
'coin_id'
);
foreach
(
$condition
as
$val
)
{
if
(
is_array
(
$val
))
{
$model
=
WalletCoin
::
find
()
->
select
(
'id,sid,icon,name,nickname,introduce,platform,chain,address as contract_address,treaty'
)
->
where
([
'name'
=>
$val
[
0
],
'platform
_id'
=>
(
int
)
$platform_id
])
->
andWhere
([
'
platform'
=>
$val
[
1
]
])
->
where
([
'name'
=>
$val
[
0
],
'platform
'
=>
$val
[
1
]
])
->
andWhere
([
'
in'
,
'id'
,
$relation_ids
])
->
asArray
()
->
one
();
}
if
(
is_string
(
$val
))
{
$model
=
WalletCoin
::
find
()
->
select
(
'id,sid,icon,name,nickname,introduce,platform,chain,address as contract_address,treaty'
)
->
where
([
'name'
=>
$val
,
'platform_id'
=>
(
int
)
$platform_id
])
->
where
([
'name'
=>
$val
])
->
andWhere
([
'in'
,
'id'
,
$relation_ids
])
->
asArray
()
->
one
();
}
...
...
@@ -120,9 +129,15 @@ class WalletCoinController extends BaseController
$page
=
empty
(
$params
[
'page'
])
?
1
:
$params
[
'page'
];
$limit
=
empty
(
$params
[
'limit'
])
?
10
:
$params
[
'limit'
];
$relation_model
=
WalletCoinRelation
::
find
()
->
select
(
'coin_id'
)
->
where
([
'platform_id'
=>
(
int
)
$platform_id
])
->
asArray
()
->
all
();
if
(
empty
(
$relation_model
))
{
goto
doEnd
;
}
$relation_ids
=
array_column
(
$relation_model
,
'coin_id'
);
$query
=
WalletCoin
::
find
()
->
select
(
'id, sid, icon, name, nickname, platform, chain, address as contract_address, treaty'
)
->
where
([
'
>'
,
"find_in_set(
$platform_id
, platform_id)"
,
0
])
->
where
([
'
in'
,
'id'
,
$relation_ids
])
->
orderBy
(
'id'
);
if
(
false
!=
$chain
)
{
...
...
@@ -172,12 +187,17 @@ class WalletCoinController extends BaseController
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
}
$this
->
data
=
WalletCoin
::
find
()
->
where
([
'id'
=>
$id
,
'platform_id'
=>
$platform_id
])
->
asArray
()
->
one
();
if
(
empty
(
$this
->
data
))
{
$relation
=
WalletCoinRelation
::
find
()
->
where
([
'coin_id'
=>
$id
,
'platform_id'
=>
(
int
)
$platform_id
])
->
one
();
if
(
empty
(
$relation
)){
goto
doEnd
;
}
$quotation
=
ExchangeBusiness
::
getquatation
(
$this
->
data
[
'name'
]);
$this
->
data
=
$relation
->
coin
;
$quotation
=
ExchangeBusiness
::
getquatation
(
$this
->
data
->
name
);
$tikerdata
=
[
'publish_count'
=>
$this
->
data
->
publish_count
,
'circulate_count'
=>
$this
->
data
->
circulate_count
];
if
(
$quotation
)
{
$tikerdata
[
'price'
]
=
$quotation
[
'rmb'
];
$tikerdata
[
'dollar'
]
=
$quotation
[
'usd'
];
...
...
@@ -185,13 +205,10 @@ class WalletCoinController extends BaseController
$tikerdata
[
'price'
]
=
0
;
$tikerdata
[
'dollar'
]
=
0
;
}
$this
->
data
[
'quotation'
]
=
$tikerdata
;
$this
->
data
[
'quotation'
][
'publish_count'
]
=
$this
->
data
[
'publish_count'
];
$this
->
data
[
'quotation'
][
'circulate_count'
]
=
$this
->
data
[
'circulate_count'
];
$nickname
=
json_decode
(
$this
->
data
[
'nickname'
],
true
);
$this
->
data
[
'nickname'
]
=
isset
(
$nickname
[
$this
->
lang
])
?
$nickname
[
$this
->
lang
]
:
''
;
$introduce
=
json_decode
(
$this
->
data
[
'introduce'
],
true
);
$this
->
data
[
'introduce'
]
=
isset
(
$introduce
[
$this
->
lang
])
?
$introduce
[
$this
->
lang
]
:
''
;
$this
->
data
->
quotation
=
$tikerdata
;
$this
->
data
->
nickname
=
isset
(
$this
->
data
->
nickname
[
$this
->
lang
])
?
$this
->
data
->
nickname
[
$this
->
lang
]
:
''
;
$this
->
data
->
introduce
=
isset
(
$this
->
data
->
introduce
[
$this
->
lang
])
?
$this
->
data
->
introduce
[
$this
->
lang
]
:
''
;
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
...
...
common/models/psources/WalletCoin.php
View file @
6ea75fa7
...
...
@@ -17,4 +17,9 @@ class WalletCoin extends BaseActiveRecord
{
return
'{{wallet_coin}}'
;
}
public
function
attributes
()
{
return
array_merge
(
parent
::
attributes
(),
[
'quotation'
]);
}
}
\ No newline at end of file
common/models/psources/WalletCoinRelation.php
0 → 100644
View file @
6ea75fa7
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
WalletCoinRelation
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{wallet_coin_relation}}'
;
}
public
function
getCoin
()
{
return
$this
->
hasOne
(
WalletCoin
::
className
(),
[
'id'
=>
'coin_id'
]);
}
}
\ 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