Commit b299d0eb authored by shajiaiming's avatar shajiaiming

推荐币添加所属链

parent cb8c089e
......@@ -57,7 +57,8 @@ class CoinRecommendController extends BaseController
} else {
$platforms = CoinPlatform::find()->where(['id' => $user_platform_id])->asArray()->all();
}
return $this->render('index', ['platforms' => $platforms]);
$chains = Coin::getPlatformList();
return $this->render('index', ['platforms' => $platforms, 'chains' => $chains]);
}
public function actionAdd()
......
......@@ -88,6 +88,17 @@
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">所属链</label>
<div class="layui-input-inline">
<select class="layui-select" name="chain">
<option value="">请选择一个链</option>
<?php foreach ($chains as $chain): ?>
<option value="<?= $chain ?>"><?= $chain ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</form>
</div>
......@@ -162,6 +173,10 @@ table.render({
templet: '#type_tpl'
},
{
field: 'chain',
title: '所属链',
},
{
field: 'sort',
title: '排序'
},
......@@ -191,7 +206,8 @@ table.on('toolbar(table1)', function(obj) {
coin: '',
sort: '',
recommend: '',
type:''
type:'',
chain:'',
});
},
btn1: function() {
......@@ -238,7 +254,8 @@ table.on('tool(table1)', function(obj) {
coin: data.coin,
sort: data.sort,
recommend: data.recommend,
type: data.type
type: data.type,
chain: data.chain
});
},
btn1: function() {
......
......@@ -82,6 +82,7 @@ class CoinRecommend extends BaseActiveRecord
$recommend_type = $params['recommend'] ?? 1;
$sort = $params['sort'] ?? 0;
$type = $params['type'] ?? 1;
$chain = $params['chain'] ?? '';
$coin = Coin::findOne(['name' => strtoupper($coin_name)]);
if (empty($coin)) {
......@@ -92,7 +93,7 @@ class CoinRecommend extends BaseActiveRecord
$coin_recommend = CoinRecommend::findOne($id);
} else {
$coin_recommend = new CoinRecommend();
$count = self::find()->where(['cid' => $coin->id, 'platform_id' => $platform_id, 'type' => $type])->count();
$count = self::find()->where(['cid' => $coin->id, 'platform_id' => $platform_id, 'type' => $type, 'chain' => $chain])->count();
if ($count > 0) {
return ['code' => -1, 'msg' => '推荐币种已经存在'];
}
......@@ -106,6 +107,7 @@ class CoinRecommend extends BaseActiveRecord
$coin_recommend->platform_id = $platform_id;
$coin_recommend->sort = $sort;
$coin_recommend->type = $type;
$coin_recommend->chain = $chain;
if ($coin_recommend->save()) {
return ['code' => 0, '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