Compare commits
No commits in common. "85e6bb8a8eff3f0a1512068a324e1b365ec61f10" and "47902c467f8c0f340e831a5fa10fc7a9c651131e" have entirely different histories.
85e6bb8a8e
...
47902c467f
@ -57,8 +57,8 @@ type Spu struct {
|
|||||||
SpuId int `json:"spu_id"`
|
SpuId int `json:"spu_id"`
|
||||||
CategoryId int `json:"category_id"`
|
CategoryId int `json:"category_id"`
|
||||||
CategoryName string `json:"category_name"`
|
CategoryName string `json:"category_name"`
|
||||||
BrandId BrandId `json:"brand_id"`
|
BrandId int `json:"brand_id"`
|
||||||
BrandName BrandName `json:"brand_name"`
|
BrandName string `json:"brand_name"`
|
||||||
ArticleNumber string `json:"article_number"` //商品货号
|
ArticleNumber string `json:"article_number"` //商品货号
|
||||||
OtherNumbers string `json:"other_numbers"` // 辅助货号,逗号分隔,可传多个
|
OtherNumbers string `json:"other_numbers"` // 辅助货号,逗号分隔,可传多个
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
package dw_sdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/bytedance/sonic"
|
|
||||||
"github.com/gofiber/fiber/v3/client"
|
|
||||||
"github.com/google/go-querystring/query"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/valyala/fasthttp/fasthttpproxy"
|
|
||||||
)
|
|
||||||
|
|
||||||
// https://open.dewu.com/#/api/body?apiId=97&id=3&title=%E5%87%BA%E4%BB%B7%E6%9C%8D%E5%8A%A1API
|
|
||||||
|
|
||||||
// 预售出价服务客户端
|
|
||||||
type PreSaleBidClientImpl struct {
|
|
||||||
cli *client.Client
|
|
||||||
cfg PublicConfig
|
|
||||||
baseUrl string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewPreSaleBidClient(cfg Config) BidClient {
|
|
||||||
baseUrl := GetUrl(cfg.Public.Env)
|
|
||||||
cli := client.New().SetJSONMarshal(func(v any) ([]byte, error) {
|
|
||||||
return sonic.Marshal(v)
|
|
||||||
}).SetJSONUnmarshal(func(data []byte, v any) error {
|
|
||||||
return sonic.Unmarshal(data, v)
|
|
||||||
}).AddRequestHook(func(c *client.Client, request *client.Request) error {
|
|
||||||
request.SetURL(baseUrl + request.URL())
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
if cfg.Proxy != nil {
|
|
||||||
cli.SetDial(fasthttpproxy.FasthttpHTTPDialer(fmt.Sprintf("%s:%s@%s:%s", cfg.Proxy.User, cfg.Proxy.Pass, cfg.Proxy.Host, cfg.Proxy.Port)))
|
|
||||||
}
|
|
||||||
return &PreSaleBidClientImpl{
|
|
||||||
cli: cli,
|
|
||||||
cfg: cfg.Public,
|
|
||||||
baseUrl: baseUrl,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取平台sku最低价【全款预售】
|
|
||||||
const PreSaleLowestPriceUrl = "/dop/api/v1/bidding/normal_pre_sale/lowest_price"
|
|
||||||
|
|
||||||
func (a *PreSaleBidClientImpl) LowestPrice(skuId int) (*PublicResponse[LowestPriceResponse], error) {
|
|
||||||
if skuId == 0 {
|
|
||||||
return nil, Err_Params_None
|
|
||||||
}
|
|
||||||
data := LowestPriceReq{
|
|
||||||
PublicParams: PublicParams{
|
|
||||||
AppKey: a.cfg.Key,
|
|
||||||
Timestamp: time.Now().UnixMilli(),
|
|
||||||
},
|
|
||||||
SkuId: skuId,
|
|
||||||
}
|
|
||||||
|
|
||||||
Sign(&data, a.cfg.Secret)
|
|
||||||
v, _ := query.Values(data)
|
|
||||||
s := v.Encode()
|
|
||||||
r := a.cli.R()
|
|
||||||
defer client.ReleaseRequest(r)
|
|
||||||
|
|
||||||
response, err := r.Get(PreSaleLowestPriceUrl + "?" + s)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(Err_Request_Err, "%s err:%v", PreSaleLowestPriceUrl, err)
|
|
||||||
}
|
|
||||||
defer client.ReleaseResponse(response)
|
|
||||||
var resp PublicResponse[LowestPriceResponse]
|
|
||||||
if err = response.JSON(&resp); err != nil {
|
|
||||||
return nil, errors.Wrapf(Err_JSON_UNMarshal, "%s err:%v", PreSaleLowestPriceUrl, err)
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user