- update cache

master v1.0.29
李光春 1 year ago
parent 7214d36827
commit 2ad3efbb7a

@ -8,12 +8,6 @@ import (
"net/http"
)
const (
CacheGoodsStatusNormal = "normal" // 正常
CacheGoodsStatusProhibit = "prohibit" // 异常
CacheGoodsStatusNoneStock = "none_stock" // 无库存
)
type ApiProductCacheResponse struct {
Code int `json:"code"`
Message string `json:"message"`
@ -46,8 +40,10 @@ func newApiProductCacheResult(result ApiProductCacheResponse, body []byte, http
func (c *Client) ApiProductCache(ctx context.Context, productId int64) *ApiProductCacheResult {
// 参数
params := gorequest.NewParams()
params.Set("customer_id", c.GetCustomerId())
params.Set("product_id", productId)
// 请求
request, err := c.requestCache(ctx, fmt.Sprintf("%s/%d/goods_info/%d", apiUrlCache, c.GetCustomerId(), productId), params, http.MethodGet)
request, err := c.requestCache(ctx, fmt.Sprintf("%s/goods_info", apiUrlCache), params, http.MethodGet)
// 定义
var response ApiProductCacheResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,46 +0,0 @@
package kashangwl
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
"net/http"
)
type ApiProductRechargeParamsCacheResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data struct {
GoodsId string `json:"goods_id"`
ApiGoodsId int64 `json:"api_goods_id"`
PurchaseTips string `json:"purchase_tips"`
} `json:"data"`
Time int `json:"time"`
TraceId string `json:"trace_id"`
}
type ApiProductRechargeParamsCacheResult struct {
Result ApiProductRechargeParamsCacheResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
}
func newApiProductRechargeParamsCacheResult(result ApiProductRechargeParamsCacheResponse, body []byte, http gorequest.Response, err error) *ApiProductRechargeParamsCacheResult {
return &ApiProductRechargeParamsCacheResult{Result: result, Body: body, Http: http, Err: err}
}
// ApiProductRechargeParamsCache 接口说明
// 获取商品的充值参数(仅支持充值类商品)
// http://doc.cqmeihu.cn/sales/ProductParams.html
func (c *Client) ApiProductRechargeParamsCache(ctx context.Context, productId int64) *ApiProductRechargeParamsCacheResult {
// 参数
params := gorequest.NewParams()
// 请求
request, err := c.requestCache(ctx, fmt.Sprintf("%s/%d/goods_info_params/%d", apiUrlCache, c.GetCustomerId(), productId), params, http.MethodGet)
// 定义
var response ApiProductRechargeParamsCacheResponse
err = json.Unmarshal(request.ResponseBody, &response)
return newApiProductRechargeParamsCacheResult(response, request.ResponseBody, request, err)
}

@ -15,5 +15,5 @@ const (
const (
LogTable = "kashangwl"
Version = "1.0.28"
Version = "1.0.29"
)

@ -4,7 +4,6 @@ go 1.19
require (
github.com/gin-gonic/gin v1.8.1
go.dtapp.net/dorm v1.0.51
go.dtapp.net/golog v1.0.101
go.dtapp.net/gorequest v1.0.32
)
@ -71,6 +70,7 @@ require (
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.dtapp.net/dorm v1.0.51 // indirect
go.dtapp.net/goip v1.0.38 // indirect
go.dtapp.net/gorandom v1.0.1 // indirect
go.dtapp.net/gostring v1.0.10 // indirect
@ -81,9 +81,9 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 // indirect
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20221004154528-8021a29435af // indirect
golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458 // indirect
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 // indirect
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
golang.org/x/text v0.3.8 // indirect

@ -571,8 +571,8 @@ golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 h1:x8vtB3zMecnlqZIwJNUUpwYKYSqCz5jXbiyv0ZJJZeI=
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a h1:NmSIgad6KjE6VvHciPZuNRTKxGhlPfD6OA87W/PLkqg=
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@ -604,8 +604,8 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20221004154528-8021a29435af h1:wv66FM3rLZGPdxpYL+ApnDe2HzHcTFta3z5nsc13wI4=
golang.org/x/net v0.0.0-20221004154528-8021a29435af/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458 h1:MgJ6t2zo8v0tbmLCueaCbF1RM+TtB0rs3Lv8DGtOIpY=
golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

Loading…
Cancel
Save