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.
69 lines
1.6 KiB
69 lines
1.6 KiB
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class MigrateStore extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'migrateData:store';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command 迁移店铺数据';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
// 如果表不存在则创建
|
|
// if(!Schema::hasTable('lanzu_store_users')){
|
|
// Schema::create('lanzu_store_users',function (Blueprint $table){
|
|
// $table->id();
|
|
// });
|
|
// }
|
|
$oldData = DB::table('ims_cjdc_store_new')->get();
|
|
$bar = $this->output->createProgressBar(count($oldData));
|
|
$bar->start();
|
|
$newData = [];
|
|
foreach ($oldData as $ka => $va){
|
|
|
|
// $storeUsers = DB::table('lanzu_store_users')->find($va->uid);
|
|
// if(!empty($storeUsers)){
|
|
$newData =[
|
|
'user_category'=>$va->role,
|
|
'store_id'=>$va->storeid
|
|
];
|
|
// DB::table('lanzu_store_users')->where('id',$va->uid)->update($data);
|
|
// }
|
|
$bar->advance();
|
|
}
|
|
|
|
DB::table('lanzu_store_new')->insert($newData);
|
|
$bar->finish();
|
|
|
|
return 0;
|
|
}
|
|
}
|