1
This commit is contained in:
@@ -167,6 +167,10 @@ func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int, eclpIDs []string
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func UpdateSkuNameTiktokAttr(db *DaoDB, id int64, attr string) {
|
||||
sql := ` UPDATE sku_name SET tiktok_attribute = ? WHERE id = ? `
|
||||
ExecuteSQL(db, sql, []interface{}{attr, id}...)
|
||||
}
|
||||
func GetSkuNames(db *DaoDB, nameIDs []int, upcs []string, name string, isExd bool) (skuNameList []*model.SkuName, err error) {
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
|
||||
@@ -171,14 +171,44 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
|
||||
// spec_prices
|
||||
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, 0, storeSku)
|
||||
param.ProductFormatNew = storeSku.TiktokAttribute
|
||||
// 获取商品的属性
|
||||
if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" {
|
||||
categoryList, err := api.GetCatePropertyV2(param.CategoryLeafId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
categoryMap := make(map[string][]map[string]interface{})
|
||||
for _, v := range categoryList.Data.Data {
|
||||
if v.Required == model.YES {
|
||||
options := make([]map[string]interface{}, 0)
|
||||
if v.PropertyName == "品牌" {
|
||||
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 297375059, "diy_type": v.DiyType})
|
||||
categoryMap[utils.Int64ToStr(v.PropertyId)] = options
|
||||
} else if v.PropertyName == "产地" {
|
||||
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 13850, "diy_type": v.DiyType})
|
||||
categoryMap[utils.Int64ToStr(v.PropertyId)] = options
|
||||
} else if len(options) == 0 {
|
||||
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 0, "diy_type": v.DiyType})
|
||||
categoryMap[utils.Int64ToStr(v.PropertyId)] = options
|
||||
} else {
|
||||
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": v.Options[0].Value, "diy_type": v.DiyType})
|
||||
categoryMap[utils.Int64ToStr(v.PropertyId)] = options
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
param.ProductFormatNew = utils.Format4Output(categoryMap, false)
|
||||
dao.UpdateSkuNameTiktokAttr(dao.GetDB(), int64(storeSku.NameID), param.ProductFormatNew)
|
||||
} else {
|
||||
param.ProductFormatNew = storeSku.TiktokAttribute
|
||||
}
|
||||
|
||||
// 获取品牌
|
||||
//param.StandardBrandId, err = api.GetSkuBrand(param.CategoryLeafId)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
param.StandardBrandId = 596120136 // 默认品牌
|
||||
param.StandardBrandId = 297375059 // 默认品牌
|
||||
|
||||
// 根据本地商品id获取线上商品是否存在,存在则只创建子商品
|
||||
var tiktokResultProductId int64 = 0
|
||||
@@ -247,7 +277,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
}
|
||||
storeSku.VendorSkuID = utils.Int64ToStr(tiktokResultChildren.ProductId) // 子商品主id
|
||||
storeSku.VendorMainId = utils.Int64ToStr(tiktokResultProductId) // 商品主id
|
||||
|
||||
}
|
||||
} else {
|
||||
syncType = "更新商品"
|
||||
|
||||
Reference in New Issue
Block a user