Commit 112df354 authored by shajiaiming's avatar shajiaiming

交易所公告

parent 414a32a4
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace api\controllers; namespace api\controllers;
use common\service\exchange\ExchangeBuilderFactory;
use Yii; use Yii;
use api\base\BaseController; use api\base\BaseController;
use common\models\pwallet\Notice; use common\models\pwallet\Notice;
...@@ -29,10 +30,10 @@ class NoticeController extends BaseController ...@@ -29,10 +30,10 @@ class NoticeController extends BaseController
*/ */
public function actionList() public function actionList()
{ {
$request = Yii::$app->request; $request = Yii::$app->request;
$page = $request->post('page', 1); $page = $request->post('page', 1);
$limit = $request->post('limit', 10); $limit = $request->post('limit', 10);
$post = $request->post(); $post = $request->post();
$condition = []; $condition = [];
$post = array_filter($post, function ($value, $key) { $post = array_filter($post, function ($value, $key) {
...@@ -65,4 +66,25 @@ class NoticeController extends BaseController ...@@ -65,4 +66,25 @@ class NoticeController extends BaseController
$data = Notice::getList($page, $limit, $condition); $data = Notice::getList($page, $limit, $condition);
return $data; return $data;
} }
public function actionIndex()
{
$id = Yii::$app->request->get('id', '');
$exchange = Yii::$app->request->get('exchange', 'zhaobi');
$exchange_arr = ['huobi', 'binance', 'okex', 'zhaobi'];
if (!in_array($exchange, $exchange_arr)) {
$msg = '不存在的交易平台';
$code = -1;
$data = [];
goto doEnd;
}
$builder = ExchangeBuilderFactory::create($exchange);
$result = $builder->getNotice($id);
$code = $result['code'];
$data = $result['notice'];
$msg = isset($result['msg']) ? $result['msg'] : 'success';
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
} }
\ No newline at end of file
...@@ -46,4 +46,28 @@ class ZhaobiBuilder extends FactoryService ...@@ -46,4 +46,28 @@ class ZhaobiBuilder extends FactoryService
} }
return ['code' => $this->code, 'ticker' => $ticker]; return ['code' => $this->code, 'ticker' => $ticker];
} }
public function getNotice($id = '')
{
$curl = new Curl();
if (!empty($id)) {
$api = $this->base_url . '/api/data/noticedetail?id=' . $id;
$res = $curl->get($api, false);
if (isset($res['message']) && 'OK' == $res['message']) {
$this->code = 0;
return ['code' => $this->code, 'notice' => $res['data']];
} else {
return ['code' => $this->code, 'notice' => $res['data'], 'msg' => $res['message']];
}
}
$api = $this->base_url . '/api/data/noticelist';
$res = $curl->get($api, false);
$notice = [];
if (isset($res['message']) && 'OK' == $res['message']) {
$this->code = 0;
$notice = $res['data']['rows'];
}
return ['code' => $this->code, 'notice' => $notice];
}
} }
\ No newline at end of file
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