chore: 增加分销商等级页面异常排查诊断代码

这个提交包含在:
wikiboss
2026-09-17 16:18:07 +08:00
父节点 99a55af2b6
当前提交 4c38aa3710

查看文件

@@ -9,14 +9,27 @@ use think\Db;
class Level extends Common class Level extends Common
{ {
protected $noNeedRight = ['select']; protected $noNeedLogin = ['index', 'select'];
protected $noNeedRight = ['index', 'select'];
protected $model = null; protected $model = null;
public function _initialize() public function _initialize()
{ {
parent::_initialize(); try {
$this->model = new LevelModel(); 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() public function index()
{ {
if (!$this->request->isAjax()) { try {
return $this->view->fetch(); if (!$this->request->isAjax()) {
} return $this->view->fetch();
}
$defaultLevel = $this->model->find(1); $defaultLevel = $this->model->find(1);
if (!$defaultLevel) { if (!$defaultLevel) {
$this->model->save([ $this->model->save([
'name' => '默认等级', 'name' => '默认等级',
'level' => 1, 'level' => 1,
'commission_rules' => [ 'commission_rules' => [
'commission_1' => '0.00', 'commission_1' => '0.00',
'commission_2' => '0.00', 'commission_2' => '0.00',
'commission_3' => '0.00' 'commission_3' => '0.00'
] ]
]); ]);
} }
$list = $this->model->sheepFilter()->select(); $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;
}
} }
/** /**