mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-04 00:17:45 +08:00
feat: 强化用量计费状态机,新增钱包每日消费汇总分类账
- 将 usage.billing_status 默认值从 settled 改为 pending,完善 pending -> settled/void 的状态转换逻辑,确保终态不可逆 - 新增 WalletDailyUsageLedger 模型和聚合服务,按账单日汇总 每个钱包的消费金额、请求数和 token 用量 - 前端钱包中心页面集成每日消费流水展示,支持与充值记录混合 排序和分页 - 新增两个数据库迁移:修复历史数据状态一致性、创建每日汇总表 - 补充计费状态机单元测试 Closes #218 Co-authored-by: LewisPen <[email protected]>
This commit is contained in:
@@ -378,6 +378,7 @@ async def test_event_to_record_body_deserialization(monkeypatch: Any) -> None:
|
||||
event = build_usage_event(
|
||||
event_type=UsageEventType.COMPLETED,
|
||||
request_id="req-body-test",
|
||||
timestamp_ms=1_700_000_000_123,
|
||||
data={
|
||||
"user_id": "user-1",
|
||||
"api_key_id": "key-1",
|
||||
@@ -396,6 +397,7 @@ async def test_event_to_record_body_deserialization(monkeypatch: Any) -> None:
|
||||
assert record["request_body"]["messages"][0]["content"] == "hello"
|
||||
assert isinstance(record["response_body"], dict)
|
||||
assert record["response_body"]["choices"][0]["message"]["content"] == "hi"
|
||||
assert record["finalized_at"] is not None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user