Commit 0172be5d authored by shajiaiming's avatar shajiaiming

托管接口调整

parent 79e4e7de
......@@ -60,15 +60,17 @@ class AppController extends BaseController
$platform_id = \Yii::$app->request->post('platform_id', 1);
$data = CoinAppVersion::getLastStable($type,$platform_id);
if ($data) {
$logItems = json_decode($data['log']);
$logstr = '';
foreach($logItems as $item){
if($logstr){
$logstr .="\n".$item;
}else{
$logstr = $item;
if(!empty($data['log'])){
$logItems = json_decode($data['log']);
$logstr = '';
foreach($logItems as $item){
if($logstr){
$logstr .="\n".$item;
}else{
$logstr = $item;
}
}
}
$data['log'] = $logstr;
$data['id']=(integer)$data['id'];
......
......@@ -11,8 +11,9 @@ class TrusteeShipService
public function __construct($parameter = [])
{
$platform_id = Yii::$app->request->getPlatformId();
if (empty($parameter)) {
$this->node_params = Yii::$app->params['trusteeship'];
$this->node_params = Yii::$app->params['trusteeship']['node_' . $platform_id];
} else {
$this->node_params = $parameter;
}
......@@ -20,22 +21,14 @@ class TrusteeShipService
public function urlBuild($uri = '')
{
$config = $this->node_params;
$scheme = $config['scheme'] ?? 'http';
$host = $config['host'] ?? '127.0.0.1';
$port = (string)$config['port'] ?? '';
if ($port) {
return $scheme . '://' . $host . ':' . $port . '/' . $uri;
} else {
return $scheme . '://' . $host . '/' . $uri;
}
return $this->node_params . '/' . $uri;
}
public function send($method = 'GET', $uri, $params = [])
{
$ch = new Curl();
if(!empty($params)) {
if (!empty($params)) {
$ch->setGetParams($params);
}
$result = $ch->$method($this->urlBuild($uri), false);
......@@ -43,7 +36,7 @@ class TrusteeShipService
return ['code' => -1, 'msg' => $ch->errorText];
}
if (200 == $result['code'] && isset($result['data'])) {
return ['code' => $result['code'], 'msg' =>$result['data']];
return ['code' => $result['code'], 'msg' => $result['data']];
} else {
return ['code' => -1, 'msg' => $result['message']];
}
......
......@@ -132,15 +132,11 @@ class UserController extends BaseController
} else {
$platform_id = Yii::$app->request->getPlatformId();
}
if(!isset(Yii::$app->params['trusteeship']['port'][$platform_id])){
if(!isset(Yii::$app->params['trusteeship']['node_'. $platform_id])){
return ['code' => -1, 'data' => [], 'msg' => '此钱包节点尚未开通'];
}
$node_params = [
'scheme' => Yii::$app->params['trusteeship']['scheme'],
'host' => Yii::$app->params['trusteeship']['host'],
'port' => Yii::$app->params['trusteeship']['port'][$platform_id]
];
$node_params = Yii::$app->params['trusteeship']['node_'. $platform_id];
$page = Yii::$app->request->get('page', 1);
$size = Yii::$app->request->get('size', 15);
......
......@@ -38,14 +38,10 @@ class WalletController extends BaseController
} else {
$platform_id = Yii::$app->request->getPlatformId();
}
if(!isset(Yii::$app->params['trusteeship']['port'][$platform_id])){
if(!isset(Yii::$app->params['trusteeship']['node_'. $platform_id])){
return ['code' => -1, 'data' => [], 'msg' => '此钱包节点尚未开通'];
}
$node_params = [
'scheme' => Yii::$app->params['trusteeship']['scheme'],
'host' => Yii::$app->params['trusteeship']['host'],
'port' => Yii::$app->params['trusteeship']['port'][$platform_id]
];
$node_params = Yii::$app->params['trusteeship']['node_'. $platform_id];
$type = Yii::$app->request->get('type', 1);
$page = Yii::$app->request->get('page', 1);
......@@ -68,12 +64,7 @@ class WalletController extends BaseController
public function actionUserAsset()
{
$platform_id = Yii::$app->request->getPlatformId();
$node_params = [
'scheme' => Yii::$app->params['trusteeship']['scheme'],
'host' => Yii::$app->params['trusteeship']['host'],
'port' => Yii::$app->params['trusteeship']['port'][$platform_id]
];
$node_params = Yii::$app->params['trusteeship']['node_'. $platform_id];
$uid = Yii::$app->request->get('uid', '');
$params = [
'uid' => $uid
......
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