Commit 7a940eae authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/20190718' into 'master'

调整 See merge request !63
parents b637efc4 e0b188e6
...@@ -347,42 +347,32 @@ class CoinController extends BaseController ...@@ -347,42 +347,32 @@ class CoinController extends BaseController
$request = Yii::$app->request; $request = Yii::$app->request;
$platform = $request->get('platform', ''); $platform = $request->get('platform', '');
$coin_name = $request->get('coinname', ''); $coin_name = $request->get('coinname', '');
if ($platform && $coin_name) { if (empty($coin_name)) {
$platform_with_hold = CoinPlatformWithHold::getRecord($platform);
$des = Yii::$app->des;
$platform_with_hold['private_key'] = $des->encrypt($platform_with_hold['private_key']);
return ['code' => 0, 'data' => $platform_with_hold];
}
$platform_with_hold = CoinPlatformWithHold::getRecord($platform); $platform_with_hold = CoinPlatformWithHold::getRecord($platform);
$coin_info = Coin::find()->select('treaty')->where(['name' => strtoupper($coin_name)])->asArray()->one(); $coin_info = Coin::find()->select('treaty')->where(['name' => strtoupper($coin_name)])->asArray()->one();
if ($platform_with_hold) {
$des = Yii::$app->des; $des = Yii::$app->des;
$platform_with_hold['private_key'] = $des->encrypt($platform_with_hold['private_key']); $platform_with_hold['private_key'] = $des->encrypt($platform_with_hold['private_key']);
if(1 == $coin_info['treaty']){ if (1 == $coin_info['treaty']) {
$platform_with_hold['exer'] = 'user.p.'. $platform .'.token'; $platform_with_hold['exer'] = 'user.p.' . $platform . '.token';
$platform_with_hold['tokensymbol'] = $coin_name; $platform_with_hold['tokensymbol'] = $coin_name;
$platform_with_hold['fee'] = 0; $platform_with_hold['fee'] = 0;
} else { } else {
$platform_with_hold['exer'] = 'user.p.'. $platform .'.coins'; $platform_with_hold['exer'] = 'user.p.' . $platform . '.coins';
$platform_with_hold['tokensymbol'] = $platform .'.coins'; $platform_with_hold['tokensymbol'] = $platform . '.coins';
$platform_with_hold['fee'] = (float)sprintf("%0.4f", (double)$platform_with_hold['fee']); $platform_with_hold['fee'] = (float)sprintf("%0.4f", (double)$platform_with_hold['fee']);
} }
$service = new Chain33Business(); $service = new Chain33Business();
$result = $service->getProperFee(); $result = $service->getProperFee();
if(0 === $result['code']) { if (0 === $result['code']) {
$platform_with_hold['bty_fee'] = (float)sprintf("%0.4f", $result['result']['properFee'] / 1e8); $platform_with_hold['bty_fee'] = (float)sprintf("%0.4f", $result['result']['properFee'] / 1e8);
} else { } else {
$platform_with_hold['bty_fee'] = (float)sprintf("%0.4f", Yii::$app->params['bty_fee']); $platform_with_hold['bty_fee'] = (float)sprintf("%0.4f", Yii::$app->params['bty_fee']);
} }
return ['code' => 0, 'data' => $platform_with_hold]; return ['code' => 0, 'data' => $platform_with_hold];
} else {
$data = [
'id' => 0,
'platform' => '',
'address' => '',
'private_key' => '',
'exer' => ''
];
return ['code' => 0, 'data' => $data];
}
} else {
return ['code' => 1, '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