This commit is contained in:
2026-02-28 10:38:33 +08:00
parent fa37deb209
commit a5ba7e045f
13 changed files with 133 additions and 112 deletions
@@ -36,6 +36,12 @@ class AppMessageQueuePushShopee extends HyperfCommand
InputOption::VALUE_REQUIRED,
'Queue type: product, order, refund, inventory'
);
$this->addOption(
'ids',
null,
InputOption::VALUE_REQUIRED,
'Comma-separated primary key IDs to fetch specific records'
);
}
/**
@@ -48,21 +54,25 @@ class AppMessageQueuePushShopee extends HyperfCommand
'table' => 'wpic_shopee_order',
'column' => 'raw',
'producer' => ShopeeOrderProducer::class,
'primary' => 'order_sn',
],
'product' => [
'table' => 'wpic_shopee_item',
'column' => 'raw',
'producer' => ShopeeProductProducer::class,
'primary' => 'item_id',
],
'refund' => [
'table' => 'wpic_shopee_return',
'column' => 'raw',
'producer' => ShopeeRefundProducer::class,
'primary' => 'return_sn',
],
'inventory' => [
'table' => 'wpic_shopee_inventory',
'column' => 'raw',
'producer' => ShopeeInventoryProducer::class,
'primary' => 'item_id',
],
];
@@ -86,7 +96,7 @@ class AppMessageQueuePushShopee extends HyperfCommand
// 尝试更新 store 信息
$store = Store::where('platform_id', '=', 25)
->where('platform_store_id', '=', 1669343109 )
->where('platform_store_id', '=', 1402800321 )
->first();
if(!$store){
@@ -98,7 +108,7 @@ class AppMessageQueuePushShopee extends HyperfCommand
'partner_id' => 2006675,
'app_id' => '',
'merchant_id' => 3726273,
'name' => 'owala.sg',
'name' => 'nanit.sg',
'zone' => 'SG',
];
@@ -107,11 +117,21 @@ class AppMessageQueuePushShopee extends HyperfCommand
$store->save();
// 从 raw 数据库连接获取数据
$records = Db::connection('raw')
$query = Db::connection('raw')
->table($config['table'])
->where('store_id', '=', 1669343109)
->orderBy('id', 'desc')
->limit(4)->get($config['column'])->lazy();
->where('store_id', '=', 1402800321);
$idsOption = $this->input->getOption('ids');
if (!empty($idsOption)) {
$ids = array_map('trim', explode(',', $idsOption));
$ids = array_unique(array_filter($ids, fn($id) => $id !== ''));
$query->whereIn($config['primary'], $ids);
$this->info(sprintf('Fetching records by IDs: %s', implode(', ', $ids)));
} else {
$query->orderBy('id', 'desc')->limit(4);
}
$records = $query->get([$config['column']])->lazy();
if ($records->isEmpty()) {
$this->warn(sprintf('No records found in %s table', $config['table']));
@@ -136,10 +156,10 @@ class AppMessageQueuePushShopee extends HyperfCommand
//@ATTENTION 生产环境需要注意, 暂时使用 Shopee Loop SG 进行测试
$messageData = [
'company_id' => 171,
'company_id' => 198,
'platform_id' => 25,
'store_id' => 255,
'platform_store_id' => 1669343109,
'store_id' => 340,
'platform_store_id' => 1402800321,
'unique_id' => time() . '_' . uniqid(),
'raw_data' => $raw_data, // 包含 2 条原始记录
];
@@ -167,3 +187,4 @@ class AppMessageQueuePushShopee extends HyperfCommand
}
}
}