优化结构

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
@@ -1,11 +1,10 @@
package payment
import (
"kra/internal/biz/system"
"strings"
"testing"
"kra/internal/biz"
gopayAlipay "github.com/go-pay/gopay/alipay"
"github.com/go-pay/gopay/douyin"
)
@@ -29,7 +28,7 @@ func TestWechatV2ResponseRequiresBusinessSuccessCode(t *testing.T) {
func TestPopulateDouyinPaymentAmountUsesSignedFieldPresence(t *testing.T) {
amount := &douyin.AmountInfo{Total: 100, PayerTotal: 0, Currency: "CNY", PayerCurrency: "CNY"}
result := &biz.PaymentResult{}
result := &system.PaymentResult{}
if err := populateDouyinPaymentAmount(result, amount, []byte(`{"amount":{"total":100,"payer_total":0,"currency":"CNY","payer_currency":"CNY"}}`)); err != nil {
t.Fatal(err)
}
@@ -37,7 +36,7 @@ func TestPopulateDouyinPaymentAmountUsesSignedFieldPresence(t *testing.T) {
t.Fatalf("explicit zero payer_total was not preserved: %+v", result)
}
result = &biz.PaymentResult{}
result = &system.PaymentResult{}
if err := populateDouyinPaymentAmount(result, amount, []byte(`{"amount":{"total":100,"currency":"CNY"}}`)); err != nil {
t.Fatal(err)
}
@@ -45,7 +44,7 @@ func TestPopulateDouyinPaymentAmountUsesSignedFieldPresence(t *testing.T) {
t.Fatalf("missing payer_total was treated as authoritative: %+v", result)
}
if err := populateDouyinPaymentAmount(&biz.PaymentResult{}, &douyin.AmountInfo{Total: 100, PayerTotal: 101}, []byte(`{"amount":{"total":100,"payer_total":101}}`)); err == nil {
if err := populateDouyinPaymentAmount(&system.PaymentResult{}, &douyin.AmountInfo{Total: 100, PayerTotal: 101}, []byte(`{"amount":{"total":100,"payer_total":101}}`)); err == nil {
t.Fatal("accepted payer_total greater than total")
}
}
@@ -74,7 +73,7 @@ func TestValidateDouyinMerchantIdentity(t *testing.T) {
}
func TestAlipayRefundResultValidatesIdentityAndAmount(t *testing.T) {
req := &biz.PaymentRefundRequest{
req := &system.PaymentRefundRequest{
TradeNo: "T-ALIPAY", ProviderTradeNo: "P-ALIPAY", RefundNo: "R-ALIPAY",
Amount: 123, Currency: "CNY",
}