diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index ddaab7126..d182af693 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -165,8 +165,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI param.Description = detailImg // 部分商品没有所属的分类,直接跳过! - if storeSku.VendorVendorCatID != 0 { - param.CategoryLeafId = storeSku.VendorVendorCatID + if storeSku.SkuVendorMapCatID != "" { + param.CategoryLeafId = utils.Str2Int64(storeSku.SkuVendorMapCatID) } else if len(param.Pic) != 0 { // 自动推导分类id param.CategoryLeafId, err = api.GetRecommendCategory(strings.Split(img, "|")) if param.CategoryLeafId == 0 || err != nil { @@ -302,17 +302,11 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI updateParam.ProductId = mainOrderDetail.ProductId updateParam.MainProductId = mainProductId updateParam.SpecPrices = param.SpecPrices - //updateParam.StoreId = utils.Str2Int64(vendorStoreID) - err := api.EditStoreCommodity(updateParam) - if err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + if err := api.EditStoreCommodity(updateParam); err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) - } //else { - // localThing[0].UpdatedAt = time.Now() - // localThing[0].SyncStatus = 0 - // localThing[0].ThingType = model.ThingTypeSku - // dao.UpdateThingMap(localThing[0]) - //} + } + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("修改子品,没创建子商品"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } } @@ -357,11 +351,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI StartSaleType: 0, PickupMethod: "0", } - if storeSku.SkuVendorMapCatID != "" { - param.CategoryLeafId = utils.Str2Int64(storeSku.SkuVendorMapCatID) - } else { - param.CategoryLeafId = storeSku.VendorVendorCatID - } param.Name = checkNameLenght(param.Name) // 获取上传图,商品轮播图 @@ -374,6 +363,16 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI param.Description = detailImg param.WeightUnit = tiktokShop.WeightUint_G + // 部分商品没有所属的分类,直接跳过! + if storeSku.SkuVendorMapCatID != "" { + param.CategoryLeafId = utils.Str2Int64(storeSku.SkuVendorMapCatID) + } else if len(param.Pic) != 0 { // 自动推导分类id + param.CategoryLeafId, err = api.GetRecommendCategory(strings.Split(img, "|")) + if param.CategoryLeafId == 0 || err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("当前商品本地未设置抖音分类/抖音推荐分类查询错误:"+err.Error()), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue + } + } // 获取商品的属性 if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" { param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId)