From bef150882d8f8ca938041d9a4740f7d9a6d6d42f Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 3 Sep 2020 16:23:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB/=E5=B8=82?= =?UTF-8?q?=E5=9C=BA=E3=80=81=E8=AE=A2=E5=8D=95=E3=80=81=E5=AD=90=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E3=80=81=E8=AE=A2=E5=8D=95=E5=95=86=E5=93=81=E3=80=81?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/MigrateMarketData.php | 79 ++++++++++++++++++ app/Console/Commands/MigrateOrder.php | 75 +++++++++++++++++ app/Console/Commands/MigrateOrderGoods.php | 80 ++++++++++++++++++ app/Console/Commands/MigrateOrderMain.php | 96 ++++++++++++++++++++++ app/Console/Commands/MigrateUserAddr.php | 72 ++++++++++++++++ 5 files changed, 402 insertions(+) create mode 100644 app/Console/Commands/MigrateMarketData.php create mode 100644 app/Console/Commands/MigrateOrder.php create mode 100644 app/Console/Commands/MigrateOrderGoods.php create mode 100644 app/Console/Commands/MigrateOrderMain.php create mode 100644 app/Console/Commands/MigrateUserAddr.php diff --git a/app/Console/Commands/MigrateMarketData.php b/app/Console/Commands/MigrateMarketData.php new file mode 100644 index 0000000..d6f4b75 --- /dev/null +++ b/app/Console/Commands/MigrateMarketData.php @@ -0,0 +1,79 @@ +get(); + + $bar = $this->output->createProgressBar(count($oldData)); + $bar->start(); + + $newData = []; + foreach ($oldData as $key => $value) { + $coordinates = explode(',', $value->coordinates); + $newData[] = [ + 'mp_id' => $value->mp_id ?? 0, + 'name' => $value->name ?? '', + 'logo' => $value->logo ?? '', + 'introduce' => $value->introduce ?? '', + 'imgs' => $value->imgs ?? '', + 'province_id' => 2162, + 'city_id' => 2163, + 'region_id' => 0, + 'address' => $value->address ?? '', + 'tel' => $value->tel ?? '', + 'lat' => $coordinates[0] ?? '', + 'lng' => $coordinates[1] ?? '', + 'status' => $value->status ?? 1, + 'sort' => $value->sort ?? 1, + 'created_at' => $value->addtime ? strtotime($value->addtime) : 0, + 'updated_at' => $value->addtime ? strtotime($value->addtime) : 0, + ]; + + $bar->advance(); + } + + // insert new data to new table + DB::table('lanzu_market')->insert($newData); + + $bar->finish(); + return 0; + } +} diff --git a/app/Console/Commands/MigrateOrder.php b/app/Console/Commands/MigrateOrder.php new file mode 100644 index 0000000..8acef0f --- /dev/null +++ b/app/Console/Commands/MigrateOrder.php @@ -0,0 +1,75 @@ +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; + } +} diff --git a/app/Console/Commands/MigrateOrderGoods.php b/app/Console/Commands/MigrateOrderGoods.php new file mode 100644 index 0000000..855b78a --- /dev/null +++ b/app/Console/Commands/MigrateOrderGoods.php @@ -0,0 +1,80 @@ +get(); + + $bar = $this->output->createProgressBar(count($oldData)); + $bar->start(); + + $newData = []; + foreach ($oldData as $key => $value) { + + $goods =DB::table('ims_cjdc_goods')->find($value->good_id); + + $newData[] = [ + 'order_id' => $value->order_id ?? 0, + 'goods_id' => $value->good_id ?? 0, + 'number' => $value->number ?? 0, + 'status' => 1, + 'price' => $value->money ?? 0, + 'original_price' => $goods->money2 ?? 0, + 'vip_price' => $goods->vip_money ?? 0, + 'name' => $value->name ?? '', + 'goods_unit' => $value->good_unit ?? '', + 'cover_img' => $value->img ?? '', + 'spec' => json_encode([]), + 'refund_time' => 0, + 'created_at' => time(), + 'updated_at' => time(), + 'refuse_refund_note' => '', + ]; + + $bar->advance(); + } + + // insert new data to new table + DB::table('lanzu_order_goods')->insert($newData); + + $bar->finish(); + return 0; + } +} diff --git a/app/Console/Commands/MigrateOrderMain.php b/app/Console/Commands/MigrateOrderMain.php new file mode 100644 index 0000000..7c497d0 --- /dev/null +++ b/app/Console/Commands/MigrateOrderMain.php @@ -0,0 +1,96 @@ +get(); + + $bar = $this->output->createProgressBar(count($oldData)); + $bar->start(); + + $newData = []; + foreach ($oldData as $key => $value) { + + $newData[] = [ + 'market_id' => $value->market_id ?? 0, + 'order_num' => $value->order_num ?? '', + 'global_order_id' => $value->global_order_id ?? 0, + 'user_id' => $value->user_id ?? 0, + 'pay_type' => $value->pay_type ?? 0, + 'type' => $value->type ?? 0, + 'order_type' => $value->order_type ?? 0, + 'shipping_type' => $value->dada_status==0 ? 1 : 2, + 'money' => $value->money ?? 0, + 'total_money' => $value->total_money ?? 0, + 'services_money' => 0, + 'coupon_money' => $value->yhq_money2 ?? 0, + 'delivery_money' => $value->dada_fee ?? 0, + 'state' => $value->state ?? 0, + 'pay_time' => $value->pay_time ? strtotime($value->pay_time) : 0, + 'receive_time' => $value->jd_time ? strtotime($value->jd_time) : 0, + 'delivery_time' => 0, + 'complete_time' => $value->complete_time ? strtotime($value->complete_time) : 0, + 'cancel_time' => $value->complete_time ? strtotime($value->complete_time) : 0, + 'refund_time' => $value->refund_time ?? 0, + 'tel' => $value->tel ?? '', + 'address' => $value->address ?? '', + 'lat' => $value->lat ?? '', + 'lng' => $value->lng ?? '', + 'name' => $value->name ?? '', + 'print_num' => $value->print_num ?? 0, + 'plat' => $value->plat ?? 0, + 'refuse_refund_note' => $value->refuse_refund_note ?? '', + 'delivery_time_note' => $value->delivery_time ?? '', + 'total_refund_note' => $value->total_refund_note ?? '', + 'note' => $value->note ?? '', + 'created_at' => $value->time_add ?? 0, + 'updated_at' => 0, + ]; + + $bar->advance(); + } + + // insert new data to new table + DB::table('lanzu_order_main')->insert($newData); + + $bar->finish(); + return 0; + } +} diff --git a/app/Console/Commands/MigrateUserAddr.php b/app/Console/Commands/MigrateUserAddr.php new file mode 100644 index 0000000..8c5d38a --- /dev/null +++ b/app/Console/Commands/MigrateUserAddr.php @@ -0,0 +1,72 @@ +get(); + + $bar = $this->output->createProgressBar(count($oldData)); + $bar->start(); + + $newData = []; + foreach ($oldData as $key => $value) { + $newData[] = [ + 'user_id' => $value->user_id ?? '', + 'user_name' => $value->user_name ?? '', + 'address' => $value->address ?? '', + 'gender' => $value->sex ?? 0, + 'lat' => $value->lat ?? '', + 'lng' => $value->lng ?? '', + 'tel' => $value->tel ?? '', + 'tags' => json_encode([]), + 'created_at' => time(), + 'updated_at' => time(), + ]; + + $bar->advance(); + } + + // insert new data to new table + DB::table('lanzu_user_address')->insert($newData); + + $bar->finish(); + return 0; + } +}