fix(supply-api): 修复编译错误和测试问题
- 添加 ErrNotFound 和 ErrConcurrencyConflict 错误定义 - 修复 pgx.NullTime 替换为 *time.Time - 修复 db.go 事务类型 (pgx.Tx vs pgxpool.Tx) - 移除未使用的导入和变量 - 修复 NewSupplyAPI 调用参数 - 修复中间件链路 handler 类型问题 - 修复适配器类型引用 (storage.InMemoryAccountStore 等) - 所有测试通过 Test: go test ./...
This commit is contained in:
@@ -207,9 +207,9 @@ func (s *InMemorySettlementStore) GetWithdrawableBalance(ctx context.Context, su
|
||||
|
||||
// 内存收益存储
|
||||
type InMemoryEarningStore struct {
|
||||
mu sync.RWMutex
|
||||
records map[int64]*domain.EarningRecord
|
||||
nextID int64
|
||||
mu sync.RWMutex
|
||||
records map[int64]*domain.EarningRecord
|
||||
nextID int64
|
||||
}
|
||||
|
||||
func NewInMemoryEarningStore() *InMemoryEarningStore {
|
||||
@@ -252,28 +252,28 @@ func (s *InMemoryEarningStore) GetBillingSummary(ctx context.Context, supplierID
|
||||
},
|
||||
Summary: domain.BillingTotal{
|
||||
TotalRevenue: 10000.0,
|
||||
TotalOrders: 100,
|
||||
TotalUsage: 1000000,
|
||||
TotalRequests: 50000,
|
||||
TotalOrders: 100,
|
||||
TotalUsage: 1000000,
|
||||
TotalRequests: 50000,
|
||||
AvgSuccessRate: 99.5,
|
||||
PlatformFee: 100.0,
|
||||
NetEarnings: 9900.0,
|
||||
PlatformFee: 100.0,
|
||||
NetEarnings: 9900.0,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 内存幂等存储
|
||||
type InMemoryIdempotencyStore struct {
|
||||
mu sync.RWMutex
|
||||
mu sync.RWMutex
|
||||
records map[string]*IdempotencyRecord
|
||||
}
|
||||
|
||||
type IdempotencyRecord struct {
|
||||
Key string
|
||||
Status string // processing, succeeded, failed
|
||||
Response interface{}
|
||||
CreatedAt time.Time
|
||||
ExpiresAt time.Time
|
||||
Key string
|
||||
Status string // processing, succeeded, failed
|
||||
Response interface{}
|
||||
CreatedAt time.Time
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
||||
func NewInMemoryIdempotencyStore() *InMemoryIdempotencyStore {
|
||||
|
||||
Reference in New Issue
Block a user