|
|
|
@@ -141,15 +141,16 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|
|
|
if storeSku.StoreSkuStatus != model.YES { // 未可售的商品不参与修改
|
|
|
|
if storeSku.StoreSkuStatus != model.YES { // 未可售的商品不参与修改
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
globals.SugarLogger.Debugf("------------1")
|
|
|
|
// 根据本地商品id获取线上商品是否存在,存在则只创建子商品
|
|
|
|
// 根据本地商品id获取线上商品是否存在,存在则只创建子商品
|
|
|
|
// 获取本地存储映射关系,获取本地主商品id是否存在
|
|
|
|
// 获取本地存储映射关系,获取本地主商品id是否存在
|
|
|
|
var mainProductId int64 = 0
|
|
|
|
var mainProductId int64 = 0
|
|
|
|
var mainOrderDetail *product_detail_response.ProductDetailData
|
|
|
|
var mainOrderDetail *product_detail_response.ProductDetailData
|
|
|
|
localThing, _ := dao.GetThingToTiktokMapList(db, model.VendorIDDD, int64(storeSku.SkuID), storeDetail.VendorOrgCode)
|
|
|
|
localThing, _ := dao.GetThingToTiktokMapList(db, model.VendorIDDD, int64(storeSku.SkuID), storeDetail.VendorOrgCode)
|
|
|
|
if len(localThing) != 0 {
|
|
|
|
if len(localThing) != 0 && localThing[0].VendorThingID != "" {
|
|
|
|
mainProductId = utils.Str2Int64(localThing[0].VendorThingID)
|
|
|
|
mainProductId = utils.Str2Int64(localThing[0].VendorThingID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
globals.SugarLogger.Debugf("------------2")
|
|
|
|
|
|
|
|
|
|
|
|
if len(localThing) == 0 {
|
|
|
|
if len(localThing) == 0 {
|
|
|
|
param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType)
|
|
|
|
param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType)
|
|
|
|
@@ -218,6 +219,7 @@ 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
|
|
|
|
@@ -441,7 +443,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|
|
|
//param.MainProductId = mainIdInt
|
|
|
|
//param.MainProductId = mainIdInt
|
|
|
|
//param.FreightId, _ = api.GetStoreBindTemp(utils.Str2Int64(vendorStoreID))
|
|
|
|
//param.FreightId, _ = api.GetStoreBindTemp(utils.Str2Int64(vendorStoreID))
|
|
|
|
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, mainIdInt, storeSku)
|
|
|
|
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, mainIdInt, storeSku)
|
|
|
|
globals.SugarLogger.Debugf("--------param2 := %s", utils.Format4Output(param, false))
|
|
|
|
|
|
|
|
err = api.EditStoreCommodity(param)
|
|
|
|
err = api.EditStoreCommodity(param)
|
|
|
|
if err != nil && !strings.Contains(err.Error(), "您上传的商品主图存在重复") {
|
|
|
|
if err != nil && !strings.Contains(err.Error(), "您上传的商品主图存在重复") {
|
|
|
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
|
|
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
|
|
|
@@ -477,9 +478,12 @@ 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
|
|
|
|
@@ -503,6 +507,7 @@ 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 {
|
|
|
|
|