Commit dd51be96 authored by shajiaiming's avatar shajiaiming

修复已知问题

parent c8622bfc
......@@ -20,11 +20,19 @@ class TickerController extends BaseController
{
$page = Yii::$app->request->get('page', 1);
$device_code = Yii::$app->request->get('device_code', '');
$platform_id = Yii::$app->request->get('platform_id', '');
$exchange = Yii::$app->request->get('exchange', 'zhaobi');
$data_value = Yii::$app->request->get('data-value','');
$sort = Yii::$app->request->get('sort','');
$data_value = Yii::$app->request->get('data-value', '');
$sort = Yii::$app->request->get('sort', '');
$exchange_arr = ['huobi', 'binance', 'okex', 'zhaobi'];
if (false == $platform_id) {
$msg = '参数错误';
$code = -1;
$data = [];
goto doEnd;
}
if (!in_array($exchange, $exchange_arr)) {
$msg = '不存在的交易平台';
$code = -1;
......@@ -37,7 +45,7 @@ class TickerController extends BaseController
$data = $result['data'];
if (false != $device_code) {
$coin_optional = CoinOptional::find()->select('symbol')->where(['platform' => $exchange, 'device_code' => $device_code])->asArray()->all();
$coin_optional = CoinOptional::find()->select('symbol')->where(['platform' => $exchange, 'device_code' => $device_code, 'platform_id' => $platform_id])->asArray()->all();
$coin_optional = ArrayHelper::getColumn($coin_optional, 'symbol');
foreach ($data['ticker'] as &$val) {
if (in_array($val['symbol'], $coin_optional)) {
......@@ -82,8 +90,9 @@ class TickerController extends BaseController
$symbol = $request->post('symbol', '');
$platform = $request->post('platform', '');
$device_code = $request->post('device_code', '');
$platform_id = $request->post('platform_id', '');
if (empty($symbol) || empty($platform) || empty($device_code)) {
if (empty($symbol) || empty($platform) || empty($device_code) || empty($platform_id)) {
$msg = '参数错误';
goto doEnd;
}
......@@ -106,14 +115,15 @@ class TickerController extends BaseController
if ($request->isGet) {
$device_code = $request->get('device_code', '');
$platform_id = $request->get('platform_id', '');
$page = Yii::$app->request->get('page', 1);
if (empty($device_code)) {
if (false == $device_code || false == $platform_id) {
$msg = '参数错误';
goto doEnd;
}
$temp = [];
$query = CoinOptional::find()->select('symbol, platform')
->where(['device_code' => $device_code])
->where(['device_code' => $device_code, 'platform_id' => $platform_id])
->orderBy('update_time desc');
$data = $query->offset(($page - 1) * 50)->limit(50)->asArray()->all();
if (false == $data) {
......@@ -122,7 +132,7 @@ class TickerController extends BaseController
$data = [
'ticker' => [],
'page' => [
'pageSize' => 50,
'pageSize' => 50,
'currentPage' => (int)$page,
]
];
......@@ -145,7 +155,7 @@ class TickerController extends BaseController
$exchange = ExchangeFactory::createExchange($exchange);
$quotation = $exchange->getTicker(strtolower($tag_first), strtolower($tag_second));
if(empty($quotation)) continue;
if (empty($quotation)) continue;
$temp['symbol'] = $val['symbol'];
$temp['currency'] = strtoupper($tag_first);
$temp['base_currency'] = strtoupper($tag_second);
......@@ -179,7 +189,7 @@ class TickerController extends BaseController
$data = [
'ticker' => $ticker,
'page' => [
'pageSize' => 50,
'pageSize' => 50,
'currentPage' => (int)$page,
]
];
......
......@@ -21,16 +21,18 @@ class CoinOptional extends BaseActiveRecord
const SCENARIOS_CREATE = 'create';
public function rules() {
public function rules()
{
return [
[['symbol','platform', 'device_code'], 'required'],
[['symbol', 'platform', 'device_code', 'platform_id'], 'required'],
];
}
public function scenarios() {
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['symbol','platform', 'device_code'],
self:: SCENARIOS_CREATE => ['symbol', 'platform', 'device_code', 'platform_id'],
];
return array_merge( parent:: scenarios(), $scenarios);
return array_merge(parent:: scenarios(), $scenarios);
}
}
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