This commit is contained in:
邹宗楠
2023-08-28 13:33:03 +08:00
parent ce47cf1e89
commit 0330d6e6aa
3 changed files with 39 additions and 27 deletions

View File

@@ -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,

View File

@@ -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"`
}

View File

@@ -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 {