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
e03bbbc0
Commit
e03bbbc0
authored
Feb 10, 2020
by
shajiaming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into develop
parents
99dea189
f507a8ca
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
41 deletions
+40
-41
MarketController.php
api/controllers/MarketController.php
+22
-30
WalletChainController.php
api/controllers/WalletChainController.php
+1
-1
Bilaxy.php
common/service/exchange/Bilaxy.php
+17
-10
No files found.
api/controllers/MarketController.php
View file @
e03bbbc0
...
@@ -39,47 +39,38 @@ class MarketController extends BaseController
...
@@ -39,47 +39,38 @@ class MarketController extends BaseController
$currency
=
Yii
::
$app
->
request
->
post
(
'currency'
,
''
);
$currency
=
Yii
::
$app
->
request
->
post
(
'currency'
,
''
);
$base_currency
=
Yii
::
$app
->
request
->
post
(
'base_currency'
,
''
);
$base_currency
=
Yii
::
$app
->
request
->
post
(
'base_currency'
,
''
);
$exchange
=
Yii
::
$app
->
request
->
post
(
"exchange"
,
'Zhaobi'
);
$exchange
=
Yii
::
$app
->
request
->
post
(
"exchange"
,
'Zhaobi'
);
$base_exchange
=
Yii
::
$app
->
request
->
post
(
"base_exchange"
,
'Zhaobi'
);
if
(
false
==
$currency
||
false
==
$base_currency
)
{
if
(
false
==
$currency
||
false
==
$base_currency
)
{
$msg
=
'invalid symbol'
;
$
this
->
msg
=
'invalid symbol'
;
$code
=
-
1
;
$
this
->
code
=
-
1
;
goto
doEnd
;
goto
doEnd
;
}
}
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
$quotation
=
$exchange
->
getTicker
(
$currency
);
$currency_ticker
=
$exchange
->
getTicker
(
$currency
,
'USDT'
);
$quotation
=
[
$base_currency_ticker
=
$exchange
->
getTicker
(
$base_currency
,
'USDT'
);
'low'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]
/
100
),
if
(
empty
(
$currency_ticker
)
||
empty
(
$base_currency_ticker
))
{
'high'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
/
100
),
$this
->
code
=
-
1
;
'last'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
100
),
$this
->
msg
=
'此交易所暂不支持所选币种!'
;
'rmb'
=>
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]
/
100
),
goto
doEnd
;
}
$currency_quotation
=
[
'low'
=>
(
float
)
sprintf
(
"%0.4f"
,
$currency_ticker
[
'low'
]),
'high'
=>
(
float
)
sprintf
(
"%0.4f"
,
$currency_ticker
[
'high'
]),
'last'
=>
(
float
)
sprintf
(
"%0.4f"
,
$currency_ticker
[
'last'
]),
'rmb'
=>
(
float
)
sprintf
(
"%0.2f"
,
$currency_ticker
[
'last'
]),
];
];
echo
json_encode
(
$quotation
);
exit
;
$base_exchange
=
ExchangeFactory
::
createExchange
(
$base_exchange
);
$base_currency_quotation
=
[
$base_quotation
=
$base_exchange
->
getTicker
(
$base_currency
);
'low'
=>
(
float
)
sprintf
(
"%0.4f"
,
$base_currency_ticker
[
'low'
]),
$base_quotation
=
[
'high'
=>
(
float
)
sprintf
(
"%0.4f"
,
$base_currency_ticker
[
'high'
]),
'low'
=>
(
float
)
sprintf
(
"%0.4f"
,
$base_quotation
[
'low'
]
/
100
),
'last'
=>
(
float
)
sprintf
(
"%0.4f"
,
$base_currency_ticker
[
'last'
]),
'high'
=>
(
float
)
sprintf
(
"%0.4f"
,
$base_quotation
[
'high'
]
/
100
),
'rmb'
=>
(
float
)
sprintf
(
"%0.2f"
,
$base_currency_ticker
[
'last'
]),
'last'
=>
(
float
)
sprintf
(
"%0.4f"
,
$base_quotation
[
'last'
]
/
100
),
'rmb'
=>
(
float
)
sprintf
(
"%0.2f"
,
$base_quotation
[
'last'
]
/
100
),
];
];
$this
->
data
=
(
float
)
sprintf
(
"%0.4f"
,
$currency_quotation
[
'last'
]
/
$base_currency_quotation
[
'last'
]);
$builder
=
ExchangeBuilderFactory
::
create
(
'Zhaobi'
);
$result
=
$builder
->
getDetail
(
strtoupper
(
$currency
),
strtoupper
(
$base_currency
));
if
(
-
1
==
$result
[
'code'
])
{
$msg
=
'invalid symbol'
;
$code
=
-
1
;
goto
doEnd
;
}
$code
=
0
;
$msg
=
'ok'
;
$ticker
=
$result
[
'ticker'
];
doEnd
:
doEnd
:
return
[
'code'
=>
$
code
,
'msg'
=>
$msg
,
'tick'
=>
$ticker
??
[]
];
return
[
'code'
=>
$
this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
}
}
}
\ No newline at end of file
api/controllers/WalletChainController.php
View file @
e03bbbc0
...
@@ -36,7 +36,7 @@ class WalletChainController extends BaseController
...
@@ -36,7 +36,7 @@ class WalletChainController extends BaseController
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$query
=
WalletChain
::
find
()
$query
=
WalletChain
::
find
()
->
select
(
'id, token, platform, status'
)
->
select
(
'id, token, platform,
create_time,
status'
)
->
where
([
'wallet_address'
=>
$wallet_address
])
->
where
([
'wallet_address'
=>
$wallet_address
])
->
orderBy
(
'id'
);
->
orderBy
(
'id'
);
...
...
common/service/exchange/Bilaxy.php
View file @
e03bbbc0
...
@@ -8,7 +8,7 @@ class Bilaxy extends Exchange implements ExchangeInterface
...
@@ -8,7 +8,7 @@ class Bilaxy extends Exchange implements ExchangeInterface
{
{
protected
$supported_symbol
=
'supported_symbol_bilaxy'
;
protected
$supported_symbol
=
'supported_symbol_bilaxy'
;
protected
$quotation_prefix
=
'quotation_bilaxy_'
;
protected
$quotation_prefix
=
'quotation_bilaxy_'
;
protected
$base_url
=
'https://
api.bilaxy.com/v1/tickers
'
;
protected
$base_url
=
'https://
newapi.bilaxy.com/
'
;
public
function
symbolExists
(
$tag
=
'BVA'
,
$aim
=
"USDT"
)
public
function
symbolExists
(
$tag
=
'BVA'
,
$aim
=
"USDT"
)
...
@@ -38,7 +38,15 @@ class Bilaxy extends Exchange implements ExchangeInterface
...
@@ -38,7 +38,15 @@ class Bilaxy extends Exchange implements ExchangeInterface
*/
*/
public
function
setSupportedSymbol
()
public
function
setSupportedSymbol
()
{
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'BVA_USDT'
);
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/v1/ticker/24hr'
;
$content
=
$curl
->
get
(
$api
,
false
);
//json
if
(
is_array
(
$content
))
{
foreach
(
$content
as
$key
=>
$item
)
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtoupper
(
$key
));
}
}
}
}
/**
/**
...
@@ -49,14 +57,13 @@ class Bilaxy extends Exchange implements ExchangeInterface
...
@@ -49,14 +57,13 @@ class Bilaxy extends Exchange implements ExchangeInterface
public
function
setQuotation
()
public
function
setQuotation
()
{
{
$curl
=
new
Curl
();
$curl
=
new
Curl
();
$content
=
$curl
->
get
(
$this
->
base_url
,
false
);
$api
=
$this
->
base_url
.
'/v1/ticker/24hr'
;
if
(
is_array
(
$content
)
&&
isset
(
$content
[
'data'
]))
{
$content
=
$curl
->
get
(
$api
,
false
);
$data
=
$content
[
'data'
];
if
(
is_array
(
$content
))
{
$key
=
$this
->
quotation_prefix
.
'BVA_USDT'
;
foreach
(
$content
as
$key
=>
$item
)
{
foreach
(
$data
as
$item
)
{
$this
->
redis
->
hmset
(
$this
->
quotation_prefix
.
strtoupper
(
$key
),
'low'
,
$item
[
'low'
],
'high'
,
$item
[
'height'
],
'last'
,
$item
[
'close'
]);
if
(
260
==
$item
[
'symbol'
])
{
if
(
!
$this
->
redis
->
sismember
(
$this
->
supported_symbol
,
strtoupper
(
$key
))){
$this
->
redis
->
hmset
(
$key
,
'low'
,
$item
[
'low'
],
'high'
,
$item
[
'high'
],
'last'
,
$item
[
'last'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtoupper
(
$key
));
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'KPC8_USDT'
);
}
}
}
}
}
}
...
...
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