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
45c902dd
Commit
45c902dd
authored
Aug 05, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into 'master'
Feature/optimize See merge request
!77
parents
af4b7bda
901c8e50
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
20 deletions
+41
-20
CoinController.php
api/controllers/CoinController.php
+10
-3
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+31
-17
No files found.
api/controllers/CoinController.php
View file @
45c902dd
...
@@ -223,9 +223,16 @@ class CoinController extends BaseController
...
@@ -223,9 +223,16 @@ class CoinController extends BaseController
return
[
'code'
=>
0
,
'data'
=>
[]];
return
[
'code'
=>
0
,
'data'
=>
[]];
}
}
foreach
(
$names
as
$key
=>
$val
)
{
foreach
(
$names
as
$key
=>
$val
)
{
$val_array
=
explode
(
','
,
$val
);
if
(
strpos
(
$val
,
','
)
!==
false
){
if
(
count
(
$val_array
)
<
2
)
continue
;
$val_array
=
explode
(
','
,
$val
);
$condition
[]
=
[
$val_array
[
0
],
$val_array
[
1
]];
if
(
'USDT'
==
strtoupper
(
$val_array
[
0
])
&&
'BTC'
==
strtoupper
(
$val_array
[
1
]))
{
$condition
[]
=
[
$val_array
[
0
],
'omni'
];
continue
;
}
$condition
[]
=
[
$val_array
[
0
],
$val_array
[
1
]];
}
else
{
$condition
[]
=
$val
;
}
}
}
$result
=
ExchangeBusiness
::
getApiListForIndex
(
1
,
999
,
$condition
);
$result
=
ExchangeBusiness
::
getApiListForIndex
(
1
,
999
,
$condition
);
if
(
$result
)
{
if
(
$result
)
{
...
...
common/business/ExchangeBusiness.php
View file @
45c902dd
...
@@ -101,49 +101,52 @@ class ExchangeBusiness
...
@@ -101,49 +101,52 @@ class ExchangeBusiness
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Ex"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Ex"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'USDT'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'GM'
,
'BSTC'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'GM'
,
'BSTC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Token7"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Token7"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'HA'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'HA'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'BECC'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'BECC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"S"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"S"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'ST'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'ST'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'GHP'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'GHP'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Zg"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Zg"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNZ'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNZ'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'SFT'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'SFT'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Zhaobi"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Zhaobi"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNY'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNY'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]);
$quotation
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]);
$quotation
[
'last'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'CTG'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'CTG'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Gdpro"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Gdpro"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNY'
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNY'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'USDT'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'USDT'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'USD'
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'USD'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]);
goto
doEnd
;
goto
doEnd
;
}
}
...
@@ -154,7 +157,7 @@ class ExchangeBusiness
...
@@ -154,7 +157,7 @@ class ExchangeBusiness
'low'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]
/
100
),
'low'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]
/
100
),
'high'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
/
100
),
'high'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
/
100
),
'last'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
100
),
'last'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
100
),
'rmb'
=>
(
float
)
sprintf
(
"%0.
4
f"
,
$quotation
[
'last'
]
/
100
),
'rmb'
=>
(
float
)
sprintf
(
"%0.
2
f"
,
$quotation
[
'last'
]
/
100
),
];
];
goto
doEnd
;
goto
doEnd
;
}
}
...
@@ -216,7 +219,12 @@ class ExchangeBusiness
...
@@ -216,7 +219,12 @@ class ExchangeBusiness
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$cny_usd_rate
=
1
/
$rate
[
'last'
];
$cny_usd_rate
=
1
/
$rate
[
'last'
];
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'rmb'
]
*
$cny_usd_rate
);
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
]))
{
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
$cny_usd_rate
);
}
else
{
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'rmb'
]
*
$cny_usd_rate
);
}
return
$quotation
;
return
$quotation
;
}
}
...
@@ -260,19 +268,25 @@ class ExchangeBusiness
...
@@ -260,19 +268,25 @@ class ExchangeBusiness
*/
*/
public
static
function
getApiListForIndex
(
$page
=
1
,
$limit
=
999
,
$condition
=
[],
$fields
=
[])
public
static
function
getApiListForIndex
(
$page
=
1
,
$limit
=
999
,
$condition
=
[],
$fields
=
[])
{
{
foreach
(
$condition
as
$val
)
{
if
(
count
(
$condition
[
0
])
>
1
)
{
if
(
$val
[
1
]
==
'null'
){
foreach
(
$condition
as
$val
)
{
if
(
'null'
==
$val
[
1
]
||
'coin'
==
$val
[
1
])
{
$data
[]
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty'
)
->
where
([
'name'
=>
$val
[
0
]])
->
asArray
()
->
one
();
continue
;
}
$data
[]
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty'
)
$data
[]
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty'
)
->
where
([
'name'
=>
$val
[
0
]])
->
where
([
'name'
=>
$val
[
0
]])
->
andWhere
([
'platform'
=>
$val
[
1
]])
->
asArray
()
->
asArray
()
->
one
();
->
one
();
continue
;
}
}
$data
[]
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty'
)
}
else
{
->
where
([
'name'
=>
$val
[
0
]])
$data
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty'
)
->
andWhere
([
'platform'
=>
$val
[
1
]])
->
where
([
'in'
,
'name'
,
$condition
])
->
asArray
()
->
asArray
()
->
all
();
->
one
();
}
}
$rows
=
[
$rows
=
[
'count'
=>
count
(
$data
),
'count'
=>
count
(
$data
),
...
...
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