提交 9277c04d authored 作者: zhanglibo's avatar zhanglibo

商品

上级 7c5ff93b
...@@ -13,15 +13,18 @@ type goodsAli struct { ...@@ -13,15 +13,18 @@ type goodsAli struct {
var Goods = goodsAli{} var Goods = goodsAli{}
type GoodsListReq struct { type GoodsListReq struct {
Biztype string `json:"biztype"` //经营模式 【1:生产加工,2:经销批发,3:招商代理,4:商业服务】 Biztype string `json:"biztype,omitempty"` //经营模式 【1:生产加工,2:经销批发,3:招商代理,4:商业服务】
BuyerProtection string `json:"buyerProtection"` //买家保障,多个值用逗号分割;【qtbh:7天包换;swtbh:15天包换】 BuyerProtection string `json:"buyerProtection,omitempty"` //买家保障,多个值用逗号分割;【qtbh:7天包换;swtbh:15天包换】
City string `json:"city"` //所在地区- 市 示例:杭州 City string `json:"city,omitempty"` //所在地区- 市 示例:杭州
DeliveryTimeType string `json:"deliveryTimeType"` //发货时间;【1:24小时发货;2:48小时发货;3:72小时发货】 DeliveryTimeType string `json:"deliveryTimeType,omitempty"` //发货时间;【1:24小时发货;2:48小时发货;3:72小时发货】
DescendOrder bool `json:"descendOrder"` //是否倒序;【正序: false;倒序:true】 DescendOrder bool `json:"descendOrder,omitempty"` //是否倒序;【正序: false;倒序:true】
HolidayTagId string `json:"holidayTagId"` //商品售卖类型筛选;枚举,多个值用分号分割;免费赊账:50000114 HolidayTagId string `json:"holidayTagId,omitempty"` //商品售卖类型筛选;枚举,多个值用分号分割;免费赊账:50000114
KeyWords string `json:"keyWords"` //搜索关键词 KeyWords string `json:"keyWords,omitempty"` //搜索关键词
Page int `json:"page"` //页码 Page int `json:"page"` //页码
PageSize int `json:"pageSize"` //页面数量;最大20 PageSize int `json:"pageSize"` //页面数量;最大20
OfferIds string `json:"offerIds,omitempty"` //ID
CategoryId string `json:"postCategoryId,omitempty"` //分类ID
SortType string `json:"sortType,omitempty"` //排序字段
AccessToken string `json:"access_token"` AccessToken string `json:"access_token"`
} }
...@@ -42,13 +45,6 @@ type GoodsListRes struct { ...@@ -42,13 +45,6 @@ type GoodsListRes struct {
} `json:"result"` } `json:"result"`
} }
type GoodsInfoReq struct {
GoodsID int64 `json:"offerId"` //1688商品ID,等同于productId
NeedCpsSuggestPrice bool `json:"needCpsSuggestPrice"` //是否需要CPS建议价
NeedIntelligentInfo bool `json:"needIntelligentInfo"` //是否返回算法改写的信息,包括标题、图片和详情图片
AccessToken string `json:"access_token"`
}
type GoodsInfoRes struct { type GoodsInfoRes struct {
CommonRes CommonRes
BizGroupInfos []struct { BizGroupInfos []struct {
...@@ -58,10 +54,13 @@ type GoodsInfoRes struct { ...@@ -58,10 +54,13 @@ type GoodsInfoRes struct {
} `json:"bizGroupInfos"` } `json:"bizGroupInfos"`
ProductInfo struct { ProductInfo struct {
ProductID int64 `json:"productID"` ProductID int64 `json:"productID"`
SupplierLoginId string `json:"SupplierLoginId"`
MainVedio string `json:"MainVedio"`
CategoryID int `json:"categoryID"` CategoryID int `json:"categoryID"`
Subject string `json:"subject"` Subject string `json:"subject"`
Description string `json:"description"` Description string `json:"description"`
PictureAuth bool `json:"pictureAuth"` PictureAuth bool `json:"pictureAuth"`
IntelligentInfo IntelligentInfo `json:"intelligentInfo"` //商品算法智能改写信息,包含算法优化后的商品标题和图片信息,未改写的则直接返回原标题和原图片
Image struct { Image struct {
Images []string `json:"images"` Images []string `json:"images"`
} `json:"image"` } `json:"image"`
...@@ -78,6 +77,7 @@ type GoodsInfoRes struct { ...@@ -78,6 +77,7 @@ type GoodsInfoRes struct {
SkuID int64 `json:"skuId"` SkuID int64 `json:"skuId"`
SpecID string `json:"specId"` SpecID string `json:"specId"`
ConsignPrice float64 `json:"consignPrice"` ConsignPrice float64 `json:"consignPrice"`
Retailprice float64 `json:"retailprice"`
ChannelPrice float64 `json:"channelPrice"` ChannelPrice float64 `json:"channelPrice"`
} `json:"skuInfos"` } `json:"skuInfos"`
SaleInfo struct { SaleInfo struct {
...@@ -92,6 +92,9 @@ type GoodsInfoRes struct { ...@@ -92,6 +92,9 @@ type GoodsInfoRes struct {
Unit string `json:"unit"` Unit string `json:"unit"`
MinOrderQuantity int `json:"minOrderQuantity"` MinOrderQuantity int `json:"minOrderQuantity"`
QuoteType int `json:"quoteType"` QuoteType int `json:"quoteType"`
Retailprice float64 `json:"retailprice"`
ConsignPrice float64 `json:"consignPrice"`
ChannelPrice float64 `json:"channelPrice"`
} `json:"saleInfo"` } `json:"saleInfo"`
ShippingInfo struct { ShippingInfo struct {
FreightTemplateID int `json:"freightTemplateID"` FreightTemplateID int `json:"freightTemplateID"`
...@@ -149,6 +152,16 @@ type GoodsInfoRes struct { ...@@ -149,6 +152,16 @@ type GoodsInfoRes struct {
} `json:"productInfo"` } `json:"productInfo"`
} }
type IntelligentInfo struct {
Title string `json:"title"` //算法优化后的商品标题
Images []string `json:"images"` //主图列表,使用相对路径,需要增加域名:https://cbu01.alicdn.com/
SkuImages []struct { //算法优化后的规格图片
SkuId int64 `json:"skuId"` //规格ID
ImageUrl string `json:"imageUrl"` //图片
} `json:"skuImages"`
DescriptionImages []string `json:"descriptionImages"` //算法优化后的详情图片
}
type GoodsFollowRes struct { type GoodsFollowRes struct {
Code int `json:"code"` Code int `json:"code"`
Message int `json:"message"` Message int `json:"message"`
...@@ -178,7 +191,7 @@ type GoodsCategoryReq struct { ...@@ -178,7 +191,7 @@ type GoodsCategoryReq struct {
} }
type GoodsCategoryRes struct { type GoodsCategoryRes struct {
CommonRes Succes string `json:"succes"`
CategoryInfo []struct { CategoryInfo []struct {
CategoryID int `json:"categoryID"` CategoryID int `json:"categoryID"`
Name string `json:"name"` Name string `json:"name"`
...@@ -206,11 +219,16 @@ func (goodsAli) List(ctx context.Context, req *GoodsListReq) (res *GoodsListRes, ...@@ -206,11 +219,16 @@ func (goodsAli) List(ctx context.Context, req *GoodsListReq) (res *GoodsListRes,
return return
} }
func (goodsAli) Info(ctx context.Context, req *GoodsInfoReq) (res *GoodsInfoRes, err error) { func (goodsAli) Info(ctx context.Context, req interface{}) (res *GoodsInfoRes, err error) {
method := "com.alibaba.product/alibaba.cpsMedia.productInfo" method := "com.alibaba.product/alibaba.cpsMedia.productInfo"
request := g.Map{
"offerId": gconv.Int64(req),
"needCpsSuggestPrice": true,
"needIntelligentInfo": true,
"access_token": server.AccessToken,
}
req.AccessToken = server.AccessToken result, err := server.Post(ctx, method, request)
result, err := server.Post(ctx, method, gconv.Map(req))
_ = gjson.New(result).Scan(&res) _ = gjson.New(result).Scan(&res)
return return
} }
......
...@@ -234,10 +234,10 @@ func (*goodsJD) GetProductsPrice(ctx context.Context, skus *garray.Array) (res * ...@@ -234,10 +234,10 @@ func (*goodsJD) GetProductsPrice(ctx context.Context, skus *garray.Array) (res *
} }
//GetDetail 查询商品详情 //GetDetail 查询商品详情
func (*goodsJD) GetDetail(ctx context.Context, skus *garray.Array) (res *GetDetailRes, err error) { func (*goodsJD) GetDetail(ctx context.Context, skus interface{}) (res *GetDetailRes, err error) {
method := "product/getDetail" method := "product/getDetail"
param := g.Map{ param := g.Map{
"sku": skus.Join(","), "sku": gconv.String(skus),
"queryExts": "spuId,pName,isFactoryShip,isSelf,LowestBuy,wxintroduction", "queryExts": "spuId,pName,isFactoryShip,isSelf,LowestBuy,wxintroduction",
} }
result, err := server.requestApi(ctx, method, param) result, err := server.requestApi(ctx, method, param)
...@@ -290,3 +290,52 @@ func (*goodsJD) GetSimilarSku(ctx context.Context, skus interface{}) (res *GetSi ...@@ -290,3 +290,52 @@ func (*goodsJD) GetSimilarSku(ctx context.Context, skus interface{}) (res *GetSi
err = gjson.New(result).Scan(&res) err = gjson.New(result).Scan(&res)
return return
} }
type GetPageNumRes struct {
Success bool `json:"success"`
ResultCode string `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Result []struct {
Name string `json:"name"`
PageNum string `json:"page_num"`
} `json:"result"`
}
//GetPageNum 查询商品池编号
func (*goodsJD) GetPageNum(ctx context.Context) (res *GetPageNumRes, err error) {
method := "product/getPageNum"
param := g.Map{}
result, err := server.requestApi(ctx, method, param)
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
type QueryByPageRes struct {
Success bool `json:"success"`
ResultMessage string `json:"resultMessage"`
ResultCode string `json:"resultCode"`
Result struct {
RemainPage int `json:"remainPage"`
Skus []int `json:"skus"`
Offset int `json:"offset"`
} `json:"result"`
}
//QueryByPage 查询池内商品编号
func (*goodsJD) QueryByPage(ctx context.Context, pageNum, pageNo, offset interface{}) (res *QueryByPageRes, err error) {
method := "product/querySkuByPage"
param := g.Map{
"pageNum": pageNum,
"pageSize": pageNo,
"offset": offset,
}
result, err := server.requestApi(ctx, method, param)
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
...@@ -3,6 +3,7 @@ package tm ...@@ -3,6 +3,7 @@ package tm
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv" "github.com/gogf/gf/util/gconv"
) )
...@@ -46,3 +47,55 @@ func (s *goodsTm) Inventory(ctx context.Context, DivisionCode string, req []Good ...@@ -46,3 +47,55 @@ func (s *goodsTm) Inventory(ctx context.Context, DivisionCode string, req []Good
_ = json.Unmarshal([]byte(result), &res) _ = json.Unmarshal([]byte(result), &res)
return return
} }
type GoodsDetailRes struct {
Code string `json:"Code"`
Success bool `json:"Success"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
Item struct {
ItemId int `json:"ItemId"`
ItemTitle string `json:"ItemTitle"`
CanSell bool `json:"IsCanSell"`
ReservePrice int `json:"ReservePrice"` //
Quantity int `json:"Quantity"`
MinPrice int `json:"MinPrice"`
TotalSoldQuantity int `json:"TotalSoldQuantity"` //销量
DescOption string `json:"DescOption"`
SellerId int `json:"SellerId"`
CategoryId int `json:"CategoryId"`
MainPicUrl string `json:"MainPicUrl"`
TbShopName string `json:"TbShopName"`
SellerPayPostfee bool `json:"SellerPayPostfee"` //是否包邮
PropertiesJson string `json:"PropertiesJson"` //属性
Properties map[string][]string `json:"Properties"` //属性
Skus struct {
Sku []struct {
ItemId int `json:"ItemId"`
Quantity int `json:"Quantity"`
ReservePrice int `json:"ReservePrice"`
CanSell bool `json:"CanSell"`
SkuId int `json:"SkuId"`
PriceCent int `json:"PriceCent"` //售价
SkuProperties map[string]string `json:"SkuProperties"`
SkuPropertiesJson string `json:"SkuPropertiesJson"`
SkuPicUrl string `json:"SkuPicUrl"`
} `json:"Sku"`
} `json:"Skus"`
ItemImages struct {
ItemImage []string `json:"ItemImage"`
} `json:"ItemImages"`
} `json:"Item"`
}
//Detail 详情
func (*goodsTm) Detail(ctx context.Context, req interface{}) (res *GoodsDetailRes, err error) {
method := "QueryItemDetail"
request := g.MapStrStr{
"ItemId": gconv.String(req),
}
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论