feat 添加获取预售商品接口

This commit is contained in:
timerzz 2024-09-02 14:34:11 +08:00
parent b04e8891dc
commit 47902c467f
5 changed files with 14 additions and 9 deletions

View File

@ -47,9 +47,9 @@ func NewConsignBidClient(cfg Config) BidClient {
// 获取平台sku最低价【闪电直发】
const FastLowestPriceUrl = "/dop/api/v1/consign/bidding/lowest_price"
type ConsignLowestPriceReq struct {
PublicParams
SkuId int `json:"sku_id" url:"sku_id"`
type LowestPriceReq struct {
PublicParams `param:",inline"`
SkuId int `json:"sku_id" url:"sku_id" param:"sku_id"`
}
type LowestPriceResponse struct {
@ -66,7 +66,7 @@ func (a *ConsignBidClientImpl) LowestPrice(skuId int) (*PublicResponse[LowestPri
if skuId == 0 {
return nil, Err_Params_None
}
data := ConsignLowestPriceReq{
data := LowestPriceReq{
PublicParams: PublicParams{
AppKey: a.cfg.Key,
Timestamp: time.Now().UnixMilli(),

View File

@ -12,7 +12,7 @@ var testConfig = Config{
}
func TestNewBidConsignClient(t *testing.T) {
cli := NewConsignBidClient(testConfig)
cli := NewPreSaleBidClient(testConfig)
resp, err := cli.LowestPrice(626512954)
if err != nil {
t.Fatal(err)

2
bid.go
View File

@ -3,5 +3,7 @@ package dw_sdk
type BiddingType int8
const (
BiddingType_PreSale BiddingType = 1 //预售
BiddingType_Consign BiddingType = 5 //闪电直发
BiddingType_Fast_PreSale BiddingType = 8 //急速预售
)

View File

@ -3,12 +3,14 @@ package dw_sdk
type Client struct {
articleServiceClient ArticleServiceClient
consignBidClient BidClient
preSaleBidClient BidClient
}
func NewClient(cfg Config) *Client {
return &Client{
articleServiceClient: NewArticleServiceClient(cfg),
consignBidClient: NewConsignBidClient(cfg),
preSaleBidClient: NewPreSaleBidClient(cfg),
}
}

View File

@ -3,15 +3,16 @@ package dw_sdk
import (
"crypto/md5"
"fmt"
"github.com/bytedance/sonic"
"github.com/google/go-querystring/query"
"net/url"
"strings"
"github.com/bytedance/sonic"
"github.com/google/go-querystring/query"
)
type PublicParams struct {
AppKey string `json:"app_key" url:"app_key"`
Sign string `json:"sign" url:"-"`
Sign string `json:"sign" url:"sign,omitempty"`
AccessToken string `json:"access_token,omitempty" url:"access_token,omitempty"`
Timestamp int64 `json:"timestamp" url:"timestamp"`
}