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
c7117a49
Commit
c7117a49
authored
Jan 14, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into develop
parents
70bfc715
0e16c28d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
345 additions
and
29 deletions
+345
-29
IssueCoinController.php
api/controllers/IssueCoinController.php
+5
-1
RecommendCoinController.php
api/controllers/RecommendCoinController.php
+28
-17
WalletCoinController.php
api/controllers/WalletCoinController.php
+200
-0
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+9
-2
RecommendCoin.php
common/models/psources/RecommendCoin.php
+2
-3
WalletCoin.php
common/models/psources/WalletCoin.php
+21
-0
Coinka.php
common/service/exchange/Coinka.php
+74
-0
FlashController.php
wallet/controllers/FlashController.php
+6
-6
No files found.
api/controllers/IssueCoinController.php
View file @
c7117a49
...
@@ -207,6 +207,10 @@ class IssueCoinController extends BaseController
...
@@ -207,6 +207,10 @@ class IssueCoinController extends BaseController
$header
=
Yii
::
$app
->
request
->
headers
;
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$address
=
Yii
::
$app
->
request
->
get
(
'address'
,
''
);
$address
=
Yii
::
$app
->
request
->
get
(
'address'
,
''
);
$status
=
Yii
::
$app
->
request
->
get
(
'status'
,
''
);
if
(
false
==
$status
)
{
$status
=
[
CoinIssueCoin
::
STATUS_PEDDING
,
CoinIssueCoin
::
STATUS_CANCEL_SUCCESS
,
CoinIssueCoin
::
STATUS_CANCEL_FAILED
,
CoinIssueCoin
::
STATUS_CONFIRM
,
CoinIssueCoin
::
STATUS_ALLOW
,
CoinIssueCoin
::
STATUS_REFUSE
,
CoinIssueCoin
::
STATUS_SUCCESS
,
CoinIssueCoin
::
STATUS_FAILED
];
}
if
(
empty
(
$platform_id
)
||
empty
(
$address
))
{
if
(
empty
(
$platform_id
)
||
empty
(
$address
))
{
$msg
=
'缺少必要的参数'
;
$msg
=
'缺少必要的参数'
;
...
@@ -220,7 +224,7 @@ class IssueCoinController extends BaseController
...
@@ -220,7 +224,7 @@ class IssueCoinController extends BaseController
$query
=
CoinIssueCoin
::
find
()
$query
=
CoinIssueCoin
::
find
()
->
select
(
'id, name, symbol, type, total, create_time, status, chain_id, token_type'
)
->
select
(
'id, name, symbol, type, total, create_time, status, chain_id, token_type'
)
->
where
([
'owner'
=>
$address
])
->
where
([
'owner'
=>
$address
])
->
andWhere
([
'in'
,
'status'
,
[
CoinIssueCoin
::
STATUS_PEDDING
,
CoinIssueCoin
::
STATUS_CANCEL_SUCCESS
,
CoinIssueCoin
::
STATUS_CANCEL_FAILED
,
CoinIssueCoin
::
STATUS_CONFIRM
,
CoinIssueCoin
::
STATUS_ALLOW
,
CoinIssueCoin
::
STATUS_REFUSE
,
CoinIssueCoin
::
STATUS_SUCCESS
,
CoinIssueCoin
::
STATUS_FAILED
]
])
->
andWhere
([
'in'
,
'status'
,
$status
])
->
orderBy
(
'create_time desc'
);
->
orderBy
(
'create_time desc'
);
$countQuery
=
clone
$query
;
$countQuery
=
clone
$query
;
...
...
api/controllers/RecommendCoinController.php
View file @
c7117a49
...
@@ -9,39 +9,50 @@ use common\models\psources\RecommendCoin;
...
@@ -9,39 +9,50 @@ use common\models\psources\RecommendCoin;
class
RecommendCoinController
extends
BaseController
class
RecommendCoinController
extends
BaseController
{
{
/**
* 获取推荐币种
* @param integer recommend 1首页推介,2次页推介
* @return array
*/
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$recommend
=
Yii
::
$app
->
request
->
post
(
'recommend'
,
0
);
$recommend
=
Yii
::
$app
->
request
->
post
(
'recommend'
,
0
);
$platform_id
=
Yii
::
$app
->
request
->
post
(
'platform_id'
,
0
);
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
if
(
false
==
$recommend
||
false
==
$platform_id
)
{
if
(
false
==
$recommend
||
false
==
$platform_id
)
{
$this
->
code
=
-
1
;
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
goto
doEnd
;
}
}
$recommend_coins
=
RecommendCoin
::
find
()
->
where
([
'platform_id'
=>
(
int
)
$platform_id
])
->
all
();
$recommend_coins
=
RecommendCoin
::
find
()
->
where
([
'platform_id'
=>
(
int
)
$platform_id
])
->
orderBy
(
"sort desc"
)
->
all
();
if
(
empty
(
$recommend_coins
))
{
if
(
empty
(
$recommend_coins
))
{
goto
doEnd
;
goto
doEnd
;
}
}
$this
->
data
=
[];
$this
->
data
=
[];
foreach
(
$recommend_coins
as
$coin
)
{
foreach
(
$recommend_coins
as
$coin
)
{
//$this->data[$coin->coin[0]['chain']] = $coin->coin;
$recommend_coin_info
=
[
$this
->
data
=
array_merge
(
$this
->
data
,
$coin
->
coin
);
'recommend'
=>
$coin
->
recommend
,
'sort'
=>
$coin
->
sort
,
'type'
=>
$coin
->
type
,
];
$this
->
data
=
array_merge
(
$this
->
data
,
[
array_merge
(
$coin
->
coin
[
0
],
$recommend_coin_info
)]);
}
}
$chains
=
array_column
(
$this
->
data
,
'chain'
);
$chains
=
array_column
(
$this
->
data
,
'chain'
);
$coin_quotations
=
ExchangeBusiness
::
getQuatationByNames
(
$chains
);
$symbol
=
array_column
(
$this
->
data
,
'name'
);
$chains_symbols
=
array_keys
(
array_flip
(
$chains
)
+
array_flip
(
$symbol
));
$i
=
0
;
$coin_quotations
=
ExchangeBusiness
::
getQuatationByNames
(
$chains_symbols
);
foreach
(
$coin_quotations
as
$key
=>
$val
)
{
$nickname
=
json_decode
(
$this
->
data
[
$i
][
'nickname'
],
true
);
$ticker
=
[
'low'
=>
0
,
'high'
=>
0
,
'last'
=>
0
,
'open'
=>
0
,
'vol'
=>
0
,
'rmb'
=>
0
,
'usd'
=>
0
];
$this
->
data
[
$i
][
'nickname'
]
=
isset
(
$nickname
[
$this
->
lang
])
?
$nickname
[
$this
->
lang
]
:
''
;
foreach
(
$this
->
data
as
$key
=>
&
$val
)
{
$introduce
=
json_decode
(
$this
->
data
[
$i
][
'introduce'
],
true
);
$val
[
'chain_quotation'
]
=
isset
(
$coin_quotations
[
strtoupper
(
$val
[
'chain'
])])
?
$coin_quotations
[
strtoupper
(
$val
[
'chain'
])]
:
[];
$this
->
data
[
$i
][
'introduce'
]
=
isset
(
$introduce
[
$this
->
lang
])
?
$introduce
[
$this
->
lang
]
:
''
;
$nickname
=
json_decode
(
$val
[
'nickname'
],
true
);
$this
->
data
[
$i
][
'chain_quotation'
]
=
$val
;
$val
[
'nickname'
]
=
isset
(
$nickname
[
$this
->
lang
])
?
$nickname
[
$this
->
lang
]
:
''
;
foreach
(
$val
as
$key
=>
$cloumn
)
{
$introduce
=
json_decode
(
$val
[
'introduce'
],
true
);
$this
->
data
[
$i
][
$key
]
=
$cloumn
;
$val
[
'introduce'
]
=
isset
(
$introduce
[
$this
->
lang
])
?
$introduce
[
$this
->
lang
]
:
''
;
}
$this
->
data
[
$key
]
=
array_merge
(
$val
,
isset
(
$coin_quotations
[
strtoupper
(
$val
[
'name'
])])
?
$coin_quotations
[
strtoupper
(
$val
[
'name'
])]
:
$ticker
);
$i
++
;
}
}
doEnd
:
doEnd
:
...
...
api/controllers/WalletCoinController.php
0 → 100644
View file @
c7117a49
<?php
namespace
api\controllers
;
use
Yii
;
use
api\base\BaseController
;
use
common\business\ExchangeBusiness
;
use
common\models\psources\WalletCoin
;
use
common\models\psources\CoinCurrency
;
class
WalletCoinController
extends
BaseController
{
/**
* 币种列表
* @param array names
* @return array
*/
public
function
actionIndex
()
{
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$names
=
Yii
::
$app
->
request
->
post
(
'names'
,
''
);
if
(
false
==
$names
||
false
==
$platform_id
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
}
foreach
(
$names
as
$key
=>
$val
)
{
if
(
strpos
(
$val
,
','
)
!==
false
)
{
$val_array
=
explode
(
','
,
$val
);
if
(
'USDT'
==
strtoupper
(
$val_array
[
0
])
&&
'BTC'
==
strtoupper
(
$val_array
[
1
]))
{
$condition
[]
=
[
$val_array
[
0
],
'omni'
];
continue
;
}
$condition
[]
=
[
$val_array
[
0
],
$val_array
[
1
]];
}
else
{
$condition
[]
=
$val
;
}
}
$this
->
data
=
[];
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
]])
->
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
])
->
asArray
()
->
one
();
}
if
(
!
empty
(
$model
))
{
$this
->
data
=
array_merge
(
$this
->
data
,
[
$model
]);
}
}
if
(
empty
(
$this
->
data
))
{
goto
doEnd
;
}
$chains
=
array_column
(
$this
->
data
,
'chain'
);
$symbol
=
array_column
(
$this
->
data
,
'name'
);
$chains_symbols
=
array_keys
(
array_flip
(
$chains
)
+
array_flip
(
$symbol
));
$coin_quotations
=
ExchangeBusiness
::
getQuatationByNames
(
$chains_symbols
);
$last
[]
=
1
;
$currency
=
CoinCurrency
::
find
()
->
where
([
'pj_id'
=>
$this
->
currency_id
])
->
one
();
if
(
false
!=
$currency
)
{
if
(
1111
==
$this
->
currency_id
)
{
$last
[]
=
1
;
}
else
{
$last
=
Yii
::
$app
->
redis_currency
->
hmget
(
'quotation_boc_'
.
'CNY_'
.
$currency
->
symbol
,
'last'
);
}
}
$ticker
=
[
'low'
=>
0
,
'high'
=>
0
,
'last'
=>
0
,
'open'
=>
0
,
'vol'
=>
0
,
'rmb'
=>
0
,
'usd'
=>
0
];
foreach
(
$this
->
data
as
$key
=>
&
$val
)
{
$val
[
'chain_quotation'
]
=
isset
(
$coin_quotations
[
strtoupper
(
$val
[
'chain'
])])
?
$coin_quotations
[
strtoupper
(
$val
[
'chain'
])]
:
[];
$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
]
:
''
;
$this
->
data
[
$key
]
=
array_merge
(
$val
,
isset
(
$coin_quotations
[
strtoupper
(
$val
[
'name'
])])
?
$coin_quotations
[
strtoupper
(
$val
[
'name'
])]
:
$ticker
);
$val
[
'chain_rmb'
]
=
isset
(
$val
[
'chain_quotation'
][
'rmb'
])
?
$val
[
'chain_quotation'
][
'rmb'
]
:
0
;
$val
[
'chain_usd'
]
=
isset
(
$val
[
'chain_quotation'
][
'usd'
])
?
$val
[
'chain_quotation'
][
'usd'
]
:
0
;
$val
[
'chain_country_rate'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$last
[
0
]
*
$val
[
'chain_rmb'
]);
$val
[
'country_rate'
]
=
(
false
==
$currency
)
?
$val
[
'rmb'
]
:
(
float
)
sprintf
(
"%0.4f"
,
$last
[
0
]
*
$val
[
'rmb'
]);
}
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
/**
* 币种搜索
* @param string chain
* @param string keyword
* @return array
*/
public
function
actionSearch
()
{
$params
=
Yii
::
$app
->
request
->
post
();
$chain
=
isset
(
$params
[
'chain'
])
?
$params
[
'chain'
]
:
''
;
$keyword
=
isset
(
$params
[
'keyword'
])
?
$params
[
'keyword'
]
:
''
;
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
if
(
false
==
$platform_id
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
}
$page
=
empty
(
$params
[
'page'
])
?
1
:
$params
[
'page'
];
$limit
=
empty
(
$params
[
'limit'
])
?
10
:
$params
[
'limit'
];
$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
])
->
orderBy
(
'id'
);
if
(
false
!=
$chain
)
{
$query
->
andWhere
([
'chain'
=>
$chain
]);
}
if
(
false
!=
$keyword
)
{
$query
->
andWhere
([
'or'
,
[
'like'
,
'address'
,
$keyword
],
[
'like'
,
'name'
,
$keyword
]]);
}
$this
->
data
=
$query
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
if
(
false
!=
$this
->
data
)
{
$chains
=
array_unique
(
array_column
(
$this
->
data
,
'chain'
));
$chain_quotation
=
[];
foreach
(
$chains
as
$key
=>
$value
)
{
$chain_quotation
[
$value
]
=
ExchangeBusiness
::
getquatation
(
$value
);
}
foreach
(
$this
->
data
as
$key
=>
$value
)
{
$this
->
data
[
$key
][
'chain_quotation'
]
=
$chain_quotation
[
$value
[
'chain'
]]
?:
null
;
}
foreach
(
$this
->
data
as
$key
=>
&
$value
)
{
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
$value
[
'nickname'
]
=
isset
(
$nickname
[
$this
->
lang
])
?
$nickname
[
$this
->
lang
]
:
''
;
$value
[
'chain_rmb'
]
=
isset
(
$value
[
'chain_quotation'
][
'rmb'
])
?
$value
[
'chain_quotation'
][
'rmb'
]
:
0
;
$value
[
'chain_usd'
]
=
isset
(
$value
[
'chain_quotation'
][
'usd'
])
?
$value
[
'chain_quotation'
][
'usd'
]
:
0
;
}
}
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
/**
* 获取币种简介
* @param integer id
* @return array
*/
public
function
actionGetCoinById
()
{
$params
=
Yii
::
$app
->
request
->
post
();
$id
=
isset
(
$params
[
'id'
])
?
$params
[
'id'
]
:
0
;
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
if
(
false
==
$platform_id
||
false
==
$id
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
}
$this
->
data
=
WalletCoin
::
find
()
->
where
([
'id'
=>
$id
,
'platform_id'
=>
$platform_id
])
->
asArray
()
->
one
();
if
(
empty
(
$this
->
data
))
{
goto
doEnd
;
}
$quotation
=
ExchangeBusiness
::
getquatation
(
$this
->
data
[
'name'
]);
if
(
$quotation
)
{
$tikerdata
[
'price'
]
=
$quotation
[
'rmb'
];
$tikerdata
[
'dollar'
]
=
$quotation
[
'usd'
];
}
else
{
$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
]
:
''
;
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
}
\ No newline at end of file
common/business/ExchangeBusiness.php
View file @
c7117a49
...
@@ -44,7 +44,8 @@ class ExchangeBusiness
...
@@ -44,7 +44,8 @@ class ExchangeBusiness
15
=>
'Bilaxy'
,
15
=>
'Bilaxy'
,
16
=>
'Bitnasdaq'
,
16
=>
'Bitnasdaq'
,
17
=>
'Dag'
,
17
=>
'Dag'
,
18
=>
'Boc'
,
18
=>
'Coinka'
,
19
=>
'Boc'
,
//1 => 'Hadax', //不需要
//1 => 'Hadax', //不需要
//2 => 'Bitfinex', //不需要
//2 => 'Bitfinex', //不需要
...
@@ -219,6 +220,12 @@ class ExchangeBusiness
...
@@ -219,6 +220,12 @@ class ExchangeBusiness
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'STH'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Coinka"
);
$quotation
=
$exchange
->
getTicker
(
'sth'
,
'usdt'
);
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'TSC'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'TSC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Tsc"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Tsc"
);
$quotation
=
$exchange
->
getTicker
(
'TSC'
,
'CNDT'
);
$quotation
=
$exchange
->
getTicker
(
'TSC'
,
'CNDT'
);
...
@@ -320,7 +327,7 @@ class ExchangeBusiness
...
@@ -320,7 +327,7 @@ class ExchangeBusiness
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$cny_usd_rate
=
1
/
$rate
[
'last'
];
$cny_usd_rate
=
1
/
$rate
[
'last'
];
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
,
'CIC'
,
'KPC8'
,
'BVA'
,
'DAG'
,
'BNC'
,
'GHP'
,
'DRA'
,
'ETC'
,
'PAX'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
,
'CIC'
,
'KPC8'
,
'BVA'
,
'DAG'
,
'BNC'
,
'GHP'
,
'DRA'
,
'ETC'
,
'PAX'
,
'STH'
]))
{
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
$cny_usd_rate
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
$cny_usd_rate
);
}
else
if
(
in_array
(
strtoupper
(
$tag
),
[
'SUSD'
]))
{
}
else
if
(
in_array
(
strtoupper
(
$tag
),
[
'SUSD'
]))
{
...
...
common/models/psources/RecommendCoin.php
View file @
c7117a49
...
@@ -3,9 +3,7 @@
...
@@ -3,9 +3,7 @@
namespace
common\models\psources
;
namespace
common\models\psources
;
use
Yii
;
use
Yii
;
use
yii\db\Expression
;
use
common\core\BaseActiveRecord
;
use
common\core\BaseActiveRecord
;
use
yii\behaviors\TimestampBehavior
;
class
RecommendCoin
extends
BaseActiveRecord
class
RecommendCoin
extends
BaseActiveRecord
{
{
...
@@ -21,6 +19,6 @@ class RecommendCoin extends BaseActiveRecord
...
@@ -21,6 +19,6 @@ class RecommendCoin extends BaseActiveRecord
public
function
getCoin
()
public
function
getCoin
()
{
{
return
$this
->
hasOne
(
Coin
::
className
(),
[
'id'
=>
'cid'
])
->
select
([
'id'
,
'sid'
,
'icon'
,
'name'
,
'introduce'
,
'optional_name'
,
'nickname'
,
'platform'
,
'chain'
,
'treaty
'
])
->
asArray
()
->
all
();
return
$this
->
hasOne
(
WalletCoin
::
className
(),
[
'id'
=>
'cid'
])
->
select
([
'id'
,
'sid'
,
'icon'
,
'name'
,
'introduce'
,
'nickname'
,
'platform'
,
'chain'
,
'treaty'
,
'exchange_id
'
])
->
asArray
()
->
all
();
}
}
}
}
\ No newline at end of file
common/models/psources/WalletCoin.php
0 → 100644
View file @
c7117a49
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
WalletCoin
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{wallet_coin}}'
;
}
}
\ No newline at end of file
common/service/exchange/Coinka.php
0 → 100644
View file @
c7117a49
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace
common\service\exchange
;
use
linslin\yii2\curl\Curl
;
class
Coinka
extends
Exchange
implements
ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_coinka'
;
protected
$quotation_prefix
=
'quotation_coinka_'
;
protected
$base_url
=
'https://app.coinka.com.cn/api/v1/allticker'
;
public
function
symbolExists
(
$tag
=
'STH'
,
$aim
=
"USDT"
)
{
$supported
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
is_array
(
$supported
)
&&
in_array
(
$this
->
formatSymbol
(
$tag
,
$aim
),
$supported
))
{
return
true
;
}
return
false
;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public
function
formatSymbol
(
$tag
=
'STH'
,
$aim
=
'USDT'
)
{
return
$tag
.
'_'
.
$aim
;
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setSupportedSymbol
()
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'STHUSDT'
);
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setQuotation
()
{
$curl
=
new
Curl
();
$content
=
$curl
->
get
(
$this
->
base_url
,
false
);
if
(
is_array
(
$content
)
&&
isset
(
$content
[
'ticker'
]))
{
$data
=
$content
[
'ticker'
];
foreach
(
$data
as
$item
)
{
if
(
in_array
(
strtoupper
(
$item
[
'symbol'
]),
[
'STH_USDT'
]))
{
$data
=
$item
;
$key
=
$this
->
quotation_prefix
.
$item
[
'symbol'
];
$this
->
redis
->
hmset
(
$key
,
'low'
,
$data
[
'low'
],
'high'
,
$data
[
'high'
],
'last'
,
$data
[
'last'
],
'change'
,
$data
[
'change'
],
'vol'
,
$data
[
'vol'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
$item
[
'symbol'
]);
}
}
}
}
}
\ No newline at end of file
wallet/controllers/FlashController.php
View file @
c7117a49
...
@@ -337,12 +337,12 @@ class FlashController extends BaseController
...
@@ -337,12 +337,12 @@ class FlashController extends BaseController
$data
=
null
;
$data
=
null
;
$group
=
Yii
::
$app
->
request
->
getGroup
();
$group
=
Yii
::
$app
->
request
->
getGroup
();
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
0
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
0
);
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
if
(
User
::
AUTH_SUPER
!==
$group
&&
$platform_id
!=
Yii
::
$app
->
request
->
getPlatformId
())
{
//
if (User::AUTH_SUPER !== $group && $platform_id != Yii::$app->request->getPlatformId()) {
$msg
=
'暂无权限'
;
//
$msg = '暂无权限';
$code
=
-
1
;
//
$code = -1;
goto
doEnd
;
//
goto doEnd;
}
//
}
if
(
!
isset
(
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
]))
{
if
(
!
isset
(
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
]))
{
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'此钱包节点尚未开通'
];
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'此钱包节点尚未开通'
];
}
}
...
...
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