You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.8 KiB
75 lines
1.8 KiB
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class MigrateOrder extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'migrateData:order';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'migrate order data';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
|
|
// get old data from old table
|
|
$oldData = DB::table('ims_cjdc_order')->get();
|
|
|
|
$bar = $this->output->createProgressBar(count($oldData));
|
|
$bar->start();
|
|
|
|
$newData = [];
|
|
foreach ($oldData as $key => $value) {
|
|
$newData[] = [
|
|
'order_main_id' => $value->order_main_id ?? 0,
|
|
'user_id' => $value->user_id ?? 0,
|
|
'store_id' => $value->store_id ?? 0,
|
|
'status' => 1,
|
|
'refund_time' => 0,
|
|
'order_num' => $value->order_num ?? '',
|
|
'money' => $value->money ?? 0,
|
|
'oid' => $value->oid ?? 0,
|
|
'refuse_refund_note' => '',
|
|
'refund_note' => '',
|
|
'note' => $value->note ?? '',
|
|
'created_at' => $value->time_add ? strtotime($value->time_add) : 0,
|
|
'updated_at' => $value->time_add ? strtotime($value->time_add) : 0,
|
|
];
|
|
|
|
$bar->advance();
|
|
}
|
|
|
|
// insert new data to new table
|
|
DB::table('lanzu_order')->insert($newData);
|
|
|
|
$bar->finish();
|
|
return 0;
|
|
}
|
|
}
|