1
This commit is contained in:
@@ -249,7 +249,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
updateParam.Pic = param.Pic
|
updateParam.Pic = param.Pic
|
||||||
updateParam.Description = param.Description
|
updateParam.Description = param.Description
|
||||||
updateParam.WeightUnit = tiktokShop.WeightUint_G
|
updateParam.WeightUnit = tiktokShop.WeightUint_G
|
||||||
updateParam.StandardBrandId, _ = getTiktokBrandId(api, db, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId, updateParam.CategoryLeafId)
|
//updateParam.StandardBrandId, _ = getTiktokBrandId(api, db, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId, updateParam.CategoryLeafId)
|
||||||
|
|
||||||
updateParam.ProductId = mainOrderDetail.ProductId
|
updateParam.ProductId = mainOrderDetail.ProductId
|
||||||
updateParam.MainProductId = mainProductId
|
updateParam.MainProductId = mainProductId
|
||||||
@@ -369,7 +369,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
|
|
||||||
// 获取商品的属性
|
// 获取商品的属性
|
||||||
if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" {
|
if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" {
|
||||||
param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId)
|
param.ProductFormatNew, param.StandardBrandId, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId)
|
||||||
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)
|
||||||
continue
|
continue
|
||||||
@@ -378,8 +378,9 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
param.ProductFormatNew = storeSku.TiktokAttribute
|
param.ProductFormatNew = storeSku.TiktokAttribute
|
||||||
}
|
}
|
||||||
// 获取品牌
|
// 获取品牌
|
||||||
|
if param.StandardBrandId == 0 {
|
||||||
param.StandardBrandId, _ = getTiktokBrandId(api, db, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId, param.CategoryLeafId)
|
param.StandardBrandId, _ = getTiktokBrandId(api, db, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId, param.CategoryLeafId)
|
||||||
|
}
|
||||||
// 修改商品
|
// 修改商品
|
||||||
param.ProductId = mainIdInt
|
param.ProductId = mainIdInt
|
||||||
param.MainProductId = mainIdInt
|
param.MainProductId = mainIdInt
|
||||||
@@ -459,18 +460,21 @@ func makeMainProductSku(db *dao.DaoDB, api *tiktokShop.API, storeSku *dao.StoreS
|
|||||||
} else if storeSku.VendorSkuAttrId != "" && storeSku.VendorSkuAttrId != "{}" {
|
} else if storeSku.VendorSkuAttrId != "" && storeSku.VendorSkuAttrId != "{}" {
|
||||||
param.ProductFormatNew = storeSku.TiktokAttribute
|
param.ProductFormatNew = storeSku.TiktokAttribute
|
||||||
} else {
|
} else {
|
||||||
param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId)
|
param.ProductFormatNew, param.StandardBrandId, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId)
|
||||||
|
//param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId)
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if param.StandardBrandId == 0 {
|
||||||
param.StandardBrandId, err = getTiktokBrandId(api, db, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId, param.CategoryLeafId)
|
param.StandardBrandId, err = getTiktokBrandId(api, db, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId, param.CategoryLeafId)
|
||||||
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
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
param.FreightId, param.SaleLimitId, err = getFreightIdAndSaleLimitId(api, db, storeDetail, vendorStoreID)
|
param.FreightId, param.SaleLimitId, err = getFreightIdAndSaleLimitId(api, db, storeDetail, vendorStoreID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -907,19 +911,22 @@ func GetTiktokImgList(api *tiktokShop.API, storeId, appOrgCode string, detailImg
|
|||||||
return strings.Join(tiktokImg, "|"), detailTiktok, nil
|
return strings.Join(tiktokImg, "|"), detailTiktok, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeProductFormatNew(api *tiktokShop.API, skuNameId int64, categoryLeafId int64) (string, error) {
|
func MakeProductFormatNew(api *tiktokShop.API, skuNameId int64, categoryLeafId int64, upcCode, upcBrandName, upcTiktokBrandId string) (string, int64, error) {
|
||||||
|
db := dao.GetDB()
|
||||||
categoryList, err := api.GetCatePropertyV2(categoryLeafId)
|
categoryList, err := api.GetCatePropertyV2(categoryLeafId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", 0, err
|
||||||
}
|
}
|
||||||
categoryMap := make(map[string][]map[string]interface{})
|
categoryMap := make(map[string][]map[string]interface{})
|
||||||
|
var tiktokBrandId int64 = 0
|
||||||
for _, v := range categoryList.Data.Data {
|
for _, v := range categoryList.Data.Data {
|
||||||
if v.Required != model.YES {
|
if v.Required != model.YES {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
options := make([]map[string]interface{}, 0)
|
options := make([]map[string]interface{}, 0)
|
||||||
if v.PropertyName == "品牌" {
|
if v.PropertyName == "品牌" {
|
||||||
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 789194134, "diy_type": v.DiyType})
|
tiktokBrandId, _ = getTiktokBrandId(api, db, upcCode, upcBrandName, upcTiktokBrandId, categoryLeafId)
|
||||||
|
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": tiktokBrandId, "diy_type": v.DiyType})
|
||||||
categoryMap[utils.Int64ToStr(v.PropertyId)] = options
|
categoryMap[utils.Int64ToStr(v.PropertyId)] = options
|
||||||
} else if v.PropertyName == "产地" {
|
} else if v.PropertyName == "产地" {
|
||||||
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 13850, "diy_type": v.DiyType})
|
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 13850, "diy_type": v.DiyType})
|
||||||
@@ -934,7 +941,7 @@ func MakeProductFormatNew(api *tiktokShop.API, skuNameId int64, categoryLeafId i
|
|||||||
}
|
}
|
||||||
productFormatNew := utils.Format4Output(categoryMap, false)
|
productFormatNew := utils.Format4Output(categoryMap, false)
|
||||||
dao.UpdateSkuNameTiktokAttr(dao.GetDB(), skuNameId, productFormatNew)
|
dao.UpdateSkuNameTiktokAttr(dao.GetDB(), skuNameId, productFormatNew)
|
||||||
return utils.Format4Output(categoryMap, false), nil
|
return utils.Format4Output(categoryMap, false), tiktokBrandId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSpecPrices 解析属性和规格参数
|
// GetSpecPrices 解析属性和规格参数
|
||||||
|
|||||||
Reference in New Issue
Block a user