1
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package product_GetRecommendCategory_response
|
||||
|
||||
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
|
||||
type ProductGetRecommendCategoryResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *ProductGetRecommendCategoryData `json:"data"`
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
brand_list_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/brand_list/request"
|
||||
order_batchDecrypt_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_batchDecrypt/request"
|
||||
order_batchSensitive_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_batchSensitive/request"
|
||||
product_GetRecommendCategory_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_GetRecommendCategory/request"
|
||||
product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request"
|
||||
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"
|
||||
@@ -8164,3 +8165,58 @@ func (a *API) GetProductAuditList(page, pageSize, status int64) ([]product_audit
|
||||
|
||||
return result.Data.Records, result.Data.Total, nil
|
||||
}
|
||||
|
||||
// GetRecommendCategory 根据图片预测商品类目,优先四级>三级>二级>1级
|
||||
func (a *API) GetRecommendCategory(picParams []string) int64 {
|
||||
if len(picParams) == 0 {
|
||||
return 0
|
||||
}
|
||||
request := product_GetRecommendCategory_request.New()
|
||||
request.Param.Scene = "smart_publish" // 根据图片获取分类属性
|
||||
picList := make([]product_GetRecommendCategory_request.PicItem, 0, 0)
|
||||
for _, v := range picParams {
|
||||
picList = append(picList, product_GetRecommendCategory_request.PicItem{Url: v})
|
||||
}
|
||||
request.Param.Pic = picList
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0
|
||||
}
|
||||
|
||||
var firstCid int64
|
||||
var secondCid int64
|
||||
var thirdCid int64
|
||||
var fourthCid int64
|
||||
|
||||
for _, v := range result.Data.CategoryDetails {
|
||||
if v.CategoryDetail.FirstCid != 0 {
|
||||
firstCid = v.CategoryDetail.FirstCid
|
||||
}
|
||||
if v.CategoryDetail.SecondCid != 0 {
|
||||
secondCid = v.CategoryDetail.SecondCid
|
||||
}
|
||||
if v.CategoryDetail.ThirdCid != 0 {
|
||||
thirdCid = v.CategoryDetail.ThirdCid
|
||||
}
|
||||
if v.CategoryDetail.FourthCid != 0 {
|
||||
fourthCid = v.CategoryDetail.FourthCid
|
||||
}
|
||||
}
|
||||
if fourthCid != 0 {
|
||||
return fourthCid
|
||||
}
|
||||
if thirdCid != 0 {
|
||||
return thirdCid
|
||||
}
|
||||
if secondCid != 0 {
|
||||
return secondCid
|
||||
}
|
||||
if firstCid != 0 {
|
||||
return firstCid
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user