Commit d40b4c89 authored by shajiaiming's avatar shajiaiming

Merge branch 'master' into feature/optimize

parents 75649d9a b5b6252a
<?php
namespace api\controllers;
use Yii;
use api\base\BaseController;
use common\models\psources\CoinSupportedChain;
class SupportedChainController extends BaseController
{
public function actionIndex()
{
$header = Yii::$app->request->headers;
$platform_id = $header['FZM-PLATFORM-ID'] ?? null;
$data = null;
if (false == $platform_id) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
$supported_chain_model = CoinSupportedChain::find()->where(['platform_id' => $platform_id])->all();
if (false == $supported_chain_model) {
$msg = 'success';
$code = 0;
goto doEnd;
}
$data = [];
foreach ($supported_chain_model as $key => &$val) {
$data[] = !empty($val->coin) ? $val->coin : '';
}
$msg = 'success';
$code = 0;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use common\core\BaseActiveRecord;
class CoinSupportedChain extends BaseActiveRecord
{
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coin_supported_chain}}';
}
public function rules()
{
return [
[['coin_id', 'platform_id'], 'required'],
[['coin_id', 'platform_id'], 'integer'],
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['coin_id', 'platform_id'],
self:: SCENARIOS_UPDATE => ['id', 'coin_id', 'platform_id']
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function attributes()
{
return array_merge(parent::attributes(), ['coins']);
}
public function getCoin()
{
return $this->hasOne(Coin::className(), ['id' => 'coin_id'])->select('name as chain');
}
}
......@@ -13,7 +13,7 @@ use linslin\yii2\curl\Curl;
abstract class FactoryService
{
protected $code = -1;
protected $basic_coin = ['ETH', 'BTC', 'USDT', 'BTY', 'CNYT', 'CCNY'];
protected $basic_coin = ['ETH', 'BTC', 'USDT', 'BTY', 'CNYT'];
protected $basic_price = [];
protected $redis;
......
......@@ -196,7 +196,7 @@ class ZhaobiBuilder extends FactoryService
}
}
if ($this->basic_coin[5] == $base_currency) { //基础货币为CCNY
if ('CCNY' == $base_currency) { //基础货币为CCNY
$symbol_currency = $currency . $this->basic_coin[2];
$symbol_base_currency = $this->basic_coin[2] . $base_currency;
list($low_currency, $high_currency, $close_currency, $open_currency) = $this->redis->hmget($this->quotation_prefix . strtolower($symbol_currency), 'low', 'high', 'last', 'open');
......@@ -222,7 +222,7 @@ class ZhaobiBuilder extends FactoryService
goto doEnd;
}
if ($this->basic_coin[5] == $currency) { //交易货币为CCNY
if ('CCNY' == $currency) { //交易货币为CCNY
$symbol_currency = $base_currency . $this->basic_coin[2];
$symbol_base_currency = $this->basic_coin[2] . $currency;
if ($currency . $base_currency == 'CCNYUSDT') {
......
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