'datetime', 'created_at' => 'datetime', ]; // 获取代理商分配信息 public function agentCode() { return $this->hasOne('app\manager\model\AgentCode', 'code_id'); } // 检查是否已分配给代理商 public function isAssigned() { return (bool)$this->agentCode; } // 检查是否可用 public function isAvailable() { return !$this->is_used && !$this->isAssigned(); } }