Commit b804c441 authored by rlgy's avatar rlgy

首页接口v2

parent c4a45aed
......@@ -10,6 +10,7 @@ namespace common\business;
use common\models\pwallet\Coin;
use common\service\exchange\ExchangeFactory;
use common\service\coin\CoinFactory;
/**
* Class ExchangeBusiness
......@@ -22,6 +23,8 @@ class ExchangeBusiness
0 => 'HuoBi',
1 => 'Hadax',
2 => 'Bitfinex',
3 => 'Bittrex',
4 => 'Zb',
];
/**
......@@ -96,10 +99,21 @@ class ExchangeBusiness
}, $price_btc, $btc_usd);
$rows[$key] = array_merge($rows[$key],
['low' => $result[0], 'high' => $result[1], 'last' => $result[2]]);
$f = true;
break;
}
}
}
if (!$f) {
//使用Coin服务
$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]['high'] = $coinServer->getHigh();
$coinServer->__destruct();
}
}
return $rows;
}
......
......@@ -125,7 +125,7 @@ class CoinBTYService extends Coin implements CoinInterface
public function setHigh($high)
{
return $this->high = "\$$high";
return $this->high = $high;
}
public function getLow()
......@@ -140,7 +140,7 @@ class CoinBTYService extends Coin implements CoinInterface
public function setLow($low)
{
$this->low = "\$$low";
$this->low = $low;
}
public function getChange()
......
......@@ -16,6 +16,15 @@ class Bitfinex extends Exchange implements ExchangeInterface
protected $supported_symbol = 'supported_symbol_bitfinex';
protected $quotation_prefix = 'quotation_bitfinex_';
public function symbolExists($tag = 'BTC', $aim = "USD")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
return true;
}
return false;
}
public function formatSymbol($tag = 'BTC', $aim = 'USD')
{
return 't' . strtoupper(trim($tag) . trim($aim));
......
......@@ -49,7 +49,7 @@ abstract class Exchange
* @param string $aim
* @return mixed
*/
abstract public function formatSymbol($tag = 'BTC', $aim = 'USD');
abstract public function formatSymbol($tag = 'BTC', $aim = 'USDT');
/**
* 获取支持查询行情的交易对
......@@ -58,7 +58,7 @@ abstract class Exchange
* @param string $aim
* @return bool
*/
public function symbolExists($tag = 'BTC', $aim = "USD")
public function symbolExists($tag = 'BTC', $aim = "USDT")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
......
......@@ -37,8 +37,8 @@ class ExchangeController extends Controller
public function actionTest()
{
$a = new \common\service\exchange\Bittrex();
// $a->setSupportedSymbol();
$a = new \common\service\exchange\Zb();
$a->setSupportedSymbol();
$a->setQuotation();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment