'integer', 'direct_count_required' => 'integer', 'promotion_count_required' => 'integer', 'active_count_required' => 'integer', 'active_direct_required' => 'integer', 'promotion_direct_group' => 'integer', 'promotion_indirect_group' => 'integer', 'promotion_third_group' => 'integer', 'planting_direct_rate' => 'decimal:4', 'planting_indirect_rate' => 'decimal:4', 'planting_third_rate' => 'decimal:4', 'sort_order' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; /** * 状态常量 */ const STATUS_DISABLED = 0; // 禁用 const STATUS_ENABLED = 1; // 启用 /** * 获取达人等级枚举 */ public function getTalentLevelEnum(): UrsTalentLevel { return UrsTalentLevel::fromInt($this->level) ?? UrsTalentLevel::NONE; } /** * 检查配置是否启用 */ public function isEnabled(): bool { return $this->status === self::STATUS_ENABLED; } /** * 获取推广收益奖励组ID * * @param int $relationLevel 推荐层级 1:直推 2:间推 3:三推 * @return int|null */ public function getPromotionRewardGroupId(int $relationLevel): ?int { return match($relationLevel) { 1 => $this->promotion_direct_group ?: null, 2 => $this->promotion_indirect_group ?: null, 3 => $this->promotion_third_group ?: null, default => null, }; } /** * 获取种植收益分成比例 * * @param int $relationLevel 推荐层级 1:直推 2:间推 3:三推 * @return float */ public function getPlantingRewardRate(int $relationLevel): float { return match($relationLevel) { 1 => (float)$this->planting_direct_rate, 2 => (float)$this->planting_indirect_rate, 3 => (float)$this->planting_third_rate, default => 0.0, }; } /** * 设置推广收益奖励组配置 * * @param array $groups 奖励组配置 [1 => 1001, 2 => 1002, 3 => 1003] */ public function setPromotionRewardGroups(array $groups): void { $this->promotion_direct_group = $groups[1] ?? 0; $this->promotion_indirect_group = $groups[2] ?? 0; $this->promotion_third_group = $groups[3] ?? 0; } /** * 设置种植收益分成比例 * * @param array $rates 分成比例配置 [1 => 0.05, 2 => 0.03, 3 => 0.01] */ public function setPlantingRewardRates(array $rates): void { $this->planting_direct_rate = $rates[1] ?? 0; $this->planting_indirect_rate = $rates[2] ?? 0; $this->planting_third_rate = $rates[3] ?? 0; } /** * 检查是否满足升级条件 * * @param int $directCount 直推人数 * @param int $promotionCount 团队总人数 * @return bool */ public function meetsRequirements(int $directCount, int $promotionCount): bool { return $directCount >= $this->direct_count_required && $promotionCount >= $this->promotion_count_required; } /** * 获取状态文本 */ public function getStatusText(): string { return match($this->status) { self::STATUS_ENABLED => '启用', self::STATUS_DISABLED => '禁用', default => '未知', }; } }