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
0ea1024d
Commit
0ea1024d
authored
Jun 11, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
矿工费api
parent
8c982e00
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
17 deletions
+61
-17
BaseResponse.php
api/base/BaseResponse.php
+7
-1
CoinController.php
api/controllers/CoinController.php
+36
-12
CoinBusiness.php
common/business/CoinBusiness.php
+1
-1
Coin.php
common/models/pwallet/Coin.php
+17
-3
No files found.
api/base/BaseResponse.php
View file @
0ea1024d
...
...
@@ -14,7 +14,12 @@ class BaseResponse extends Response
{
public
function
send
()
{
//TODO 错误处理
//错误处理
$excpetion
=
\Yii
::
$app
->
errorHandler
->
exception
;
if
(
$excpetion
!==
null
)
{
$this
->
data
=
[
'code'
=>
$excpetion
->
getCode
(),
'msg'
=>
$excpetion
->
getMessage
()];
}
//TODO 在这里对数据进行format,这样控制器中可以直接return一个array,保存到数据域data中即可,eg:['code'=>0,'data'=>$data]
parent
::
send
();
}
}
\ No newline at end of file
api/controllers/CoinController.php
View file @
0ea1024d
...
...
@@ -8,6 +8,8 @@
namespace
api\controllers
;
use
common\base\Exception
;
use
common\models\pwallet\Coin
;
use
Yii
;
use
api\base\BaseController
;
use
common\business\CoinBusiness
;
...
...
@@ -20,23 +22,13 @@ use common\business\CoinBusiness;
class
CoinController
extends
BaseController
{
/**
* 获取币种列表
*/
public
function
actionList
()
{
\Yii
::
$app
->
response
->
data
=
Coin
::
getList
();
}
/**
* 获取行情列表,可簺选(coin.id,coin.name),可分页
* 获取行情列表,可筛选可分页
*
* @var int $id coin.id
* @var string $name coin.name
* @var int $page 第几页
* @var int $limit 多少条数据
*
* @return array 格式 [code,msg,count,data]
*
* 返回data数组格式[coin.id coin.name coin.nickname coin.quotation]
* coin.quatation=>['price' => '', 'dollar' => '', 'btc' => '', 'high' => '', 'low' => '', 'change' => '']
* 对应:价格 价格美元 价格btc 最高价 最低价 涨幅(跌幅)
...
...
@@ -79,7 +71,7 @@ class CoinController extends BaseController
$condition
[]
=
[
'like'
,
'nickname'
,
$post
[
'nickname'
]];
}
//平台
saixuan
//平台
筛选
if
(
isset
(
$post
[
'platform'
]))
{
$condition
[]
=
[
'platform'
=>
$post
[
'platform'
]];
}
...
...
@@ -88,4 +80,35 @@ class CoinController extends BaseController
Yii
::
$app
->
response
->
data
=
$data
;
}
/**
* 获取推介币种列表
*/
public
function
actionGetRecList
()
{
//todo 推介币种列表
}
/**
* 矿工费获取
*
* 根据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
[
'code'
=>
1
,
'msg'
=>
'数据为空'
];
}
}
else
{
//如果coin为null,$coin->minerFee会抛出Trying to get property 'minerFee' of non-object",code=>8
throw
new
Exception
(
'8'
,
'币种不存在'
);
}
return
[
'code'
=>
0
,
'data'
=>
$miner_fee
];
}
}
\ No newline at end of file
common/business/CoinBusiness.php
View file @
0ea1024d
...
...
@@ -8,7 +8,6 @@
namespace
common\business
;
use
Yii
;
use
common\models\pwallet\Coin
;
use
common\service\CoinService
;
...
...
@@ -45,6 +44,7 @@ class CoinBusiness
* @param int $page
* @param int $limit
* @param array $condition
* @return array
*/
public
static
function
getApiList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
{
...
...
common/models/pwallet/Coin.php
View file @
0ea1024d
...
...
@@ -8,12 +8,21 @@
namespace
common\models\pwallet
;
use
common\base\Exception
;
use
common\core\BaseActiveRecord
;
use
Yii
;
use
common\core\BaseActiveRecord
;
/**
* Class Coin
*
* @property array $minerFee 矿工费用
* @package common\models\pwallet
*/
class
Coin
extends
BaseActiveRecord
{
/**
* @return null|object|\yii\db\Connection
* @throws \yii\base\InvalidConfigException
*/
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'db_pwallet'
);
...
...
@@ -80,9 +89,13 @@ class Coin extends BaseActiveRecord
$coin
->
setAttributes
(
$params
,
false
);
try
{
return
(
bool
)
$coin
->
save
();
}
catch
(
Exception
$exception
)
{
}
catch
(
\
Exception
$exception
)
{
return
[
'code'
=>
$exception
->
getCode
(),
'message'
=>
$exception
->
getMessage
()];
}
}
public
function
getMinerFee
()
{
return
$this
->
hasOne
(
MinerFee
::
className
(),
[
'platform'
=>
'platform'
]);
}
}
\ 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