diff --git a/supply-api/internal/domain/settlement.go b/supply-api/internal/domain/settlement.go index 11c4363e..21524db8 100644 --- a/supply-api/internal/domain/settlement.go +++ b/supply-api/internal/domain/settlement.go @@ -86,6 +86,7 @@ type SettlementService interface { Cancel(ctx context.Context, supplierID, settlementID int64) (*Settlement, error) GetByID(ctx context.Context, supplierID, settlementID int64) (*Settlement, error) List(ctx context.Context, supplierID int64) ([]*Settlement, error) + GetBillingSummary(ctx context.Context, supplierID int64, startDate, endDate string) (*BillingSummary, error) } // 收益服务接口 diff --git a/supply-api/internal/domain/settlement_test.go b/supply-api/internal/domain/settlement_test.go index 436d1299..806c1493 100644 --- a/supply-api/internal/domain/settlement_test.go +++ b/supply-api/internal/domain/settlement_test.go @@ -605,3 +605,19 @@ func TestGenerateSettlementNo(t *testing.T) { // 格式为时间戳 20060102150405 assert.Equal(t, 14, len(no)) } + +// TestSettlementService_GetBillingSummary 测试通过结算服务获取账单摘要 +func TestSettlementService_GetBillingSummary(t *testing.T) { + store := newMockSettlementStore() + earningStore := newMockEarningStore() + auditStore := &mockAuditStoreForSettlement{} + + svc := NewSettlementService(store, earningStore, auditStore) + + summary, err := svc.GetBillingSummary(context.Background(), 1001, "2024-01-01", "2024-01-31") + assert.NoError(t, err) + assert.NotNil(t, summary) + assert.Equal(t, "2024-01-01", summary.Period.Start) + assert.Equal(t, "2024-01-31", summary.Period.End) + assert.Equal(t, float64(1000), summary.Summary.TotalRevenue) +}