This commit is contained in:
邹宗楠
2022-10-09 21:31:27 +08:00
parent a92b7635fb
commit 3325250330
2 changed files with 37 additions and 17 deletions

View File

@@ -294,13 +294,12 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
if isCreate {
syncType = "创建商品"
for _, storeSku := range storeSkuList {
// 创建商品
// 创建商品
param := &product_addV2_request.ProductAddV2Param{
CategoryLeafId: utils.Str2Int64(storeSku.SkuVendorMapCatID),
Name: storeSku.Name,
PayType: tiktokShop.TiktokPayType1,
ReduceType: tiktokShop.SkuReduceTypePayMakeOrder,
FreightId: freightId,
Weight: utils.Int2Float64(storeSku.Weight),
DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay,
PresellType: tiktokShop.SendGoodsTypeNow,
@@ -313,7 +312,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
StartSaleType: 0,
PickupMethod: "0",
StoreId: utils.Str2Int64(vendorStoreID),
MainProductId: int64(storeSku.NameID),
}
// 获取上传图,商品轮播图
@@ -338,7 +336,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
}
// spec_prices
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, storeSku)
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, 0, storeSku)
// ProductFormatNew
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
globals.SugarLogger.Debug("创建=============productFormatNew", productFormatNew)
@@ -349,6 +347,16 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
param.ProductFormatNew = productFormatNew
globals.SugarLogger.Debug("创建=============param", utils.Format4Output(param, false))
tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品
if err != nil {
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
continue
}
// 创建子商品
param.FreightId = freightId
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, tiktokResult.ProductId, storeSku)
// 获取门店限售模板
saleLimitId, err := CreateSaleTemp(param.StoreId, api)
globals.SugarLogger.Debug("==22213123131231231", saleLimitId)
@@ -357,13 +365,13 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
}
param.SaleLimitId = saleLimitId
// 抖店创建商品
tiktokResult, err := api.CreateStoreCommodity(param)
tiktokResultChildren, err := api.CreateStoreCommodity(param)
if err != nil {
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
continue
}
storeSku.VendorSkuID = utils.Int64ToStr(tiktokResult.ProductId)
storeSku.VendorSkuID = utils.Int64ToStr(tiktokResultChildren.ProductId)
}
} else {
syncType = "更新商品"
@@ -412,7 +420,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
}
// spec_prices
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, storeSku)
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, 0, storeSku)
// ProductFormatNew
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
globals.SugarLogger.Debug("更新=============productFormatNew", productFormatNew)