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
2b85dcd2
Commit
2b85dcd2
authored
Jun 15, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CoinServer update&index API
parent
d26e197c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
3 deletions
+55
-3
BaseResponse.php
api/base/BaseResponse.php
+10
-0
CoinController.php
api/controllers/CoinController.php
+5
-3
CoinBusiness.php
common/business/CoinBusiness.php
+22
-0
Coin.php
common/models/pwallet/Coin.php
+18
-0
CoinService.php
common/service/CoinService.php
+0
-0
No files found.
api/base/BaseResponse.php
View file @
2b85dcd2
...
@@ -20,6 +20,15 @@ class BaseResponse extends Response
...
@@ -20,6 +20,15 @@ class BaseResponse extends Response
$this
->
data
=
[
'code'
=>
$excpetion
->
getCode
(),
'msg'
=>
$excpetion
->
getMessage
()];
$this
->
data
=
[
'code'
=>
$excpetion
->
getCode
(),
'msg'
=>
$excpetion
->
getMessage
()];
}
}
//TODO 在这里对数据进行format,这样控制器中可以直接return一个array,保存到数据域data中即可,eg:['code'=>0,'data'=>$data]
//TODO 在这里对数据进行format,这样控制器中可以直接return一个array,保存到数据域data中即可,eg:['code'=>0,'data'=>$data]
$data
=
\Yii
::
$app
->
response
->
data
;
if
(
empty
(
$data
))
{
$return
[
'code'
]
=
1
;
$return
[
'msg'
]
=
'数据为空'
;
}
else
{
$return
[
'code'
]
=
0
;
$return
[
'data'
]
=
$data
;
}
\Yii
::
$app
->
response
->
data
=
$return
;
parent
::
send
();
parent
::
send
();
}
}
}
}
\ No newline at end of file
api/controllers/CoinController.php
View file @
2b85dcd2
...
@@ -123,9 +123,10 @@ class CoinController extends BaseController
...
@@ -123,9 +123,10 @@ class CoinController extends BaseController
/**
/**
* app首页接口
* app首页接口
*/
*/
public
function
action
SearchByNames
()
public
function
action
CoinIndex
()
{
{
$names
=
Yii
::
$app
->
request
->
post
(
'names'
);
$names
=
Yii
::
$app
->
request
->
post
(
'names'
);
$condition
=
[[
'in'
,
'name'
,
$names
]];
Yii
::
$app
->
response
->
data
=
CoinBusiness
::
getApiListForIndex
(
$condition
);
}
}
}
}
\ No newline at end of file
common/business/CoinBusiness.php
View file @
2b85dcd2
...
@@ -82,4 +82,25 @@ class CoinBusiness
...
@@ -82,4 +82,25 @@ class CoinBusiness
}
}
return
$rows
;
return
$rows
;
}
}
/**
* @param array $condition 需要的币种sid列表
* @return array
*/
public
static
function
getApiListForIndex
(
$condition
=
[])
{
$rows
=
Coin
::
getSelectList
(
1
,
999
,
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
],
$condition
);
if
(
$rows
[
'count'
]
>
0
)
{
$rows
=
$rows
[
'data'
];
foreach
(
$rows
as
$key
=>
$row
)
{
$coinServer
=
new
CoinService
(
$row
[
'id'
],
$row
[
'sid'
]);
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
$rows
[
$key
][
'rmb'
]
=
$coinServer
->
getPrice
();
$rows
[
$key
][
'usd'
]
=
$coinServer
->
getDollar
();
$coinServer
->
__destruct
();
}
return
$rows
;
}
return
[];
}
}
}
\ No newline at end of file
common/models/pwallet/Coin.php
View file @
2b85dcd2
...
@@ -56,6 +56,24 @@ class Coin extends BaseActiveRecord
...
@@ -56,6 +56,24 @@ class Coin extends BaseActiveRecord
}
}
/**
/**
* 获取币种信息列表
* @param int $page
* @param int $limit
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
*/
public
static
function
getSelectList
(
$page
=
1
,
$limit
=
10
,
$columns
=
[],
$condition
=
[])
{
$query
=
self
::
find
();
foreach
(
$condition
as
$item
)
{
$query
=
$query
->
andWhere
(
$item
);
}
$count
=
$query
->
count
();
$data
=
$query
->
select
(
$columns
)
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
return
[
'count'
=>
$count
,
'data'
=>
$data
];
}
/**
* 添加一个币种信息
* 添加一个币种信息
*/
*/
public
function
addOne
(
$params
)
public
function
addOne
(
$params
)
...
...
common/service/CoinService.php
View file @
2b85dcd2
This diff is collapsed.
Click to expand it.
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