fix: poll shopee sync with task id

This commit is contained in:
QiuSW
2026-09-14 10:58:55 +08:00
parent 012269cfda
commit 7ba8860171
2 changed files with 8 additions and 2 deletions
+3 -2
View File
@@ -230,11 +230,12 @@ func (e ShopeeProduct) getByShopeeID(c *gin.Context, requireAPIKey bool, syncSho
return
}
if syncShopee {
if _, err := client.SyncShopProduct(ctx, *record); err != nil {
task, err := client.SyncShopProduct(ctx, *record)
if err != nil {
e.Error(502, err, "Shopee 商品同步失败:"+err.Error())
return
}
if _, err := client.WaitForProductSync(ctx, record.ID, time.Second); err != nil {
if _, err := client.WaitForProductSync(ctx, task.TaskID, time.Second); err != nil {
e.Error(502, err, "Shopee 商品同步失败:"+err.Error())
return
}
@@ -38,3 +38,8 @@ POST /api/v1/shopee/products/{shopeeId}/sync-wait
- 保留原有异步 `/sync` 与 `/sync-status` 接口。
- 验证:`go test ./app/admin/apis ./app/admin/router ./internal/huohanhan` 通过,`git diff --check` 通过。
- 当前状态:待验收
## 问题修复
- 修复同步等待时错误使用商品内部 ID 轮询状态的问题。
- 现在使用 `SyncShopProduct` 返回的真实 `task.TaskID` 查询同步状态,完成后再使用商品内部 ID 获取 detail。
- 验证:`go test ./app/admin/apis ./internal/huohanhan` 通过。