优化结构

This commit is contained in:
Yvan
2026-08-22 12:13:16 +08:00
parent d987244d0e
commit b27a66e9d3
200 changed files with 1794 additions and 1715 deletions
@@ -4,13 +4,12 @@ import (
"context"
"encoding/json"
"io"
"kra/internal/biz/system"
"net/http"
"net/http/httptest"
"strings"
"testing"
"kra/internal/biz"
gopayWechatV3 "github.com/go-pay/gopay/wechat/v3"
)
@@ -52,8 +51,8 @@ func TestWechatV3CodePayUsesGoPaySDK(t *testing.T) {
}))
defer server.Close()
result, err := (&wechatV3Adapter{}).Create(context.Background(), &biz.PaymentRequest{
Provider: biz.PaymentWechatV3,
result, err := (&wechatV3Adapter{}).Create(context.Background(), &system.PaymentRequest{
Provider: system.PaymentWechatV3,
TradeNo: "T-WECHAT-CODEPAY",
Subject: "subject",
Amount: 123,
@@ -86,7 +85,7 @@ func TestWechatV3CodePayUsesGoPaySDK(t *testing.T) {
if amount["total"] != float64(123) || amount["currency"] != "CNY" {
t.Fatalf("request amount = %#v", amount)
}
if result.Provider != biz.PaymentWechatV3 || result.Status != "success" || result.TradeNo != "T-WECHAT-CODEPAY" || result.ProviderTradeNo != "WX-CODEPAY-1" || result.QueryID != "" {
if result.Provider != system.PaymentWechatV3 || result.Status != "success" || result.TradeNo != "T-WECHAT-CODEPAY" || result.ProviderTradeNo != "WX-CODEPAY-1" || result.QueryID != "" {
t.Fatalf("result identity = %+v", result)
}
if result.Amount != 123 || result.Currency != "CNY" || result.PayerCurrency != "CNY" || !result.AmountBreakdownKnown || result.PayerPaidAmount != 100 || result.CashPaidAmount != 100 || result.DiscountAmount != 23 {
@@ -109,7 +108,7 @@ func TestWechatV3CodePayAliasesRequireAuthCode(t *testing.T) {
for _, method := range []string{"micropay", "micro_pay", "micro-pay", "codepay", "code_pay", "code-pay", "barcode", "barcode_pay", "facepay", "face_pay"} {
t.Run(method, func(t *testing.T) {
_, err := (&wechatV3Adapter{}).Create(context.Background(), &biz.PaymentRequest{
_, err := (&wechatV3Adapter{}).Create(context.Background(), &system.PaymentRequest{
TradeNo: "T-WECHAT-CODEPAY", Subject: "subject", Amount: 1, Currency: "CNY",
Extra: map[string]any{"method": method},
}, config)