Commit bc82505f authored by shajiaiming's avatar shajiaiming

根据平台获取不同节点参数

parent af4b7bda
......@@ -13,9 +13,9 @@ class TrusteeShipService
{
$platform_id = Yii::$app->request->getPlatformId();
if (empty($parameter)) {
$this->node_params = Yii::$app->params['trusteeship']['node_' . $platform_id];
$this->node_params = Yii::$app->params['trusteeship']['node_' . $platform_id]['url'];
} else {
$this->node_params = $parameter;
$this->node_params = $parameter['url'];
}
}
......@@ -25,9 +25,13 @@ class TrusteeShipService
}
public function send($method = 'GET', $uri, $params = [])
public function send($method = 'GET', $uri, $params = [], $headers = [])
{
$ch = new Curl();
if(!empty($headers)){
$ch->setHeaders($headers);
}
if (!empty($params)) {
$ch->setGetParams($params);
}
......@@ -53,7 +57,21 @@ class TrusteeShipService
{
$uri = 'backend/account/wallet-balance';
return $this->send("GET", $uri, $params);
$time = time();
$platform_id = Yii::$app->request->getPlatformId();
$node_params = Yii::$app->params['trusteeship']['node_'. $platform_id];
$appKey = isset($node_params['appKey']) ? $node_params['appKey'] : null;
$appSecret = isset($node_params['appSecret']) ? $node_params['appSecret'] : null;
$signature = self::getSign($params, $appKey, $appSecret, $time);
$headers = [
'FZM-Wallet-Signature' => $signature,
'FZM-Wallet-Timestamp' => $time,
'FZM-Wallet-AppKey' => $appKey,
'FZM-Wallet-AppIp' => Yii::$app->request->userIP
];
return $this->send("GET", $uri, $params, $headers);
}
public function getUserAsset($params = [])
......@@ -62,4 +80,13 @@ class TrusteeShipService
return $this->send("GET", $uri, $params);
}
protected function getSign($params, $appkey, $appSecret, $time)
{
ksort($params);
$string = http_build_query($params);
$result = md5($appkey . $string . $appSecret . $time);
$sign = strtoupper($result);
return $sign;
}
}
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