From e5aeda9c31187c48095556e9452ac4b22fa0b402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 7 Dec 2020 14:44:51 +0800 Subject: [PATCH] aa --- platformapi/ejyapi/ejyapi.go | 20 ++++++++++++++++++++ platformapi/ejyapi/ejyapi_test.go | 12 ++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/platformapi/ejyapi/ejyapi.go b/platformapi/ejyapi/ejyapi.go index eef151b2..f3ec11ec 100644 --- a/platformapi/ejyapi/ejyapi.go +++ b/platformapi/ejyapi/ejyapi.go @@ -177,3 +177,23 @@ func (a *API) GetUserOrders(userPhone string, page int) (getUserOrdersResult *Ge } return getUserOrdersResult, err } + +type UserRefundResult struct { + OrderID string `json:"orderId"` + Status string `json:"status"` + RefundTime string `json:"refundTime"` + Msg string `json:"msg"` + UserPhone string `json:"userPhone"` +} + +//用户申请退款 +func (a *API) UserRefund(orderId, userPhone, reason string) (userRefundResult *UserRefundResult, err error) { + params := make(map[string]interface{}) + params["reason"] = reason + sign := a.signParam(params) + result, err := a.AccessAPI("oreo/ejiayou_open_api/platform/refund/v1/"+a.platformName+"/"+userPhone+"/"+orderId+"/"+sign+"/"+utils.Int64ToStr(a.timeStamp), TestUrl, params, false) + if err == nil { + utils.Map2StructByJson(result["data"], &userRefundResult, false) + } + return userRefundResult, err +} diff --git a/platformapi/ejyapi/ejyapi_test.go b/platformapi/ejyapi/ejyapi_test.go index 05f53c06..8a2f0ff7 100644 --- a/platformapi/ejyapi/ejyapi_test.go +++ b/platformapi/ejyapi/ejyapi_test.go @@ -18,8 +18,8 @@ func init() { logger, _ := zap.NewDevelopment() sugarLogger = logger.Sugar() baseapi.Init(sugarLogger) - // api = New("1Zbve", "ymsrrxlZXlmglK6Q", "MYsFZGgwwprIahzQ") - api = New("1Zbve", "htvse3XEDhBnCTNo", "QM5RnGl6kNh3ENLT") + api = New("1Zbve", "ymsrrxlZXlmglK6Q", "MYsFZGgwwprIahzQ") + // api = New("1Zbve", "htvse3XEDhBnCTNo", "QM5RnGl6kNh3ENLT") api.SetTimestamp(time.Now().Unix()) } @@ -38,3 +38,11 @@ func TestGetUserOrders(t *testing.T) { } t.Log(utils.Format4Output(result, false)) } + +func TestUserRefund(t *testing.T) { + result, err := api.UserRefund("9000000020023544", "13111111111", "测试") + if err != nil { + t.Fatal(err) + } + t.Log(utils.Format4Output(result, false)) +}