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
638cae70
Commit
638cae70
authored
Nov 04, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
617943cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
13 deletions
+22
-13
ServiceController.php
api/controllers/ServiceController.php
+1
-1
Coin.php
common/models/psources/Coin.php
+21
-12
No files found.
api/controllers/ServiceController.php
View file @
638cae70
...
@@ -100,7 +100,7 @@ class ServiceController extends BaseController
...
@@ -100,7 +100,7 @@ class ServiceController extends BaseController
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
1
);
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
1
);
$coin_recommendItems
=
$this
->
coinRecommendList
(
$platform_id
,
$type
);
$coin_recommendItems
=
$this
->
coinRecommendList
(
$platform_id
,
$type
);
$fields
=
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
,
'chain'
,
'platform'
];
$fields
=
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
,
'chain'
,
'platform'
];
$rows
=
Coin
::
getSelectList
(
1
,
999
,
$fields
,
[[
'in'
,
'id'
,
$coin_recommendItems
]]);
$rows
=
Coin
::
getSelectList
(
1
,
999
,
$fields
,
[[
'in'
,
'id'
,
$coin_recommendItems
]]
,
$coin_recommendItems
);
foreach
(
$rows
[
'data'
]
as
$key
=>
&
$value
)
{
foreach
(
$rows
[
'data'
]
as
$key
=>
&
$value
)
{
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
$value
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
$value
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
...
...
common/models/psources/Coin.php
View file @
638cae70
...
@@ -36,8 +36,8 @@ class Coin extends BaseActiveRecord
...
@@ -36,8 +36,8 @@ class Coin extends BaseActiveRecord
/**
/**
* 获取币种信息列表
* 获取币种信息列表
*
*
* @param int
$page
* @param int $page
* @param int
$limit
* @param int $limit
* @param array $condition
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
* @return array|\yii\db\ActiveRecord[]
*/
*/
...
@@ -48,7 +48,7 @@ class Coin extends BaseActiveRecord
...
@@ -48,7 +48,7 @@ class Coin extends BaseActiveRecord
$query
=
$query
->
andWhere
(
$item
);
$query
=
$query
->
andWhere
(
$item
);
}
}
$count
=
$query
->
count
();
$count
=
$query
->
count
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
foreach
(
$data
as
$key
=>
$item
)
{
foreach
(
$data
as
$key
=>
$item
)
{
$data
[
$key
][
'price'
]
=
sprintf
(
"%0.6f"
,
$item
[
'price'
]);
$data
[
$key
][
'price'
]
=
sprintf
(
"%0.6f"
,
$item
[
'price'
]);
}
}
...
@@ -58,19 +58,28 @@ class Coin extends BaseActiveRecord
...
@@ -58,19 +58,28 @@ class Coin extends BaseActiveRecord
/**
/**
* 获取币种信息列表
* 获取币种信息列表
*
*
* @param int
$page
* @param int $page
* @param int
$limit
* @param int $limit
* @param array $condition
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
* @return array|\yii\db\ActiveRecord[]
*/
*/
public
static
function
getSelectList
(
$page
=
1
,
$limit
=
10
,
$columns
=
[],
$condition
=
[])
public
static
function
getSelectList
(
$page
=
1
,
$limit
=
10
,
$columns
=
[],
$condition
=
[]
,
$orderBy
=
[]
)
{
{
$ids_str
=
implode
(
','
,
$orderBy
);
$order
=
"FIELD(`id`,
$ids_str
)"
;
$query
=
self
::
find
();
$query
=
self
::
find
();
foreach
(
$condition
as
$item
)
{
foreach
(
$condition
as
$item
)
{
$query
=
$query
->
andWhere
(
$item
);
$query
=
$query
->
andWhere
(
$item
);
}
}
$count
=
$query
->
count
();
$count
=
$query
->
count
();
$data
=
$query
->
select
(
$columns
)
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
if
(
false
!=
$orderBy
)
{
$ids_str
=
implode
(
','
,
$orderBy
);
$order
=
"FIELD(`id`,
$ids_str
)"
;
$data
=
$query
->
select
(
$columns
)
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
asArray
()
->
orderBy
([
$order
=>
true
])
->
all
();
}
else
{
$data
=
$query
->
select
(
$columns
)
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
}
return
[
'count'
=>
$count
,
'data'
=>
$data
];
return
[
'count'
=>
$count
,
'data'
=>
$data
];
}
}
...
@@ -173,8 +182,8 @@ class Coin extends BaseActiveRecord
...
@@ -173,8 +182,8 @@ class Coin extends BaseActiveRecord
/**
/**
* 根据id列表获取币种信息
* 根据id列表获取币种信息
*
*
* @param array
$ids
[description]
* @param array
$ids
[description]
* @param array
$select
[description]
* @param array
$select
[description]
* @param string $sort_by [description]
* @param string $sort_by [description]
* @return array [description]
* @return array [description]
*/
*/
...
@@ -200,8 +209,8 @@ class Coin extends BaseActiveRecord
...
@@ -200,8 +209,8 @@ class Coin extends BaseActiveRecord
/**
/**
* 获取推介币种信息列表
* 获取推介币种信息列表
*
*
* @param int
$page
* @param int $page
* @param int
$limit
* @param int $limit
* @param array $condition
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
* @return array|\yii\db\ActiveRecord[]
*/
*/
...
@@ -213,7 +222,7 @@ class Coin extends BaseActiveRecord
...
@@ -213,7 +222,7 @@ class Coin extends BaseActiveRecord
}
}
$query
=
$query
->
rightJoin
(
'coin_recommend'
,
'coin.id=coin_recommend.cid'
);
$query
=
$query
->
rightJoin
(
'coin_recommend'
,
'coin.id=coin_recommend.cid'
);
$count
=
$query
->
count
();
$count
=
$query
->
count
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
foreach
(
$data
as
$key
=>
$item
)
{
foreach
(
$data
as
$key
=>
$item
)
{
$data
[
$key
][
'price'
]
=
sprintf
(
"%0.6f"
,
$item
[
'price'
]);
$data
[
$key
][
'price'
]
=
sprintf
(
"%0.6f"
,
$item
[
'price'
]);
}
}
...
...
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