Commit 3a12c875 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

Feature/optimize See merge request !46
parents b7af8d09 b35c8b41
......@@ -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>
......
......@@ -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)) {
......@@ -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