diff --git a/const.go b/const.go index 5e40062..6ed022c 100644 --- a/const.go +++ b/const.go @@ -12,4 +12,4 @@ const ( logTable = "wikeyun" ) -const Version = "1.0.5" +const Version = "1.0.6" diff --git a/go.mod b/go.mod index 2619995..b51e160 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module go.dtapp.net/wikeyun go 1.19 require ( - go.dtapp.net/dorm v1.0.14 + go.dtapp.net/dorm v1.0.16 go.dtapp.net/goip v1.0.24 - go.dtapp.net/golog v1.0.21 + go.dtapp.net/golog v1.0.22 go.dtapp.net/gorequest v1.0.24 go.dtapp.net/gostring v1.0.6 gorm.io/gorm v1.23.8 @@ -68,14 +68,14 @@ require ( go.dtapp.net/gotime v1.0.5 // indirect go.dtapp.net/goxml v1.0.1 // indirect go.mongodb.org/mongo-driver v1.10.1 // indirect - go.uber.org/atomic v1.9.0 // indirect + go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.22.0 // indirect golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect - golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced // indirect + golang.org/x/net v0.0.0-20220811182439-13a9a731de15 // indirect golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect - golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 // indirect + golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 90b0636..65f38fe 100644 --- a/go.sum +++ b/go.sum @@ -504,14 +504,16 @@ github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxt github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= go.dtapp.net/dorm v1.0.14 h1:HDsaMwKGlKFKt59Y3hPI9aVnSjfXOyjoHw2uoXErKEo= go.dtapp.net/dorm v1.0.14/go.mod h1:bHG7BmgeLaAlc56myYF63lwZAIuMeWRAqHBb/L84dLM= +go.dtapp.net/dorm v1.0.16 h1:aLBW9mgXjN9enV7cAqNpErQPDZk1oM6JxX62vz6hTdQ= +go.dtapp.net/dorm v1.0.16/go.mod h1:bHG7BmgeLaAlc56myYF63lwZAIuMeWRAqHBb/L84dLM= go.dtapp.net/goip v1.0.24 h1:62k3xt9I/YLUwA5tLp7YC8XPskkswc4RJrvxRRxjwIY= go.dtapp.net/goip v1.0.24/go.mod h1:tps0yoq5kSykLGDb01vuai47hzAQ6nYUPFWLdlQA2Oo= go.dtapp.net/gojson v1.0.1 h1:MHeSGlq1KxzL7rCkm18fhwW4GNORHohdDMmxY5PupKY= go.dtapp.net/gojson v1.0.1/go.mod h1:TkkpTNxHBKxul0e7gC5MrL1K4ICFB9mQ7wHzjBah3/k= -go.dtapp.net/golog v1.0.20 h1:Rf0ZBAi9VQiBzAgBf2Pup+AY5awhVYo4bkKEgVzY0XQ= -go.dtapp.net/golog v1.0.20/go.mod h1:Wxm2Kh77JN5zFDZ72el9E9c/YkoJnOvHVusB7SqvoC8= go.dtapp.net/golog v1.0.21 h1:pSGmDz3SJTH7M/NvVLZb+YJd8uNl5g18aORibuaY2JU= go.dtapp.net/golog v1.0.21/go.mod h1:Wxm2Kh77JN5zFDZ72el9E9c/YkoJnOvHVusB7SqvoC8= +go.dtapp.net/golog v1.0.22 h1:sOJr5f/iLk/6irT/RuwTQSTwvL2DR8SIhzMsKdHo0Ic= +go.dtapp.net/golog v1.0.22/go.mod h1:sbn2WQXmlukcZ4T3Kz9iWOSznL8H3RCkD+1nicZHMfI= go.dtapp.net/gorandom v1.0.1 h1:IWfMClh1ECPvyUjlqD7MwLq4mZdUusD1qAwAdsvEJBs= go.dtapp.net/gorandom v1.0.1/go.mod h1:ZPdgalKpvFV/ATQqR0k4ns/F/IpITAZpx6WkWirr5Y8= go.dtapp.net/gorequest v1.0.24 h1:N2RJOpCXPWbsjfQ8iYJI1EYC2se3I4QhK1l94DSJsuE= @@ -536,6 +538,8 @@ go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= @@ -608,6 +612,8 @@ golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced h1:3dYNDff0VT5xj+mbj2XucFst9WKk6PdGOrb9n+SbIvw= golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20220811182439-13a9a731de15 h1:cik0bxZUSJVDyaHf1hZPSDsU8SZHGQZQMeueXCE7yBQ= +golang.org/x/net v0.0.0-20220811182439-13a9a731de15/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= @@ -654,6 +660,8 @@ golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs= golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/request.go b/request.go index e7d67f9..acef11d 100644 --- a/request.go +++ b/request.go @@ -1,12 +1,13 @@ package wikeyun import ( + "context" "fmt" "go.dtapp.net/gorequest" ) // 请求接口 -func (c *Client) request(url string, params map[string]interface{}) (gorequest.Response, error) { +func (c *Client) request(ctx context.Context, url string, params map[string]interface{}) (gorequest.Response, error) { // 签名 sign := c.sign(params) @@ -31,7 +32,7 @@ func (c *Client) request(url string, params map[string]interface{}) (gorequest.R // 日志 if c.config.PgsqlDb != nil { - go c.log.GormMiddleware(request, Version) + go c.log.GormMiddleware(ctx, request, Version) } if c.config.MongoDb != nil { go c.log.MongoMiddleware(request) diff --git a/rest.oil.add_card.go b/rest.oil.add_card.go index 4a235be..e00c120 100644 --- a/rest.oil.add_card.go +++ b/rest.oil.add_card.go @@ -1,12 +1,15 @@ package wikeyun -import "go.dtapp.net/gorequest" +import ( + "context" + "go.dtapp.net/gorequest" +) // RestOilCardAdd 添加充值卡 -func (c *Client) RestOilCardAdd(notMustParams ...gorequest.Params) (body []byte, err error) { +func (c *Client) RestOilCardAdd(ctx context.Context, notMustParams ...gorequest.Params) (body []byte, err error) { // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(apiUrl+"/rest/Oil/addCard", params) + request, err := c.request(ctx, apiUrl+"/rest/Oil/addCard", params) return request.ResponseBody, err } diff --git a/rest.oil.card_info.go b/rest.oil.card_info.go index 12ea780..445ded2 100644 --- a/rest.oil.card_info.go +++ b/rest.oil.card_info.go @@ -1,12 +1,15 @@ package wikeyun -import "go.dtapp.net/gorequest" +import ( + "context" + "go.dtapp.net/gorequest" +) // RestOilCardInfo 油卡详情 -func (c *Client) RestOilCardInfo(notMustParams ...gorequest.Params) (body []byte, err error) { +func (c *Client) RestOilCardInfo(ctx context.Context, notMustParams ...gorequest.Params) (body []byte, err error) { // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(apiUrl+"/rest/Oil/cardInfo", params) + request, err := c.request(ctx, apiUrl+"/rest/Oil/cardInfo", params) return request.ResponseBody, err } diff --git a/rest.oil.del_card.go b/rest.oil.del_card.go index 917c529..e43ca35 100644 --- a/rest.oil.del_card.go +++ b/rest.oil.del_card.go @@ -1,12 +1,15 @@ package wikeyun -import "go.dtapp.net/gorequest" +import ( + "context" + "go.dtapp.net/gorequest" +) // RestOilCardDel 油卡删除 -func (c *Client) RestOilCardDel(notMustParams ...gorequest.Params) (body []byte, err error) { +func (c *Client) RestOilCardDel(ctx context.Context, notMustParams ...gorequest.Params) (body []byte, err error) { // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(apiUrl+"/rest/Oil/delCard", params) + request, err := c.request(ctx, apiUrl+"/rest/Oil/delCard", params) return request.ResponseBody, err } diff --git a/rest.oil.push_order.go b/rest.oil.push_order.go index 6593fef..cb2597c 100644 --- a/rest.oil.push_order.go +++ b/rest.oil.push_order.go @@ -1,12 +1,15 @@ package wikeyun -import "go.dtapp.net/gorequest" +import ( + "context" + "go.dtapp.net/gorequest" +) // RestOilOrderPush 充值下单 -func (c *Client) RestOilOrderPush(notMustParams ...gorequest.Params) (body []byte, err error) { +func (c *Client) RestOilOrderPush(ctx context.Context, notMustParams ...gorequest.Params) (body []byte, err error) { // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(apiUrl+"/rest/Oil/pushOrder", params) + request, err := c.request(ctx, apiUrl+"/rest/Oil/pushOrder", params) return request.ResponseBody, err } diff --git a/rest.oil.query.go b/rest.oil.query.go index e1bb280..95f52ce 100644 --- a/rest.oil.query.go +++ b/rest.oil.query.go @@ -1,12 +1,15 @@ package wikeyun -import "go.dtapp.net/gorequest" +import ( + "context" + "go.dtapp.net/gorequest" +) // RestOilOrderQuery 订单查询 -func (c *Client) RestOilOrderQuery(notMustParams ...gorequest.Params) (body []byte, err error) { +func (c *Client) RestOilOrderQuery(ctx context.Context, notMustParams ...gorequest.Params) (body []byte, err error) { // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(apiUrl+"/rest/Oil/query", params) + request, err := c.request(ctx, apiUrl+"/rest/Oil/query", params) return request.ResponseBody, err } diff --git a/rest.oiledit_card.go b/rest.oiledit_card.go index f8e2a28..dbd8440 100644 --- a/rest.oiledit_card.go +++ b/rest.oiledit_card.go @@ -1,12 +1,15 @@ package wikeyun -import "go.dtapp.net/gorequest" +import ( + "context" + "go.dtapp.net/gorequest" +) // RestOilCardEdit 编辑充值卡 -func (c *Client) RestOilCardEdit(notMustParams ...gorequest.Params) (body []byte, err error) { +func (c *Client) RestOilCardEdit(ctx context.Context, notMustParams ...gorequest.Params) (body []byte, err error) { // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(apiUrl+"/rest/Oil/editCard", params) + request, err := c.request(ctx, apiUrl+"/rest/Oil/editCard", params) return request.ResponseBody, err } diff --git a/rest.power.add_card.go b/rest.power.add_card.go index 209954a..8527f43 100644 --- a/rest.power.add_card.go +++ b/rest.power.add_card.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -34,12 +35,12 @@ func newRestPowerAddCardResult(result RestPowerAddCardResponse, body []byte, htt // RestPowerAddCard 添加电费充值卡 // https://open.wikeyun.cn/#/apiDocument/9/document/326 -func (c *Client) RestPowerAddCard(notMustParams ...gorequest.Params) *RestPowerAddCardResult { +func (c *Client) RestPowerAddCard(ctx context.Context, notMustParams ...gorequest.Params) *RestPowerAddCardResult { // 参数 params := gorequest.NewParamsWith(notMustParams...) params.Set("store_id", c.config.StoreId) // 店铺ID // 请求 - request, err := c.request(apiUrl+"/rest/Power/addCard", params) + request, err := c.request(ctx, apiUrl+"/rest/Power/addCard", params) // 定义 var response RestPowerAddCardResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/rest.power.cancel.go b/rest.power.cancel.go index b5b1bbd..3a89efd 100644 --- a/rest.power.cancel.go +++ b/rest.power.cancel.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -24,13 +25,13 @@ func newRestPowerCancelResult(result RestPowerCancelResponse, body []byte, http // RestPowerCancel 电费订单取消 // https://open.wikeyun.cn/#/apiDocument/9/document/323 -func (c *Client) RestPowerCancel(orderNumber string) *RestPowerCancelResult { +func (c *Client) RestPowerCancel(ctx context.Context, orderNumber string) *RestPowerCancelResult { // 参数 param := gorequest.NewParams() param.Set("order_number", orderNumber) // 取消的单号,多个用英文逗号隔开 params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(apiUrl+"/rest/Power/cancel", params) + request, err := c.request(ctx, apiUrl+"/rest/Power/cancel", params) // 定义 var response RestPowerCancelResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/rest.power.card_info.go b/rest.power.card_info.go index a61c5d5..9b08596 100644 --- a/rest.power.card_info.go +++ b/rest.power.card_info.go @@ -1,13 +1,16 @@ package wikeyun -import "go.dtapp.net/gorequest" +import ( + "context" + "go.dtapp.net/gorequest" +) // PowerCardInfo 电费充值卡详情 // https://open.wikeyun.cn/#/apiDocument/9/document/333 -func (c *Client) PowerCardInfo(notMustParams ...gorequest.Params) (body []byte, err error) { +func (c *Client) PowerCardInfo(ctx context.Context, notMustParams ...gorequest.Params) (body []byte, err error) { // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(apiUrl+"/rest/Power/cardInfo", params) + request, err := c.request(ctx, apiUrl+"/rest/Power/cardInfo", params) return request.ResponseBody, err } diff --git a/rest.power.del_card.go b/rest.power.del_card.go index 34b4f94..2684f2c 100644 --- a/rest.power.del_card.go +++ b/rest.power.del_card.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -25,13 +26,13 @@ func newRestPowerDelCardResult(result RestPowerDelCardResponse, body []byte, htt // RestPowerDelCard 删除电费充值卡 // https://open.wikeyun.cn/#/apiDocument/9/document/330 -func (c *Client) RestPowerDelCard(cardId string) *RestPowerDelCardResult { +func (c *Client) RestPowerDelCard(ctx context.Context, cardId string) *RestPowerDelCardResult { // 参数 param := gorequest.NewParams() param.Set("card_id", cardId) params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(apiUrl+"/rest/Power/delCard", params) + request, err := c.request(ctx, apiUrl+"/rest/Power/delCard", params) // 定义 var response RestPowerDelCardResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/rest.power.edit_card.go b/rest.power.edit_card.go index cad8fb4..dbc8bd3 100644 --- a/rest.power.edit_card.go +++ b/rest.power.edit_card.go @@ -1,13 +1,16 @@ package wikeyun -import "go.dtapp.net/gorequest" +import ( + "context" + "go.dtapp.net/gorequest" +) // RestPowerEditCard 编辑电费充值卡 // https://open.wikeyun.cn/#/apiDocument/9/document/329 -func (c *Client) RestPowerEditCard(notMustParams ...gorequest.Params) (body []byte, err error) { +func (c *Client) RestPowerEditCard(ctx context.Context, notMustParams ...gorequest.Params) (body []byte, err error) { // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(apiUrl+"/rest/Power/editCard", params) + request, err := c.request(ctx, apiUrl+"/rest/Power/editCard", params) return request.ResponseBody, err } diff --git a/rest.power.push_order.go b/rest.power.push_order.go index 4ba9fff..83b575c 100644 --- a/rest.power.push_order.go +++ b/rest.power.push_order.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -27,12 +28,12 @@ func newRestPowerPushOrderResult(result RestPowerPushOrderResponse, body []byte, // RestPowerPushOrder 电费充值API // https://open.wikeyun.cn/#/apiDocument/9/document/311 -func (c *Client) RestPowerPushOrder(notMustParams ...gorequest.Params) *RestPowerPushOrderResult { +func (c *Client) RestPowerPushOrder(ctx context.Context, notMustParams ...gorequest.Params) *RestPowerPushOrderResult { // 参数 params := gorequest.NewParamsWith(notMustParams...) params.Set("store_id", c.config.StoreId) // 店铺ID // 请求 - request, err := c.request(apiUrl+"/rest/Power/pushOrder", params) + request, err := c.request(ctx, apiUrl+"/rest/Power/pushOrder", params) // 定义 var response RestPowerPushOrderResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/rest.power.query.go b/rest.power.query.go index 9759fc5..7444da9 100644 --- a/rest.power.query.go +++ b/rest.power.query.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -35,13 +36,13 @@ func newRestPowerQueryResult(result RestPowerQueryResponse, body []byte, http go // RestPowerQuery 电费订单查询 // https://open.wikeyun.cn/#/apiDocument/9/document/313 -func (c *Client) RestPowerQuery(orderNumber string) *RestPowerQueryResult { +func (c *Client) RestPowerQuery(ctx context.Context, orderNumber string) *RestPowerQueryResult { // 参数 param := gorequest.NewParams() param.Set("order_number", orderNumber) // 平台单号 params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(apiUrl+"/rest/Power/query", params) + request, err := c.request(ctx, apiUrl+"/rest/Power/query", params) // 定义 var response RestPowerQueryResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/rest.recharge.cancel.go b/rest.recharge.cancel.go index 7af3582..76bfdc1 100644 --- a/rest.recharge.cancel.go +++ b/rest.recharge.cancel.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -24,13 +25,13 @@ func newRestRechargeCancelResult(result RestRechargeCancelResponse, body []byte, // RestRechargeCancel 话费订单取消 // https://open.wikeyun.cn/#/apiDocument/9/document/300 -func (c *Client) RestRechargeCancel(orderNumber string) *RestRechargeCancelResult { +func (c *Client) RestRechargeCancel(ctx context.Context, orderNumber string) *RestRechargeCancelResult { // 参数 param := gorequest.NewParams() param.Set("order_number", orderNumber) // 取消的单号,多个用英文逗号隔开 params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(apiUrl+"/rest/Recharge/cancel", params) + request, err := c.request(ctx, apiUrl+"/rest/Recharge/cancel", params) // 定义 var response RestRechargeCancelResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/rest.recharge.mobileInfo.go b/rest.recharge.mobileInfo.go index e71e879..ddc8426 100644 --- a/rest.recharge.mobileInfo.go +++ b/rest.recharge.mobileInfo.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -44,13 +45,13 @@ func newRestRechargeMobileInfoResult(result RestRechargeMobileInfoResponse, body // RestRechargeMobileInfo 查询手机归属地信息以及是否携号转网 // https://open.wikeyun.cn/#/apiDocument/9/document/374 -func (c *Client) RestRechargeMobileInfo(orderNumber string) *RestRechargeMobileInfoResult { +func (c *Client) RestRechargeMobileInfo(ctx context.Context, orderNumber string) *RestRechargeMobileInfoResult { // 参数 param := gorequest.NewParams() param.Set("order_number", orderNumber) // 平台单号 params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(apiUrl+"/rest/Recharge/mobileInfo", params) + request, err := c.request(ctx, apiUrl+"/rest/Recharge/mobileInfo", params) // 定义 var response RestRechargeMobileInfoResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/rest.recharge.push_order.go b/rest.recharge.push_order.go index 64e54e6..fd7e15b 100644 --- a/rest.recharge.push_order.go +++ b/rest.recharge.push_order.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -26,12 +27,12 @@ func newRestRechargePushOrderResult(result RestRechargePushOrderResponse, body [ // RestRechargePushOrder 话费充值推送 // https://open.wikeyun.cn/#/apiDocument/9/document/298 -func (c *Client) RestRechargePushOrder(notMustParams ...gorequest.Params) *RestRechargePushOrderResult { +func (c *Client) RestRechargePushOrder(ctx context.Context, notMustParams ...gorequest.Params) *RestRechargePushOrderResult { // 参数 params := gorequest.NewParamsWith(notMustParams...) params.Set("store_id", c.config.StoreId) // 店铺ID // 请求 - request, err := c.request(apiUrl+"/rest/Recharge/pushOrder", params) + request, err := c.request(ctx, apiUrl+"/rest/Recharge/pushOrder", params) // 定义 var response RestRechargePushOrderResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/rest.recharge.query.go b/rest.recharge.query.go index f7bde97..de03ccf 100644 --- a/rest.recharge.query.go +++ b/rest.recharge.query.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -35,13 +36,13 @@ func newRestRechargeQueryResult(result RestRechargeQueryResponse, body []byte, h // RestRechargeQuery 话费订单查询 // https://open.wikeyun.cn/#/apiDocument/9/document/299 -func (c *Client) RestRechargeQuery(orderNumber string) *RestRechargeQueryResult { +func (c *Client) RestRechargeQuery(ctx context.Context, orderNumber string) *RestRechargeQueryResult { // 参数 param := gorequest.NewParams() param.Set("order_number", orderNumber) // 平台订单号 params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(apiUrl+"/rest/Recharge/query", params) + request, err := c.request(ctx, apiUrl+"/rest/Recharge/query", params) // 定义 var response RestRechargeQueryResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/rest.recharge.verify.go b/rest.recharge.verify.go index 9961a99..ddca2fd 100644 --- a/rest.recharge.verify.go +++ b/rest.recharge.verify.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -24,7 +25,7 @@ func newRestRechargeVerifyResult(result RestRechargeVerifyResponse, body []byte, // RestRechargeVerify 话费充值验证 // https://open.wikeyun.cn/#/apiDocument/9/document/405 -func (c *Client) RestRechargeVerify(mobile string, amount int64, rechargeType int) *RestRechargeVerifyResult { +func (c *Client) RestRechargeVerify(ctx context.Context, mobile string, amount int64, rechargeType int) *RestRechargeVerifyResult { // 参数 param := gorequest.NewParams() param.Set("mobile", mobile) // 需要充值的手机号 @@ -32,7 +33,7 @@ func (c *Client) RestRechargeVerify(mobile string, amount int64, rechargeType in param.Set("recharge_type", rechargeType) // 充值类型 params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(apiUrl+"/rest/Recharge/verify", params) + request, err := c.request(ctx, apiUrl+"/rest/Recharge/verify", params) // 定义 var response RestRechargeVerifyResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/rest.user.query.go b/rest.user.query.go index 93e7572..7a0eac9 100644 --- a/rest.user.query.go +++ b/rest.user.query.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "encoding/json" "go.dtapp.net/gorequest" ) @@ -29,9 +30,9 @@ func newRestUserQueryResult(result RestUserQueryResponse, body []byte, http gore // RestUserQuery 用户信息 // https://open.wikeyun.cn/#/apiDocument/10/document/336 -func (c *Client) RestUserQuery() *RestUserQueryResult { +func (c *Client) RestUserQuery(ctx context.Context) *RestUserQueryResult { // 请求 - request, err := c.request(apiUrl+"/rest/User/query", map[string]interface{}{}) + request, err := c.request(ctx, apiUrl+"/rest/User/query", map[string]interface{}{}) // 定义 var response RestUserQueryResponse err = json.Unmarshal(request.ResponseBody, &response)