'integer', 'talent_level' => 'integer', 'direct_count' => 'integer', 'indirect_count' => 'integer', 'third_count' => 'integer', 'promotion_count' => 'integer', 'last_level_update_time' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; /** * 获取用户映射关系 */ public function userMapping(): BelongsTo { return $this->belongsTo(UrsUserMapping::class, 'user_id', 'user_id'); } /** * 获取达人等级枚举 */ public function getTalentLevelEnum(): UrsTalentLevel { return UrsTalentLevel::fromInt($this->talent_level) ?? UrsTalentLevel::NONE; } /** * 获取达人等级名称 */ public function getTalentLevelName(): string { return $this->getTalentLevelEnum()->getName(); } /** * 检查是否为达人 */ public function isTalent(): bool { return $this->getTalentLevelEnum()->isTalent(); } /** * 更新团队统计数据 * * @param int $directCount 直推人数 * @param int $indirectCount 间推人数 * @param int $thirdCount 三推人数 * @param int $promotionCount 团队总人数(20代统计) */ public function updateTeamStats(int $directCount, int $indirectCount, int $thirdCount, int $promotionCount): void { $this->direct_count = $directCount; $this->indirect_count = $indirectCount; $this->third_count = $thirdCount; $this->promotion_count = $promotionCount; } /** * 升级达人等级 */ public function upgradeTalentLevel(int $newLevel): void { if ($newLevel > $this->talent_level) { $this->talent_level = $newLevel; $this->last_level_update_time = now(); } } /** * 获取团队总人数(20代统计) */ public function getTotalTeamCount(): int { return $this->promotion_count; } /** * 获取前三代团队总人数 */ public function getThreeGenTeamCount(): int { return $this->direct_count + $this->indirect_count + $this->third_count; } }