request->isAjax) { if (\Yii::$app->request->isPost) { } elseif (\Yii::$app->request->isGet) { $params = \Yii::$app->request->get(); $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['=','store_id', $this->store_id]; $where[] = ['=','is_delete', 0]; if($params['keyword']){ $where[]=['or', ['like', 'name',$params['keyword']], ['like', 'level', $params['keyword']]]; } $params = [ 'select' => '*', 'where' => $where, 'order' => 'level asc', 'page' => $params['page'], 'limit' => 20, ]; $lists = StoreBossLevel::listPage($params, false, true); $data= [ 'code' => 0, 'msg' => '', 'data' => [ 'list' => $lists['list'], 'pagination' => $lists['pagination'] ] ]; return $this->asJson($data); } } return $this->render('/store-boss-level/index'); } /** * @Author: 广东七件事 ganxiaohao * Date: 2020-05-10 * Time: 22:26 * @Note:已经启用的等级 */ public function actionEnableList() { if (\Yii::$app->request->isAjax) { if (\Yii::$app->request->isGet) { $where = [['mall_id' => $this->mall_id], ['store_id'=>$this->store_id],['is_enable'=>1],['=', 'status', StatusEnum::ENABLED]]; $args['where'] = $where; $args['select'] = 'id,level,name'; $args['order'] = 'level asc'; $list['list'] = StoreBossLevel::lists($args, true); return $this->success('操作成功', $list); } } return $this->error(); } /** * @Author: 广东七件事 ganxiaohao * @Date: 2020-05-12 * @Time: 9:23 * @Note:编辑 * @return string|\yii\web\Response */ public function actionEdit() { if (\Yii::$app->request->isAjax) { if (\Yii::$app->request->isPost) { $form = new StoreBossLevelForm(); $form->attributes = \Yii::$app->request->post('form'); $form->store_id = $this->store_id; $form->mall_id = $this->mall_id; return $this->asJson($form->setData( )); } elseif (\Yii::$app->request->isGet) { $form = new StoreBossLevelForm(); $form->attributes=\Yii::$app->request->get(); return $this->asJson($form->getDetail()); } } return $this->render('/store-boss-level/edit'); } /** * @Author: 广东七件事 ganxiaohao * @Date: 2020-05-12 * @Time: 9:52 * @Note:等级状态变更 * @return \yii\web\Response */ public function actionSwitchStatus() { $level = StoreBossLevel::findOne(['id' => \Yii::$app->request->post('id'),'store_id' => $this->store_id, 'is_delete' => 0]); if (!$level) { return $this->asJson([ 'code' => 1, 'msg' => '该等级不存在或已被删除!', ]); } try { if ($level->is_use) { $level->is_use = 0; } else { $level->is_use = 1; } if ($level->save()) { return $this->asJson([ 'code' =>1, 'msg' => '分销等级状态变更成功', ]); } } catch (\Exception $exception) { return $this->asJson([ 'code' => 1, 'msg' => $exception->getMessage() ]); } } /** * @Author: 广东七件事 ganxiaohao * @Date: 2020-05-12 * @Time: 9:52 * @Note:删除 * @return \yii\web\Response */ public function actionDelete() { if (\Yii::$app->request->isAjax) { if (\Yii::$app->request->isPost) { $id = \Yii::$app->request->post('id'); if(!$id){ return $this->error('参数错误'); } $level = StoreBossLevel::findOne(['id' => $id,'store_id' => $this->store_id, 'is_delete' => 0]); $level->is_delete = 1; if (!$level->save()) { return $this->error($level->getError()); } return $this->success('操作成功'); } } } /** * @Author: 广东七件事 ganxiaohao * @Date: 2020-05-12 * @Time: 9:47 * @Note:获取分销配置以及权重 * @return \yii\web\Response */ public function actionSetting() { $list = (new StoreBossLevelCommon())->getLevelWeights(); return $this->asJson([ 'code' =>0, 'msg' => '', 'data' => [ 'weights' => $list['newList'], 'match_weights' => $list['matchList'], ] ]); } }