From 0330d6e6aa39820cdad9e963c2ae6479f6689923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 28 Aug 2023 13:33:03 +0800 Subject: [PATCH] 1 --- platformapi/ebaiapi/ebaiapi.go | 1 + platformapi/ebaiapi/order.go | 23 ++++++++--------- platformapi/ebaiapi/order_test.go | 42 ++++++++++++++++++++----------- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/platformapi/ebaiapi/ebaiapi.go b/platformapi/ebaiapi/ebaiapi.go index 5d4faf58..71b7a903 100644 --- a/platformapi/ebaiapi/ebaiapi.go +++ b/platformapi/ebaiapi/ebaiapi.go @@ -104,6 +104,7 @@ func (a *API) AccessAPI2(cmd string, body map[string]interface{}, trackInfo stri "body": []string{string(utils.MustMarshal(body))}, "encrypt": []string{a.encrypt}, } + params[signKey] = []string{a.signParams(params)} encodedParams := params.Encode() err = platformapi.AccessPlatformAPIWithRetry(a.client, diff --git a/platformapi/ebaiapi/order.go b/platformapi/ebaiapi/order.go index 408526e2..658050b1 100644 --- a/platformapi/ebaiapi/order.go +++ b/platformapi/ebaiapi/order.go @@ -2,7 +2,6 @@ package ebaiapi import ( "fmt" - "git.rosy.net.cn/jx-callback/globals" "time" "git.rosy.net.cn/baseapi/utils" @@ -660,9 +659,7 @@ func (a *API) EbaiRefundOrder(param *RefundOrderExamine) error { param.ReasonCode = "7001" } - globals.SugarLogger.Debugf("param := %s", utils.Format4Output(param, false)) - data, err := a.AccessAPI("order.reverse.process", utils.Struct2MapByJson(param)) - globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data, false)) + _, err := a.AccessAPI("order.reverse.process", utils.Struct2MapByJson(param)) return err } @@ -680,18 +677,18 @@ func (a *API) GetReverseOrder(orderId string) ([]interface{}, error) { // RefundOrderExamine 商家审核是售后单 type RefundOrderExamine struct { - ReverseOrderId string `json:"reverse_order_id" required:"true"` // 逆向单ID - OrderId string `json:"order_id" required:"true"` // 订单id - IdempotentId string `json:"idempotent_id" required:"true"` // 请求唯一标示 - ActionType string `json:"action_type" required:"true"` // 逆向单审批操作类型,枚举值:【1-同意全单/部分退款申请 、 2-拒绝全单/部分退款申请、 3-同意退货申请 、 4-拒绝退货申请】 - ReasonCode string `json:"reason_code" required:"false"` // 当拒绝场景必填,即action_type = 2 or action_type =4 时 必填,枚举值: 7019-双方协商一致不再取消订单、 7020-商品已经备货完成、 7021-商品已送出、 7802-商品发出时完好、 7803-用户未举证/举证无效、 7804-商品影响二次销售、 7805-商品不符合7天无理由退款、 7302-未收到退货(仅退货单支持传入该code)、 7001-其他原因 - ReasonRemarks string `json:"reason_remarks" required:"false"` // 原因备注说明信息 - RefundProductList string `json:"refund_product_list" required:"false"` // 订单id + ReverseOrderId string `json:"reverse_order_id" required:"true"` // 逆向单ID + OrderId string `json:"order_id" required:"true"` // 订单id + IdempotentId string `json:"idempotent_id" required:"true"` // 请求唯一标示 + ActionType string `json:"action_type" required:"true"` // 逆向单审批操作类型,枚举值:【1-同意全单/部分退款申请 、 2-拒绝全单/部分退款申请、 3-同意退货申请 、 4-拒绝退货申请】 + ReasonCode string `json:"reason_code" required:"false"` // 当拒绝场景必填,即action_type = 2 or action_type =4 时 必填,枚举值: 7019-双方协商一致不再取消订单、 7020-商品已经备货完成、 7021-商品已送出、 7802-商品发出时完好、 7803-用户未举证/举证无效、 7804-商品影响二次销售、 7805-商品不符合7天无理由退款、 7302-未收到退货(仅退货单支持传入该code)、 7001-其他原因 + ReasonRemarks string `json:"reason_remarks" required:"false"` // 原因备注说明信息 + RefundProductList []*RefundProductList `json:"refund_product_list" required:"false"` // 订单id } type RefundProductList struct { SubBizOrderId string `json:"sub_biz_order_id" required:"false"` // 商品子单ID PlatformSkuId string `json:"platform_sku_id" required:"false"` // 平台商品ID - //Number string `json:"number"` - //RefundAmount string `json:"refund_amount"` + Number string `json:"number"` + RefundAmount string `json:"refund_amount"` } diff --git a/platformapi/ebaiapi/order_test.go b/platformapi/ebaiapi/order_test.go index dbc8ac2c..461f8055 100644 --- a/platformapi/ebaiapi/order_test.go +++ b/platformapi/ebaiapi/order_test.go @@ -1,7 +1,6 @@ package ebaiapi import ( - "encoding/json" "fmt" "git.rosy.net.cn/jx-callback/globals" "testing" @@ -24,30 +23,45 @@ func TestOrderGet(t *testing.T) { func TestOrderAgreePartRefund(t *testing.T) { param := &RefundOrderExamine{ - ReverseOrderId: "2308258682813174525", - OrderId: "4045250124015619672", - IdempotentId: utils.Int64ToStr(time.Now().UnixNano()), - ActionType: RefundTypeAgree, - ReasonCode: "", - ReasonRemarks: "同意了", - RefundProductList: "", + ReverseOrderId: "2308279044977730245", + OrderId: "4002450124418844395", + IdempotentId: utils.Int64ToStr(time.Now().UnixNano()), + ActionType: RefundTypeAgree, + ReasonCode: "", + ReasonRemarks: "", } refundProductList := make([]*RefundProductList, 0, 0) - date, _ := api.GetReverseOrder("4045250124015619672") + date, _ := api.GetReverseOrder("4002450124418844395") for _, v := range date { + v2 := v.(map[string]interface{}) refundProduct := &RefundProductList{ - SubBizOrderId: v.(map[string]interface{})["sub_biz_order_id"].(string), - PlatformSkuId: utils.Int64ToStr(utils.Interface2Int64WithDefault(v.(map[string]interface{})["platform_sku_id"], 0)), + SubBizOrderId: v2["sub_biz_order_id"].(string), + PlatformSkuId: utils.Int64ToStr(utils.Interface2Int64WithDefault(v2["platform_sku_id"], 0)), + } + switch utils.MustInterface2Int64(v2["fund_calculate_type"]) { + case 0: + refundProduct.Number = utils.Int64ToStr(utils.MustInterface2Int64(v2["refund_quantity"])) + case 1: + refundProduct.RefundAmount = utils.Int64ToStr(utils.MustInterface2Int64(v2["refund_user_amount"])) } - refundProductList = append(refundProductList, refundProduct) } - refundProductListStr, _ := json.Marshal(refundProductList) - param.RefundProductList = string(refundProductListStr) + param.RefundProductList = refundProductList err := api.EbaiRefundOrder(param) globals.SugarLogger.Debugf("err := %s", utils.Format4Output(err, false)) } +func TestOrderAgreeRefund(t *testing.T) { + err := api.OrderAgreeRefund(&RefundOrderExamine{ + ReverseOrderId: "2308279044977730245", + OrderId: "4002450124418844395", + IdempotentId: utils.Int64ToStr(time.Now().UnixNano()), + ActionType: "1", + ReasonRemarks: "", + }) + fmt.Println(err) +} + func TestGetReverseOrder(t *testing.T) { date, _ := api.GetReverseOrder("4099660048407490187") for _, v := range date {