// +---------------------------------------------------------------------- declare (strict_types = 1); namespace addon\appmall\controller\backend; use think\facade\Db; use think\facade\View; use Exception; use ywxapp\controller\BackendBase; /** * 插件审核(运营后台,中心站) * * 审核开发者通过 Market::submit 提交的插件上架申请(appmall_addon_submissions)。 * status: 0=待审核 1=已发布 2=已驳回。 */ class AddonReview extends BackendBase { /** * 审核列表 / 页面 */ public function index() { if ($this->request->isAjax()) { $status = $this->request->param('status', ''); $query = Db::name('appmall_addon_submissions')->order('id', 'desc'); if ($status !== '') { $query->where('status', (int) $status); } $list = $query->paginate([ 'page' => (int) $this->request->param('page', 1), 'list_rows' => (int) $this->request->param('limit', 10), ]); $this->result->setCount($list->total())->success($list->items(), '获取成功'); } return View::fetch('addonreview/index'); } /** * 审核通过:标记已发布(status=1) * 注意:正式上架到 appmall_addon_list 由发布流程处理,此处仅切换审核态。 */ public function audit() { try { $id = (int) input('id'); $row = Db::name('appmall_addon_submissions')->where('id', $id)->find(); if (empty($row)) { return $this->result->error('提交记录不存在'); } if ((int) $row['status'] === 1) { return $this->result->error('该提交已发布'); } Db::name('appmall_addon_submissions')->where('id', $id) ->update(['status' => 1, 'reject_reason' => '', 'update_at' => time()]); return $this->result->success([], '已通过审核'); } catch (Exception $e) { return $this->result->error($e->getMessage()); } } /** * 驳回:标记已驳回(status=2)并记录原因 */ public function reject() { try { $id = (int) input('id'); $reason = trim(input('reason', '')); if ($reason === '') { return $this->result->error('请填写驳回原因'); } $row = Db::name('appmall_addon_submissions')->where('id', $id)->find(); if (empty($row)) { return $this->result->error('提交记录不存在'); } Db::name('appmall_addon_submissions')->where('id', $id) ->update(['status' => 2, 'reject_reason' => $reason, 'update_at' => time()]); return $this->result->success([], '已驳回'); } catch (Exception $e) { return $this->result->error($e->getMessage()); } } }