feat(payment): 增加支付配置测试支付与全链路报文
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
package payment
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
var ErrConfigTestPaymentInvalid = errors.New("invalid config test payment")
|
||||
|
||||
type StartConfigTestPaymentRequest struct {
|
||||
AmountCent int64 `json:"amount_cent" binding:"required,min=1"`
|
||||
}
|
||||
|
||||
type ConfigTestPaymentQuery struct {
|
||||
PaymentConfigID uint64
|
||||
Provider string
|
||||
PayWay string
|
||||
Status string
|
||||
TestNo string
|
||||
Page int
|
||||
PageSize int
|
||||
}
|
||||
|
||||
type ConfigTestPaymentDTO struct {
|
||||
ID uint64 `json:"id"`
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
PaymentConfigID uint64 `json:"payment_config_id"`
|
||||
ConfigName string `json:"config_name"`
|
||||
Provider string `json:"provider"`
|
||||
MerchantID string `json:"merchant_id"`
|
||||
PayWay string `json:"pay_way"`
|
||||
Environment string `json:"environment"`
|
||||
ConfigStatus string `json:"config_status"`
|
||||
TestNo string `json:"test_no"`
|
||||
ThirdOrderID string `json:"third_order_id"`
|
||||
ProviderOrderID string `json:"provider_order_id"`
|
||||
AmountCent int64 `json:"amount_cent"`
|
||||
Status string `json:"status"`
|
||||
TDCode string `json:"td_code,omitempty"`
|
||||
JSPayURL string `json:"jspay_url,omitempty"`
|
||||
JSPayInfo string `json:"jspay_info,omitempty"`
|
||||
ErrorMessage string `json:"error_message"`
|
||||
RawRequest datatypes.JSON `json:"raw_request,omitempty"`
|
||||
RawResponse datatypes.JSON `json:"raw_response,omitempty"`
|
||||
CreateRequest datatypes.JSON `json:"create_request,omitempty"`
|
||||
CreateResponse datatypes.JSON `json:"create_response,omitempty"`
|
||||
QueryRequest datatypes.JSON `json:"query_request,omitempty"`
|
||||
QueryResponse datatypes.JSON `json:"query_response,omitempty"`
|
||||
NotifyRequest datatypes.JSON `json:"notify_request,omitempty"`
|
||||
NotifyResult datatypes.JSON `json:"notify_result,omitempty"`
|
||||
NotifyAck string `json:"notify_ack,omitempty"`
|
||||
QueryCount int `json:"query_count"`
|
||||
LastQueriedAt *time.Time `json:"last_queried_at,omitempty"`
|
||||
PaidAt *time.Time `json:"paid_at,omitempty"`
|
||||
NotifiedAt *time.Time `json:"notified_at,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type ConfigTestPaymentListResponse struct {
|
||||
Items []ConfigTestPaymentDTO `json:"items"`
|
||||
Total int64 `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
func toConfigTestPaymentDTO(row model.PaymentConfigTestOrder, includeRaw bool) ConfigTestPaymentDTO {
|
||||
dto := ConfigTestPaymentDTO{
|
||||
ID: row.ID,
|
||||
TenantID: row.TenantID,
|
||||
PaymentConfigID: row.PaymentConfigID,
|
||||
ConfigName: row.ConfigName,
|
||||
Provider: row.Provider,
|
||||
MerchantID: row.MerchantID,
|
||||
PayWay: row.PayWay,
|
||||
Environment: row.Environment,
|
||||
ConfigStatus: row.ConfigStatus,
|
||||
TestNo: row.TestNo,
|
||||
ThirdOrderID: row.ThirdOrderID,
|
||||
ProviderOrderID: row.ProviderOrderID,
|
||||
AmountCent: row.AmountCent,
|
||||
Status: row.Status,
|
||||
TDCode: row.TDCode,
|
||||
JSPayURL: row.JSPayURL,
|
||||
JSPayInfo: row.JSPayInfo,
|
||||
ErrorMessage: row.ErrorMessage,
|
||||
QueryCount: row.QueryCount,
|
||||
LastQueriedAt: row.LastQueriedAt,
|
||||
PaidAt: row.PaidAt,
|
||||
NotifiedAt: row.NotifiedAt,
|
||||
CreatedAt: row.CreatedAt,
|
||||
UpdatedAt: row.UpdatedAt,
|
||||
}
|
||||
if includeRaw {
|
||||
dto.RawRequest = row.RawRequest
|
||||
dto.RawResponse = row.RawResponse
|
||||
dto.CreateRequest = row.CreateRequest
|
||||
dto.CreateResponse = row.CreateResponse
|
||||
dto.QueryRequest = row.QueryRequest
|
||||
dto.QueryResponse = row.QueryResponse
|
||||
dto.NotifyRequest = row.NotifyRequest
|
||||
dto.NotifyResult = row.NotifyResult
|
||||
dto.NotifyAck = row.NotifyAck
|
||||
}
|
||||
return dto
|
||||
}
|
||||
Reference in New Issue
Block a user