1
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
product_addV2_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/response"
|
||||
product_auditList_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_auditList/request"
|
||||
product_auditList_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_auditList/response"
|
||||
product_batchGetChannelCategoryMapping_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_batchGetChannelCategoryMapping/request"
|
||||
product_del_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_del/request"
|
||||
product_detail_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail/request"
|
||||
product_detail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail/response"
|
||||
@@ -66,9 +67,11 @@ func (a *API) UpdateSkuStock(param *sku_syncStock_request.SkuSyncStockParam) err
|
||||
// 3、循环获取最小层级类目id方式:再判断is_leaf=true或false。is_leaf=true表示是叶子节点,最小层级类目id。is_leaf=false表示不是子节点,请求参数cid=上一次响应参数id,直到获取最小层级类目id。
|
||||
func (a *API) GetShopCategory(cid int64) ([]*RetailCategoryInfo, error) {
|
||||
// 如果cid为0,则获取所有的分类,如果cid不为0,则获取该分类下面的所有子分类
|
||||
channel := int32(1) // 0获取老的分类ID 1获取最新的分类id
|
||||
request := shop_getShopCategory_request.New()
|
||||
param := request.GetParams()
|
||||
param.Cid = cid
|
||||
param.Channel = &channel
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -117,18 +120,43 @@ func (a *API) GetCatePropertyV2(categoryLeftId int64) (*product_getCatePropertyV
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// BatchGetChannelCategoryMapping 根据旧的抖音分类获取新的分类
|
||||
func (a *API) BatchGetChannelCategoryMapping(categoryIds []int64) (map[int64]int64, error) {
|
||||
request := product_batchGetChannelCategoryMapping_request.New()
|
||||
param := request.GetParams()
|
||||
categoryList := make([]product_batchGetChannelCategoryMapping_request.ReqItemsItem, 0, len(categoryIds))
|
||||
for _, v := range categoryIds {
|
||||
categoryList = append(categoryList, product_batchGetChannelCategoryMapping_request.ReqItemsItem{
|
||||
CategoryId: utils.Int64ToPointer(v),
|
||||
})
|
||||
}
|
||||
param.ReqItems = categoryList
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
mappingData := make(map[int64]int64, 0)
|
||||
for _, v := range result.Data.RespItems {
|
||||
mappingData[v.SourceCategoryId] = v.CategoryMappings[0].MappingCategoryId
|
||||
}
|
||||
|
||||
return mappingData, nil
|
||||
}
|
||||
|
||||
// CreateStoreCommodity (新增总部商品)
|
||||
func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2Param) (*product_addV2_response.ProductAddV2Data, error) {
|
||||
skuParam.AfterSaleServiceV2 = &product_addV2_request.AfterSaleServiceV2{
|
||||
ThreeGuarantees: struct {
|
||||
Duration int64 `json:"duration"`
|
||||
ServiceType int64 `json:"service_type"`
|
||||
}{
|
||||
Duration: 7,
|
||||
ServiceType: 1,
|
||||
},
|
||||
IsLargeProduct: 0,
|
||||
}
|
||||
//skuParam.AfterSaleServiceV2 = &product_addV2_request.AfterSaleServiceV2{
|
||||
// IsLargeProduct: utils.Int64ToPointer(0),
|
||||
// ThreeGuarantees: &product_addV2_request.ThreeGuarantees{
|
||||
// Duration: utils.Int64ToPointer(7),
|
||||
// ServiceType: utils.Int64ToPointer(1),
|
||||
// },
|
||||
//}
|
||||
qualityList := make([]product_addV2_request.QualityListItem, 0, 0)
|
||||
switch a.accessTokenObj.ShopId {
|
||||
case TiktokFloderKeyVegetableKey: // 京西速食
|
||||
@@ -164,8 +192,19 @@ func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2P
|
||||
},
|
||||
},
|
||||
})
|
||||
case 260477060:
|
||||
qualityList = append(qualityList, product_addV2_request.QualityListItem{
|
||||
QualityKey: "6966228537426575660",
|
||||
QualityName: "包装标签图",
|
||||
QualityAttachments: []product_addV2_request.QualityAttachmentsItem{
|
||||
product_addV2_request.QualityAttachmentsItem{
|
||||
MediaType: 1,
|
||||
Url: "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/jpeg_m_94ab77cb6e8b8812abac65f89640e6b9_sx_466038_www1000-1000",
|
||||
},
|
||||
},
|
||||
})
|
||||
default:
|
||||
return nil, errors.New("创建商品是,资质获取异常")
|
||||
//return nil, errors.New("创建商品是,资质获取异常")
|
||||
}
|
||||
skuParam.QualityList = qualityList
|
||||
request := product_addV2_request.New()
|
||||
@@ -180,6 +219,7 @@ func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2P
|
||||
return result.Data, nil
|
||||
}
|
||||
|
||||
// QualityList 商品资质查询
|
||||
func (a *API) QualityList(categoryId int64) ([]*product_qualificationConfig_response.ConfigListItem, error) {
|
||||
if categoryId <= 0 {
|
||||
return nil, errors.New("categoryId 不能为0")
|
||||
@@ -253,7 +293,8 @@ func (a *API) EditStoreCommodityCommit(sku *product_editV2_commit_request.Produc
|
||||
func (a *API) DeleteStoreCommodity(productId int64) error {
|
||||
request := product_del_request.New()
|
||||
param := request.GetParams()
|
||||
param.ProductId = productId
|
||||
//param.ProductId = productId
|
||||
param.OutProductId = 6119735
|
||||
param.DeleteForever = true
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
@@ -369,8 +410,8 @@ func (a *API) EditPrice(skuPrice *sku_editPrice_request.SkuEditPriceParam) error
|
||||
// GetSkuBrand 获取商品所属品牌
|
||||
func (a *API) GetSkuBrand(categoryId int64, brandName string) (int64, error) {
|
||||
request := brand_list_request.New()
|
||||
request.Param.CategoryId = categoryId
|
||||
request.Param.Query = brandName
|
||||
request.Param.CategoryId = utils.Int64ToPointer(categoryId)
|
||||
request.Param.Query = utils.String2Pointer(brandName)
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -601,36 +642,22 @@ func (a *API) GetRecommendCategoryByName(name string) (int64, error) {
|
||||
return 0, errors.New("抖音根据图片获取分类,返回值为0")
|
||||
}
|
||||
|
||||
var firstCid int64
|
||||
var secondCid int64
|
||||
var thirdCid int64
|
||||
var fourthCid int64
|
||||
if len(result.Data.CategoryDetails) == 0 {
|
||||
return 0, errors.New("抖音根据名称获取分类,返回值为0")
|
||||
}
|
||||
categoryDetail := result.Data.CategoryDetails[0].CategoryDetail
|
||||
cids := []int64{
|
||||
categoryDetail.FourthCid,
|
||||
categoryDetail.ThirdCid,
|
||||
categoryDetail.SecondCid,
|
||||
categoryDetail.FirstCid,
|
||||
}
|
||||
for _, cid := range cids {
|
||||
if cid != 0 {
|
||||
return cid, nil
|
||||
}
|
||||
}
|
||||
|
||||
index := len(result.Data.CategoryDetails) - 1
|
||||
if result.Data.CategoryDetails[index].CategoryDetail.FirstCid != 0 {
|
||||
firstCid = result.Data.CategoryDetails[index].CategoryDetail.FirstCid
|
||||
}
|
||||
if result.Data.CategoryDetails[index].CategoryDetail.SecondCid != 0 {
|
||||
secondCid = result.Data.CategoryDetails[index].CategoryDetail.SecondCid
|
||||
}
|
||||
if result.Data.CategoryDetails[index].CategoryDetail.ThirdCid != 0 {
|
||||
thirdCid = result.Data.CategoryDetails[index].CategoryDetail.ThirdCid
|
||||
}
|
||||
if result.Data.CategoryDetails[index].CategoryDetail.FourthCid != 0 {
|
||||
fourthCid = result.Data.CategoryDetails[index].CategoryDetail.FourthCid
|
||||
}
|
||||
if fourthCid != 0 {
|
||||
return fourthCid, nil
|
||||
}
|
||||
if thirdCid != 0 {
|
||||
return thirdCid, nil
|
||||
}
|
||||
if secondCid != 0 {
|
||||
return secondCid, nil
|
||||
}
|
||||
if firstCid != 0 {
|
||||
return firstCid, nil
|
||||
}
|
||||
return 0, errors.New("抖音获取推荐分类异常")
|
||||
}
|
||||
|
||||
@@ -640,7 +667,7 @@ func (a *API) GetRecommendCategory(picParams []string) (int64, error) {
|
||||
return 0, errors.New("抖音根据图片预测分类,图片不能为空")
|
||||
}
|
||||
request := product_GetRecommendCategory_request.New()
|
||||
request.Param.Scene = "smart_publish" // 根据图片获取分类属性
|
||||
request.Param.Scene = "predict_by_title_and_img" // 根据图片获取分类属性
|
||||
picList := make([]product_GetRecommendCategory_request.PicItem, 0, 0)
|
||||
for _, v := range picParams {
|
||||
picList = append(picList, product_GetRecommendCategory_request.PicItem{Url: v})
|
||||
@@ -658,36 +685,19 @@ func (a *API) GetRecommendCategory(picParams []string) (int64, error) {
|
||||
if len(result.Data.CategoryDetails) == 0 {
|
||||
return 0, errors.New("抖音根据图片获取分类,返回值为0")
|
||||
}
|
||||
categoryDetail := result.Data.CategoryDetails[0].CategoryDetail
|
||||
cids := []int64{
|
||||
categoryDetail.FourthCid,
|
||||
categoryDetail.ThirdCid,
|
||||
categoryDetail.SecondCid,
|
||||
categoryDetail.FirstCid,
|
||||
}
|
||||
for _, cid := range cids {
|
||||
if cid != 0 {
|
||||
return cid, nil
|
||||
}
|
||||
}
|
||||
|
||||
var firstCid int64
|
||||
var secondCid int64
|
||||
var thirdCid int64
|
||||
var fourthCid int64
|
||||
|
||||
if result.Data.CategoryDetails[0].CategoryDetail.FirstCid != 0 {
|
||||
firstCid = result.Data.CategoryDetails[0].CategoryDetail.FirstCid
|
||||
}
|
||||
if result.Data.CategoryDetails[0].CategoryDetail.SecondCid != 0 {
|
||||
secondCid = result.Data.CategoryDetails[0].CategoryDetail.SecondCid
|
||||
}
|
||||
if result.Data.CategoryDetails[0].CategoryDetail.ThirdCid != 0 {
|
||||
thirdCid = result.Data.CategoryDetails[0].CategoryDetail.ThirdCid
|
||||
}
|
||||
if result.Data.CategoryDetails[0].CategoryDetail.FourthCid != 0 {
|
||||
fourthCid = result.Data.CategoryDetails[0].CategoryDetail.FourthCid
|
||||
}
|
||||
if fourthCid != 0 {
|
||||
return fourthCid, nil
|
||||
}
|
||||
if thirdCid != 0 {
|
||||
return thirdCid, nil
|
||||
}
|
||||
if secondCid != 0 {
|
||||
return secondCid, nil
|
||||
}
|
||||
if firstCid != 0 {
|
||||
return firstCid, nil
|
||||
}
|
||||
return 0, errors.New("抖音获取推荐分类异常")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user