京东商城api

This commit is contained in:
苏尹岚
2020-05-08 16:05:10 +08:00
parent c638575d8b
commit 80d050b1c5
7 changed files with 285 additions and 2 deletions

View File

@@ -0,0 +1,52 @@
package jdshopapi
import (
"fmt"
"git.rosy.net.cn/baseapi/utils"
)
type FindShopCategoriesResult struct {
CID int64 `json:"cid"` //123456 分类编号
VenderID int `json:"vender_id"` //123456 商家编号
ShopID int `json:"shop_id"` // 123456 店铺编号
ParentCID int64 `json:"parent_cid"` //123456 父分类编号
OrderNo int `json:"order_no"` //1 分类排序
Name string `json:"name"` //分类1 分类名称
IsOpen bool `json:"is_open"` //false 是否展开子分类false不展开true展开
IsHomeShow bool `json:"is_home_show"` //false 是否在首页展示分类false前台不展示true前台展示
Status int `json:"status"` // 1 状态(1删除 1正常)
CreateTime int64 `json:"create_time"` //1394089643000 创建时间
ModifyTime int64 `json:"modify_time"` // 修改时间。每修改一次此值都会发生变化。
}
//查询商家所有的店内分类
//https://open.jd.com/home/home#/doc/api?apiCateId=88&apiId=2801&apiName=jingdong.vender.shopcategory.findShopCategoriesByVenderId
func (a *API) FindShopCategories() (findShopCategoriesResult []*FindShopCategoriesResult, err error) {
result, err := a.AccessAPI("jingdong.vender.shopcategory.findShopCategoriesByVenderId", prodURL, nil)
if err == nil {
utils.Map2StructByJson(result["jingdong_vender_shopcategory_findShopCategoriesByVenderId_responce"].(map[string]interface{})["shopCategoryResult"].(map[string]interface{})["shop_category_list"], &findShopCategoriesResult, false)
}
return findShopCategoriesResult, err
}
//删除店内分类
//https://open.jd.com/home/home#/doc/api?apiCateId=88&apiId=3031&apiName=jingdong.vender.shopcategory.deleteShopCategoryByVenderIdAndCid
func (a *API) DeleteShopCategory(cid int64) (uniteResp *UniteResp, err error) {
result, err := a.AccessAPI("jingdong.vender.shopcategory.deleteShopCategoryByVenderIdAndCid", prodURL, map[string]interface{}{
"cid": cid,
})
if err == nil {
utils.Map2StructByJson(result["jingdong_vender_shopcategory_deleteShopCategoryByVenderIdAndCid_responce"].(map[string]interface{})["shopCategoryResult"], &uniteResp, false)
if !uniteResp.IsSuccess {
return nil, fmt.Errorf(uniteResp.ErrorMsgCn)
}
}
return uniteResp, err
}
//京东商城发布商品(创建商品?)
//https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1379&apiName=jingdong.ware.write.add
func (a *API) CreateSkuName() (err error) {
return err
}