1
This commit is contained in:
@@ -294,13 +294,12 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
if isCreate {
|
if isCreate {
|
||||||
syncType = "创建商品"
|
syncType = "创建商品"
|
||||||
for _, storeSku := range storeSkuList {
|
for _, storeSku := range storeSkuList {
|
||||||
// 创建商品
|
// 创建子商品
|
||||||
param := &product_addV2_request.ProductAddV2Param{
|
param := &product_addV2_request.ProductAddV2Param{
|
||||||
CategoryLeafId: utils.Str2Int64(storeSku.SkuVendorMapCatID),
|
CategoryLeafId: utils.Str2Int64(storeSku.SkuVendorMapCatID),
|
||||||
Name: storeSku.Name,
|
Name: storeSku.Name,
|
||||||
PayType: tiktokShop.TiktokPayType1,
|
PayType: tiktokShop.TiktokPayType1,
|
||||||
ReduceType: tiktokShop.SkuReduceTypePayMakeOrder,
|
ReduceType: tiktokShop.SkuReduceTypePayMakeOrder,
|
||||||
FreightId: freightId,
|
|
||||||
Weight: utils.Int2Float64(storeSku.Weight),
|
Weight: utils.Int2Float64(storeSku.Weight),
|
||||||
DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay,
|
DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay,
|
||||||
PresellType: tiktokShop.SendGoodsTypeNow,
|
PresellType: tiktokShop.SendGoodsTypeNow,
|
||||||
@@ -313,7 +312,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
StartSaleType: 0,
|
StartSaleType: 0,
|
||||||
PickupMethod: "0",
|
PickupMethod: "0",
|
||||||
StoreId: utils.Str2Int64(vendorStoreID),
|
StoreId: utils.Str2Int64(vendorStoreID),
|
||||||
MainProductId: int64(storeSku.NameID),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取上传图,商品轮播图
|
// 获取上传图,商品轮播图
|
||||||
@@ -338,7 +336,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// spec_prices
|
// spec_prices
|
||||||
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, storeSku)
|
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, 0, storeSku)
|
||||||
// ProductFormatNew
|
// ProductFormatNew
|
||||||
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
||||||
globals.SugarLogger.Debug("创建=============productFormatNew", productFormatNew)
|
globals.SugarLogger.Debug("创建=============productFormatNew", productFormatNew)
|
||||||
@@ -349,6 +347,16 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
param.ProductFormatNew = productFormatNew
|
param.ProductFormatNew = productFormatNew
|
||||||
globals.SugarLogger.Debug("创建=============param", utils.Format4Output(param, false))
|
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)
|
saleLimitId, err := CreateSaleTemp(param.StoreId, api)
|
||||||
globals.SugarLogger.Debug("==22213123131231231", saleLimitId)
|
globals.SugarLogger.Debug("==22213123131231231", saleLimitId)
|
||||||
@@ -357,13 +365,13 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
}
|
}
|
||||||
param.SaleLimitId = saleLimitId
|
param.SaleLimitId = saleLimitId
|
||||||
// 抖店创建商品
|
// 抖店创建商品
|
||||||
tiktokResult, err := api.CreateStoreCommodity(param)
|
tiktokResultChildren, err := api.CreateStoreCommodity(param)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
||||||
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
storeSku.VendorSkuID = utils.Int64ToStr(tiktokResult.ProductId)
|
storeSku.VendorSkuID = utils.Int64ToStr(tiktokResultChildren.ProductId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
syncType = "更新商品"
|
syncType = "更新商品"
|
||||||
@@ -412,7 +420,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// spec_prices
|
// spec_prices
|
||||||
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, storeSku)
|
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, 0, storeSku)
|
||||||
// ProductFormatNew
|
// ProductFormatNew
|
||||||
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
||||||
globals.SugarLogger.Debug("更新=============productFormatNew", productFormatNew)
|
globals.SugarLogger.Debug("更新=============productFormatNew", productFormatNew)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func GetTiktokImgList(storeId, appOrgCode string, img ...string) (string, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetSpecPrices 解析属性和规格参数
|
// GetSpecPrices 解析属性和规格参数
|
||||||
func GetSpecPrices(specs, storeId string, localSku *dao.StoreSkuSyncInfo) string {
|
func GetSpecPrices(specs, storeId string, mainSkuId int64, localSku *dao.StoreSkuSyncInfo) string {
|
||||||
skuSize := make([]*tiktokShop.SpecDetailList, 0, 0)
|
skuSize := make([]*tiktokShop.SpecDetailList, 0, 0)
|
||||||
detail1 := strings.Split(specs, "^")
|
detail1 := strings.Split(specs, "^")
|
||||||
if len(detail1) > 3 {
|
if len(detail1) > 3 {
|
||||||
@@ -80,7 +80,6 @@ func GetSpecPrices(specs, storeId string, localSku *dao.StoreSkuSyncInfo) string
|
|||||||
for i := 0; i < len(name1); i++ {
|
for i := 0; i < len(name1); i++ {
|
||||||
sku := &tiktokShop.SpecDetailList{
|
sku := &tiktokShop.SpecDetailList{
|
||||||
SpecDetailName1: name1[i],
|
SpecDetailName1: name1[i],
|
||||||
StockNum: localSku.Stock,
|
|
||||||
Price: int(localSku.VendorPrice),
|
Price: int(localSku.VendorPrice),
|
||||||
Code: utils.Int2Str(localSku.SkuID),
|
Code: utils.Int2Str(localSku.SkuID),
|
||||||
StepStockNum: 0,
|
StepStockNum: 0,
|
||||||
@@ -89,8 +88,13 @@ func GetSpecPrices(specs, storeId string, localSku *dao.StoreSkuSyncInfo) string
|
|||||||
DeliveryInfos: []*tiktokShop.DeliveryInfos{
|
DeliveryInfos: []*tiktokShop.DeliveryInfos{
|
||||||
{InfoType: "weight", InfoUnit: localSku.SpecUnit, InfoValue: fmt.Sprintf("%f", localSku.SpecQuality)},
|
{InfoType: "weight", InfoUnit: localSku.SpecUnit, InfoValue: fmt.Sprintf("%f", localSku.SpecQuality)},
|
||||||
},
|
},
|
||||||
SkuType: 1,
|
}
|
||||||
StockNumMap: map[string]int64{storeId: 999999},
|
if mainSkuId == 0 {
|
||||||
|
sku.StockNum = 0
|
||||||
|
} else {
|
||||||
|
sku.StockNum = localSku.Stock
|
||||||
|
sku.SkuType = 1
|
||||||
|
sku.StockNumMap = map[string]int64{storeId: 999999}
|
||||||
}
|
}
|
||||||
skuSize = append(skuSize, sku)
|
skuSize = append(skuSize, sku)
|
||||||
}
|
}
|
||||||
@@ -102,7 +106,6 @@ func GetSpecPrices(specs, storeId string, localSku *dao.StoreSkuSyncInfo) string
|
|||||||
sku := &tiktokShop.SpecDetailList{
|
sku := &tiktokShop.SpecDetailList{
|
||||||
SpecDetailName1: name1[i],
|
SpecDetailName1: name1[i],
|
||||||
SpecDetailName2: name2[j],
|
SpecDetailName2: name2[j],
|
||||||
StockNum: localSku.Stock,
|
|
||||||
Price: int(localSku.UnitPrice),
|
Price: int(localSku.UnitPrice),
|
||||||
Code: utils.Int2Str(localSku.SkuID),
|
Code: utils.Int2Str(localSku.SkuID),
|
||||||
StepStockNum: 0,
|
StepStockNum: 0,
|
||||||
@@ -111,8 +114,13 @@ func GetSpecPrices(specs, storeId string, localSku *dao.StoreSkuSyncInfo) string
|
|||||||
DeliveryInfos: []*tiktokShop.DeliveryInfos{
|
DeliveryInfos: []*tiktokShop.DeliveryInfos{
|
||||||
{InfoType: "weight", InfoUnit: localSku.SpecUnit, InfoValue: fmt.Sprintf("%f", localSku.SpecQuality)},
|
{InfoType: "weight", InfoUnit: localSku.SpecUnit, InfoValue: fmt.Sprintf("%f", localSku.SpecQuality)},
|
||||||
},
|
},
|
||||||
SkuType: 1,
|
}
|
||||||
StockNumMap: map[string]int64{storeId: 999999},
|
if mainSkuId == 0 {
|
||||||
|
sku.StockNum = 0
|
||||||
|
} else {
|
||||||
|
sku.StockNum = localSku.Stock
|
||||||
|
sku.SkuType = 1
|
||||||
|
sku.StockNumMap = map[string]int64{storeId: 999999}
|
||||||
}
|
}
|
||||||
skuSize = append(skuSize, sku)
|
skuSize = append(skuSize, sku)
|
||||||
}
|
}
|
||||||
@@ -128,7 +136,6 @@ func GetSpecPrices(specs, storeId string, localSku *dao.StoreSkuSyncInfo) string
|
|||||||
SpecDetailName1: name1[i],
|
SpecDetailName1: name1[i],
|
||||||
SpecDetailName2: name2[j],
|
SpecDetailName2: name2[j],
|
||||||
SpecDetailName3: name3[k],
|
SpecDetailName3: name3[k],
|
||||||
StockNum: localSku.Stock,
|
|
||||||
Price: int(localSku.UnitPrice),
|
Price: int(localSku.UnitPrice),
|
||||||
Code: utils.Int2Str(localSku.SkuID),
|
Code: utils.Int2Str(localSku.SkuID),
|
||||||
StepStockNum: 0,
|
StepStockNum: 0,
|
||||||
@@ -137,8 +144,13 @@ func GetSpecPrices(specs, storeId string, localSku *dao.StoreSkuSyncInfo) string
|
|||||||
DeliveryInfos: []*tiktokShop.DeliveryInfos{
|
DeliveryInfos: []*tiktokShop.DeliveryInfos{
|
||||||
{InfoType: "weight", InfoUnit: localSku.SpecUnit, InfoValue: fmt.Sprintf("%f", localSku.SpecQuality)},
|
{InfoType: "weight", InfoUnit: localSku.SpecUnit, InfoValue: fmt.Sprintf("%f", localSku.SpecQuality)},
|
||||||
},
|
},
|
||||||
SkuType: 1,
|
}
|
||||||
StockNumMap: map[string]int64{storeId: 999999}, // 最大库存数
|
if mainSkuId == 0 {
|
||||||
|
sku.StockNum = 0
|
||||||
|
} else {
|
||||||
|
sku.StockNum = localSku.Stock
|
||||||
|
sku.SkuType = 1
|
||||||
|
sku.StockNumMap = map[string]int64{storeId: 999999}
|
||||||
}
|
}
|
||||||
skuSize = append(skuSize, sku)
|
skuSize = append(skuSize, sku)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user