This commit is contained in:
邹宗楠
2023-10-10 17:04:21 +08:00
parent a6707c71d6
commit 88bb777be1

View File

@@ -319,11 +319,17 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
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 {
var vendorCategoryId int64 = 0
// 根据图片推导分类
vendorCategoryId, _ = api.GetRecommendCategory(strings.Split(img, "|"))
if vendorCategoryId == 0 {
vendorCategoryId, _ = api.GetRecommendCategoryByName(storeSku.SkuName)
}
if vendorCategoryId == 0 || err != nil {
failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("当前商品本地未设置抖音分类/抖音推荐分类查询错误:"+err.Error()), storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
continue
}
param.CategoryLeafId = vendorCategoryId
}
// 获取主商品id
@@ -426,11 +432,16 @@ func makeMainProductSku(db *dao.DaoDB, api *tiktokShop.API, storeSku *dao.StoreS
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 {
var vendorCategoryId int64 = 0
vendorCategoryId, _ = api.GetRecommendCategory(strings.Split(img, "|")) // 根据图片推导分类
if vendorCategoryId == 0 {
vendorCategoryId, _ = api.GetRecommendCategoryByName(storeSku.SkuName) // 根据名字推导分类
}
if vendorCategoryId == 0 || err != nil {
failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("当前商品本地未设置抖音分类/抖音推荐分类查询错误:"+err.Error()), storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
return
}
param.CategoryLeafId = vendorCategoryId
}
// 这个情况是原有商品不存在和推荐查询不到类目id是,使用京西类目和抖音类目的绑定关系
// 但是不太实用,导致商品类目错误被暂停营业等