优化结构
This commit is contained in:
@@ -84,6 +84,24 @@ type PaymentResultResponse struct {
|
||||
RefundStatus string `json:"refundStatus,omitempty"`
|
||||
}
|
||||
|
||||
type PaymentTestStage struct {
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message,omitempty"`
|
||||
TradeNo string `json:"tradeNo,omitempty"`
|
||||
Duration int64 `json:"durationMs,omitempty"`
|
||||
}
|
||||
|
||||
type PaymentTestResult struct {
|
||||
Provider string `json:"provider"`
|
||||
TradeNo string `json:"tradeNo"`
|
||||
Passed bool `json:"passed"`
|
||||
FullFlow bool `json:"fullFlow"`
|
||||
Mode string `json:"mode,omitempty"`
|
||||
Stages []*PaymentTestStage `json:"stages"`
|
||||
Result *PaymentResultResponse `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type PaymentOrderResponse struct {
|
||||
ID uint64 `json:"ID"`
|
||||
Provider string `json:"provider"`
|
||||
|
||||
@@ -105,6 +105,8 @@ type PaymentQueryRequest = dto.PaymentQueryRequest
|
||||
type PaymentRefundRequest = dto.PaymentRefundRequest
|
||||
type PaymentRequest = dto.PaymentRequest
|
||||
type PaymentResultResponse = dto.PaymentResultResponse
|
||||
type PaymentTestResult = dto.PaymentTestResult
|
||||
type PaymentTestStage = dto.PaymentTestStage
|
||||
type PolicyPathRequest = dto.PolicyPathRequest
|
||||
type PositionListRequest = dto.PositionListRequest
|
||||
type PositionRequest = dto.PositionRequest
|
||||
|
||||
@@ -107,6 +107,19 @@ func (s *PaymentService) Refund(ctx context.Context, req *PaymentRefundRequest)
|
||||
return paymentResultResponse(result), err
|
||||
}
|
||||
|
||||
func (s *PaymentService) TestProvider(ctx context.Context, provider string) (*PaymentTestResult, error) {
|
||||
result, err := s.uc.TestProvider(ctx, provider)
|
||||
if result == nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &PaymentTestResult{Provider: result.Provider, TradeNo: result.TradeNo, Passed: result.Passed, FullFlow: result.FullFlow, Mode: result.Mode, Stages: make([]*PaymentTestStage, 0, len(result.Stages))}
|
||||
for _, stage := range result.Stages {
|
||||
response.Stages = append(response.Stages, &PaymentTestStage{Name: stage.Name, Status: stage.Status, Message: stage.Message, TradeNo: stage.TradeNo, Duration: stage.Duration})
|
||||
}
|
||||
response.Result = paymentResultResponse(result.Result)
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (s *PaymentService) Fulfill(ctx context.Context, req *PaymentFulfillRequest) (*PaymentResultResponse, error) {
|
||||
if req == nil {
|
||||
return nil, errors.New("支付发货请求为空")
|
||||
|
||||
@@ -47,6 +47,7 @@ var apiMetadata = map[string]apiMetadataValue{
|
||||
"GET /integration/configs/:kind": {group: "集成配置", description: "按类型获取集成配置"},
|
||||
"GET /integration/configs/:kind/:provider": {group: "集成配置", description: "获取指定集成配置"},
|
||||
"GET /payment/orders": {group: "支付", description: "分页查询支付订单"},
|
||||
"POST /payment/providers/:provider/test": {group: "支付", description: "测试支付渠道配置与沙箱交易链路"},
|
||||
"GET /securityConfig/getSecurityConfig": {group: "安全配置", description: "获取安全配置"},
|
||||
"GET /sysDictionary/exportSysDictionary": {group: "系统字典", description: "导出字典JSON"},
|
||||
"GET /sysDictionary/findSysDictionary": {group: "系统字典", description: "根据ID获取字典(建议选择)"},
|
||||
|
||||
Reference in New Issue
Block a user