Commit a9d677a9 authored by shajiaiming's avatar shajiaiming

币信息增加可选简称

parent 2f8da1bb
......@@ -131,7 +131,7 @@ class CoinController extends BaseController
if ($recommend) {
$condition['recommend'] = $recommend;
}
$select = ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain', 'treaty'];
$select = ['id', 'sid', 'icon', 'name', 'optional_name', 'nickname', 'platform', 'chain', 'treaty'];
$order_by = ['sort' => SORT_ASC];
$datas = CoinRecommend::getList($page, $limit, $condition, $order_by, $select);
//获取详细信息
......
......@@ -69,7 +69,7 @@ class CoinController extends BaseController
}
$platforms = Coin::getPlatformList();
$chains = Coin::getChainList();
return $this->render('index', ['platforms' => $platforms,'chains' => $chains]);
return $this->render('index', ['platforms' => $platforms, 'chains' => $chains]);
}
/**
......@@ -89,6 +89,9 @@ class CoinController extends BaseController
$coin = Yii::createObject(Coin::className());
$data = array_merge($request->post(), ['platform_id' => Yii::$app->user->identity->platform_id]);
unset($data['id']);
if (isset($data['optional_name'])) {
$data['optional_name'] = strtoupper($data['optional_name']);
}
$data['name'] = strtoupper($data['name']);
$data['platform'] = strtolower($data['platform']);
$data['chain'] = strtoupper($data['chain']);
......@@ -101,10 +104,10 @@ class CoinController extends BaseController
$introduce_arr = $data['introduce'];
$nickname = [];
$introduce = [];
foreach ($nickname_arr as $key => $val){
foreach ($nickname_arr as $key => $val) {
$nickname[$lang[$key]] = $val;
}
foreach ($introduce_arr as $key => $val){
foreach ($introduce_arr as $key => $val) {
$introduce[$lang[$key]] = $val;
}
unset($data['nickname']);
......@@ -146,6 +149,9 @@ class CoinController extends BaseController
$data['name'] = strtoupper($data['name']);
$data['platform'] = strtolower($data['platform']);
$data['chain'] = strtoupper($data['chain']);
if (isset($data['optional_name'])) {
$data['optional_name'] = strtoupper($data['optional_name']);
}
Yii::$app->response->format = 'json';
if ($model->load($data) && $model->validate()) {
$platform_id = Yii::$app->user->identity->platform_id;
......@@ -170,10 +176,10 @@ class CoinController extends BaseController
$introduce_arr = $data['introduce'];
$nickname = [];
$introduce = [];
foreach ($nickname_arr as $key => $val){
foreach ($nickname_arr as $key => $val) {
$nickname[$lang[$key]] = $val;
}
foreach ($introduce_arr as $key => $val){
foreach ($introduce_arr as $key => $val) {
$introduce[$lang[$key]] = $val;
}
unset($data['nickname']);
......@@ -245,7 +251,7 @@ class CoinController extends BaseController
if ($id) {
$coin_recommend = CoinRecommend::find()->where(['cid' => $id])->one();
if($coin_recommend){
if ($coin_recommend) {
return ['code' => -1, 'msg' => '推荐币种里有改币种,无法删除'];
}
$model = Coin::findOne(['id' => $id]);
......@@ -467,11 +473,11 @@ class CoinController extends BaseController
}
$user_platform_id = Yii::$app->user->identity->platform_id;
if ($user_platform_id == Yii::$app->params['admin']) {
$coin_id_items = explode(',',$coin_ids);
foreach($coin_id_items as $id) {
$coin_id_items = explode(',', $coin_ids);
foreach ($coin_id_items as $id) {
$coin = Coin::getOneById($id);
if($coin){
$platform_ids = explode(',',$coin->platform_id);
if ($coin) {
$platform_ids = explode(',', $coin->platform_id);
$platform_ids = implode(',', array_unique(array_merge($platform_ids, [$platform_id])));
$coin->platform_id = $platform_ids;
$coin->save();
......@@ -501,11 +507,11 @@ class CoinController extends BaseController
}
$user_platform_id = Yii::$app->user->identity->platform_id;
if ($user_platform_id == Yii::$app->params['admin']) {
$coin_id_items = explode(',',$coin_ids);
foreach($coin_id_items as $id) {
$coin_id_items = explode(',', $coin_ids);
foreach ($coin_id_items as $id) {
$coin = Coin::getOneById($id);
if($coin){
$platform_ids = explode(',',$coin->platform_id);
if ($coin) {
$platform_ids = explode(',', $coin->platform_id);
$platform_ids = implode(',', array_diff($platform_ids, [$platform_id]));
$coin->platform_id = $platform_ids;
$coin->save();
......@@ -527,11 +533,11 @@ class CoinController extends BaseController
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$data = Coin::getPlatformList();
foreach ($data as $item){
if($item){
foreach ($data as $item) {
if ($item) {
$platformInfo['platform'] = $item;
$icon = Yii::$app->redis->hget('platform_image_info',$item);
$brower_url = Yii::$app->redis->hget('platform_brower_info',$item);
$icon = Yii::$app->redis->hget('platform_image_info', $item);
$brower_url = Yii::$app->redis->hget('platform_brower_info', $item);
$platformInfo['icon'] = $icon ?? '';
$platformInfo['brower_url'] = $brower_url ?? '';
$platformItems[] = $platformInfo;
......@@ -548,12 +554,12 @@ class CoinController extends BaseController
*/
public function actionAddPlatformCoin()
{
if(Yii::$app->request->isPost){
if (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json';
$platform = Yii::$app->request->post('platform');
$image = Yii::$app->request->post('image');
if($platform && $image){
Yii::$app->redis->hset('platform_image_info',$platform,$image);
if ($platform && $image) {
Yii::$app->redis->hset('platform_image_info', $platform, $image);
return ['code' => 0, 'msg' => '图片添加成功'];
}
return ['code' => 0, 'msg' => '图片添加失败'];
......@@ -569,13 +575,13 @@ class CoinController extends BaseController
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$platform = $request->get('platform','');
$brower_url = $request->get('brower_url','');
if($platform){
Yii::$app->redis->hset('platform_brower_info',$platform,$brower_url);
return ['code' => 0,'msg' => '区块链浏览器地址设置成功'];
}else{
return ['code' => 1 ,'msg' => '区块链浏览器地址设置失败'];
$platform = $request->get('platform', '');
$brower_url = $request->get('brower_url', '');
if ($platform) {
Yii::$app->redis->hset('platform_brower_info', $platform, $brower_url);
return ['code' => 0, 'msg' => '区块链浏览器地址设置成功'];
} else {
return ['code' => 1, 'msg' => '区块链浏览器地址设置失败'];
}
}
}
......
......@@ -14,6 +14,7 @@ class CoinForm extends Model
{
public $id;
public $name;
public $optional_name;
public $nickname;
public $sid;
public $icon;
......@@ -49,6 +50,7 @@ class CoinForm extends Model
return [
'id' => 'ID',
'name' => '名称',
'optional_name' => '可选简称',
'nickname' => '别称',
'sid' => '全称',
'icon' => '图标',
......@@ -74,6 +76,7 @@ class CoinForm extends Model
'add' => [
'id',
'name',
'optional_name',
'nickname',
'sid',
'icon',
......@@ -92,6 +95,7 @@ class CoinForm extends Model
'update' => [
'id',
'name',
'optional_name',
'nickname',
'sid',
'icon',
......
......@@ -19,25 +19,33 @@
<input name="id" type="hidden" value="<?= $model->id ?>">
<div class="layui-inline">
<label class="layui-form-label">简称</label>
<div class="layui-input-block">
<input class="layui-input" name="name" placeholder="请填写大写字母" value="<?= $model->name ?>" lay-verify="required">
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name" placeholder="请填写大写字母" value="<?= $model->name ?>"
lay-verify="required">
</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="optional_name" placeholder="请填写大写字母"
value="<?= $model->optional_name ?>" lay-verify="required">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['zh-CN'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['en-US'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['ja'] ?>">
</div>
</div>
......
......@@ -20,7 +20,15 @@
<div class="layui-inline">
<label class="layui-form-label">简称</label>
<div class="layui-input-block">
<input class="layui-input" name="name" placeholder="请填写大写字母" value="<?= $model->name ?>" lay-verify="required">
<input class="layui-input" name="name" placeholder="请填写大写字母" value="<?= $model->name ?>"
lay-verify="required">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">可选简称</label>
<div class="layui-input-block">
<input class="layui-input" name="optional_name" placeholder="请填写大写字母" value="<?= $model->optional_name ?>"
lay-verify="required">
</div>
</div>
<div class="layui-inline">
......@@ -121,10 +129,12 @@
<select name="treaty">
<option value="1" <?php if ($model->treaty == 1) {
echo "selected";
} ?>>token</option>
} ?>>token
</option>
<option value="2" <?php if ($model->treaty == 2) {
echo "selected";
} ?>>coins</option>
} ?>>coins
</option>
</select>
</div>
</div>
......
......@@ -253,7 +253,7 @@ class ExchangeBusiness
public static function getApiListForIndex($page = 1, $limit = 999, $condition = [], $fields = [])
{
if (!$fields) {
$fields = ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain', 'address as contract_address', 'treaty'];
$fields = ['id', 'sid', 'icon', 'name', 'optional_name', 'nickname', 'platform', 'chain', 'address as contract_address', 'treaty'];
}
$rows = Coin::getSelectList($page, $limit, $fields, $condition);
$count = 0;
......@@ -307,7 +307,7 @@ class ExchangeBusiness
*/
public static function SearchByName($page = 1, $limit = 10, $condition = [])
{
$rows = Coin::getSelectList($page, $limit, ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain', 'address as contract_address', 'treaty'],
$rows = Coin::getSelectList($page, $limit, ['id', 'sid', 'icon', 'name', 'optional_name', 'nickname', 'platform', 'chain', 'address as contract_address', 'treaty'],
$condition);
if ($rows['count'] > 0) {
$total = $rows['count'];
......
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