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
674ffd86
Commit
674ffd86
authored
5 years ago
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature/ucenter
parents
bc82505f
45c902dd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
10 deletions
+31
-10
CoinController.php
api/controllers/CoinController.php
+8
-1
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+23
-9
No files found.
api/controllers/CoinController.php
View file @
674ffd86
...
...
@@ -223,9 +223,16 @@ class CoinController extends BaseController
return
[
'code'
=>
0
,
'data'
=>
[]];
}
foreach
(
$names
as
$key
=>
$val
)
{
if
(
strpos
(
$val
,
','
)
!==
false
){
$val_array
=
explode
(
','
,
$val
);
if
(
count
(
$val_array
)
<
2
)
continue
;
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
);
if
(
$result
)
{
...
...
This diff is collapsed.
Click to expand it.
common/business/ExchangeBusiness.php
View file @
674ffd86
...
...
@@ -101,49 +101,52 @@ class ExchangeBusiness
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Ex"
);
$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
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'GM'
,
'BSTC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Token7"
);
$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
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'BECC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"S"
);
$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
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'GHP'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Zg"
);
$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
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'SFT'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Zhaobi"
);
$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
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'CTG'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Gdpro"
);
$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
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'USDT'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$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
;
}
...
...
@@ -154,7 +157,7 @@ class ExchangeBusiness
'low'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]
/
100
),
'high'
=>
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
/
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
;
}
...
...
@@ -216,7 +219,12 @@ class ExchangeBusiness
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$cny_usd_rate
=
1
/
$rate
[
'last'
];
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
;
}
...
...
@@ -260,8 +268,9 @@ class ExchangeBusiness
*/
public
static
function
getApiListForIndex
(
$page
=
1
,
$limit
=
999
,
$condition
=
[],
$fields
=
[])
{
if
(
count
(
$condition
[
0
])
>
1
)
{
foreach
(
$condition
as
$val
)
{
if
(
$val
[
1
]
==
'null'
)
{
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
()
...
...
@@ -274,6 +283,11 @@ class ExchangeBusiness
->
asArray
()
->
one
();
}
}
else
{
$data
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty'
)
->
where
([
'in'
,
'name'
,
$condition
])
->
asArray
()
->
all
();
}
$rows
=
[
'count'
=>
count
(
$data
),
'data'
=>
$data
...
...
This diff is collapsed.
Click to expand it.
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