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
eb0f7d01
Commit
eb0f7d01
authored
Sep 06, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
38cd98f1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+20
-14
No files found.
common/business/ExchangeBusiness.php
View file @
eb0f7d01
...
...
@@ -9,8 +9,8 @@
namespace
common\business
;
use
common\models\psources\Coin
;
use
common\service\exchange\ExchangeFactory
;
use
common\service\coin\CoinFactory
;
use
common\service\exchange\ExchangeFactory
;
/**
* Class ExchangeBusiness
...
...
@@ -33,8 +33,8 @@ class ExchangeBusiness
/**
* 获取行情
* @param
string
$tag 目标币种
* @param
string
$aim 计数币种
* @param
string
$tag 目标币种
* @param
string
$aim 计数币种
* @return array|bool
*/
public
static
function
getquatation
(
$tag
=
'btc'
,
$aim
=
''
)
...
...
@@ -64,7 +64,7 @@ class ExchangeBusiness
if
(
$exchange
->
symbolExists
(
$tag
,
'btc'
))
{
$price_btc
=
$exchange
->
getTicker
(
$tag
,
'btc'
);
//获取btcusdt
$result
=
array_map
(
function
(
$a
,
$b
)
{
$result
=
array_map
(
function
(
$a
,
$b
)
{
return
$a
*
$b
;
},
$price_btc
,
$btc_usd
);
$quotation
=
[
'low'
=>
$result
[
0
],
'high'
=>
$result
[
1
],
'last'
=>
$result
[
2
]];
...
...
@@ -78,9 +78,9 @@ class ExchangeBusiness
}
//格式化行情数据
foreach
(
$quotation
as
$key
=>
$item
)
{
$quotation
[
$key
]
=
(
float
)
sprintf
(
"%0.4f"
,
(
double
)
$item
);
$quotation
[
$key
]
=
(
float
)
sprintf
(
"%0.4f"
,
(
double
)
$item
);
}
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
6.6
*
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
6.6
*
$quotation
[
'last'
]);
return
$quotation
;
}
...
...
@@ -116,12 +116,12 @@ class ExchangeBusiness
/**
* 根据name返回币种信息
* @param
array
$condition 需要的币种sid列表
* @param
array
$condition 需要的币种sid列表
* @return array
*/
public
static
function
getApiListForIndex
(
$page
=
1
,
$limit
=
999
,
$condition
=
[])
{
$rows
=
Coin
::
getSelectList
(
$page
,
$limit
,
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
,
'platform'
,
'chain'
,
'recommend'
],
$rows
=
Coin
::
getSelectList
(
$page
,
$limit
,
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
,
'platform'
,
'chain'
,
'recommend'
],
$condition
);
$count
=
0
;
if
(
!
empty
(
$rows
)
&&
is_array
(
$rows
)
&&
array_key_exists
(
'count'
,
$rows
))
{
...
...
@@ -151,7 +151,14 @@ class ExchangeBusiness
\Yii
::
error
(
$exception
->
getMessage
());
}
}
$rows
[
$key
]
=
array_merge
(
$rows
[
$key
],
$quotation
);
if
(
strtoupper
(
$row
[
'platform'
])
==
'GUODUN'
)
{
$rows
[
$key
][
'rmb'
]
=
0
;
$rows
[
$key
][
'last'
]
=
0
;
$rows
[
$key
][
'low'
]
=
0
;
$rows
[
$key
][
'high'
]
=
0
;
}
else
{
$rows
[
$key
]
=
array_merge
(
$rows
[
$key
],
$quotation
);
}
}
return
[
'code'
=>
0
,
'count'
=>
$count
,
'data'
=>
$rows
];
}
...
...
@@ -160,9 +167,9 @@ class ExchangeBusiness
/**
* 根据名称搜索
* @param
int
$page
* @param
int
$limit
* @param
array
$condition
* @param
int
$page
* @param
int
$limit
* @param
array
$condition
* @return array|\yii\db\ActiveRecord|\yii\db\ActiveRecord[]
*/
public
static
function
SearchByName
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
...
...
@@ -179,4 +186,4 @@ class ExchangeBusiness
}
return
[];
}
}
\ 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