Files
dpl/plugins/VipLoyalty/Plugin.php
T
hellcat 0501711267 feat(fuc-xb): prepare isolated staging theme and VIP auto upgrades
Port the Fuc 0.12.0 frontend and default-off VIP plugin. Include the previously approved password-reset token revocation. Deploy only to an independent FUC-XB test instance; no production cutover.
2026-11-04 13:44:33 +08:00

25 lines
1.1 KiB
PHP

<?php
namespace Plugin\VipLoyalty;
use App\Services\Plugin\AbstractPlugin;
use Illuminate\Support\Facades\{Log,Schema};
use Illuminate\Validation\ValidationException;
final class Plugin extends AbstractPlugin {
public function boot(): void {
if(!Schema::hasTable('fuc_vip_accounts'))return;
$service=app(Service::class);
try {$enabled=$service->enabled();}
catch(ValidationException $e) {
// An enabled but corrupt policy must not silently lose paid consumption.
// Hooks below reject new creation/opening until an administrator repairs it.
Log::warning('vip_loyalty_invalid_configuration');$enabled=true;
}
if(!$enabled){$service->suspend();return;}
$this->listen('order.create.before',static function($payload)use($service){$service->sync($payload[0]->id);});
$this->listen('order.open.before',[$service,'openingOrder']);
$this->listen('admin.user.update.after',[$service,'manualChanged']);
}
public function cleanup(): void {
if(Schema::hasTable('fuc_vip_accounts'))app(Service::class)->suspend();
}
}