vd/tests/Activate.php

32 lines
819 B
PHP

<?php
use Illuminate\Http\UploadedFile;
use App\Domains\Export\Services\ImportService;
require_once realpath(dirname(__FILE__) . '/TestCase.php');
$file = new UploadedFile(__DIR__ . '/激活处理.xlsx', '激活处理.xlsx');
$data = ImportService::load($file, null, 2);
$sim = join(',', array_pluck($data, 'sim'));
DB::update(
sprintf(
"
update cards set virtual_activated_at =
to_timestamp(floor(random() * (EXTRACT(epoch FROM '%s'::timestamp) - EXTRACT(epoch FROM '%s'::timestamp) + 1) + EXTRACT(epoch FROM '%s'::timestamp)))
where sim in (%s) AND virtual_activated_at is null
",
'2019-11-30 23:59:59',
'2019-11-01 00:00:00',
'2019-11-01 00:00:00',
$sim
)
);
DB::select(sprintf("SELECT fix_timelines(ARRAY[%s])", $sim));
dd($sim);