<?php


require_once realpath(dirname(__FILE__) . '/TestCase.php');

use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB;
use App\Models\Real\OrderCardPartition;
use App\Domains\Export\Services\ImportService;

echo 'started.' . PHP_EOL;

$file = new UploadedFile(__DIR__ . '/数据不进vd.xlsx', '数据不进vd.xlsx');

$data = ImportService::load($file, null, 0);

echo 'loaded.' . PHP_EOL;

$simArray = array_pluck($data, 'sim');
unset($data);
deleteOrderCard($simArray);

$data = ImportService::load($file, null, 1);

echo 'loaded.' . PHP_EOL;

$simArray = array_pluck($data, 'sim');
unset($data);
deleteOrderCard($simArray);


function deleteOrderCard($simArray)
{
    foreach (array_chunk($simArray, 1000) as $key => $value) {
        OrderCardPartition::whereIn('sim', $value)->delete();
    }
}

dd($data);
