feat 修改获取最低价返回值
This commit is contained in:
parent
a19977d88f
commit
235a5f1bd6
@ -2,6 +2,7 @@ package dw_sdk
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/gofiber/fiber/v3/client"
|
||||
@ -14,7 +15,7 @@ import (
|
||||
//https://open.dewu.com/#/api/body?apiId=42&id=3&title=%E5%87%BA%E4%BB%B7%E6%9C%8D%E5%8A%A1API
|
||||
|
||||
type BidClient interface {
|
||||
LowestPrice(skuId int) (*PublicResponse[LowestPriceResponse], error)
|
||||
LowestPrice(skuId int) (LowestPriceResponse, error)
|
||||
}
|
||||
|
||||
type ConsignBidClientImpl struct {
|
||||
@ -62,9 +63,9 @@ type LowestPriceItem struct {
|
||||
BiddingType BiddingType `json:"bidding_type"`
|
||||
}
|
||||
|
||||
func (a *ConsignBidClientImpl) LowestPrice(skuId int) (*PublicResponse[LowestPriceResponse], error) {
|
||||
func (a *ConsignBidClientImpl) LowestPrice(skuId int) (LowestPriceResponse, error) {
|
||||
if skuId == 0 {
|
||||
return nil, Err_Params_None
|
||||
return LowestPriceResponse{}, Err_Params_None
|
||||
}
|
||||
data := LowestPriceReq{
|
||||
PublicParams: PublicParams{
|
||||
@ -81,12 +82,15 @@ func (a *ConsignBidClientImpl) LowestPrice(skuId int) (*PublicResponse[LowestPri
|
||||
|
||||
response, err := r.SetJSON(data).Post(FastLowestPriceUrl)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(Err_Request_Err, "consign/bidding/lowest_price err:%v", err)
|
||||
return LowestPriceResponse{}, errors.Wrapf(Err_Request_Err, "consign/bidding/lowest_price err:%v", err)
|
||||
}
|
||||
defer client.ReleaseResponse(response)
|
||||
var resp PublicResponse[LowestPriceResponse]
|
||||
if err = response.JSON(&resp); err != nil {
|
||||
return nil, errors.Wrapf(Err_JSON_UNMarshal, "consign/bidding/lowest_price err:%v", err)
|
||||
return LowestPriceResponse{}, errors.Wrapf(Err_JSON_UNMarshal, "consign/bidding/lowest_price err:%v", err)
|
||||
}
|
||||
return &resp, nil
|
||||
if resp.Code != http.StatusOK {
|
||||
return LowestPriceResponse{}, errors.Wrapf(Err_Request_Err, "consign/bidding/lowest_price resp.msg:%v", resp.Msg)
|
||||
}
|
||||
return resp.Data, nil
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package dw_sdk
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/bytedance/sonic"
|
||||
@ -44,9 +45,9 @@ func NewPreSaleBidClient(cfg Config) BidClient {
|
||||
// 获取平台sku最低价【全款预售】
|
||||
const PreSaleLowestPriceUrl = "/dop/api/v1/bidding/normal_pre_sale/lowest_price"
|
||||
|
||||
func (a *PreSaleBidClientImpl) LowestPrice(skuId int) (*PublicResponse[LowestPriceResponse], error) {
|
||||
func (a *PreSaleBidClientImpl) LowestPrice(skuId int) (LowestPriceResponse, error) {
|
||||
if skuId == 0 {
|
||||
return nil, Err_Params_None
|
||||
return LowestPriceResponse{}, Err_Params_None
|
||||
}
|
||||
data := LowestPriceReq{
|
||||
PublicParams: PublicParams{
|
||||
@ -64,12 +65,15 @@ func (a *PreSaleBidClientImpl) LowestPrice(skuId int) (*PublicResponse[LowestPri
|
||||
|
||||
response, err := r.Get(PreSaleLowestPriceUrl + "?" + s)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(Err_Request_Err, "%s err:%v", PreSaleLowestPriceUrl, err)
|
||||
return LowestPriceResponse{}, 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 LowestPriceResponse{}, errors.Wrapf(Err_JSON_UNMarshal, "%s err:%v", PreSaleLowestPriceUrl, err)
|
||||
}
|
||||
return &resp, nil
|
||||
if resp.Code != http.StatusOK {
|
||||
return LowestPriceResponse{}, errors.Wrapf(Err_Request_Err, "%s resp.msg:%v", PreSaleLowestPriceUrl, resp.Msg)
|
||||
}
|
||||
return resp.Data, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user