package pay

import (
	"fmt"
	"testing"
	"time"
)

func TestWxSDKPay(t *testing.T) {
	WxSDKPay(55191926, "元气森林")

}

func TestTransfer(t *testing.T) {
	//Transfer(400,"ohuHh4riVVPxwKHrYHsWwZRpxVMk")
}

// 生成随机订单号
func generateRandomOrderNumber() string {
	currentDate := time.Now().Format("20060102")
	tradeNO := "sale" + currentDate + RandomNumString(10000000, 99999999)
	return tradeNO
}

// 支付
func TestHmJsPayBToCOrder(t *testing.T) {
	orderId := generateRandomOrderNumber()

	fmt.Println("orderId:", orderId)
	totalFee := 0.01
	authCode := "6264900646139788518"
	notifyUrl := "https://dev.switch.deovo.com:8004/api/v1/wxpay/notice"

	order, err := HmJsPayBToCOrder(13, orderId, totalFee, authCode, notifyUrl)
	if err != nil {
		fmt.Println("err:", err)
	}

	fmt.Println("order:", order)
}

// 查询
func TestHmQueryOrder(t *testing.T) {
	orderId := "sale2024070569804727"

	order, err := HmQueryOrder(orderId, 13)
	if err != nil {
		fmt.Println("err:", err)
	}

	fmt.Println("order:", order)
}

// 撤销
func TestHmCancelOrder(t *testing.T) {
	orderId := "CF56C27AE0"

	order, err := HmCancelOrder(orderId, 100001)
	if err != nil {
		fmt.Println("err:", err)
	}

	fmt.Println("order:", order)
}

func TestHmRefundOrder(t *testing.T) {

	testReq := HmPayTradeRefundContent{
		OutOrderNo:      "CF56C27AE0",
		BankOrderNo:     "HMP2505270003044236901990400",
		RefundAmount:    0.11,
		RefundRequestNo: "R202505291545301234567890",
	}

	order, err := HmRefundOrder(testReq, 100001)
	if err != nil {
		fmt.Println("err:", err)
	}

	fmt.Println("order:", order)
}
