Commit fabc54f0 authored by ZhuChunYang's avatar ZhuChunYang

update

parent 4f7460d7
...@@ -11,6 +11,7 @@ use api\base\BaseController; ...@@ -11,6 +11,7 @@ use api\base\BaseController;
use common\business\ExchangeBusiness; use common\business\ExchangeBusiness;
use common\models\psources\Coin; use common\models\psources\Coin;
use common\models\psources\CoinRecommend;
use common\service\coin\CoinFactory; use common\service\coin\CoinFactory;
use Yii; use Yii;
...@@ -31,10 +32,12 @@ class ServiceController extends BaseController ...@@ -31,10 +32,12 @@ class ServiceController extends BaseController
{ {
$request = Yii::$app->request; $request = Yii::$app->request;
$coinItems = $request->post('names'); $coinItems = $request->post('names');
if(!$coinItems){
return ['code' => 1,'data' => [],'msg' => '币种不能为空'];
}
if(!is_array($coinItems)){ if(!is_array($coinItems)){
$coinItems = [$coinItems]; $coinItems = [$coinItems];
} }
$tickerData = []; $tickerData = [];
if($coinItems){ if($coinItems){
foreach($coinItems as $item){ foreach($coinItems as $item){
...@@ -62,8 +65,6 @@ class ServiceController extends BaseController ...@@ -62,8 +65,6 @@ class ServiceController extends BaseController
} }
return ['code' => 0,'data' => $tickerData,'msg' => '行情获取成功']; return ['code' => 0,'data' => $tickerData,'msg' => '行情获取成功'];
} }
return ['code' => 1,'data' => [],'msg' => '币种不能为空'];
} }
public function actionCoinIndex() public function actionCoinIndex()
...@@ -80,4 +81,16 @@ class ServiceController extends BaseController ...@@ -80,4 +81,16 @@ class ServiceController extends BaseController
$rows = Coin::getSelectList(1, 999, $fields,[['in','name',$coinItems]]); $rows = Coin::getSelectList(1, 999, $fields,[['in','name',$coinItems]]);
return ['code' => 0,'data' => $rows,'msg' => '币种列表获取成功']; return ['code' => 0,'data' => $rows,'msg' => '币种列表获取成功'];
} }
public function actionCoinRecommendList()
{
$recommend_list = CoinRecommend::find()->select('cid')->where(['platform_id' => 6 ])->all();
if($recommend_list){
$coin_ids = array_column($recommend_list,'cid');
$coin_items = Coin::find()->select('name')->where(['in','id',$coin_ids])->all();
$coin_names = array_column($coin_items,'name');
return ['code' => 0, 'data' => $coin_names, 'msg' => '推荐币种获取成功'];
}
return ['code' => 0, 'data' => [], 'msg' => '推荐币种获取成功'];
}
} }
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