From de6af8dfefe6fc4249e3c2fba240335f606ec948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 17 May 2024 15:39:40 +0800 Subject: [PATCH] 1 --- business/model/sync_map.go | 1 + .../purchase/tiktok_store/store_sku2_utils.go | 60 +++++++++++-------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/business/model/sync_map.go b/business/model/sync_map.go index fe5539c86..0f2391c82 100644 --- a/business/model/sync_map.go +++ b/business/model/sync_map.go @@ -13,6 +13,7 @@ const ( ThingTypeSyncSuccess = 0 // 主商品创建成功 ThingTypeSyncFail = 2 // 主商品创建失败 ThingTypeSyncing = 3 // 主商品创建中 + ThingTypeSyncingStop = 4 // 主商品创建失败,不在创建 ) type ThingMap struct { diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 5025f33c5..092ebebbe 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -156,32 +156,43 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI failedList = append(failedList, failedList2...) continue } - tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 - if err != nil && strings.Contains(err.Error(), "outProductId或者outerProductId已经存在") { // 主品以创建但是未返回出来 - mainProductDetail, _ := api.GetSkuDetail("", utils.Int2Str(storeSku.SkuID)) - if mainProductDetail != nil || mainProductDetail.ProductId != 0 { - tiktokResult.ProductId = mainProductDetail.ProductId - specPrices := make([]product_addV2_response.SkuItem, 0, 0) - for _, v := range mainProductDetail.SpecPrices { - specPrices = append(specPrices, product_addV2_response.SkuItem{ - SkuId: v.SkuId, - OutSkuId: v.OutSkuId, - OuterSkuId: v.OuterSkuId, - Code: v.Code, - SpecDetailId1: v.SpecDetailId1, - SpecDetailId2: v.SpecDetailId2, - SpecDetailId3: v.SpecDetailId3, - }) + tiktokResult, errCreate := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 + if errCreate != nil { + if strings.Contains(errCreate.Error(), "outProductId或者outerProductId已经存在") { // 主品以创建但是未返回出来 + mainProductDetail, _ := api.GetSkuDetail("", utils.Int2Str(storeSku.SkuID)) + if mainProductDetail != nil || mainProductDetail.ProductId != 0 { + tiktokResult.ProductId = mainProductDetail.ProductId + specPrices := make([]product_addV2_response.SkuItem, 0, 0) + for _, v := range mainProductDetail.SpecPrices { + specPrices = append(specPrices, product_addV2_response.SkuItem{ + SkuId: v.SkuId, + OutSkuId: v.OutSkuId, + OuterSkuId: v.OuterSkuId, + Code: v.Code, + SpecDetailId1: v.SpecDetailId1, + SpecDetailId2: v.SpecDetailId2, + SpecDetailId3: v.SpecDetailId3, + }) + } + tiktokResult.Sku = specPrices + } else { + //storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 + storeSku.SkuSyncStatus = 0 // 后续不在做定时任务更新 + storeSku.VendorSonSkuID = "此商品已经创建抖音主商品了" + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errCreate, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue } - tiktokResult.Sku = specPrices + } else if strings.Contains(errCreate.Error(), "无资质授权") { + storeSku.SkuSyncStatus = 0 // 门店无资质不在做定时任务更新 + storeSku.VendorSonSkuID = "无资质授权" + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errCreate, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue } else { - storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 - failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + storeSku.SkuSyncStatus = 0 // 门店无资质不在做定时任务更新 + storeSku.VendorSonSkuID = errCreate.Error() + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errCreate, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } - } else if err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - continue } if tiktokResult.ProductId > model.NO { @@ -208,8 +219,9 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 if err != nil { - storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 - dao.UpdateThingMap(db, model.ThingTypeSyncFail, utils.Int64ToStr(time.Now().Unix()), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode) + storeSku.SkuSyncStatus = 0 // 只创建主品,子品都没做 + storeSku.VendorSonSkuID = err.Error() + dao.UpdateThingMap(db, model.ThingTypeSyncingStop, err.Error(), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode) failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue }