diff --git a/app/Console/Commands/MigrateGoods.php b/app/Console/Commands/MigrateGoods.php new file mode 100644 index 0000000..6795bb2 --- /dev/null +++ b/app/Console/Commands/MigrateGoods.php @@ -0,0 +1,143 @@ +id(); + // }); + // } + $specData = [ + '克' => '净含量', + '斤' => '净含量', + '两' => '净含量', + '只' => '净含量', + '份' => '净含量', + 'g' => '净含量', + 'l' => '净含量', + 'ml' => '净含量', + 'ML' => '净含量', + 'L' => '净含量', + '个' => '净含量', + '条' => '净含量', + '公分' => '净含量', + '边' => '净含量', + '包' => '净含量', + '辣' => '口味', + '馅' => '馅料', + 'mm' => '尺寸' + ]; + $oldData = DB::table('ims_cjdc_goods_new')->get(); + $bar = $this->output->createProgressBar(count($oldData)); + $bar->start(); + $startTime = time(); + $total = 0; + foreach ($oldData as $value){ + $goodsData =[ + // 'id'=>$value->id, + 'market_id'=>$value->market_id, + 'store_id'=>$value->store_id, + 'on_sale'=> $value->is_show == 1 ? 1 : 0, + 'sort'=>$value->num, + 'price'=>$value->money, + 'original_price'=>$value->money2, + 'vip_price'=>$value->vip_money, + 'sales'=>$value->sales, + 'start_num'=>$value->start_num, + 'restrict_num'=>$value->restrict_num, + 'is_infinite'=> $value->is_max == 1 ? 1 :0, + 'inventory'=>$value->inventory, + 'name'=>$value->name, + 'cover_img'=>$value->logo, + 'goods_unit'=>$value->good_unit, + + 'spec'=>$value->spec, + + 'content'=>$value->content, + 'details'=>$value->details, + ]; + $specs = DB::table('ims_cjdc_spec_combination_new')->where('good_id',$value->id)->get(); + if(!empty($specs)){ + foreach($specs as $vs){ + $spec = ['spec_key'=>'净含量','spec_value'=>$vs->combination]; + if(strstr($vs->combination,'辣')){ + $spec['spec_key'] = '口味'; + }else if(strstr($vs->combination,'馅')){ + $spec['spec_key'] = '馅料'; + }else if(strstr($vs->combination,'mm')){ + $spec['spec_key'] = '尺寸'; + } + $goodsData['spec'] = json_encode($spec); + $newData = $goodsData; + $newBanner = [ + 'type' =>1, + 'path' =>$value->logo, + 'created_at' =>time(), + 'updated_at' =>time(), + ]; + $id = DB::table('lanzu_goods_new')->insertGetId($newData); + $newBanner['goods_id'] = $id; + DB::table('lanzu_goods_banners_new')->insertGetId($newBanner); + $total++; + if($total == 2){ + break; + } + } + }else{ + $newData = $goodsData; + $id = DB::table('lanzu_goods_new')->insertGetId($newData); + $newBanner['goods_id'] = $id; + DB::table('lanzu_goods_banners_new')->insertGetId($newBanner); + $total++; + if($total == 2){ + break; + } + } + + $bar->advance(); + } + + $bar->finish(); + echo '\r\n '; + echo time()-$startTime; + echo '\r\n '.$total; + return 0; + } +} diff --git a/app/Console/Commands/MigrateStore.php b/app/Console/Commands/MigrateStore.php index 5db6063..4e32ae0 100644 --- a/app/Console/Commands/MigrateStore.php +++ b/app/Console/Commands/MigrateStore.php @@ -44,26 +44,68 @@ class MigrateStore extends Command // $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 $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); - // } + 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(); } - DB::table('lanzu_store_new')->insert($newData); $bar->finish(); - + echo '\r\n '; + echo time()-$startTime; return 0; } }