'integer', 'talent_level' => 'integer', 'transfer_type' => 'string', 'fee_rate' => 'decimal:4', 'priority' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; /** * 状态常量 */ const STATUS_DISABLED = 0; // 禁用 const STATUS_ENABLED = 1; // 启用 /** * 转账类型常量 */ const TYPE_IN = 'in'; // 转入 const TYPE_OUT = 'out'; // 转出 /** * 转账类型映射 */ public static $typeMap = [ self::TYPE_IN => '转入', self::TYPE_OUT => '转出', ]; /** * 检查配置是否启用 */ public function isEnabled(): bool { return $this->status === self::STATUS_ENABLED; } /** * 检查是否为转入类型 */ public function isTransferIn(): bool { return $this->transfer_type === self::TYPE_IN; } /** * 检查是否为转出类型 */ public function isTransferOut(): bool { return $this->transfer_type === self::TYPE_OUT; } /** * 获取转账类型文本 */ public function getTransferTypeText(): string { return self::$typeMap[$this->transfer_type] ?? '未知'; } /** * 检查是否匹配指定的房屋等级 * * @param int $houseLevel 房屋等级 * @return bool */ public function matchesHouseLevel(int $houseLevel): bool { return $this->house_level === 0 || $this->house_level === $houseLevel; } /** * 检查是否匹配指定的达人等级 * * @param int $talentLevel 达人等级 * @return bool */ public function matchesTalentLevel(int $talentLevel): bool { return $this->talent_level === 0 || $this->talent_level === $talentLevel; } /** * 检查是否匹配指定的房屋等级和达人等级 * * @param int $houseLevel 房屋等级 * @param int $talentLevel 达人等级 * @param string|null $transferType 转账类型 * @return bool */ public function matches(int $houseLevel, int $talentLevel, ?string $transferType = null): bool { $matchesLevels = $this->matchesHouseLevel($houseLevel) && $this->matchesTalentLevel($talentLevel); if ($transferType !== null) { return $matchesLevels && $this->transfer_type === $transferType; } return $matchesLevels; } /** * 获取手续费率百分比显示 * * @return string */ public function getFeeRatePercentage(): string { return number_format($this->fee_rate * 100, 2) . '%'; } /** * 获取配置的匹配条件描述 * * @return string */ public function getMatchConditionDescription(): string { $conditions = []; // 转账类型 $conditions[] = $this->getTransferTypeText(); if ($this->house_level > 0) { $conditions[] = "房屋等级{$this->house_level}级"; } else { $conditions[] = "所有房屋等级"; } if ($this->talent_level > 0) { $conditions[] = "达人等级{$this->talent_level}级"; } else { $conditions[] = "所有达人等级"; } return implode(' + ', $conditions); } }