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
6bc52020
Commit
6bc52020
authored
Jun 28, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api v2
parent
cdde6ddc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
CoinController.php
api/controllers/v2/CoinController.php
+99
-0
No files found.
api/controllers/v2/CoinController.php
0 → 100644
View file @
6bc52020
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午1:02
*/
namespace
api\controllers\v2
;
use
Yii
;
use
common\base\Exception
;
use
api\base\BaseController
;
use
common\models\pwallet\Coin
;
use
common\business\CoinBusiness
;
use
common\business\ExchangeBusiness
;
/**
* 币种信息管理控制器
* Class CoinController
* @package api\controllers
*/
class
CoinController
extends
BaseController
{
/**
* 单币种按照id查询
* @return array|null|\yii\db\ActiveRecord
*/
public
function
actionGetCoinById
()
{
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
post
(
'id'
,
0
);
if
(
$id
)
{
return
CoinBusiness
::
getCoinAllById
(
$id
);
}
return
[];
}
/**
* 获取推介币种列表
*/
public
function
actionGetRecList
()
{
$request
=
Yii
::
$app
->
request
;
$page
=
$request
->
post
(
'page'
,
1
);
$limit
=
$request
->
post
(
'limit'
,
999
);
$condition
=
[[
'recommend'
=>
'1'
]];
return
CoinBusiness
::
getApiList
(
$page
,
$limit
,
$condition
);
}
/**
* 矿工费获取
*
* 根据name获取
* @throws Exception
*/
public
function
actionGetMinerFeeByName
()
{
$names
=
Yii
::
$app
->
request
->
post
(
'name'
);
$coin
=
Coin
::
findOne
([
'name'
=>
$names
]);
if
(
$coin
)
{
$miner_fee
=
$coin
->
minerFee
;
if
(
empty
(
$miner_fee
))
{
return
[];
}
}
else
{
//如果coin为null,$coin->minerFee会抛出Trying to get property 'minerFee' of non-object",code=>8
throw
new
Exception
(
'8'
,
'币种不存在'
);
}
return
[
$miner_fee
];
}
/**
* app首页接口V2
*/
public
function
actionCoinIndex
()
{
$names
=
Yii
::
$app
->
request
->
post
(
'names'
);
$condition
=
[[
'in'
,
'name'
,
$names
]];
return
ExchangeBusiness
::
getApiListForIndex
(
$condition
);
}
/**
* 按照名称搜索币种
* @return array
*/
public
function
actionSearchCoinByName
()
{
$request
=
Yii
::
$app
->
request
;
$name
=
$request
->
post
(
'name'
,
''
);
$page
=
$request
->
post
(
'page'
,
1
);
$limit
=
$request
->
post
(
'limit'
,
10
);
if
(
$name
)
{
$condition
=
[[
'or'
,
[
'like'
,
'name'
,
$name
],
[
'like'
,
'nickname'
,
$name
]]];
return
CoinBusiness
::
SearchByName
(
$page
,
$limit
,
$condition
);
}
}
}
\ 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