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
4f70fb8a
Commit
4f70fb8a
authored
Jun 19, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
结构规范
parent
cf355d7f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
24 deletions
+42
-24
CoinBusiness.php
common/business/CoinBusiness.php
+9
-15
CoinService.php
common/service/CoinService.php
+0
-0
CoinBTYService.php
common/service/coin/CoinBTYService.php
+17
-0
CoinInterface.php
common/service/coin/CoinInterface.php
+7
-0
CoinService.php
common/service/coin/CoinService.php
+9
-9
No files found.
common/business/CoinBusiness.php
View file @
4f70fb8a
...
...
@@ -10,7 +10,6 @@ namespace common\business;
use
common\models\pwallet\Coin
;
use
common\service\coin\CoinFactory
;
use
common\service\CoinService
;
/**
* 币种逻辑层
...
...
@@ -34,7 +33,8 @@ class CoinBusiness
$datas
=
$rows
[
'data'
];
foreach
(
$datas
as
$key
=>
$value
)
{
//获取交易所信息
$rows
[
'data'
][
$key
][
'exchange'
]
=
CoinService
::
exchange_count
(
$value
[
'sid'
]);
$coin
=
CoinFactory
::
createCoin
(
$value
[
'name'
],
$value
[
'id'
],
$value
[
'sid'
]);
$rows
[
'data'
][
$key
][
'exchange'
]
=
$coin
->
exchange_count
();
}
}
return
$rows
;
...
...
@@ -51,7 +51,8 @@ class CoinBusiness
if
(
$id
)
{
$coin
=
Coin
::
findOne
([
'id'
=>
$id
]);
if
(
$coin
)
{
$datas
=
CoinService
::
exchange
(
$coin
->
sid
);
$model
=
CoinFactory
::
createCoin
(
$coin
->
name
,
$coin
->
id
,
$coin
->
sid
);
$datas
=
$model
->
exchange
();
if
(
$datas
[
'count'
]
>
0
)
{
return
$datas
[
'data'
];
}
...
...
@@ -73,12 +74,8 @@ class CoinBusiness
if
(
$rows
[
'count'
]
>
0
)
{
$rows
=
$rows
[
'data'
];
foreach
(
$rows
as
$key
=>
$value
)
{
//获取行情信息
if
(
strtoupper
(
$value
[
'name'
])
==
'BTY'
)
{
$rows
[
$key
][
'quotation'
]
=
CoinService
::
quotationBTY
();
continue
;
}
$rows
[
$key
][
'quotation'
]
=
CoinService
::
quotation
(
$value
[
'sid'
]);
$coin
=
CoinFactory
::
createCoin
(
$value
[
'name'
],
$value
[
'id'
],
$value
[
'sid'
]);
$rows
[
$key
][
'quotation'
]
=
$coin
->
quotation
();
}
}
return
$rows
;
...
...
@@ -138,14 +135,11 @@ class CoinBusiness
{
$row
=
Coin
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
One
();
if
(
$row
)
{
$coin
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
//TODO 获取行情
$row
[
'quotation'
]
=
CoinService
::
quotation
(
$row
[
'sid'
]);
//行情BTY
if
(
strtoupper
(
$row
[
'name'
])
==
'BTY'
)
{
$row
[
'quotation'
]
=
CoinService
::
quotationBTY
();
}
$row
[
'quotation'
]
=
$coin
->
quotation
(
$row
[
'sid'
]);
//TODO 获取交易所详情
$row
[
'exchange'
]
=
CoinService
::
exchange
(
$row
[
'sid'
]);
$row
[
'exchange'
]
=
$coin
->
exchange
(
$row
[
'sid'
]);
}
return
$row
?
[
$row
]
:
[];
}
...
...
common/service/CoinService.php
deleted
100644 → 0
View file @
cf355d7f
This diff is collapsed.
Click to expand it.
common/service/coin/CoinBTYService.php
View file @
4f70fb8a
...
...
@@ -10,6 +10,23 @@ namespace common\service\coin;
class
CoinBTYService
extends
Coin
implements
CoinInterface
{
public
function
exchange
()
{
// TODO: Implement exchange() method.
return
[
'count'
=>
0
,
'data'
=>
[]];
}
public
function
exchange_count
()
{
// TODO: Implement exchange_count() method.
return
0
;
}
public
function
quotation
()
{
// TODO: Implement quotation() method.
}
public
function
__construct
(
$id
,
$sid
)
{
...
...
common/service/coin/CoinInterface.php
View file @
4f70fb8a
...
...
@@ -18,4 +18,10 @@ interface CoinInterface
//币种销毁
public
function
__destruct
();
public
function
exchange
();
public
function
exchange_count
();
public
function
quotation
();
}
\ No newline at end of file
common/service/coin/CoinService.php
View file @
4f70fb8a
...
...
@@ -399,18 +399,18 @@ class CoinService extends Coin implements CoinInterface
* @param $name string 币种名称
* @return array
*/
public
static
function
exchange
(
$name
=
'eos'
)
public
function
exchange
(
)
{
//缓存数据
$key
=
[
__CLASS__
,
__METHOD__
,
'coin'
,
//表名
$
name
,
//sid
$
this
->
sid
,
//sid
];
$result
=
Yii
::
$app
->
cache
->
get
(
$key
);
if
(
$result
===
false
)
{
$url
=
Yii
::
$app
->
params
[
'feixiaohao_domain'
]
.
Yii
::
$app
->
params
[
'feixiaohao_page'
][
'coinmarket'
]
.
$
name
.
'/'
;
$url
=
Yii
::
$app
->
params
[
'feixiaohao_domain'
]
.
Yii
::
$app
->
params
[
'feixiaohao_page'
][
'coinmarket'
]
.
$
this
->
sid
.
'/'
;
$ch
=
new
Curl
();
try
{
$content
=
$ch
->
get
(
$url
,
true
);
...
...
@@ -453,17 +453,17 @@ class CoinService extends Coin implements CoinInterface
* @param string $sid
* @return integer|bool
*/
public
static
function
exchange_count
(
$sid
=
'eos'
)
public
function
exchange_count
(
)
{
$key
=
[
__CLASS__
,
__METHOD__
,
'coin'
,
//表名
$sid
,
//sid
$
this
->
sid
,
//sid
];
$result
=
Yii
::
$app
->
cache
->
get
(
$key
);
if
(
!
$result
)
{
$url
=
Yii
::
$app
->
params
[
'feixiaohao_domain'
]
.
Yii
::
$app
->
params
[
'feixiaohao_page'
][
'coinmarket'
]
.
$sid
.
'/'
;
$url
=
Yii
::
$app
->
params
[
'feixiaohao_domain'
]
.
Yii
::
$app
->
params
[
'feixiaohao_page'
][
'coinmarket'
]
.
$
this
->
sid
.
'/'
;
$ch
=
new
Curl
();
try
{
$content
=
$ch
->
get
(
$url
,
true
);
...
...
@@ -490,18 +490,18 @@ class CoinService extends Coin implements CoinInterface
* @param string $sid
* @return object|string
*/
public
static
function
quotation
(
$sid
=
'eos'
)
public
function
quotation
(
)
{
//使用缓存
$key
=
[
__CLASS__
,
__METHOD__
,
'coin'
,
//表名
$sid
,
//sid
$
this
->
sid
,
//sid
];
$result
=
Yii
::
$app
->
cache
->
get
(
$key
);
if
(
$result
===
false
)
{
$url
=
Yii
::
$app
->
params
[
'feixiaohao_domain'
]
.
Yii
::
$app
->
params
[
'feixiaohao_page'
][
'currencies'
]
.
$sid
.
'/'
;
$url
=
Yii
::
$app
->
params
[
'feixiaohao_domain'
]
.
Yii
::
$app
->
params
[
'feixiaohao_page'
][
'currencies'
]
.
$
this
->
sid
.
'/'
;
$ch
=
new
Curl
();
try
{
$content
=
$ch
->
get
(
$url
,
true
);
...
...
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