提交 3d5e4f8e authored 作者: 张立波's avatar 张立波

京东

上级 d321e526
...@@ -435,3 +435,42 @@ func (*goodsJD) Search(ctx context.Context, req GoodsSearchReq) (res *GoodsSearc ...@@ -435,3 +435,42 @@ func (*goodsJD) Search(ctx context.Context, req GoodsSearchReq) (res *GoodsSearc
err = gjson.New(result).Scan(&res) err = gjson.New(result).Scan(&res)
return return
} }
type GoodsBeforeReq struct {
SkuId int `json:"skuId"`
Num int `json:"num"`
Price float64 `json:"price"`
}
type GoodsBeforeBase struct {
CommonRes
Result string `json:"result"`
}
type GoodsBeforeRes struct {
CommonRes
Result []struct {
SkuID string
CanPurchase bool
MessageList []string
}
}
// Before 下单前商品校验
func (*goodsJD) Before(ctx context.Context, req []GoodsBeforeReq, address *garray.StrArray) (res *GoodsBeforeRes, err error) {
method := "/stock/checkSkuSaleStateAndStock"
var request = g.Map{
"skuNums": gjson.New(req).MustToJsonString(),
"area": address.Join("_"),
}
result, err := server.requestApi(ctx, method, request)
if err != nil {
return
}
var base *GoodsBeforeBase
_ = gjson.New(result).Scan(&base)
res = &GoodsBeforeRes{}
res.CommonRes = base.CommonRes
_ = gjson.New(base.Result).Scan(res.Result)
return
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论