getIdentityList(); $this->success('获取成功', $identities); } catch (Exception $e) { $this->error($e->getMessage()); } } /** * 检查代理商身份是否需要地区信息 */ public function checkAreaRequirement() { try { $identityId = $this->request->param('agent_identity_id'); if (empty($identityId)) { $this->error('代理商身份ID不能为空'); } $requirement = AgentApplyValidate::getAreaRequirement($identityId); $this->success('获取成功', $requirement); } catch (Exception $e) { $this->error($e->getMessage()); } } /** * 提交代理商申请 */ public function apply() { try { $user = auth_user(); $data = $this->request->param(); // 使用验证器验证参数 $validate = new AgentApplyValidate(); if (!$validate->scene('apply')->check($data)) { $this->error($validate->getError()); } $service = new AgentApplyService(); $apply = $service->submitApply($user->id, $data); if ($apply->status == ApplyModel::STATUS_APPROVED) { $this->success('申请提交成功,您已成为代理商!', $apply); } else { $this->success('申请提交成功,请等待审核!', $apply); } } catch (Exception $e) { $this->error($e->getMessage()); } } /** * 获取申请状态 */ public function status() { try { $user = auth_user(); $service = new AgentApplyService(); $apply = $service->getUserApply($user->id); if (!$apply) { $this->success('未找到申请记录', null); } // 增强申请数据信息 $data = $apply->toArray(); $this->success('获取成功', $data); } catch (Exception $e) { $this->error($e->getMessage()); } } }