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
b627fbda
Commit
b627fbda
authored
5 years ago
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature/issue_coin
parents
a20a540a
f837e880
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
11 deletions
+25
-11
TickerController.php
api/controllers/TickerController.php
+11
-3
CoinBannerItem.php
common/models/psources/CoinBannerItem.php
+5
-2
BitnasdaqBuilder.php
common/service/exchange/factory/BitnasdaqBuilder.php
+3
-3
FactoryService.php
common/service/exchange/factory/FactoryService.php
+3
-2
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+3
-1
No files found.
api/controllers/TickerController.php
View file @
b627fbda
...
@@ -14,7 +14,7 @@ use common\service\exchange\ExchangeBuilderFactory;
...
@@ -14,7 +14,7 @@ use common\service\exchange\ExchangeBuilderFactory;
class
TickerController
extends
BaseController
class
TickerController
extends
BaseController
{
{
protected
$basic_coin
=
[
'ETH'
,
'BTC'
,
'USDT'
,
'BTY'
];
protected
$basic_coin
=
[
'ETH'
,
'BTC'
,
'USDT'
,
'BTY'
,
'CNYT'
];
protected
$basic_price
=
[];
protected
$basic_price
=
[];
public
function
actionIndex
()
public
function
actionIndex
()
...
@@ -76,6 +76,7 @@ class TickerController extends BaseController
...
@@ -76,6 +76,7 @@ class TickerController extends BaseController
"btc,btc"
,
"btc,btc"
,
"usdt,ethereum"
,
"usdt,ethereum"
,
"bty,bty"
,
"bty,bty"
,
"cnyt,bitnasdaqchain"
]
]
];
];
$params
=
json_encode
(
$data
);
$params
=
json_encode
(
$data
);
...
@@ -103,7 +104,7 @@ class TickerController extends BaseController
...
@@ -103,7 +104,7 @@ class TickerController extends BaseController
$msg
=
'参数错误'
;
$msg
=
'参数错误'
;
goto
doEnd
;
goto
doEnd
;
}
}
$model
=
CoinOptional
::
find
()
->
where
([
'device_code'
=>
$device_code
,
'symbol'
=>
$symbol
,
'platform_id'
=>
(
int
)
$platform_id
])
->
one
();
$model
=
CoinOptional
::
find
()
->
where
([
'device_code'
=>
$device_code
,
'symbol'
=>
$symbol
,
'platform
'
=>
$platform
,
'platform
_id'
=>
(
int
)
$platform_id
])
->
one
();
if
(
$model
)
{
if
(
$model
)
{
$msg
=
'数据已存在!'
;
$msg
=
'数据已存在!'
;
goto
doEnd
;
goto
doEnd
;
...
@@ -164,13 +165,16 @@ class TickerController extends BaseController
...
@@ -164,13 +165,16 @@ class TickerController extends BaseController
$exchange
=
'Binance'
;
$exchange
=
'Binance'
;
}
else
if
(
'zhaobi'
==
$val
[
'platform'
])
{
}
else
if
(
'zhaobi'
==
$val
[
'platform'
])
{
$exchange
=
'Zhaobi'
;
$exchange
=
'Zhaobi'
;
}
else
if
(
'bitnasdaq'
==
strtolower
(
$val
[
'platform'
]))
{
$exchange
=
'Bitnasdaq'
;
}
else
{
}
else
{
}
}
$symbol
=
explode
(
'/'
,
$val
[
'symbol'
]);
$symbol
=
explode
(
'/'
,
$val
[
'symbol'
]);
$tag_first
=
$currency
=
$symbol
[
0
];
$tag_first
=
$currency
=
$symbol
[
0
];
$tag_second
=
$symbol
[
1
];
$tag_second
=
$symbol
[
1
];
if
(
'BCH'
==
strtoupper
(
$tag_first
)){
if
(
'BCH'
==
strtoupper
(
$tag_first
))
{
$tag_first
=
'BCC'
;
$tag_first
=
'BCC'
;
}
}
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
...
@@ -201,6 +205,10 @@ class TickerController extends BaseController
...
@@ -201,6 +205,10 @@ class TickerController extends BaseController
$temp
[
'platform_zh'
]
=
'币安'
;
$temp
[
'platform_zh'
]
=
'币安'
;
$temp
[
'platform_us'
]
=
'binance'
;
$temp
[
'platform_us'
]
=
'binance'
;
}
}
if
(
'BITNASDAQ'
==
strtoupper
(
$val
[
'platform'
]))
{
$temp
[
'platform_zh'
]
=
'比特纳斯达克'
;
$temp
[
'platform_us'
]
=
'bitnasdaq'
;
}
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
}
}
if
(
!
empty
(
$condition
))
{
if
(
!
empty
(
$condition
))
{
...
...
This diff is collapsed.
Click to expand it.
common/models/psources/CoinBannerItem.php
View file @
b627fbda
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
* Date: 2018/12/18
* Date: 2018/12/18
* Time: 16:56
* Time: 16:56
*/
*/
namespace
common\models\psources
;
namespace
common\models\psources
;
use
common\core\BaseActiveRecord
;
use
common\core\BaseActiveRecord
;
...
@@ -30,8 +31,9 @@ class CoinBannerItem extends BaseActiveRecord
...
@@ -30,8 +31,9 @@ class CoinBannerItem extends BaseActiveRecord
{
{
return
[
return
[
[[
'image_url'
,
'platform_id'
],
'required'
],
[[
'image_url'
,
'platform_id'
],
'required'
],
[
'banner_url'
,
'default'
,
'value'
=>
'#'
],
[[
'banner_url'
,
'title'
],
'safe'
],
[[
'banner_url'
,
'title'
],
'safe'
],
[[
'
banner_url'
,
'
image_url'
],
'url'
]
[[
'image_url'
],
'url'
]
];
];
}
}
...
@@ -57,6 +59,6 @@ class CoinBannerItem extends BaseActiveRecord
...
@@ -57,6 +59,6 @@ class CoinBannerItem extends BaseActiveRecord
public
function
getPlatform
()
public
function
getPlatform
()
{
{
return
$this
->
hasOne
(
CoinPlatform
::
className
(),
[
'id'
=>
'platform_id'
]);
return
$this
->
hasOne
(
CoinPlatform
::
className
(),
[
'id'
=>
'platform_id'
]);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
common/service/exchange/factory/BitnasdaqBuilder.php
View file @
b627fbda
...
@@ -34,7 +34,7 @@ class BitnasdaqBuilder extends FactoryService
...
@@ -34,7 +34,7 @@ class BitnasdaqBuilder extends FactoryService
$keys
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
$keys
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
false
==
$this
->
redis
->
exists
(
$this
->
supported_symbol_list
))
{
if
(
false
==
$this
->
redis
->
exists
(
$this
->
supported_symbol_list
))
{
foreach
(
$keys
as
$val
)
{
foreach
(
$keys
as
$val
)
{
if
(
in_array
(
strtoupper
(
$val
),
[
'BNCUSDT'
,
'BTCUSDT'
,
'CNYTUSDT'
,
'ETCUSDT'
,
'ETHUSDT'
,
'GHPUSDT'
,
'LTCUSD
T'
]))
{
if
(
in_array
(
strtoupper
(
$val
),
[
'BNCUSDT'
,
'BTCUSDT'
,
'CNYTUSDT'
,
'ETCUSDT'
,
'ETHUSDT'
,
'GHPUSDT'
,
'LTCUSDT'
,
'BTCCNYT'
,
'ETCCNYT'
,
'ETHCNYT'
,
'GHPCNYT'
,
'LTCCNY
T'
]))
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_list
,
strtoupper
(
$val
));
$this
->
redis
->
lpush
(
$this
->
supported_symbol_list
,
strtoupper
(
$val
));
}
}
}
}
...
@@ -73,8 +73,8 @@ class BitnasdaqBuilder extends FactoryService
...
@@ -73,8 +73,8 @@ class BitnasdaqBuilder extends FactoryService
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$close
)),
'0'
);
$temp
[
'close'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$close
)),
'0'
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$close
*
$this
->
basic_price
[
$coin
][
'usd'
])),
'0'
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$close
*
$this
->
basic_price
[
$coin
][
'usd'
])),
'0'
);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
false
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'change'
]
=
(
false
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'usd'
]);
...
...
This diff is collapsed.
Click to expand it.
common/service/exchange/factory/FactoryService.php
View file @
b627fbda
...
@@ -13,7 +13,7 @@ use linslin\yii2\curl\Curl;
...
@@ -13,7 +13,7 @@ use linslin\yii2\curl\Curl;
abstract
class
FactoryService
abstract
class
FactoryService
{
{
protected
$code
=
-
1
;
protected
$code
=
-
1
;
protected
$basic_coin
=
[
'ETH'
,
'BTC'
,
'USDT'
,
'BTY'
];
protected
$basic_coin
=
[
'ETH'
,
'BTC'
,
'USDT'
,
'BTY'
,
'CNYT'
];
protected
$basic_price
=
[];
protected
$basic_price
=
[];
protected
$redis
;
protected
$redis
;
...
@@ -30,7 +30,8 @@ abstract class FactoryService
...
@@ -30,7 +30,8 @@ abstract class FactoryService
"eth,ethereum"
,
"eth,ethereum"
,
"btc,btc"
,
"btc,btc"
,
"usdt,ethereum"
,
"usdt,ethereum"
,
"bty,bty"
"bty,bty"
,
"cnyt,bitnasdaqchain"
]
]
];
];
$params
=
json_encode
(
$data
);
$params
=
json_encode
(
$data
);
...
...
This diff is collapsed.
Click to expand it.
common/service/exchange/factory/ZhaobiBuilder.php
View file @
b627fbda
...
@@ -108,13 +108,15 @@ class ZhaobiBuilder extends FactoryService
...
@@ -108,13 +108,15 @@ class ZhaobiBuilder extends FactoryService
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
}
}
if
(
'SFTCNY'
==
strtoupper
(
$symbol
))
{
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
1
);
}
}
}
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
$key
=
$this
->
quotation_prefix
.
strtoupper
(
$symbol
);
$key
=
$this
->
quotation_prefix
.
strtoupper
(
$symbol
);
$this
->
redis_ticker
->
hmset
(
$key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$close
,
'open'
,
$open
,
'vol'
,
$vol
);
$this
->
redis_ticker
->
hmset
(
$key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$close
,
'open'
,
$open
,
'vol'
,
$vol
);
}
}
$ticker_sort_close
=
Tools
::
arraySort
(
$ticker
,
'close_rmb'
);
$ticker_sort_close
=
Tools
::
arraySort
(
$ticker
,
'close_rmb'
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_desc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_desc
);
...
...
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