From d72490eab3a9ad6cb88dd933ba039267c16cb2af Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Mon, 5 Oct 2026 17:42:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=8A=E4=BC=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=20Shopee=20=E5=95=86=E5=93=81=20ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_upload.go | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/app_upload.go b/app_upload.go index 0a2be1f..d8d0827 100644 --- a/app_upload.go +++ b/app_upload.go @@ -46,20 +46,21 @@ func (a *App) UploadVideos(productIDs []string) (uploadErr error) { func (a *App) uploadOneVideo(ctx context.Context, client *erpgo.Client, id string, count int) { p, found, err := a.db.GetProduct(id) if err != nil || !found { - a.log.Error("商品 %s 无法读取上传信息", id) + a.log.Error("货憨憨商品 %s 无法读取上传信息", id) return } + logID := fmt.Sprintf("%s(货憨憨 ID %s)", p.ItemID, p.ID) fail := func(code string) { if err := a.db.UpdateProductStatus(p.ID, "", "", store.UploadFailed, code); err != nil { - a.log.Error("商品 %s 更新上传状态失败:%v", p.ID, err) + a.log.Error("商品 %s 更新上传状态失败:%v", logID, err) } - a.log.Error("商品 %s 视频上传失败:%s", p.ID, code) + a.log.Error("商品 %s 视频上传失败:%s", logID, code) } pending := func(code string) { if err := a.db.UpdateProductStatus(p.ID, "", "", store.UploadUnconfirmed, code); err != nil { - a.log.Error("商品 %s 更新上传状态失败:%v", p.ID, err) + a.log.Error("商品 %s 更新上传状态失败:%v", logID, err) } - a.log.Warn("商品 %s 上传结果待确认:%s;再次操作只查询原任务", p.ID, code) + a.log.Warn("商品 %s 上传结果待确认:%s;再次操作只查询原任务", logID, code) } previous, exists, err := a.db.GetUploadOperation(p.ID) if err != nil { @@ -81,7 +82,7 @@ func (a *App) uploadOneVideo(ctx context.Context, client *erpgo.Client, id strin return } if exists && previous.Status != "succeeded" && previous.Status != "failed" { - a.waitVideoOperation(ctx, client, previous, p, pending, fail) + a.waitVideoOperation(ctx, client, previous, p, logID, pending, fail) return } current, err := client.GetCurrentVideo(ctx, p.ItemID) @@ -93,9 +94,9 @@ func (a *App) uploadOneVideo(ctx context.Context, client *erpgo.Client, id strin lastError += " requestId=" + videoErr.RequestID } if updateErr := a.db.UpdateProductStatus(p.ID, "", "", store.UploadUnconfirmed, lastError); updateErr != nil { - a.log.Error("商品 %s 保存视频状态未确认结果失败:%v", p.ID, updateErr) + a.log.Error("商品 %s 保存视频状态未确认结果失败:%v", logID, updateErr) } - a.log.Warn("商品 %s 视频状态无法确认,上传未提交:%s", p.ID, uploadRequestSummary(err)) + a.log.Warn("商品 %s 视频状态无法确认,上传未提交:%s", logID, uploadRequestSummary(err)) return } fail(videoCode(err)) @@ -107,7 +108,7 @@ func (a *App) uploadOneVideo(ctx context.Context, client *erpgo.Client, id strin } if current.Confirmed() && count > 1 { if err := a.db.UpdateProductStatus(p.ID, "", "", store.UploadSkippedExisting, ""); err != nil { - a.log.Error("商品 %s 更新上传状态失败:%v", p.ID, err) + a.log.Error("商品 %s 更新上传状态失败:%v", logID, err) } return } @@ -118,7 +119,7 @@ func (a *App) uploadOneVideo(ctx context.Context, client *erpgo.Client, id strin } if !found { if err := a.db.UpdateProductStatus(p.ID, "", "", store.UploadMissingVideo, ""); err != nil { - a.log.Error("商品 %s 更新上传状态失败:%v", p.ID, err) + a.log.Error("商品 %s 更新上传状态失败:%v", logID, err) } return } @@ -129,7 +130,7 @@ func (a *App) uploadOneVideo(ctx context.Context, client *erpgo.Client, id strin } if reason != "" { if err := a.db.UpdateProductStatus(p.ID, "", "", store.UploadInvalidVideo, reason); err != nil { - a.log.Error("商品 %s 更新上传状态失败:%v", p.ID, err) + a.log.Error("商品 %s 更新上传状态失败:%v", logID, err) } return } @@ -174,12 +175,12 @@ func (a *App) uploadOneVideo(ctx context.Context, client *erpgo.Client, id strin } // HTTP/网络异常后的结果有歧义;查询原键,不再次 PUT。 if putErr != nil { - a.log.Warn("商品 %s 提交结果未确认:%s", p.ID, videoCode(putErr)) + a.log.Warn("商品 %s 提交结果未确认:%s", logID, videoCode(putErr)) } - a.waitVideoOperation(ctx, client, op, p, pending, fail) + a.waitVideoOperation(ctx, client, op, p, logID, pending, fail) } -func (a *App) waitVideoOperation(ctx context.Context, client *erpgo.Client, op store.UploadOperation, p store.Product, pending, fail func(string)) { +func (a *App) waitVideoOperation(ctx context.Context, client *erpgo.Client, op store.UploadOperation, p store.Product, logID string, pending, fail func(string)) { for attempt := 0; attempt < 6; attempt++ { if attempt > 0 { select { @@ -214,7 +215,7 @@ func (a *App) waitVideoOperation(ctx context.Context, client *erpgo.Client, op s pending("LOCAL_STATUS_ERROR") return } - a.log.Success("商品 %s 的 erpgo 视频操作已确认成功", p.ID) + a.log.Success("商品 %s 的 erpgo 视频操作已确认成功", logID) return case "failed": code := remote.ErrorCode