'PC', 'H5', 'WECHAT', '微信' => 'H5', 'APP', 'IOS', 'ANDROID' => 'APP', default => null, }; } public static function isPublishedOn(array $activity, ?string $platform): bool { if ((int)($activity['type'] ?? 0) === 2) { return true; } $platforms = self::platforms($activity['publish_platforms'] ?? []); return !$platforms || in_array(self::normalizePlatform($platform), $platforms, true); } public static function evaluate(array $activity, ?array $member): array { if ((int)($activity['type'] ?? 0) === 2) { return self::result(); } if (!$member) { return self::result('请先登录'); } if (!empty($activity['register_time_limited'])) { $registered = strtotime($member['registered_at'] ?? ''); $start = strtotime($activity['register_start_time'] ?? ''); $end = strtotime($activity['register_end_time'] ?? ''); if (!$registered || !$start || !$end || $registered < $start || $registered > $end) { return self::result('不符合会员注册时间条件'); } } $platforms = self::platforms($activity['register_platforms'] ?? []); if ($platforms && !in_array(self::normalizePlatform($member['register_platform'] ?? null), $platforms, true)) { return self::result('不符合会员注册平台条件'); } if (!empty($activity['deposit_limited'])) { $min = $activity['deposit_min'] ?? null; $max = $activity['deposit_max'] ?? null; $total = $member['deposit_total'] ?? null; if (!is_numeric($min) || !is_numeric($max) || !is_numeric($total) || bccomp((string)$total, (string)$min, 2) < 0 || bccomp((string)$total, (string)$max, 2) > 0) { return self::result('不符合会员生涯存款条件'); } } return self::result(); } private static function platforms($value): array { return is_array($value) ? $value : (json_decode($value ?? '[]', true) ?: []); } private static function result(string $reason = ''): array { return ['is_eligible' => $reason === '', 'ineligible_reason' => $reason]; } }