链街Dcat后台
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.
 
 
 
 

111 lines
3.1 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();
$startTime = time();
$total = 0;
$newData = [];
foreach ($oldData as $value){
$storeData =[
'id'=>$value->id,
'market_id'=>$value->market_id,
'is_open'=> $value->is_open == 1 ? 1 : 0,
'is_rest'=> $value->is_rest == 1 ? 1 : 0,
'status'=>$value->state,
'category_id'=>$value->md_type,
'user_id'=>$value->user_id,
'admin_id'=>$value->admin_id,
'mm_user_id'=>$value->mm_user_id,
'sort'=>$value->number,
'loudspeaker_imei'=>$value->loudspeaker_imei,
'is_infinite'=> $value->is_max == 1 ? 1 :0,
'name'=>$value->name,
'logo'=>$value->logo,
'announcement'=>$value->announcement,
'address' => $value->address,
'business_license'=>$value->yyzz,
'zm_img' => $value->zm_img,
'fm_img'=>$value->fm_img,
'tel' => $value->tel,
'link_name'=>$value->link_name,
'link_tel' => $value->link_tel,
'expire_time'=> strtotime($value->rzdq_time),
'time1' => $value->time1,
'time2'=>$value->time2,
'time3' => $value->time3,
'time4'=>$value->time4,
'award_money' => $value->award_money,
'sales'=>$value->score,
'grade' => $value->sales,
'code'=>$value->code,
'environment' => $value->environment,
'introduction'=> strip_tags($value->introduction),
];
// preg_match('/[0-9]/', $string, $matches, PREG_OFFSET_CAPTURE);
$storeData['stall_info'] = '';
$storeData['lng'] = '';
$storeData['lat'] = '';
// DB::table('lanzu_store_new')->insert($newData);
$bar->advance();
}
$bar->finish();
echo '\r\n ';
echo time()-$startTime;
return 0;
}
}