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
4fc3b6bb
Commit
4fc3b6bb
authored
Aug 20, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
112df354
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
21 deletions
+32
-21
NoticeController.php
api/controllers/NoticeController.php
+6
-1
FactoryService.php
common/service/exchange/factory/FactoryService.php
+0
-6
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+16
-7
WorkermanWebSocketController.php
console/controllers/WorkermanWebSocketController.php
+10
-7
No files found.
api/controllers/NoticeController.php
View file @
4fc3b6bb
...
...
@@ -70,6 +70,7 @@ class NoticeController extends BaseController
public
function
actionIndex
()
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
''
);
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
if
(
!
in_array
(
$exchange
,
$exchange_arr
))
{
...
...
@@ -78,8 +79,12 @@ class NoticeController extends BaseController
$data
=
[];
goto
doEnd
;
}
$params
=
[
'id'
=>
$id
,
'page'
=>
$page
];
$builder
=
ExchangeBuilderFactory
::
create
(
$exchange
);
$result
=
$builder
->
getNotice
(
$
id
);
$result
=
$builder
->
getNotice
(
$
params
);
$code
=
$result
[
'code'
];
$data
=
$result
[
'notice'
];
$msg
=
isset
(
$result
[
'msg'
])
?
$result
[
'msg'
]
:
'success'
;
...
...
common/service/exchange/factory/FactoryService.php
View file @
4fc3b6bb
...
...
@@ -38,9 +38,4 @@ abstract class FactoryService
$this
->
basic_price
[
$val
[
'name'
]]
=
$val
[
'rmb'
];
}
}
public
function
symbolPrice
(
$symbol
=
'ETH'
)
{
}
}
\ No newline at end of file
common/service/exchange/factory/ZhaobiBuilder.php
View file @
4fc3b6bb
...
...
@@ -47,27 +47,35 @@ class ZhaobiBuilder extends FactoryService
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
}
public
function
getNotice
(
$
id
=
''
)
public
function
getNotice
(
$
params
=
[]
)
{
$curl
=
new
Curl
();
if
(
!
empty
(
$id
))
{
$api
=
$this
->
base_url
.
'/api/data/noticedetail?id='
.
$
id
;
if
(
isset
(
$params
[
'id'
])
&&
!
empty
(
$params
[
'id'
]
))
{
$api
=
$this
->
base_url
.
'/api/data/noticedetail?id='
.
$
params
[
'id'
]
;
$res
=
$curl
->
get
(
$api
,
false
);
if
(
isset
(
$res
[
'message'
])
&&
'OK'
==
$res
[
'message'
])
{
$this
->
code
=
0
;
$res
[
'data'
][
'abstract'
]
=
str_replace
(
' '
,
''
,
str_replace
(
' '
,
''
,
$res
[
'data'
][
'abstract'
]));
$res
[
'data'
][
'content'
]
=
str_replace
(
' '
,
''
,
str_replace
(
' '
,
''
,
$res
[
'data'
][
'content'
]));
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$res
[
'data'
]];
}
else
{
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$res
[
'data'
],
'msg'
=>
$res
[
'message'
]];
}
}
$api
=
$this
->
base_url
.
'/api/data/noticelist
'
;
$api
=
$this
->
base_url
.
'/api/data/noticelist
?page='
.
$params
[
'page'
]
;
$res
=
$curl
->
get
(
$api
,
false
);
$notice
=
[];
if
(
isset
(
$res
[
'message'
])
&&
'OK'
==
$res
[
'message'
])
{
$this
->
code
=
0
;
$notice
=
$res
[
'data'
][
'rows'
];
$notices
=
$res
[
'data'
][
'rows'
];
foreach
(
$notices
as
&
$notice
)
{
$notice
[
'abstract'
]
=
str_replace
(
' '
,
''
,
str_replace
(
' '
,
''
,
$notice
[
'abstract'
]));
}
$data
=
[
'list'
=>
$notices
,
'count'
=>
$res
[
'data'
][
'count'
]
];
}
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$
notice
];
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$
data
];
}
}
\ No newline at end of file
console/controllers/WorkermanWebSocketController.php
View file @
4fc3b6bb
...
...
@@ -74,7 +74,7 @@ class WorkermanWebSocketController extends Controller
$con
->
transport
=
'ssl'
;
$con
->
onMessage
=
function
(
$con
,
$data
)
use
(
$connection
)
{
$base_coin
=
[
'ETH'
,
'BTC'
,
'USDT'
,
'BT
C
'
'ETH'
,
'BTC'
,
'USDT'
,
'BT
Y
'
];
$result
=
json_decode
(
$data
,
true
);
$ticker
=
[];
...
...
@@ -82,12 +82,15 @@ class WorkermanWebSocketController extends Controller
foreach
(
$base_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
$coin
,
$val
[
's'
]);
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
$ticker
[
$val
[
's'
]][
'symbol'
]
=
$explode_arr
[
0
]
.
'/'
.
$coin
;
$ticker
[
$val
[
's'
]][
'close'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'c'
]);
$ticker
[
$val
[
's'
]][
'change'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'p'
]
*
100
);
$ticker
[
$val
[
's'
]][
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'h'
]);
$ticker
[
$val
[
's'
]][
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'l'
]);
$ticker
[
$val
[
's'
]][
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'v'
]);
$temp
=
[];
$temp
[
'symbol'
]
=
$explode_arr
[
0
]
.
'/'
.
$coin
;
$temp
[
'close'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'c'
]);
$temp
[
'change'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'p'
]
*
100
);
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'h'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'l'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'v'
]);
array_push
(
$ticker
,
$temp
);
break
;
}
}
}
...
...
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