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
e4ddd791
Commit
e4ddd791
authored
Aug 07, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加主链行情
parent
fedccb4d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
17 deletions
+39
-17
BaseResponse.php
api/base/BaseResponse.php
+2
-0
CoinController.php
api/controllers/CoinController.php
+36
-3
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+1
-14
No files found.
api/base/BaseResponse.php
View file @
e4ddd791
...
...
@@ -20,6 +20,8 @@ class BaseResponse extends Response
$this
->
data
=
[
'code'
=>
$excpetion
->
getCode
(),
'msg'
=>
$excpetion
->
getMessage
(),
'line'
=>
$excpetion
->
getLine
(),
'file'
=>
$excpetion
->
getFile
(),
];
}
//TODO 在这里对数据进行format,这样控制器中可以直接return一个array,保存到数据域data中即可,eg:['code'=>0,'data'=>$data]
...
...
api/controllers/CoinController.php
View file @
e4ddd791
...
...
@@ -49,7 +49,18 @@ class CoinController extends BaseController
$page
=
$request
->
post
(
'page'
,
1
);
$limit
=
$request
->
post
(
'limit'
,
999
);
$condition
=
[[
'recommend'
=>
'1'
]];
return
ExchangeBusiness
::
getApiListForIndex
(
$page
,
$limit
,
$condition
);
$result
=
ExchangeBusiness
::
getApiListForIndex
(
$page
,
$limit
,
$condition
);
if
(
$result
)
{
$chains
=
array_unique
(
array_column
(
$result
[
'data'
],
'chain'
));
$chain_quotation
=
[];
foreach
(
$chains
as
$key
=>
$value
)
{
$chain_quotation
[
$value
]
=
ExchangeBusiness
::
getquatation
(
$value
);
}
foreach
(
$result
[
'data'
]
as
$key
=>
&
$value
)
{
$value
[
'chain_quotation'
]
=
$chain_quotation
[
$value
[
'chain'
]];
}
return
$result
;
}
}
/**
...
...
@@ -84,7 +95,18 @@ class CoinController extends BaseController
{
$names
=
Yii
::
$app
->
request
->
post
(
'names'
);
$condition
=
[[
'in'
,
'name'
,
$names
]];
return
ExchangeBusiness
::
getApiListForIndex
(
1
,
999
,
$condition
);
$result
=
ExchangeBusiness
::
getApiListForIndex
(
1
,
999
,
$condition
);
if
(
$result
)
{
$chains
=
array_unique
(
array_column
(
$result
[
'data'
],
'chain'
));
$chain_quotation
=
[];
foreach
(
$chains
as
$key
=>
$value
)
{
$chain_quotation
[
$value
]
=
ExchangeBusiness
::
getquatation
(
$value
);
}
foreach
(
$result
[
'data'
]
as
$key
=>
&
$value
)
{
$value
[
'chain_quotation'
]
=
$chain_quotation
[
$value
[
'chain'
]];
}
return
$result
;
}
}
/**
...
...
@@ -99,7 +121,18 @@ class CoinController extends BaseController
$limit
=
$request
->
post
(
'limit'
,
10
);
if
(
$name
)
{
$condition
=
[[
'!='
,
'chain'
,
'other'
],
[
'or'
,
[
'like'
,
'name'
,
$name
],
[
'like'
,
'nickname'
,
$name
]]];
return
ExchangeBusiness
::
SearchByName
(
$page
,
$limit
,
$condition
);
$result
=
ExchangeBusiness
::
SearchByName
(
$page
,
$limit
,
$condition
);
if
(
$result
)
{
$chains
=
array_unique
(
array_column
(
$result
,
'chain'
));
$chain_quotation
=
[];
foreach
(
$chains
as
$key
=>
$value
)
{
$chain_quotation
[
$value
]
=
ExchangeBusiness
::
getquatation
(
$value
);
}
foreach
(
$result
as
$key
=>
$value
)
{
$result
[
$key
][
'chain_quotation'
]
=
$chain_quotation
[
$value
[
'chain'
]];
}
return
$result
;
}
}
}
...
...
common/business/ExchangeBusiness.php
View file @
e4ddd791
...
...
@@ -36,7 +36,7 @@ class ExchangeBusiness
* @param string $aim 计数币种
* @return array|bool
*/
p
rivate
static
function
getquatation
(
$tag
=
'btc'
,
$aim
=
''
)
p
ublic
static
function
getquatation
(
$tag
=
'btc'
,
$aim
=
''
)
{
$f
=
false
;
$quotation
=
[];
...
...
@@ -170,19 +170,6 @@ class ExchangeBusiness
$rows
=
$rows
[
'data'
];
foreach
(
$rows
as
$key
=>
$row
)
{
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
// $quotation = self::getquatation($row['name']);
// if (!$quotation) {
// $quotation = [];
// //使用Coin服务
// $coinServer = CoinFactory::createCoin($row['name'], $row['id'], $row['sid']);
// $rows[$key]['sid'] = ucfirst($rows[$key]['sid']);
// $rows[$key]['rmb'] = $coinServer->getPrice();
// $rows[$key]['last'] = $coinServer->getDollar();
// $rows[$key]['low'] = $coinServer->getLow();
// $rows[$key]['high'] = $coinServer->getHigh();
// $coinServer->__destruct();
// }
// $rows[$key] = array_merge($rows[$key], $quotation);
}
return
$rows
;
}
...
...
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