This commit is contained in:
邹宗楠
2022-10-09 22:33:37 +08:00
parent 0a549f735f
commit f616bc5959
2 changed files with 7 additions and 3 deletions

View File

@@ -334,7 +334,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
// spec_prices
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, 0, storeSku)
// ProductFormatNew
// ProductFormatNew 获取商品属性
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
globals.SugarLogger.Debug("创建=============productFormatNew", productFormatNew)
globals.SugarLogger.Debug("创建=============productFormatNew err", err)

View File

@@ -12,6 +12,10 @@ import (
"strings"
)
type PropertyObj struct {
PropertyId []*tiktokShop.ProductFormatNewList `json:"property_id"`
}
// GetProductFormatNew 获取物品属性
func GetProductFormatNew(categoryLeftId int64, vendorOrgCode string) (string, error) {
category, err := getAPI(vendorOrgCode, 0, "").GetCatePropertyV2(categoryLeftId)
@@ -19,7 +23,7 @@ func GetProductFormatNew(categoryLeftId int64, vendorOrgCode string) (string, er
if err != nil {
return "", err
}
format := make(map[string][]*tiktokShop.ProductFormatNewList, 0)
var format PropertyObj
for _, v := range category.Data.Data {
for _, d := range v.Options {
formateNew := &tiktokShop.ProductFormatNewList{
@@ -27,7 +31,7 @@ func GetProductFormatNew(categoryLeftId int64, vendorOrgCode string) (string, er
Name: d.Name,
DiyType: v.DiyType,
}
format[utils.Int64ToStr(v.CategoryId)] = append(format[utils.Int64ToStr(v.CategoryId)], formateNew)
format.PropertyId = append(format.PropertyId, formateNew)
}
}
productFormatNew, err := json.Marshal(format)