Commit 67534fea authored by shajiaiming's avatar shajiaiming

Merge branch 'master' into feature/ucenter

parents a13f279b cb8c089e
......@@ -68,7 +68,7 @@ class CoinController extends BaseController
}
$recommend = $request->post('recommend', '');
$condition = ['platform_id' => $platform_id];
$condition = ['platform_id' => $platform_id, 'type' => 1];
if ($recommend) {
$condition['recommend'] = $recommend;
}
......@@ -126,7 +126,7 @@ class CoinController extends BaseController
$platform_id = $request->post('platform_id', 1);//默认币钱包
$recommend = $request->post('recommend', '');
$condition = ['platform_id' => $platform_id];
$condition = ['platform_id' => $platform_id, 'type' => 1];
if ($recommend) {
$condition['recommend'] = $recommend;
}
......
......@@ -92,8 +92,8 @@ class ServiceController extends BaseController
public function actionCoinIndex()
{
$platform_id = Yii::$app->request->get('platform_id', 6);
//$coinItems = $request->post('names',[]);
$coin_recommendItems = $this->coinRecommendList($platform_id);
$type = Yii::$app->request->get('type', 1);
$coin_recommendItems = $this->coinRecommendList($platform_id, $type);
$fields =['id', 'sid', 'icon', 'name', 'nickname','chain','platform'];
$rows = Coin::getSelectList(1, 999, $fields,[['in','id',$coin_recommendItems]]);
foreach ($rows['data'] as $key => &$value) {
......@@ -107,9 +107,9 @@ class ServiceController extends BaseController
* @return array
* 托管钱包推荐币种
*/
private function coinRecommendList($platform_id)
private function coinRecommendList($platform_id, $type = 1)
{
$recommend_list = CoinRecommend::find()->select('cid')->where(['platform_id' => $platform_id ])->all();
$recommend_list = CoinRecommend::find()->select('cid')->where(['platform_id' => $platform_id ,'type' => $type])->all();
if($recommend_list){
$coin_ids = array_column($recommend_list,'cid');
return $coin_ids;
......
......@@ -67,9 +67,10 @@ class CoinRecommendController extends BaseController
$get = Yii::$app->request->get();
$platform_id = $get['platform_id'] ?? 1;
$platform_id = empty($get['platform_id']) ? 1 : $get['platform_id'];
$user_platform_id = Yii::$app->user->identity->platform_id;
#var_dump($platform_id, $user_platform_id);exit;
if (1 != $user_platform_id && $user_platform_id != $platform_id) {
return ['code' => -1, 'msg' => '没有权限修改'];
}
......
......@@ -79,6 +79,15 @@
<input name="sort" class="layui-input" type="text">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">所属类型</label>
<div class="layui-input-block">
<select name="type" class="layui-select">
<option value="1">币钱包</option>
<option value="2">托管钱包</option>
</select>
</div>
</div>
</form>
</div>
......@@ -100,6 +109,14 @@
{{# } }}
</script>
<script type="text/html" id="type_tpl">
{{# if(1 == d.type){ }}
币钱包
{{# } else if(2 == d.type){ }}
托管钱包
{{# } }}
</script>
<script type="text/html" id="toolBar">
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">编辑</button>
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</button>
......@@ -140,6 +157,11 @@ table.render({
templet: '#recommend_tpl'
},
{
field: 'type',
title: '所属类型',
templet: '#type_tpl'
},
{
field: 'sort',
title: '排序'
},
......@@ -168,7 +190,8 @@ table.on('toolbar(table1)', function(obj) {
platform_id: $('#platform_id').val(),
coin: '',
sort: '',
recommend: ''
recommend: '',
type:''
});
},
btn1: function() {
......@@ -214,7 +237,8 @@ table.on('tool(table1)', function(obj) {
platform_id: data.platform_id,
coin: data.coin,
sort: data.sort,
recommend: data.recommend
recommend: data.recommend,
type: data.type
});
},
btn1: function() {
......
......@@ -81,6 +81,7 @@ class CoinRecommend extends BaseActiveRecord
$coin_name = $params['coin'] ?? '';
$recommend_type = $params['recommend'] ?? 1;
$sort = $params['sort'] ?? 0;
$type = $params['type'] ?? 1;
$coin = Coin::findOne(['name' => strtoupper($coin_name)]);
if (empty($coin)) {
......@@ -91,7 +92,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])->count();
$count = self::find()->where(['cid' => $coin->id, 'platform_id' => $platform_id, 'type' => $type])->count();
if ($count > 0) {
return ['code' => -1, 'msg' => '推荐币种已经存在'];
}
......@@ -104,6 +105,7 @@ class CoinRecommend extends BaseActiveRecord
$coin_recommend->recommend = $recommend_type;
$coin_recommend->platform_id = $platform_id;
$coin_recommend->sort = $sort;
$coin_recommend->type = $type;
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