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
5e38fd2b
Commit
5e38fd2b
authored
Jan 13, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into 'master'
Feature/optimize See merge request
!271
parents
47105d9b
00bec23d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
211 additions
and
5 deletions
+211
-5
BaseController.php
api/base/BaseController.php
+4
-0
RecommendCoinController.php
api/controllers/RecommendCoinController.php
+56
-0
WalletCoinController.php
api/controllers/WalletCoinController.php
+100
-0
RecommendCoin.php
common/models/psources/RecommendCoin.php
+25
-0
WalletCoin.php
common/models/psources/WalletCoin.php
+21
-0
FlashController.php
wallet/controllers/FlashController.php
+5
-5
No files found.
api/base/BaseController.php
View file @
5e38fd2b
...
@@ -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 @
5e38fd2b
<?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
])
->
orderBy
(
"sort desc"
)
->
all
();
if
(
empty
(
$recommend_coins
))
{
goto
doEnd
;
}
$this
->
data
=
[];
foreach
(
$recommend_coins
as
$coin
)
{
$recommend_coin_info
=
[
'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'
);
$symbol
=
array_column
(
$this
->
data
,
'name'
);
$chains_symbols
=
array_keys
(
array_flip
(
$chains
)
+
array_flip
(
$symbol
));
$coin_quotations
=
ExchangeBusiness
::
getQuatationByNames
(
$chains_symbols
);
$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
);
}
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
}
\ No newline at end of file
api/controllers/WalletCoinController.php
0 → 100644
View file @
5e38fd2b
<?php
namespace
api\controllers
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinCurrency
;
use
Yii
;
use
api\base\BaseController
;
use
common\business\ExchangeBusiness
;
use
common\models\psources\RecommendCoin
;
class
WalletCoinController
extends
BaseController
{
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
=
[];
if
(
count
(
$condition
[
0
])
>
1
)
{
foreach
(
$condition
as
$val
)
{
if
(
'null'
==
$val
[
1
]
||
'coin'
==
$val
[
1
])
{
$this
->
data
[]
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,introduce,platform,chain,address as contract_address,treaty'
)
->
where
([
'name'
=>
$val
[
0
]])
->
asArray
()
->
one
();
continue
;
}
$this
->
data
[]
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,introduce,platform,chain,address as contract_address,treaty'
)
->
where
([
'name'
=>
$val
[
0
]])
->
andWhere
([
'platform'
=>
$val
[
1
]])
->
asArray
()
->
one
();
}
}
else
{
$this
->
data
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,introduce,platform,chain,address as contract_address,treaty'
)
->
where
([
'in'
,
'name'
,
$condition
])
->
asArray
()
->
all
();
}
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
];
}
}
\ No newline at end of file
common/models/psources/RecommendCoin.php
0 → 100644
View file @
5e38fd2b
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
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
(
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 @
5e38fd2b
<?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
wallet/controllers/FlashController.php
View file @
5e38fd2b
...
@@ -338,11 +338,11 @@ class FlashController extends BaseController
...
@@ -338,11 +338,11 @@ class FlashController extends BaseController
$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
);
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