package ebai

import (
	"encoding/json"
	"fmt"
	"testing"
	"time"

	"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
	"git.rosy.net.cn/jx-callback/business/partner"
	"git.rosy.net.cn/jx-callback/globals/api"
)

func TestOnFinancialMsg(t *testing.T) {
	msg := &ebaiapi.CallbackMsg{
		Timestamp: time.Now().Unix(),
		Body:      make(map[string]interface{}),
	}
	msg.Body["order_id"] = "1554939646172038357"

	// 部分退款
	msg.Cmd = "order.partrefund.push"
	msg.Body["status"] = json.Number("20")

	// 全单退款
	// msg.Cmd = "order.user.cancel"
	// msg.Body["type"] = json.Number("40")
	// msg.Body["cancel_type"] = json.Number("2")

	res := CurPurchaseHandler.onAfsOrderMsg(msg)
	fmt.Println(res)
}

func TestOnOrderDetail(t *testing.T) {
	orderID := "4074700081425894134"
	result, err := api.EbaiAPI.OrderGet(orderID)
	if err == nil {
		new(PurchaseHandler).OnOrderDetail(result, partner.CreatedPeration)
	}
}
