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
2434dfc7
Commit
2434dfc7
authored
Jul 19, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ucenter' into 'master'
fix See merge request
!58
parents
231dcb10
79e4e7de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
58 deletions
+68
-58
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+67
-57
CoinAirDropTrade.php
common/models/psources/CoinAirDropTrade.php
+1
-1
No files found.
common/business/ExchangeBusiness.php
View file @
2434dfc7
...
...
@@ -51,17 +51,17 @@ class ExchangeBusiness
public
static
function
getquatation
(
$tag
=
'btc'
)
{
$coin_quotation_disable_items
=
Yii
::
$app
->
params
[
'coin_quotation_disable_items'
];
if
(
strtoupper
(
$tag
)
==
'CCNY'
)
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Bty"
);
$rate
=
$exchange
->
getTicker
(
"BTY"
,
"USDT"
);
$rate
=
(
float
)
$rate
[
'rmb'
]
/
$rate
[
'last'
];
if
(
strtoupper
(
$tag
)
==
'CCNY'
)
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Bty"
);
$rate
=
$exchange
->
getTicker
(
"BTY"
,
"USDT"
);
$rate
=
(
float
)
$rate
[
'rmb'
]
/
$rate
[
'last'
];
$quotation
[
'rmb'
]
=
1.00
;
$quotation
[
'low'
]
=
1.00
;
$quotation
[
'high'
]
=
1.00
;
$quotation
[
'last'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'rmb'
]
/
$rate
);
$quotation
[
'last'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'rmb'
]
/
$rate
);
goto
doEnd
;
}
if
(
strtoupper
(
$tag
)
==
'BOSS'
)
{
if
(
strtoupper
(
$tag
)
==
'BOSS'
)
{
$quotation
=
[
'low'
=>
2000
,
'high'
=>
2000
,
...
...
@@ -71,7 +71,7 @@ class ExchangeBusiness
goto
doEnd
;
}
if
(
strtoupper
(
$tag
)
==
'CPF'
)
{
if
(
strtoupper
(
$tag
)
==
'CPF'
)
{
$quotation
=
[
'low'
=>
3.4
,
'high'
=>
3.4
,
...
...
@@ -81,62 +81,72 @@ class ExchangeBusiness
goto
doEnd
;
}
if
(
in_array
(
$tag
,
$coin_quotation_disable_items
)){
if
(
strtoupper
(
$tag
)
==
'WL'
||
strtoupper
(
$tag
)
==
'ETS'
||
strtoupper
(
$tag
)
==
'LIMS'
||
strtoupper
(
$tag
)
==
'AT'
||
strtoupper
(
$tag
)
==
'BTJ'
)
{
$quotation
=
[
'low'
=>
0
,
'high'
=>
0
,
'last'
=>
0
,
'rmb'
=>
0
,
];
goto
doEnd
;
}
if
(
in_array
(
$tag
,
$coin_quotation_disable_items
))
{
return
false
;
}
$f
=
false
;
$f
=
false
;
$quotation
=
[];
if
(
in_array
(
strtoupper
(
$tag
),[
'GM'
,
'BSTC'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'GM'
,
'BSTC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Token7"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'HA'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]);
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),[
'BECC'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'BECC'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"S"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'ST'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]);
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),[
'GHP'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'GHP'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Zg"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNZ'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]);
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),[
'SFT'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'SFT'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Zhaobi"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNY'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]);
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),[
'CTG'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'CTG'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Gdpro"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNY'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]);
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),[
'USDT'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'USDT'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'USD'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]);
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),[
'SJPY'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'SJPY'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Boc"
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'JPY'
);
$quotation
=
[
'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.4f"
,
$quotation
[
'last'
]
/
100
),
'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.4f"
,
$quotation
[
'last'
]
/
100
),
];
goto
doEnd
;
}
...
...
@@ -148,7 +158,7 @@ class ExchangeBusiness
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
if
(
$exchange
->
symbolExists
(
$tag
))
{
$quotation
=
$exchange
->
getTicker
(
$tag
);
$f
=
true
;
$f
=
true
;
break
;
}
}
...
...
@@ -164,11 +174,11 @@ class ExchangeBusiness
if
(
$exchange
->
symbolExists
(
$tag
,
'btc'
))
{
$price_btc
=
$exchange
->
getTicker
(
$tag
,
'btc'
);
//获取btcusdt
$result
=
array_map
(
function
(
$a
,
$b
)
{
$result
=
array_map
(
function
(
$a
,
$b
)
{
return
$a
*
$b
;
},
$price_btc
,
$btc_usd
);
$quotation
=
[
'low'
=>
$result
[
0
],
'high'
=>
$result
[
1
],
'last'
=>
$result
[
2
]];
$f
=
true
;
$f
=
true
;
break
;
}
}
...
...
@@ -184,20 +194,20 @@ class ExchangeBusiness
/**
* @var $exchange \common\service\exchange\Exchange
*/
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$rate
=
$rate
[
'last'
]
??
''
;
if
(
empty
(
$rate
))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Bty"
);
$rate
=
$exchange
->
getTicker
(
"BTY"
,
"USDT"
);
$rate
=
(
float
)
$rate
[
'rmb'
]
/
$rate
[
'last'
];
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$rate
=
$rate
[
'last'
]
??
''
;
if
(
empty
(
$rate
))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Bty"
);
$rate
=
$exchange
->
getTicker
(
"BTY"
,
"USDT"
);
$rate
=
(
float
)
$rate
[
'rmb'
]
/
$rate
[
'last'
];
}
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$rate
*
$quotation
[
'last'
]);
doEnd
:
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$cny_usd_rate
=
1
/
$rate
[
'last'
];
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$cny_usd_rate
=
1
/
$rate
[
'last'
];
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'rmb'
]
*
$cny_usd_rate
);
return
$quotation
;
}
...
...
@@ -240,12 +250,12 @@ class ExchangeBusiness
* @param array $condition 需要的币种sid列表
* @return array
*/
public
static
function
getApiListForIndex
(
$page
=
1
,
$limit
=
999
,
$condition
=
[],
$fields
=
[])
public
static
function
getApiListForIndex
(
$page
=
1
,
$limit
=
999
,
$condition
=
[],
$fields
=
[])
{
if
(
!
$fields
)
{
$fields
=
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
,
'platform'
,
'chain'
,
'address as contract_address'
,
'treaty'
];
if
(
!
$fields
)
{
$fields
=
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
,
'platform'
,
'chain'
,
'address as contract_address'
,
'treaty'
];
}
$rows
=
Coin
::
getSelectList
(
$page
,
$limit
,
$fields
,
$condition
);
$rows
=
Coin
::
getSelectList
(
$page
,
$limit
,
$fields
,
$condition
);
$count
=
0
;
if
(
!
empty
(
$rows
)
&&
is_array
(
$rows
)
&&
array_key_exists
(
'count'
,
$rows
))
{
$count
=
$rows
[
'count'
];
...
...
@@ -254,29 +264,29 @@ class ExchangeBusiness
$rows
=
$rows
[
'data'
];
foreach
(
$rows
as
$key
=>
$row
)
{
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
$quotation
=
self
::
getquatation
(
$row
[
'name'
]);
$quotation
=
self
::
getquatation
(
$row
[
'name'
]);
if
(
!
$quotation
)
{
$quotation
=
[];
if
(
in_array
(
$row
[
'name'
],
[
'BTY'
,
'YCC'
]))
{
$coinServer
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
$rows
[
$key
][
'rmb'
]
=
$coinServer
->
getPrice
();
if
(
in_array
(
$row
[
'name'
],
[
'BTY'
,
'YCC'
]))
{
$coinServer
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
$rows
[
$key
][
'rmb'
]
=
$coinServer
->
getPrice
();
$rows
[
$key
][
'last'
]
=
$coinServer
->
getDollar
();
$rows
[
$key
][
'low'
]
=
$coinServer
->
getLow
();
$rows
[
$key
][
'low'
]
=
$coinServer
->
getLow
();
$rows
[
$key
][
'high'
]
=
$coinServer
->
getHigh
();
$coinServer
->
__destruct
();
}
else
{
$rows
[
$key
][
'rmb'
]
=
0
;
$rows
[
$key
][
'rmb'
]
=
0
;
$rows
[
$key
][
'last'
]
=
0
;
$rows
[
$key
][
'low'
]
=
0
;
$rows
[
$key
][
'low'
]
=
0
;
$rows
[
$key
][
'high'
]
=
0
;
$rows
[
$key
][
'usd'
]
=
0
;
}
}
if
(
strtoupper
(
$row
[
'platform'
])
==
'GUODUN'
)
{
$rows
[
$key
][
'rmb'
]
=
0
;
$rows
[
$key
][
'rmb'
]
=
0
;
$rows
[
$key
][
'last'
]
=
0
;
$rows
[
$key
][
'low'
]
=
0
;
$rows
[
$key
][
'low'
]
=
0
;
$rows
[
$key
][
'high'
]
=
0
;
}
else
{
$rows
[
$key
]
=
array_merge
(
$rows
[
$key
],
$quotation
);
...
...
@@ -290,22 +300,22 @@ class ExchangeBusiness
/**
* 根据名称搜索
*
* @param int
$page
* @param int
$limit
* @param int $page
* @param int $limit
* @param array $condition
* @return array|\yii\db\ActiveRecord|\yii\db\ActiveRecord[]
*/
public
static
function
SearchByName
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
{
$rows
=
Coin
::
getSelectList
(
$page
,
$limit
,
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
,
'platform'
,
'chain'
,
'address as contract_address'
,
'treaty'
],
$rows
=
Coin
::
getSelectList
(
$page
,
$limit
,
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
,
'platform'
,
'chain'
,
'address as contract_address'
,
'treaty'
],
$condition
);
if
(
$rows
[
'count'
]
>
0
)
{
$total
=
$rows
[
'count'
];
$rows
=
$rows
[
'data'
];
$rows
=
$rows
[
'data'
];
foreach
(
$rows
as
$key
=>
$row
)
{
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
$platform
=
strtoupper
(
$rows
[
$key
][
'platform'
]);
$platform_icon
=
Yii
::
$app
->
redis
->
hget
(
'platform_image_info'
,
$platform
);
$platform_icon
=
Yii
::
$app
->
redis
->
hget
(
'platform_image_info'
,
$platform
);
$rows
[
$key
][
'platform_icon'
]
=
$platform_icon
??
''
;
}
...
...
@@ -323,16 +333,16 @@ class ExchangeBusiness
$quotation
=
[];
//使用Coin服务
try
{
$coinServer
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$quotation
[
'rmb'
]
=
$coinServer
->
getPrice
();
$coinServer
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$quotation
[
'rmb'
]
=
$coinServer
->
getPrice
();
$quotation
[
'last'
]
=
$coinServer
->
getDollar
();
$quotation
[
'low'
]
=
$coinServer
->
getLow
();
$quotation
[
'low'
]
=
$coinServer
->
getLow
();
$quotation
[
'high'
]
=
$coinServer
->
getHigh
();
$coinServer
->
__destruct
();
}
catch
(
\Exception
$exception
)
{
$quotation
[
'rmb'
]
=
0
;
$quotation
[
'rmb'
]
=
0
;
$quotation
[
'last'
]
=
0
;
$quotation
[
'low'
]
=
0
;
$quotation
[
'low'
]
=
0
;
$quotation
[
'high'
]
=
0
;
\Yii
::
error
(
$exception
->
getMessage
());
}
...
...
common/models/psources/CoinAirDropTrade.php
View file @
2434dfc7
...
...
@@ -10,7 +10,7 @@ class CoinAirDropTrade extends BaseActiveRecord
{
const
TYPE_GAME
=
1
;
const
AMOUNT_GAME
=
0.
5
;
const
AMOUNT_GAME
=
0.
0001
;
public
static
function
getDb
()
{
...
...
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