Commit cbd6f4d0 authored by shajiaiming's avatar shajiaiming

fix

parent f4c21ec8
......@@ -139,7 +139,7 @@ class CoinController extends BaseController
$coin_ids = array_column($coin_recommends, 'cid');
//获取币种信息
$coin_infos = Coin::getCoinInfoByIds($coin_ids, $select, 'id');
foreach ($coin_infos as $key => &$val){
foreach ($coin_infos as $key => &$val) {
$nickname = json_decode($val['nickname'], true);
$val['nickname'] = $nickname[$this->lang];
}
......@@ -179,7 +179,7 @@ class CoinController extends BaseController
unset($key, $value);
}
}
if(!$datas['data']){
if (!$datas['data']) {
$datas['data'] = null;
}
return $datas;
......@@ -198,8 +198,8 @@ class CoinController extends BaseController
$coin = Coin::findOne(['name' => $names]);
if ($coin) {
$chain = $coin->chain;
$miner_fee = MinerFee::find()->where(['platform' => $chain,'type' => 1])->one();
if(!$miner_fee){
$miner_fee = MinerFee::find()->where(['platform' => $chain, 'type' => 1])->one();
if (!$miner_fee) {
throw new Exception('8', '旷工费未设置');
}
} else {
......@@ -207,8 +207,8 @@ class CoinController extends BaseController
throw new Exception('8', '币种不存在');
}
$result = (array)$miner_fee->getAttributes();
$result['min'] = number_format($result['min'],6);
$result['max'] = number_format($result['max'],6);
$result['min'] = number_format($result['min'], 6);
$result['max'] = number_format($result['max'], 6);
return $result;
}
......@@ -220,20 +220,20 @@ class CoinController extends BaseController
$names = Yii::$app->request->post('names');
$platforms = [];
$newNames = [];
if(!$names){
return ['code' => 0,'data' => []];
if (!$names) {
return ['code' => 0, 'data' => []];
}
foreach($names as $item){
$item_array = explode(',',$item);
foreach ($names as $item) {
$item_array = explode(',', $item);
$newNames [] = $item_array[0];
if(isset($item_array[1])){
if(!in_array($item_array[1],$platforms)){
if (isset($item_array[1])) {
if (!in_array($item_array[1], $platforms)) {
$platforms [] = $item_array[1];
}
}
}
$condition = [['in', 'name', $newNames]];
if($platforms){
if ($platforms) {
$condition[] = ['in', 'platform', $platforms];
}
$result = ExchangeBusiness::getApiListForIndex(1, 999, $condition);
......@@ -267,9 +267,9 @@ class CoinController extends BaseController
$limit = $request->post('limit', 10);
$platform_ids = $request->post('platform_id', null);
$condition = [['in', 'chain', ['ETH','DCR','BTC','BTY']]];
$condition = [['in', 'chain', ['ETH', 'DCR', 'BTC', 'BTY']]];
if (!empty($name)) {
$condition[] = ['or',['address' => $name],['or', ['like', 'name', $name], ['like', 'nickname', $name]]];
$condition[] = ['or', ['address' => $name], ['or', ['like', 'name', $name], ['like', 'nickname', $name]]];
}
if ($platform_ids) {
/* $platform_id_arr = explode(',', $platform_ids);
......@@ -330,11 +330,11 @@ class CoinController extends BaseController
{
$request = Yii::$app->request;
$platform = $request->post('platform', '');
if($platform){
$brower_url = Yii::$app->redis->hget('platform_brower_info',$platform);
return ['code' => 0,'data' => $brower_url];
}else{
return ['code' => 1,'data' => [],'msg' => '平台参数不能为空'];
if ($platform) {
$brower_url = Yii::$app->redis->hget('platform_brower_info', $platform);
return ['code' => 0, 'data' => $brower_url];
} else {
return ['code' => 1, 'data' => [], 'msg' => '平台参数不能为空'];
}
}
......@@ -345,13 +345,26 @@ class CoinController extends BaseController
{
$request = Yii::$app->request;
$platform = $request->get('platform', '');
if($platform){
$coin_name = $request->get('coinname', '');
if ($platform && $coin_name) {
$platform_with_hold = CoinPlatformWithHold::getRecord($platform);
if($platform_with_hold){
$coin_info = Coin::find()->select('treaty')->where(['name' => strtoupper($coin_name)])->asArray()->one();
if ($platform_with_hold) {
$des = Yii::$app->des;
$platform_with_hold['private_key'] = $des->encrypt($platform_with_hold['private_key']);
return ['code' => 0,'data' => $platform_with_hold];
}else{
if(1 == $coin_info['treaty']){
$platform_with_hold['exer'] = 'user.p.'. $platform .'.token';
$platform_with_hold['tokensymbol'] = $platform;
$platform_with_hold['fee'] = 0;
} else {
$platform_with_hold['exer'] = 'user.p.'. $platform .'.coins';
$platform_with_hold['tokensymbol'] = $platform .'.coins';
$platform_with_hold['fee'] = (float)sprintf("%0.4f", (double)$platform_with_hold['fee']);
}
$platform_with_hold['bty_fee'] = (float)sprintf("%0.4f", (double)Yii::$app->params['bty_fee']);;
return ['code' => 0, 'data' => $platform_with_hold];
} else {
$data = [
'id' => 0,
'platform' => '',
......@@ -361,8 +374,8 @@ class CoinController extends BaseController
];
return ['code' => 0, 'data' => $data];
}
}else{
return ['code' => 1,'data' => [],'msg' => '平台参数不能为空'];
} else {
return ['code' => 1, 'data' => [], 'msg' => '平台参数或币种名称不能为空'];
}
}
}
......@@ -6,7 +6,6 @@
* Time: 17:37
*/
namespace common\models\psources;
use Yii;
class CoinPlatformWithHold extends BaseActiveRecord
{
......
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