package service import ( "encoding/json" "net/http" ) type GetGoodsListRequest struct { Page int `json:"page,omitempty"` // 分页,默认第一页 PageSize int `json:"page_size,omitempty"` // 页数 默认10条,最大100 GoodsName *string `json:"goods_name,omitempty"` // 商品名称(支持模糊) ResourceType *int `json:"resource_type,omitempty"` // 资源类型 HasDistribute *int `json:"has_distribute,omitempty"` // 是否参与推广 SaleStatus *int `json:"sale_status,omitempty"` // 上架状态 IsReturnDeleted *int `json:"is_return_deleted,omitempty"` // 是否删除 IsReturnForbid *int `json:"is_return_forbid,omitempty"` // 是否被封禁 IsReturnStopSell *int `json:"is_return_stop_sell,omitempty"` // 是否停售 IsReturnSellType *int `json:"is_return_sell_type,omitempty"` // 售卖方式 IsReturnDisplay *int `json:"is_return_display,omitempty"` // 是否显示 IsReturnSellMode []int `json:"is_return_sell_mode,omitempty"` // 售卖类型数组 IsReturnZeroPrice *int `json:"is_return_zero_price,omitempty"` // 是否返回0元商品 IsReturnPassword *int `json:"is_return_password,omitempty"` // 是否加密 IsReturnPublic *int `json:"is_return_public,omitempty"` // 是否公开售卖 StartTime *string `json:"start_time,omitempty"` // 创建开始时间 EndTime *string `json:"end_time,omitempty"` // 创建结束时间 } type Goods struct { AppId string `json:"app_id"` // 店铺ID Id int `json:"id"` // id ResourceId string `json:"resource_id"` // 资源id(唯一值) SpuId string `json:"spu_id"` // 统一商品id SpuType string `json:"spu_type"` // 统一商品类型 GoodsCategoryId string `json:"goods_category_id"` // 商品分类id GoodsName string `json:"goods_name"` // 商品名称 GoodsImg []string `json:"goods_img"` // 商品封面图(默认封面图) CustomCover string `json:"custom_cover"` // 主图视频自定义封面 SellType int `json:"sell_type"` // 付费类型:1独立售卖,2关联售卖 PriceLow int `json:"price_low"` // 商品最低价(单位:分) PriceHigh int `json:"price_high"` // 商品高价(单位:分) PriceLine int `json:"price_line"` // 划线价(单位:分) VisitNum int `json:"visit_num"` // 访问量 GoodsTag string `json:"goods_tag"` // 商品标签 GoodsTagIsShow int `json:"goods_tag_is_show"` // 商品标签是否展示 SaleStatus int `json:"sale_status"` // 上架状态:0下架 1上架 2待上架 IsTimingSale int `json:"is_timing_sale"` // 是否定时上架:1是 0否 TimingSale string `json:"timing_sale"` // 定时上架时间 SaleAt string `json:"sale_at"` // 上架的时间 HasDistribute int `json:"has_distribute"` // 是否参与推广分销:0否 1是 VideoImgUrl string `json:"video_img_url"` // 主图视频封面url IsGoodsPackage int `json:"is_goods_package"` // 是否带货:0否 1是 IsDisplay int `json:"is_display"` // 是否显示:0否(隐藏) 1是(显示) IsStopSell int `json:"is_stop_sell"` // 是否停售:0否 1是 IsForbid int `json:"is_forbid"` // 商品是否被封禁:0否 1是 IsIgnore int `json:"is_ignore"` // 商品是否被忽略:0否 1是 LimitPurchase int `json:"limit_purchase"` // 限购数量 StockDeductMode int `json:"stock_deduct_mode"` // 扣库存方式:0付款减库存 1拍下减库存 AppraiseNum int `json:"appraise_num"` // 评价数 ShowStock int `json:"show_stock"` // 是否展示库存:0不展示 1展示 IsBest int `json:"is_best"` // 是否精品:0否 1是 IsHot int `json:"is_hot"` // 是否热销产品:0否 1是 IsNew int `json:"is_new"` // 是否新品:0否 1是 IsRecom int `json:"is_recom"` // 是否推荐:0否 1是 DistributionPattern int `json:"distribution_pattern"` // 配送方式 Freight int `json:"freight"` // 运费(单位:分) AuditReason string `json:"audit_reason"` // 审核原因 AuditTime string `json:"audit_time"` // 审核时间 AuditUserId string `json:"audit_user_id"` // 审核人user_id SpuExtend string `json:"spu_extend"` // 业务侧扩展字段 ParentSpuId string `json:"parent_spu_id"` // 父级的spu_id ParentAppId string `json:"parent_app_id"` // 父级的app_id IsUniformFreight int `json:"is_uniform_freight"` // 是否统一运费:1统一运费 2运费模板 FreightTemplateId int `json:"freight_template_id"` // 运费模板ID ImgUrlCompressed string `json:"img_url_compressed"` // 压缩后的列表配图url IsDeleted int `json:"is_deleted"` // 是否删除:0正常 1已删除 CreatedAt string `json:"created_at"` // 创建时间 UpdatedAt string `json:"updated_at"` // 更新时间 Attr []interface{} `json:"attr"` // 属性信息(可根据实际结构定义) Extend []interface{} `json:"extend"` // 扩展信息 } type GetGoodsListResponseData struct { CurrentPage int `json:"current_page"` List []Goods `json:"list"` Total int `json:"total"` // 总数 } type GetGoodsListResponse struct { BaseResponse Data GetGoodsListResponseData `json:"data"` } type GetGoodsInfoResource struct { Ids []string `json:"ids"` // 资源ID集合,可使用查询商品列表2.0获取resource_id的值 Type int `json:"type"` // 资源类型,可使用查询商品列表2.0获取resource_type的值 } type GetGoodsInfoRequest struct { Resources []GetGoodsInfoResource `json:"resources"` IsReturnDeleted *int `json:"is_return_deleted,omitempty"` // 是否删除 0正常 1已删除 不传默认返回所有数据 IsReturnForbid *int `json:"is_return_forbid,omitempty"` // 商品是否被封禁:0 = 否,1 = 是 不传默认返回所有数据 IsCache *bool `json:"is_cache,omitempty"` // 是否查询缓存:false = 否,true = 是 默认是 Body *string `json:"body,omitempty"` // 传“stock”查询库存信息,传“sku”查商品规格相关信息,传“attr”查属性相关信息,不传则不查附属信息 } type GetGoodsInfoResponseData struct { ID int `json:"id"` // 自增主键 AppId string `json:"app_id"` // 店铺ID SkuCostPrice int `json:"sku_cost_price"` // sku成本价,单位:分 SkuVolume string `json:"sku_volume"` // sku体积 SkuSpecCode string `json:"sku_spec_code"` // sku规格编码 SkuWeight string `json:"sku_weight"` // sku重量 ResourceId string `json:"resource_id"` // 资源id ResourceType int `json:"resource_type"` // 资源类型 SpuId string `json:"spu_id"` // 统一商品id SpuType string `json:"spu_type"` // 统一商品类型 SpuTypeName string `json:"spu_type_name"` // 统一商品类型名称 GoodsSn string `json:"goods_sn"` // 商品编号(商家录入) GoodsCategoryId string `json:"goods_category_id"` // 商品分类id WxGoodsCategoryId string `json:"wx_goods_category_id"` // 微信商品分类id GoodsName string `json:"goods_name"` // 商品名称 GoodsImg []string `json:"goods_img"` // 商品封面图(默认封面图) CustomCover string `json:"custom_cover"` // 主图视频自定义封面 DetailCosUrl string `json:"detail_cos_url"` // 富文本的cos链接 GoodsBriefText string `json:"goods_brief_text"` // 商品简介 GoodsDetailText string `json:"goods_detail_text"` // 商品详情/买点 SellType int `json:"sell_type"` // 付费类型:1独立售卖,2关联售卖 PriceLow int `json:"price_low"` // 商品最低价(单位:分) PriceHigh int `json:"price_high"` // 商品高价(单位:分) PriceLine int `json:"price_line"` // 划线价(单位:分) GoodsTag string `json:"goods_tag"` // 商品标签 GoodsTagIsShow int `json:"goods_tag_is_show"` // 商品标签是否展示 0不展示 1展示 SaleStatus int `json:"sale_status"` // 上架状态 0下架 1上架 2待上架 IsTimingSale int `json:"is_timing_sale"` // 是否定时上架 1是 0否 IsTimingOff int `json:"is_timing_off"` // 是否定时下架 1是 0否 TimingSale string `json:"timing_sale"` // 定时上架的时间 TimingOfftime string `json:"timing_offtime"` // 实际下架的时间 TimingOff string `json:"timing_off"` // 定时下架的时间 SaleAt string `json:"sale_at"` // 上架的时间 HasDistribute int `json:"has_distribute"` // 是否参与推广分销 0否 1是 IsGoodsPackage int `json:"is_goods_package"` // 是否带货 0否 1是 IsDisplay int `json:"is_display"` // 是否显示 0否(隐藏) 1是(显示) IsStopSell int `json:"is_stop_sell"` // 是否停售 0否 1是 IsForbid int `json:"is_forbid"` // 商品是否被封禁 0否 1是 IsIgnore int `json:"is_ignore"` // 商品是否被忽略 0否 1是 IsDeleted int `json:"is_deleted"` // 是否删除 0正常 1已删除 CreatedAt string `json:"created_at"` // 创建时间 UpdatedAt string `json:"updated_at"` // 更新时间 VideoImgUrl string `json:"video_img_url"` // 实物商品主图视频封面url LimitPurchase int `json:"limit_purchase"` // 限购数量 StockDeductMode int `json:"stock_deduct_mode"` // 扣库存方式 0付款减库存 1拍下减库存 AppraiseNum int `json:"appraise_num"` // 评价数 ShowStock int `json:"show_stock"` // 是否展示库存 0不展示 1展示 IsBest int `json:"is_best"` // 是否精品 0否 1是 IsHot int `json:"is_hot"` // 是否热销产品 0否 1是 IsNew int `json:"is_new"` // 是否新品 0否 1是 IsRecom int `json:"is_recom"` // 是否推荐 0否 1是 Freight int `json:"freight"` // 运费(单位:分) ImgUrlCompressed string `json:"img_url_compressed"` // 压缩后的列表配图url FreightTemplateId int `json:"freight_template_id"` // 运费模板ID IsUniformFreight int `json:"is_uniform_freight"` // 是否统一运费 1统一运费 2运费模板 IsPublic int `json:"is_public"` // 是否公开售卖 0不公开 1公开 IsPassword int `json:"is_password"` // 是否加密 0不加密 1加密 IsFree int `json:"is_free"` // 是否免费 0收费 1免费 CanSoldStart string `json:"can_sold_start"` // 可售开始时间 CanSoldEnd string `json:"can_sold_end"` // 可售结束时间 IsSingle int `json:"is_single"` // 是否为单品 0否 1是 Period int `json:"period"` // 有效期 -1永久,>=0真实有效期 DistributionPattern int `json:"distribution_pattern"` // 配送方式 SellMode int `json:"sell_mode"` // 售卖类型 1-自营 2-内容市场 PeriodType int `json:"period_type"` // 有效期类型 0长期 1具体时间前 2有效期范围(秒) PeriodValue string `json:"period_value"` // 有效期值 Stock []StockItem `json:"stock"` // 库存信息 Sku []SkuItem `json:"sku"` // sku信息 Attr []interface{} `json:"attr"` // 属性信息 Extend []interface{} `json:"extend"` // 扩展 Pv int `json:"pv"` // 学员学习该资源的总次数 Uv int `json:"uv"` // 学习该资源的学员数 AttachCount int `json:"attach_count"` // 带货的数量 } // StockItem 库存信息 type StockItem struct { SkuId string `json:"sku_id"` // 商品 SKU_ID StockType int `json:"stock_type"` // 库存类型 0-数量购买,2-买断/免费 SettingStock int `json:"setting_stock"` // 设置库存 SellNum int `json:"sell_num"` // 售卖数量 LeftNum int `json:"left_num"` // 剩余数量 IsDeleted int `json:"is_deleted"` // 是否删除 0否 1是 Remark string `json:"remark"` // 属性备注 } // SkuItem sku信息 type SkuItem struct { SkuId string `json:"sku_id"` // 商品 SKU_ID SkuBusinessId string `json:"sku_business_id"` // 资源侧的 SKU_ID AttrData []interface{} `json:"attr_data"` // 属性信息 SkuImg int `json:"sku_img"` // sku默认图片 SkuName int `json:"sku_name"` // sku名字(文档写int,保持) SkuDesc int `json:"sku_desc"` // 规格描述(文档写int) SkuPrice int `json:"sku_price"` // 价格(单位:分) SkuLinePrice string `json:"sku_line_price"` // 划线价 LimitPurchase int `json:"limit_purchase"` // 限购数量 LimitPurchaseType int `json:"limit_purchase_type"` // 限购类型 SkuMinPurchase int `json:"sku_min_purchase"` // 起购数量 PeriodType int `json:"period_type"` // 有效期类型 PeriodValue string `json:"period_value"` // 有效期值 ValueCount int `json:"value_count"` // 规格 1-单规格 2-多规格 OrderSkuLimit int `json:"order_sku_limit"` // 下单是否受库存限制 0否 1是 State int `json:"state"` // 上下架状态 1上架 0下架 IsDefault int `json:"is_default"` // 是否默认 0否 1是 IsDeleted int `json:"is_deleted"` // 是否删除 0否 1是 IsFree int `json:"is_free"` // 是否免费 0否 1是 } type GetGoodsInfoResponse struct { BaseResponse Data []GetGoodsInfoResponseData `json:"data"` } // MKARK 获取商品列表 func (client *Client) GetGoodsList(req *GetGoodsListRequest) (*GetGoodsListResponse, error) { paramsMap, err := ToMap(req) if err != nil { return nil, err } respByte, err := client.CurlDo(http.MethodPost, GetGoodsListUrl, paramsMap) if err != nil { return nil, err } resp := GetGoodsListResponse{} err = json.Unmarshal(respByte, &resp) if err != nil { return nil, err } return &resp, nil } // MKARK 获取商品详情 func (client *Client) GetGoodsInfo(req *GetGoodsInfoRequest) (*GetGoodsInfoResponse, error) { paramsMap, err := ToMap(req) if err != nil { return nil, err } respByte, err := client.CurlDo(http.MethodPost, GetGoodsInfoUrl, paramsMap) if err != nil { return nil, err } resp := GetGoodsInfoResponse{} err = json.Unmarshal(respByte, &resp) if err != nil { return nil, err } return &resp, nil }