From 67fc583bd3e9a2c4f24a8bb4dbedbcd72ef8e7c1 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Wed, 14 May 2025 15:13:13 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BA=A7=E5=93=81=E8=B4=AD?= =?UTF-8?q?=E4=B9=B0=E9=93=BE=E6=8E=A5=E8=BF=81=E7=A7=BB=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/command/DataMigration.php | 41 ++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/app/command/DataMigration.php b/app/command/DataMigration.php index 969d791c..3fb44b47 100644 --- a/app/command/DataMigration.php +++ b/app/command/DataMigration.php @@ -48,7 +48,10 @@ class DataMigration extends Command // $this->migrateProduct(); // 迁移产品关联产品数据 - $this->migrateProductRelated(); + // $this->migrateProductRelated(); + + // 迁移产品购买链接 + $this->migrateProductPurchaseLinks(); // 迁移文章 // $this->migrateArticle([ @@ -594,6 +597,42 @@ class DataMigration extends Command Db::name('product_related')->insertAll($data); } + // 迁移产品购买链接 + private function migrateProductPurchaseLinks() + { + $platform_maps = [ + 1 => 2, + 2 => 1, + 3 => 3, + 4 => 4 + ]; + + $sources = include_once(runtime_path() . 'product_success.php'); + $maps = []; + foreach ($sources as $so) { + $maps[$so['cod_product_id']] = $so; + } + + $old_db = Db::connect('old'); + $links = $old_db->name('product_purchase_links') + ->where('country_code', 'in', ['ZH', 'US']) + ->where('link', '<>', '') + ->cursor(); + + foreach ($links as $link) { + if (empty($maps[$link['product_id']])) { + continue; + } + $item = [ + 'language_id' => $link['country_code'] == 'ZH' ? 1 : 2, + 'product_id' => $maps[$link['product_id']]['ow_product_id'], + 'platform_id' => $platform_maps[$link['platform_id']], + 'link' => $link['link'] + ]; + Db::name('product_purchase_link')->insert($item); + } + } + // 迁移文章 private function migrateArticle($category_map = []) {