From ee837eb351006c88baf0dd0f6e992f05bce4d98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Fri, 31 Mar 2023 14:25:02 +0800 Subject: [PATCH] - update wikeyun --- service/wikeyun/rest.power.query.go | 16 +++++++++------- service/wikeyun/rest.recharge.query.go | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/service/wikeyun/rest.power.query.go b/service/wikeyun/rest.power.query.go index 74c4dc4d..33e032ae 100644 --- a/service/wikeyun/rest.power.query.go +++ b/service/wikeyun/rest.power.query.go @@ -13,14 +13,14 @@ type RestPowerQueryResponse struct { Data struct { Id uint `json:"id,omitempty"` Fanli string `json:"fanli"` // 平台返利金额 - Amount int64 `json:"amount"` // 充值金额 + Amount string `json:"amount"` // 充值金额 CostPrice string `json:"cost_price"` // 成本价格 Status int `json:"status"` // 订单状态 0 待支付 1 已付 充值中 2充值成功 3充值失败 需要退款 4退款成功 5已超时 6待充值 7 已匹配 8已存单 9 已取消 10返销 11部分到账 12取消中 OrderNumber string `json:"order_number"` // 平台单号 OrderNo string `json:"order_no"` // 第三方单号 OrgOrderNumber string `json:"org_order_number"` // 组织订单号 CardId string `json:"card_id"` // 充值卡ID - ArrivedAmount int64 `json:"arrived_amount"` // 到账金额 + ArrivedAmount string `json:"arrived_amount"` // 到账金额 Reason string `json:"reason,omitempty"` // 失败原因 } `json:"data"` } @@ -29,26 +29,28 @@ type RestPowerQueryResult struct { Result RestPowerQueryResponse // 结果 Body []byte // 内容 Http gorequest.Response // 请求 - Err error // 错误 } -func newRestPowerQueryResult(result RestPowerQueryResponse, body []byte, http gorequest.Response, err error) *RestPowerQueryResult { - return &RestPowerQueryResult{Result: result, Body: body, Http: http, Err: err} +func newRestPowerQueryResult(result RestPowerQueryResponse, body []byte, http gorequest.Response) *RestPowerQueryResult { + return &RestPowerQueryResult{Result: result, Body: body, Http: http} } // RestPowerQuery 电费订单查询 // https://open.wikeyun.cn/#/apiDocument/9/document/313 -func (c *Client) RestPowerQuery(ctx context.Context, orderNumber string) *RestPowerQueryResult { +func (c *Client) RestPowerQuery(ctx context.Context, orderNumber string) (*RestPowerQueryResult, error) { // 参数 param := gorequest.NewParams() param.Set("order_number", orderNumber) // 平台单号 params := gorequest.NewParamsWith(param) // 请求 request, err := c.request(ctx, apiUrl+"/rest/Power/query", params) + if err != nil { + return newRestPowerQueryResult(RestPowerQueryResponse{}, request.ResponseBody, request), err + } // 定义 var response RestPowerQueryResponse err = gojson.Unmarshal(request.ResponseBody, &response) - return newRestPowerQueryResult(response, request.ResponseBody, request, err) + return newRestPowerQueryResult(response, request.ResponseBody, request), err } func (resp RestPowerQueryResponse) GetStatusDesc(status int) string { diff --git a/service/wikeyun/rest.recharge.query.go b/service/wikeyun/rest.recharge.query.go index 5aa1b22a..07b7afda 100644 --- a/service/wikeyun/rest.recharge.query.go +++ b/service/wikeyun/rest.recharge.query.go @@ -11,7 +11,7 @@ type RestRechargeQueryResponse struct { Data struct { Id int `json:"id,omitempty"` Fanli string `json:"fanli"` // 平台返利金额 - Amount int `json:"amount"` // 充值金额 + Amount string `json:"amount"` // 充值金额 CostPrice string `json:"cost_price"` // 充值成本价格 Status int `json:"status"` // 订单状态 0 待支付 1 已付 充值中 2充值成功 3充值失败 需要退款 4退款成功 5已超时 6待充值 7 已匹配 8已存单 9 已取消 10返销 11部分到账 12取消中 OrderNumber string `json:"order_number"` // 平台订单号 @@ -19,7 +19,7 @@ type RestRechargeQueryResponse struct { OrgOrderNumber string `json:"org_order_number"` // 组织订单号 StoreId int `json:"store_id"` // 店铺ID Mobile string `json:"mobile"` // 充值手机号 - ArrivedAmount int64 `json:"arrived_amount"` // 到账金额 + ArrivedAmount string `json:"arrived_amount"` // 到账金额 Reason string `json:"reason,omitempty"` // 失败原因 } `json:"data"` Msg string `json:"msg"` @@ -30,26 +30,28 @@ type RestRechargeQueryResult struct { Result RestRechargeQueryResponse // 结果 Body []byte // 内容 Http gorequest.Response // 请求 - Err error // 错误 } -func newRestRechargeQueryResult(result RestRechargeQueryResponse, body []byte, http gorequest.Response, err error) *RestRechargeQueryResult { - return &RestRechargeQueryResult{Result: result, Body: body, Http: http, Err: err} +func newRestRechargeQueryResult(result RestRechargeQueryResponse, body []byte, http gorequest.Response) *RestRechargeQueryResult { + return &RestRechargeQueryResult{Result: result, Body: body, Http: http} } // RestRechargeQuery 话费订单查询 // https://open.wikeyun.cn/#/apiDocument/9/document/299 -func (c *Client) RestRechargeQuery(ctx context.Context, orderNumber string) *RestRechargeQueryResult { +func (c *Client) RestRechargeQuery(ctx context.Context, orderNumber string) (*RestRechargeQueryResult, error) { // 参数 param := gorequest.NewParams() param.Set("order_number", orderNumber) // 平台订单号 params := gorequest.NewParamsWith(param) // 请求 request, err := c.request(ctx, apiUrl+"/rest/Recharge/query", params) + if err != nil { + return newRestRechargeQueryResult(RestRechargeQueryResponse{}, request.ResponseBody, request), err + } // 定义 var response RestRechargeQueryResponse err = gojson.Unmarshal(request.ResponseBody, &response) - return newRestRechargeQueryResult(response, request.ResponseBody, request, err) + return newRestRechargeQueryResult(response, request.ResponseBody, request), err } func (resp RestRechargeQueryResponse) GetStatusDesc(status int) string {