11 Commits

Author SHA1 Message Date
Hermes Agent
aad5ebd8cf chore: 添加json/build.sh脚本 2026-06-17 17:26:28 +08:00
Hermes Agent
8cb85854f3 Revert "Revert "feat(accounting): add balance update in create_accounting_record""
This reverts commit 92e1c92ed82031668002dc4b70bb546cf7ca30d2.
2026-05-28 22:38:51 +08:00
Hermes Agent
92e1c92ed8 Revert "feat(accounting): add balance update in create_accounting_record"
This reverts commit e86e2ceea3d39d7cf96f3f10a2e2c906d840a80f.
2026-05-28 22:36:36 +08:00
Hermes Agent
e86e2ceea3 feat(accounting): add balance update in create_accounting_record
记账核心逻辑补全:
1. 写分录明细 (INSERT accounting_records)
2. 记账日志 (status='accounted')
3. 更新账户余额 (UPSERT customer_balance)
4. 透支检查:余额不足时检查 credit_limit,超限拒绝
2026-05-28 22:06:20 +08:00
Hermes Agent
781216e11a refactor(models): convert to json format per database-table-definition-spec 2026-05-27 13:23:31 +08:00
Hermes Agent
40c480e488 fix: sageapi local deployment and test server
- Fix health check sqlExe calls: add missing ns parameter
- Fix accounting ID generation: use getID() instead of uuid4 (VARCHAR length)
- Fix accounting request_id: normalize empty to NULL to avoid UNIQUE constraint violation
- Fix test_server balance/update route: was incorrectly pointing to accounting handler
- Add test_server.py: standalone aiohttp test server for local development
- Update conf/config.yaml: local MySQL credentials (test/test)
- Update db/schema.sql and scripts/generate_ddl.py for local testing
- Fix router sync_status sqlExe call: add missing ns parameter
- Fix sync uapi_sync: use correct table/column names
2026-05-20 22:46:05 +08:00
Hermes Agent
acb9674375 feat: CRUD definitions, build script, DDL generation
- 3 CRUD JSON files: customer_balance, accounting_records, sync_state
- Build script with model validation, CRUD validation, DDL generation
- DDL: db/schema.sql (72 lines, 7 tables)
- Scripts: validate_models.py, validate_crud.py, generate_ddl.py
2026-05-20 18:28:59 +08:00
Hermes Agent
5936a2f328 feat: implement sync engine, API handlers, DAPI auth, HTTP client
- Sync engine: BaseSync abstract class + 4 sync modules (users/pricing/uapi/llmage)
  - Checkpoint management via sync_state table
  - Batch processing with retry and exponential backoff
  - Incremental fetch from Sage DB via sqlor
  - UPSERT to local cache tables
- API handlers: balance/accounting/users/pricing/health
  - Balance: cache lookup + Sage fallback
  - Accounting: create with idempotency, query with filters/pagination
  - Users: keyword search, org filter
  - Pricing: filter by ppid/llmid/type/status
  - Health: basic + readiness checks (DB connectivity)
- DAPI auth: middleware + authenticate_request function
  - HMAC-SHA256 signature verification
  - Timestamp window validation
  - Sage downapikey table lookup
- HTTP client: SageHttpClient with aiohttp
  - Auto DAPI signature injection
  - Connection pooling, retry, timeout
- Router: 12 routes registered
- Module init: load_sageapi() wires everything to ServerEnv
2026-05-20 18:22:23 +08:00
Hermes Agent
a9ea05ff2d Merge remote initial commit, resolve README conflict 2026-05-20 17:57:04 +08:00
Hermes Agent
5c65c78752 feat: sageapi initial scaffold
- 36 files: module structure following module-development-spec
- 7 table definitions: users_cache, pricing_cache, llmage_cache, uapi_cache, sync_state, customer_balance, accounting_records
- Auth: dapi_auth + uapi_sign
- Sync: base_sync + entity-specific sync modules (users/pricing/uapi/llmage)
- Cache: LRU cache manager with TTL
- API: balance, accounting, users, pricing, health handlers
- Config: YAML config loader with env overrides
- Utils: HTTP client, crypto helpers
2026-05-20 17:53:53 +08:00
f2fc8a7251 Initial commit 2026-05-20 14:18:15 +08:00