84 lines
3.6 KiB
PHP
84 lines
3.6 KiB
PHP
<?php
|
|
|
|
|
|
require_once realpath(dirname(__FILE__) . '/TestCase.php');
|
|
|
|
use Illuminate\Http\UploadedFile;
|
|
use App\Domains\Export\Services\ImportService;
|
|
|
|
echo 'started.' . PHP_EOL;
|
|
|
|
$file = new UploadedFile(__DIR__ . '/漏激活的卡.xls', '漏激活的卡.xls');
|
|
|
|
$data = ImportService::load($file);
|
|
|
|
echo 'loaded.' . PHP_EOL;
|
|
|
|
foreach ($data as $item) {
|
|
$item = array_values($item);
|
|
$rows = DB::connection('vd_old')->table('ckb_custom_handle_log')->where('custom_no', $item[0])->get()->collect()->toArray();
|
|
|
|
echo $item[0] . PHP_EOL;
|
|
|
|
if (count($rows) == 1 && $rows[0]['type'] == 13) {
|
|
echo '.' . PHP_EOL;
|
|
$attributes = $rows[0];
|
|
|
|
if (preg_match('/_(\d+)MONTH/', $attributes['content'], $content)) {
|
|
$month = $content['1'];
|
|
|
|
$attributes['type'] = 10;
|
|
$attributes['valid_start_time'] = strtotime($item[3]);
|
|
$attributes['valid_end_time'] = strtotime("+{$month} month", $attributes['valid_start_time']);
|
|
$attributes['valid_end_time'] = strtotime('-1 second', $attributes['valid_end_time']);
|
|
$attributes['create_time'] = strtotime($item[3]);
|
|
$attributes['task_number'] = 'jh20190425';
|
|
|
|
DB::transaction(function () use ($attributes) {
|
|
unset($attributes['id']);
|
|
DB::connection('vd_old')->table('ckb_custom_handle_log')->insert($attributes);
|
|
DB::connection('vd_old')->table('ckb_custom')->where('custom_no', $attributes['custom_no'])->update([
|
|
'card_cycle_start' => $attributes['valid_start_time'],
|
|
'card_cycle_end' => $attributes['valid_end_time'],
|
|
]);
|
|
DB::connection('vd_old')->table('ckb_user_package')->where('custom_no', $attributes['custom_no'])->update([
|
|
'service_start_time' => $attributes['valid_start_time'],
|
|
'service_end_time' => $attributes['valid_end_time'],
|
|
]);
|
|
});
|
|
}
|
|
}
|
|
|
|
if (count($rows) == 2 && ($rows[0]['type'] == 10 || $rows[1]['type'] == 10)) {
|
|
echo '*' . PHP_EOL;
|
|
$attributes = $rows[0];
|
|
|
|
if (preg_match('/_(\d+)MONTH/', $attributes['content'], $content)) {
|
|
$month = $content['1'];
|
|
|
|
$attributes['type'] = 10;
|
|
$attributes['valid_start_time'] = strtotime($item[3]);
|
|
$attributes['valid_end_time'] = strtotime("+{$month} month", $attributes['valid_start_time']);
|
|
$attributes['valid_end_time'] = strtotime('-1 second', $attributes['valid_end_time']);
|
|
$attributes['create_time'] = strtotime($item[3]);
|
|
$attributes['task_number'] = 'jh20190425';
|
|
|
|
DB::transaction(function () use ($attributes) {
|
|
unset($attributes['id']);
|
|
DB::connection('vd_old')->table('ckb_custom_handle_log')->where('custom_no', $attributes['custom_no'])->update([
|
|
'valid_start_time' => $attributes['valid_start_time'],
|
|
'valid_end_time' => $attributes['valid_end_time'],
|
|
]);
|
|
DB::connection('vd_old')->table('ckb_custom')->where('custom_no', $attributes['custom_no'])->update([
|
|
'card_cycle_start' => $attributes['valid_start_time'],
|
|
'card_cycle_end' => $attributes['valid_end_time'],
|
|
]);
|
|
DB::connection('vd_old')->table('ckb_user_package')->where('custom_no', $attributes['custom_no'])->update([
|
|
'service_start_time' => $attributes['valid_start_time'],
|
|
'service_end_time' => $attributes['valid_end_time'],
|
|
]);
|
|
});
|
|
}
|
|
}
|
|
}
|