refactor: 产品购买链接迁移程序

This commit is contained in:
2025-05-14 15:13:13 +08:00
parent 80bc067cef
commit 5fe71988fa

View File

@@ -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 = [])
{