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
cdcf8bd2
Commit
cdcf8bd2
authored
Jun 20, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
返回数据格式规范
parent
35a7af46
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
6 deletions
+9
-6
CoinBTYService.php
common/service/coin/CoinBTYService.php
+3
-3
CoinService.php
common/service/coin/CoinService.php
+5
-2
CoinYCCService.php
common/service/coin/CoinYCCService.php
+1
-1
No files found.
common/service/coin/CoinBTYService.php
View file @
cdcf8bd2
...
@@ -58,7 +58,7 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -58,7 +58,7 @@ class CoinBTYService extends Coin implements CoinInterface
{
{
$key
=
$this
->
cache_key_prifx
.
$this
->
sid
.
'all'
;
$key
=
$this
->
cache_key_prifx
.
$this
->
sid
.
'all'
;
$result
=
Yii
::
$app
->
cache
->
get
(
$key
);
$result
=
Yii
::
$app
->
cache
->
get
(
$key
);
if
(
$result
===
false
)
{
if
(
$result
===
false
||
YII_ENV_DEV
)
{
$url
=
'https://zb2api.licai.cn/api/data/Ticker?sort=cname'
;
$url
=
'https://zb2api.licai.cn/api/data/Ticker?sort=cname'
;
$ch
=
new
Curl
();
$ch
=
new
Curl
();
$content
=
$ch
->
get
(
$url
,
false
);
$content
=
$ch
->
get
(
$url
,
false
);
...
@@ -95,7 +95,7 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -95,7 +95,7 @@ class CoinBTYService extends Coin implements CoinInterface
public
function
setPrice
(
$price
)
public
function
setPrice
(
$price
)
{
{
return
$this
->
price
=
"¥
$price
"
;
return
$this
->
price
=
$price
;
}
}
public
function
getDollar
()
public
function
getDollar
()
...
@@ -110,7 +110,7 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -110,7 +110,7 @@ class CoinBTYService extends Coin implements CoinInterface
public
function
setDollar
(
$dollar
)
public
function
setDollar
(
$dollar
)
{
{
$this
->
dollar
=
"≈
\$
$dollar
"
;
$this
->
dollar
=
$dollar
;
}
}
public
function
getHigh
()
public
function
getHigh
()
...
...
common/service/coin/CoinService.php
View file @
cdcf8bd2
...
@@ -50,7 +50,9 @@ class CoinService extends Coin implements CoinInterface
...
@@ -50,7 +50,9 @@ class CoinService extends Coin implements CoinInterface
}
}
$pattern
=
'/<div class=coinprice>(.*?)<span class=(tags-red|tags-green)>(.*?)<\/span><\/div>/is'
;
$pattern
=
'/<div class=coinprice>(.*?)<span class=(tags-red|tags-green)>(.*?)<\/span><\/div>/is'
;
preg_match_all
(
$pattern
,
$this
->
content
,
$matchs
,
PREG_SET_ORDER
);
preg_match_all
(
$pattern
,
$this
->
content
,
$matchs
,
PREG_SET_ORDER
);
$this
->
setPrice
(
$matchs
[
0
][
1
]);
$price
=
$matchs
[
0
][
1
];
$price
=
str_replace
([
'¥'
,
','
],
''
,
$price
);
$this
->
setPrice
(
$price
);
Yii
::
$app
->
cache
->
set
(
$this
->
cache_key_prifx
.
$this
->
sid
.
'_price'
,
$this
->
price
,
Yii
::
$app
->
cache
->
set
(
$this
->
cache_key_prifx
.
$this
->
sid
.
'_price'
,
$this
->
price
,
Yii
::
$app
->
params
[
'curl_cache_time'
][
'quotation'
]);
Yii
::
$app
->
params
[
'curl_cache_time'
][
'quotation'
]);
}
else
{
}
else
{
...
@@ -80,7 +82,7 @@ class CoinService extends Coin implements CoinInterface
...
@@ -80,7 +82,7 @@ class CoinService extends Coin implements CoinInterface
preg_match_all
(
'/<div class=sub><span>(.*?)<\/span>(.*?)<span>(.*?)<\/span><\/div>/is'
,
$this
->
content
,
preg_match_all
(
'/<div class=sub><span>(.*?)<\/span>(.*?)<span>(.*?)<\/span><\/div>/is'
,
$this
->
content
,
$matchs
,
$matchs
,
PREG_SET_ORDER
);
PREG_SET_ORDER
);
$this
->
setDollar
(
$matchs
[
0
][
1
]
);
$this
->
setDollar
(
str_replace
([
'$'
,
'≈'
,
','
],
''
,
$matchs
[
0
][
1
])
);
Yii
::
$app
->
cache
->
set
(
$this
->
cache_key_prifx
.
$this
->
sid
.
'_usd'
,
$this
->
dollar
,
Yii
::
$app
->
cache
->
set
(
$this
->
cache_key_prifx
.
$this
->
sid
.
'_usd'
,
$this
->
dollar
,
Yii
::
$app
->
params
[
'curl_cache_time'
][
'quotation'
]);
Yii
::
$app
->
params
[
'curl_cache_time'
][
'quotation'
]);
}
else
{
}
else
{
...
@@ -556,6 +558,7 @@ class CoinService extends Coin implements CoinInterface
...
@@ -556,6 +558,7 @@ class CoinService extends Coin implements CoinInterface
$result
=
array_map
(
function
(
$value
)
{
$result
=
array_map
(
function
(
$value
)
{
return
trim
(
$value
);
return
trim
(
$value
);
},
$result
);
},
$result
);
Yii
::
$app
->
cache
->
set
(
$key
,
$result
,
Yii
::
$app
->
params
[
'curl_cache_time'
][
'quotation'
]);
//set cache
Yii
::
$app
->
cache
->
set
(
$key
,
$result
,
Yii
::
$app
->
params
[
'curl_cache_time'
][
'quotation'
]);
//set cache
return
$result
;
return
$result
;
}
catch
(
\Exception
$exception
)
{
}
catch
(
\Exception
$exception
)
{
...
...
common/service/coin/CoinYCCService.php
View file @
cdcf8bd2
...
@@ -66,7 +66,7 @@ class CoinYCCService extends Coin implements CoinInterface
...
@@ -66,7 +66,7 @@ class CoinYCCService extends Coin implements CoinInterface
public
function
getPrice
()
public
function
getPrice
()
{
{
return
"
¥
0.2"
;
return
"0.2"
;
}
}
public
function
setPrice
(
$price
)
public
function
setPrice
(
$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