|
|
|
@ -44,16 +44,24 @@ class MigrateStore extends Command |
|
|
|
// $table->id();
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
$oldData = DB::table('ims_cjdc_store_new')->get(); |
|
|
|
$oldTableName = 'ims_cjdc_store_new'; |
|
|
|
$newTableName = 'lanzu_store_new'; |
|
|
|
|
|
|
|
$oldData = DB::table($oldTableName)->orderBy('id','desc')->get(); |
|
|
|
$bar = $this->output->createProgressBar(count($oldData)); |
|
|
|
$bar->start(); |
|
|
|
$startTime = time(); |
|
|
|
$total = 0; |
|
|
|
$error = []; |
|
|
|
$newData = []; |
|
|
|
foreach ($oldData as $value){ |
|
|
|
foreach ($oldData as $key => $value){ |
|
|
|
$storeId = $value->id; |
|
|
|
// 判断在新表是否存在
|
|
|
|
$exist = DB::table($newTableName)->where('id',$storeId)->exists(); |
|
|
|
if($exist){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
$storeData =[ |
|
|
|
'id'=>$value->id, |
|
|
|
'id'=>$storeId, |
|
|
|
'market_id'=>$value->market_id, |
|
|
|
'is_open'=> $value->is_open == 1 ? 1 : 0, |
|
|
|
'is_rest'=> $value->is_rest == 1 ? 1 : 0, |
|
|
|
@ -65,13 +73,12 @@ class MigrateStore extends Command |
|
|
|
'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, |
|
|
|
'business_license'=> ($storeId == 365) ? '' :$value->yyzz,/* 因为365的数据的营业资质数据乱码,目前只有365这个店铺的有问题 */ |
|
|
|
'zm_img' => $value->zm_img, |
|
|
|
'fm_img'=>$value->fm_img, |
|
|
|
|
|
|
|
@ -79,7 +86,7 @@ class MigrateStore extends Command |
|
|
|
'link_name'=>$value->link_name, |
|
|
|
'link_tel' => $value->link_tel, |
|
|
|
'expire_time'=> strtotime($value->rzdq_time), |
|
|
|
'time1' => $value->time1, |
|
|
|
'time1' => $value->time, |
|
|
|
'time2'=>$value->time2, |
|
|
|
'time3' => $value->time3, |
|
|
|
'time4'=>$value->time4, |
|
|
|
@ -91,21 +98,37 @@ class MigrateStore extends Command |
|
|
|
'code'=>$value->code, |
|
|
|
'environment' => $value->environment, |
|
|
|
|
|
|
|
'introduction'=> strip_tags($value->introduction), |
|
|
|
'introduction'=> strip_tags($value->details), |
|
|
|
|
|
|
|
'created_at' => time(), |
|
|
|
'updated_at' => time(), |
|
|
|
]; |
|
|
|
// preg_match('/[0-9]/', $string, $matches, PREG_OFFSET_CAPTURE);
|
|
|
|
$storeData['stall_info'] = ''; |
|
|
|
$storeData['lng'] = ''; |
|
|
|
$storeData['lat'] = ''; |
|
|
|
|
|
|
|
// DB::table('lanzu_store_new')->insert($newData);
|
|
|
|
|
|
|
|
// 获商户摊号
|
|
|
|
$stallInfo = ''; |
|
|
|
$res = preg_match('/[0-9]/', $value->name, $matches, PREG_OFFSET_CAPTURE); |
|
|
|
if($res && count($matches)>0){ |
|
|
|
$stallInfo = substr($value->name,$matches[0][1]); |
|
|
|
} |
|
|
|
$storeData['stall_info'] = $stallInfo; |
|
|
|
|
|
|
|
// 商户经纬度
|
|
|
|
if(!empty($value->coordinates)){ |
|
|
|
$coordinatesArr = explode(',',$value->coordinates); |
|
|
|
$storeData['lng'] = $coordinatesArr[1]; |
|
|
|
$storeData['lat'] = $coordinatesArr[0]; |
|
|
|
} |
|
|
|
$newData = $storeData; |
|
|
|
$res = DB::table($newTableName)->insert($newData); |
|
|
|
if(!$res){ |
|
|
|
$error[] = ['id'=>$storeId]; |
|
|
|
break; |
|
|
|
} |
|
|
|
$bar->advance(); |
|
|
|
} |
|
|
|
|
|
|
|
$bar->finish(); |
|
|
|
echo '\r\n '; |
|
|
|
echo time()-$startTime; |
|
|
|
var_dump([time()-$startTime]); |
|
|
|
var_dump($error); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |