This commit is contained in:
邹宗楠
2023-10-26 16:15:02 +08:00
parent 5defccb4a7
commit 767ece0e27

View File

@@ -158,36 +158,32 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
failedList = append(failedList, failedList2...) failedList = append(failedList, failedList2...)
continue continue
} }
tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品
globals.SugarLogger.Debugf("====================tiktokResult := %s", utils.Format4Output(tiktokResult, false)) if err != nil && strings.Contains(err.Error(), "outProductId或者outerProductId已经存在") { // 主品以创建但是未返回出来
globals.SugarLogger.Debugf("====================err:= %v", err) mainProductDetail, _ := api.GetSkuDetail("", utils.Int2Str(storeSku.SkuID))
if err != nil { if mainProductDetail != nil || mainProductDetail.ProductId != 0 {
if strings.Contains(err.Error(), "outProductId或者outerProductId已经存在") { // 主品以创建但是未返回出来 tiktokResult.ProductId = mainProductDetail.ProductId
mainProductDetail, _ := api.GetSkuDetail("", utils.Int2Str(storeSku.SkuID)) specPrices := make([]product_addV2_response.SkuItem, 0, 0)
globals.SugarLogger.Debugf("====================mainProductDetail := %s", utils.Format4Output(mainProductDetail, false)) for _, v := range mainProductDetail.SpecPrices {
if mainProductDetail != nil || mainProductDetail.ProductId != 0 { specPrices = append(specPrices, product_addV2_response.SkuItem{
tiktokResult.ProductId = mainProductDetail.ProductId SkuId: v.SkuId,
OutSkuId: v.OutSkuId,
specPrices := make([]product_addV2_response.SkuItem, 0, 0) OuterSkuId: v.OuterSkuId,
for _, v := range mainProductDetail.SpecPrices { Code: v.Code,
specPrices = append(specPrices, product_addV2_response.SkuItem{ SpecDetailId1: v.SpecDetailId1,
SkuId: v.SkuId, SpecDetailId2: v.SpecDetailId2,
OutSkuId: v.OutSkuId, SpecDetailId3: v.SpecDetailId3,
OuterSkuId: v.OuterSkuId, })
Code: v.Code,
SpecDetailId1: v.SpecDetailId1,
SpecDetailId2: v.SpecDetailId2,
SpecDetailId3: v.SpecDetailId3,
})
}
tiktokResult.Sku = specPrices
} else {
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
continue
} }
tiktokResult.Sku = specPrices
} else {
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
continue
} }
//dao.UpdateThingMap(db, model.ThingTypeSyncFail, utils.Int64ToStr(time.Now().Unix()), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode) } else {
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
continue
} }
if tiktokResult.ProductId > model.NO { if tiktokResult.ProductId > model.NO {