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.
24 lines
1.5 KiB
PHP
24 lines
1.5 KiB
PHP
<?php
|
|
namespace Plugin\VipLoyalty\Commands;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Plugin\VipLoyalty\Service;
|
|
final class ImportOpening extends Command {
|
|
protected $signature='vip:import-opening {file : Private JSONL opening file} {--reference= : Snapshot SHA256}';
|
|
protected $description='导入已核定VIP期初,不导入旧订单、不改变钱包或套餐';
|
|
public function handle(Service $service): int {
|
|
$file=$this->argument('file');$reference=(string)$this->option('reference');
|
|
if(!is_file($file)||!is_readable($file)||!preg_match('/^[a-f0-9]{64}$/D',$reference)){$this->error('期初文件或快照摘要无效');return self::FAILURE;}
|
|
$count=0;
|
|
DB::transaction(function()use($file,$reference,$service,&$count){
|
|
$f=fopen($file,'r');$seen=[];
|
|
try {while(($line=fgets($f))!==false){
|
|
$v=json_decode($line,true,512,JSON_THROW_ON_ERROR);
|
|
if(!isset($v['user_id'],$v['uuid'],$v['opening_cumulative_cents']) || !is_int($v['user_id']) || !is_int($v['opening_cumulative_cents']) || isset($seen[$v['user_id']]))throw new \RuntimeException('期初字段或用户唯一性检查失败');
|
|
$seen[$v['user_id']]=true;$service->opening($v['user_id'],$v['uuid'],$v['opening_cumulative_cents'],$reference);++$count;
|
|
}}finally{fclose($f);}
|
|
});
|
|
$this->info('已核对VIP期初 '.$count.' 人;钱包、套餐和历史订单未改变。');return self::SUCCESS;
|
|
}
|
|
}
|