Commit c2e3bf26 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

Feature/optimize See merge request !215
parents 55c7d3ff 175ce151
......@@ -15,10 +15,12 @@ use common\business\Chain33Business;
use common\business\CoinBusiness;
use common\business\ExchangeBusiness;
use common\models\psources\Coin;
use common\models\psources\CoinCurrency;
use common\models\psources\CoinPlatformWithHold;
use common\models\psources\CoinRecommend;
use common\models\psources\MinerFee;
use Yii;
use yii\data\Pagination;
/**
* 币种信息管理控制器
......@@ -142,9 +144,9 @@ class CoinController extends BaseController
$coin_infos = Coin::getCoinInfoByIds($coin_ids, $select, 'id');
foreach ($coin_infos as $key => &$val) {
$nickname = json_decode($val['nickname'], true);
$val['nickname'] = $nickname[$this->lang];
$val['nickname'] = isset($nickname[$this->lang]) ? $nickname[$this->lang] : '';
$introduce = json_decode($val['introduce'], true);
$val['introduce'] = $introduce[$this->lang];
$val['introduce'] = isset($introduce[$this->lang]) ? $introduce[$this->lang] : '';
}
//获取行情信息
$coin_names = array_column($coin_infos, 'name');
......@@ -243,20 +245,87 @@ class CoinController extends BaseController
foreach ($chains as $key => $value) {
$chain_quotation[$value] = ExchangeBusiness::getquatation($value);
}
$currency = CoinCurrency::find()->where(['pj_id' => $this->currency_id])->one();
if (false != $currency) {
$last = Yii::$app->redis_currency->hmget('quotation_boc_' . 'CNY_' . $currency->symbol, 'last');
}
foreach ($result['data'] as $key => &$value) {
if (!isset($value['nickname']) || empty($value['nickname'])) continue;
$nickname = json_decode($value['nickname'], true);
$introduce = json_decode($value['introduce'], true);
$value['nickname'] = $nickname[$this->lang];
$value['introduce'] = $introduce[$this->lang];
$value['nickname'] = isset($nickname[$this->lang]) ? $nickname[$this->lang] : '';
$value['introduce'] = isset($introduce[$this->lang]) ? $introduce[$this->lang] : '';
$value['chain_quotation'] = $chain_quotation[$value['chain']] ?: null;
$value['chain_rmb'] = isset($value['chain_quotation']['rmb']) ? $value['chain_quotation']['rmb'] : 0;
$value['chain_usd'] = isset($value['chain_quotation']['usd']) ? $value['chain_quotation']['usd'] : 0;
$value['country_rate'] = (false == $currency) ? '' : (float)sprintf("%0.4f", $last[0] * $value['rmb']);
}
return $result;
}
}
public function actionSearch()
{
$params = Yii::$app->request->post();
$chain = isset($params['chain']) ? $params['chain'] : '';
$keyword = isset($params['keyword']) ? $params['keyword'] : '';
$platform = isset($params['platform']) ? $params['platform'] : '';
$platform_id = isset($params['platform_id']) ? $params['platform_id'] : '';
$page = empty($params['page']) ? 1 : $params['page'];
$limit = empty($params['limit']) ? 10 : $params['limit'];
if (false == $platform_id) {
$msg = '参数错误';
$code = -1;
$data = null;
goto doEnd;
}
$query = Coin::find()
->select('id, sid, icon, name, optional_name, nickname, platform, chain, address as contract_address, treaty')
->where(['platform_id' => (int)$platform_id])
->orderBy('id');
if (false != $chain) {
$query->andWhere(['chain' => $chain]);
}
if (false != $platform) {
$query->andWhere(['platform' => $platform]);
}
if (false != $keyword) {
$query->andWhere(['or', ['like', 'address', $keyword], ['like', 'name', $keyword], ['like', 'nickname', $keyword]]);
}
$data = $query->offset(($page - 1) * $limit)->limit($limit)->asArray()->all();
$count = $query->count();
if (false != $data) {
$chains = array_unique(array_column($data, 'chain'));
$chain_quotation = [];
foreach ($chains as $key => $value) {
$chain_quotation[$value] = ExchangeBusiness::getquatation($value);
}
foreach ($data as $key => $value) {
$data[$key]['chain_quotation'] = $chain_quotation[$value['chain']] ?: null;
}
foreach ($data as $key => &$value) {
$nickname = json_decode($value['nickname'], true);
$value['nickname'] = $nickname[$this->lang];
$value['chain_rmb'] = isset($value['chain_quotation']['rmb']) ? $value['chain_quotation']['rmb'] : 0;
$value['chain_usd'] = isset($value['chain_quotation']['usd']) ? $value['chain_quotation']['usd'] : 0;
}
}
$code = 0;
doEnd :
return ['code' => $code, 'data' => $data, 'count' => $count];
}
/**
* 按照名称搜索币种
*
......@@ -365,7 +434,7 @@ class CoinController extends BaseController
if (1 == $coin_info['treaty']) {
$platform_with_hold['exer'] = 'user.p.' . $platform . '.token';
if ('BTY' !== strtoupper($platform)) {
$platform_with_hold['tokensymbol'] = $platform.'.'.$coin_name;
$platform_with_hold['tokensymbol'] = $platform . '.' . $coin_name;
} else {
$platform_with_hold['tokensymbol'] = $coin_name;
}
......
......@@ -92,15 +92,11 @@ class ApplicationCategoryController extends BaseController
$fields = ['id', 'name', 'sort', 'icon', 'banner', 'banner_url'];
$params = $this->initParams(Yii::$app->request->post(), $fields);
$params['platform_id'] = Yii::$app->user->identity->platform_id;
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $params['name'];
$name = [];
foreach ($name_arr as $key => $val) {
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($params['name']);
......@@ -124,15 +120,10 @@ class ApplicationCategoryController extends BaseController
$category = CoinApplicationCategory::getCategoryById($params['id']);
$params['platform_id'] = $category->platform_id;
$application_category->setScenario(CoinApplicationCategoryForm::SCENARIO_EDIT);
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $params['name'];
$name = [];
foreach ($name_arr as $key => $val) {
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($params['name']);
......@@ -150,6 +141,7 @@ class ApplicationCategoryController extends BaseController
$coin['name_ja'] = isset($name_arr['ja']) ? $name_arr['ja'] : '';
$coin['name_zh'] = isset($name_arr['zh-CN']) ? $name_arr['zh-CN'] : '';
$coin['name_en'] = isset($name_arr['en-US']) ? $name_arr['en-US'] : '';
$coin['name_ko'] = isset($name_arr['ko']) ? $name_arr['ko'] : '';
$this->layout = false;
return $this->render('edit', ['model' => $coin]);
}
......
......@@ -65,15 +65,10 @@ class ApplicationController extends BaseController
$category_id = Yii::$app->request->get('category_id');
$fields = ['category_id', 'h5_icon', 'official_url', 'introduce_image', 'show_width', 'show_height', 'open_type', 'open_type_app', 'platform_type', 'name', 'sort', 'icon', 'type', 'native_url', 'native_login_url', 'h5_url', 'android_url', 'ios_url', 'app_store_url', 'advertise', 'description', 'redirect_type', 'platform_id'];
$data = Yii::$app->request->post();
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $data['name'];
$name = [];
foreach ($name_arr as $key => $val){
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($data['name']);
$data['name'] = $name;
......@@ -104,21 +99,15 @@ class ApplicationController extends BaseController
$fields = ['category_id', 'id', 'h5_icon', 'official_url', 'introduce_image', 'show_width', 'show_height', 'open_type', 'open_type_app', 'platform_type', 'name', 'sort', 'icon', 'type', 'native_url', 'native_login_url', 'h5_url', 'android_url', 'ios_url', 'app_store_url', 'advertise', 'description', 'redirect_type', 'platform_id'];
$data = Yii::$app->request->post();
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $data['name'];
$name = [];
foreach ($name_arr as $key => $val){
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($data['name']);
$data['name'] = $name;
$data['open_type_app'] = (0 == $data['open_type_app']) ? 1 : $data['open_type_app'];
#var_dump($data);exit;
$params = array_merge($data, ['platform_id' => Yii::$app->user->identity->platform_id]);
$params = $this->initParams($params, $fields);
$coin_applicateion_form = new CoinApplicationForm();
......@@ -165,9 +154,10 @@ class ApplicationController extends BaseController
#echo json_encode($applicate);exit;
$applicate['sort'] = $app_cate->sort;
$name_arr = json_decode($applicate['name'], true);
$applicate['name_ja'] = $name_arr['ja'];
$applicate['name_en'] = $name_arr['en-US'];
$applicate['name_zh'] = $name_arr['zh-CN'];
$applicate['name_ja'] = isset($name_arr['ja']) ? $name_arr['ja'] : '';
$applicate['name_en'] = isset($name_arr['en-US']) ? $name_arr['en-US'] : '';
$applicate['name_zh'] = isset($name_arr['zh-CN']) ? $name_arr['zh-CN'] : '';
$applicate['name_ko'] = isset($name_arr['ko']) ? $name_arr['ko'] : '';
$this->layout = false;
return $this->render('edit', ['item' => $applicate, 'category_id' => $category_id]);
}
......
......@@ -95,22 +95,18 @@ class CoinController extends BaseController
$data['name'] = strtoupper(trim($data['name']));
$data['platform'] = $data['platform'];
$data['chain'] = strtoupper($data['chain']);
$lang = [
'zh-CN',
'en-US',
'ja',
'ko'
];
$nickname_arr = $data['nickname'];
$introduce_arr = $data['introduce'];
$nickname = [];
$introduce = [];
foreach ($nickname_arr as $key => $val) {
$nickname[$lang[$key]] = trim($val);
foreach (Yii::$app->params['lang'] as $key => $val) {
$nickname[$val] = isset($nickname_arr[$val]) ? $nickname_arr[$val] : '';
}
foreach ($introduce_arr as $key => $val) {
$introduce[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$introduce[$val] = isset($introduce_arr[$val]) ? $introduce_arr[$val] : '';
}
unset($data['nickname']);
unset($data['introduce']);
$data['nickname'] = $nickname;
......@@ -168,21 +164,15 @@ class CoinController extends BaseController
$can = true;
}
if ($can) {
$lang = [
'zh-CN',
'en-US',
'ja',
'ko'
];
$nickname_arr = $data['nickname'];
$introduce_arr = $data['introduce'];
$nickname = [];
$introduce = [];
foreach ($nickname_arr as $key => $val) {
$nickname[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$nickname[$val] = isset($nickname_arr[$val]) ? $nickname_arr[$val] : '';
}
foreach ($introduce_arr as $key => $val) {
$introduce[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$introduce[$val] = isset($introduce_arr[$val]) ? $introduce_arr[$val] : '';
}
unset($data['nickname']);
$data['nickname'] = $nickname;
......
......@@ -21,7 +21,7 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" required lay-verify="required" placeholder=""
<input class="layui-input" name="name[zh-CN]" required lay-verify="required" placeholder=""
autocomplete="off" value=""
class="layui-input">
</div>
......@@ -29,13 +29,19 @@
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="">
<input class="layui-input" name="name[en-US]" value="">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="">
<input class="layui-input" name="name[ja]" value="">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[ko]" value="">
</div>
</div>
<div class="layui-form-item layui-form-text">
......
......@@ -21,19 +21,25 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_zh'] ?>">
<input class="layui-input" name="name[zh-CN]" value="<?= $model['name_zh'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_en'] ?>">
<input class="layui-input" name="name[en-US]" value="<?= $model['name_en'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_ja'] ?>">
<input class="layui-input" name="name[ja]" value="<?= $model['name_ja'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[ko]" value="<?= $model['name_ko'] ?>">
</div>
</div>
<div class="layui-form-item layui-form-text">
......
......@@ -48,19 +48,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
<input class="layui-input" name="name[zh-CN]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
<input class="layui-input" name="name[en-US]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
<input class="layui-input" name="name[ja]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[ko]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
......
......@@ -51,19 +51,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_zh'] ?>" lay-verify="required">
<input class="layui-input" name="name[zh-CN]" value="<?= $item['name_zh'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_en'] ?>" lay-verify="required">
<input class="layui-input" name="name[en-US]" value="<?= $item['name_en'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_ja'] ?>" lay-verify="required">
<input class="layui-input" name="name[ja]" value="<?= $item['name_ja'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[ko]" value="<?= $item['name_ko'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
......
......@@ -34,19 +34,25 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['zh-CN'] ?>">
<input class="layui-input" name="nickname[zh-CN]" value="<?= $model->nickname['zh-CN'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['en-US'] ?>">
<input class="layui-input" name="nickname[en-US]" value="<?= $model->nickname['en-US'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['ja'] ?>">
<input class="layui-input" name="nickname[ja]" value="<?= $model->nickname['ja'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[ko]" value="<?= $model->nickname['ko'] ?>">
</div>
</div>
<div class="layui-form-item">
......@@ -135,19 +141,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['zh-CN'] ?></textarea>
<textarea class="layui-textarea" name="introduce[zh-CN]"><?= $model->introduce['zh-CN'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['en-US'] ?></textarea>
<textarea class="layui-textarea" name="introduce[en-US]"><?= $model->introduce['en-US'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['ja'] ?></textarea>
<textarea class="layui-textarea" name="introduce[ja]"><?= $model->introduce['ja'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">韩文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[ko]"><?= $model->introduce['ko'] ?></textarea>
</div>
</div>
<div class="layui-inline">
......
......@@ -34,19 +34,25 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['zh-CN'] ?>">
<input class="layui-input" name="nickname[zh-CN]" value="<?= isset($model->nickname['zh-CN']) ? $model->nickname['zh-CN'] : '' ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['en-US'] ?>">
<input class="layui-input" name="nickname[en-US]" value="<?= isset($model->nickname['en-US']) ? $model->nickname['en-US'] : '' ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['ja'] ?>">
<input class="layui-input" name="nickname[ja]" value="<?= isset($model->nickname['ja']) ? $model->nickname['ja'] : '' ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[ko]" value="<?= isset($model->nickname['ko']) ? $model->nickname['ko'] : '' ?>">
</div>
</div>
<div class="layui-form-item">
......@@ -141,19 +147,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['zh-CN'] ?></textarea>
<textarea class="layui-textarea" name="introduce[zh-CN]"><?= isset($model->introduce['zh-CN']) ? $model->introduce['zh-CN'] : '' ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['en-US'] ?></textarea>
<textarea class="layui-textarea" name="introduce[en-US]"><?= isset($model->introduce['en-US']) ? $model->introduce['en-US'] : '' ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['ja'] ?></textarea>
<textarea class="layui-textarea" name="introduce[ja]"><?= isset($model->introduce['ja']) ? $model->introduce['ja'] : '' ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">韩文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[ko]"><?= isset($model->introduce['ko']) ? $model->introduce['ko'] : '' ?></textarea>
</div>
</div>
<div class="layui-inline">
......
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