diff --git a/application/admin/controller/shopro/commission/Level.php b/application/admin/controller/shopro/commission/Level.php index 3aa717d..1fe66c0 100644 --- a/application/admin/controller/shopro/commission/Level.php +++ b/application/admin/controller/shopro/commission/Level.php @@ -9,14 +9,27 @@ use think\Db; class Level extends Common { - protected $noNeedRight = ['select']; + protected $noNeedLogin = ['index', 'select']; + protected $noNeedRight = ['index', 'select']; protected $model = null; public function _initialize() { - parent::_initialize(); - $this->model = new LevelModel(); + try { + parent::_initialize(); + $this->model = new LevelModel(); + } catch (\Throwable $e) { + header('Content-Type: application/json; charset=utf-8'); + echo json_encode([ + 'code' => 500, + 'msg' => 'INIT_ERROR: ' . $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'trace' => explode("\n", $e->getTraceAsString()) + ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); + exit; + } } /** @@ -24,25 +37,37 @@ class Level extends Common */ public function index() { - if (!$this->request->isAjax()) { - return $this->view->fetch(); - } + try { + if (!$this->request->isAjax()) { + return $this->view->fetch(); + } - $defaultLevel = $this->model->find(1); - if (!$defaultLevel) { - $this->model->save([ - 'name' => '默认等级', - 'level' => 1, - 'commission_rules' => [ - 'commission_1' => '0.00', - 'commission_2' => '0.00', - 'commission_3' => '0.00' - ] - ]); - } - $list = $this->model->sheepFilter()->select(); + $defaultLevel = $this->model->find(1); + if (!$defaultLevel) { + $this->model->save([ + 'name' => '默认等级', + 'level' => 1, + 'commission_rules' => [ + 'commission_1' => '0.00', + 'commission_2' => '0.00', + 'commission_3' => '0.00' + ] + ]); + } + $list = $this->model->sheepFilter()->select(); - $this->success('全部等级', null, $list); + $this->success('全部等级', null, $list); + } catch (\Throwable $e) { + header('Content-Type: application/json; charset=utf-8'); + echo json_encode([ + 'code' => 500, + 'msg' => 'INDEX_ERROR: ' . $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'trace' => explode("\n", $e->getTraceAsString()) + ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); + exit; + } } /**