- add ApiProductRechargeParamsCache

master v1.0.7
李光春 2 years ago
parent 4cb44264e2
commit 03fdbc9793

@ -0,0 +1,45 @@
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 {
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()
params.Set("product_id", productId)
// 请求
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)
}

@ -28,7 +28,7 @@ func NewClient(config *ConfigClient) (*Client, error) {
c.requestClient = gorequest.NewHttp()
if c.config.GormClient.Db != nil {
if c.config.GormClient != nil && c.config.GormClient.Db != nil {
c.logClient, err = golog.NewApiClient(&golog.ApiClientConfig{
GormClient: c.config.GormClient,
TableName: logTable,

@ -17,4 +17,4 @@ const (
logTable = "kashangwl"
)
const Version = "1.0.6"
const Version = "1.0.7"

@ -65,7 +65,7 @@ func (c *Client) requestCache(ctx context.Context, url string, params map[string
}
// 日志
if c.config.GormClient.Db != nil {
if c.config.GormClient != nil && c.config.GormClient.Db != nil {
go c.logClient.GormMiddleware(ctx, request, Version)
}

Loading…
Cancel
Save