This commit is contained in:
邹宗楠
2025-05-07 11:41:56 +08:00
parent e65c4f4091
commit fe9ee47d0b

View File

@@ -219,7 +219,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("只创建了主商品,没创建子商品"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("只创建了主商品,没创建子商品"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
} else if localThing[0].SyncStatus == model.ThingTypeSyncFail { // 同步失败在重新创建 } else if localThing[0].SyncStatus == model.ThingTypeSyncFail { // 同步失败在重新创建
param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType) param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType)
globals.SugarLogger.Debugf("----------param := %s", utils.Format4Output(param, false))
if len(failedList2) != 0 { if len(failedList2) != 0 {
failedList = append(failedList, failedList2...) failedList = append(failedList, failedList2...)
continue continue
@@ -478,12 +477,9 @@ func makeMainProductSku(db *dao.DaoDB, api *tiktokShop.API, storeSku *dao.StoreS
OuterProductId: utils.Int2Str(storeSku.SkuID), // 本地skuId为外部商品id OuterProductId: utils.Int2Str(storeSku.SkuID), // 本地skuId为外部商品id
} }
param.Name = checkNameLenght(param.Name) param.Name = checkNameLenght(param.Name)
globals.SugarLogger.Debugf("----------param := %s", utils.Format4Output(1, false))
// 获取上传图,商品轮播图 // 获取上传图,商品轮播图
img, detailImg, whiteImg, err := GetTiktokImgList(api, utils.Int2Str(storeSku.StoreID), storeSku.SkuID, storeSku.DescImg, storeSku.Img, []string{storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5}) img, detailImg, whiteImg, err := GetTiktokImgList(api, utils.Int2Str(storeSku.StoreID), storeSku.SkuID, storeSku.DescImg, storeSku.Img, []string{storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5})
globals.SugarLogger.Debugf("----------GetTiktokImgList := %s", utils.Format4Output(img, false))
globals.SugarLogger.Debugf("----------err := %v", err)
if err != nil { if err != nil {
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
return return
@@ -507,7 +503,6 @@ func makeMainProductSku(db *dao.DaoDB, api *tiktokShop.API, storeSku *dao.StoreS
} }
param.CategoryLeafId = vendorCategoryId param.CategoryLeafId = vendorCategoryId
} }
globals.SugarLogger.Debugf("----------333 := %s", utils.Format4Output(3333, false))
// 这个情况是原有商品不存在和推荐查询不到类目id是,使用京西类目和抖音类目的绑定关系 // 这个情况是原有商品不存在和推荐查询不到类目id是,使用京西类目和抖音类目的绑定关系
// 但是不太实用,导致商品类目错误被暂停营业等 // 但是不太实用,导致商品类目错误被暂停营业等
//if storeSku.VendorVendorCatID != 0 && param.CategoryLeafId == 0 { //if storeSku.VendorVendorCatID != 0 && param.CategoryLeafId == 0 {
@@ -955,7 +950,6 @@ func GetTiktokImgList(api *tiktokShop.API, storeId string, skuId int, detailImg,
detailTiktok := "" detailTiktok := ""
whiteTiktok := "" whiteTiktok := ""
tiktokImgLocal, err := dao.GetVendorImg(skuId, model.VendorIDDD) tiktokImgLocal, err := dao.GetVendorImg(skuId, model.VendorIDDD)
globals.SugarLogger.Debugf("----------tiktokImgLocal := %s", utils.Format4Output(tiktokImgLocal, false))
if err == nil && tiktokImgLocal != nil && tiktokImgLocal.Img != "" { if err == nil && tiktokImgLocal != nil && tiktokImgLocal.Img != "" {
localImgs := make([]string, 0, 0) localImgs := make([]string, 0, 0)
localImgs = append(localImgs, tiktokImgLocal.Img) localImgs = append(localImgs, tiktokImgLocal.Img)
@@ -989,7 +983,6 @@ func GetTiktokImgList(api *tiktokShop.API, storeId string, skuId int, detailImg,
}) })
} }
} }
globals.SugarLogger.Debugf("----------imgs := %s", utils.Format4Output(imgs, false))
if detailImg != "" { if detailImg != "" {
imgs = append(imgs, tiktokShop.Imgs{ imgs = append(imgs, tiktokShop.Imgs{
Name: "detail_" + storeId + "_" + detailImg[21:54], Name: "detail_" + storeId + "_" + detailImg[21:54],
@@ -1003,8 +996,6 @@ func GetTiktokImgList(api *tiktokShop.API, storeId string, skuId int, detailImg,
}) })
} }
tiktokImgList, err := api.BatchUploadImages(imgs) tiktokImgList, err := api.BatchUploadImages(imgs)
globals.SugarLogger.Debugf("----------tiktokImgList := %s", utils.Format4Output(tiktokImgList, false))
globals.SugarLogger.Debugf("----------err := %s", utils.Format4Output(err, false))
if err != nil { if err != nil {
return "", "", "", err return "", "", "", err
} }
@@ -1021,24 +1012,17 @@ func GetTiktokImgList(api *tiktokShop.API, storeId string, skuId int, detailImg,
if strings.Contains(k, "detail_") { if strings.Contains(k, "detail_") {
detailTiktok = v.ByteUrl detailTiktok = v.ByteUrl
localTiktokObj.DescImg = v.ByteUrl localTiktokObj.DescImg = v.ByteUrl
tiktokImg = append(tiktokImg, v.ByteUrl)
continue continue
} }
if strings.Contains(k, "white_") { if strings.Contains(k, "white_") {
whiteTiktok = v.ByteUrl whiteTiktok = v.ByteUrl
localTiktokObj.Img = v.ByteUrl localTiktokObj.Img = v.ByteUrl
tiktokImg = append(tiktokImg, v.ByteUrl)
continue continue
} }
tiktokImg = append(tiktokImg, v.ByteUrl)
} }
if detailTiktok == "" {
detailTiktok = tiktokImg[0]
localTiktokObj.DescImg = detailTiktok
}
if whiteTiktok == "" {
whiteTiktok = tiktokImg[0]
localTiktokObj.Img = whiteTiktok
}
switch len(tiktokImg) { switch len(tiktokImg) {
case 2: case 2:
localTiktokObj.Img2 = tiktokImg[0] localTiktokObj.Img2 = tiktokImg[0]