Skip to content

feat(billing): DeepSeek peak-hour pricing (rant 2026-08-20T11:58:40) - #104

Merged
argszero merged 1 commit into
mainfrom
feat/deepseek-peak-pricing
Aug 20, 2026
Merged

argszero merged 1 commit into
mainfrom
feat/deepseek-peak-pricing

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Implements peak-hour pricing for DeepSeek (rant timestamp 2026-08-20T11:58:40). DeepSeek's official pricing doubles during Beijing peak hours (9:00-12:00 / 14:00-18:00); previously billing always used the off-peak price, undercharging by half during peak hours.

Changes

  • config.rs: [[models]] gains 3 optional fields — peak_input_per_m / peak_output_per_m / peak_cache_hit_input_per_m (default 0 = peak billing disabled, off-peak price applies)
  • db.rs: schema migration v9 adds the three peak_* columns to models (idempotent ensure_column); seed_models upserts them from config
  • billing.rs: is_peak_hour() — fixed Asia/Shanghai (UTC+8, no DST), peak = 09:00-12:00 / 14:00-18:00 Beijing time, Mon-Sun; effective_prices() — peak-hour price selection with 0-default fallback to off-peak
  • gateway.rs: settle_usage bills at peak prices when the current Beijing time falls in a peak window
  • dao.rs / admin_models.rs: GET /api/models, admin model list, and admin create/patch endpoints carry the peak fields (validated ≥ 0)
  • UI: market table shows a "peak ×N" badge + expanded detail shows peak-hour prices; admin model form gains three peak-price inputs; guest mock market entry updated; zh/en i18n keys
  • config.example.toml: DeepSeek official peak prices (flash 3.0/0.10/9.0, pro 9.0/0.30/27.0 CNY/M); README + docs/architecture.md updated

Acceptance checklist (from rant)

  • Models without peak config keep unchanged billing (compat: default 0 → off-peak price)
  • Beijing 09:00-12:00 / 14:00-18:00 calls to deepseek models bill at peak price
  • Boundary tests: 8:59/9:00, 11:59/12:00, 13:59/14:00, 17:59/18:00 (Beijing) switch correctly

Tests

  • cargo test: 128 passed (125 existing + 3 new: is_peak_hour_beijing_boundaries, effective_prices_selects_peak_or_falls_back, calc_points_uses_peak_price_in_peak_hour; db seed test extended)
  • cargo clippy: 0 warnings; cargo fmt --check: clean
  • JS syntax check (node --check) on app.js / i18n.js / data.js: OK

Peak hours (Beijing 9:00-12:00 / 14:00-18:00, Mon-Sun) bill at 2x the
off-peak rate for DeepSeek. Config models gain optional peak_* price
fields (default 0 = peak billing off), models table migration v9,
billing picks prices by fixed Asia/Shanghai time, market UI shows a
'peak xN' badge + detail row, admin model form supports peak prices.
@argszero
argszero merged commit c9ff9b8 into main Aug 20, 2026
1 check passed
argszero pushed a commit that referenced this pull request Aug 20, 2026
…o fmt

Post-rebase fixup: the models-refresh config renamed zhipu glm-5.2 to
glm-5.3; the peak-pricing seed test (PR #104) referenced the old name.
Also applies rustfmt to merged CNY-anchor/peak files so the tree is
fmt-clean (129 passed).
argszero pushed a commit that referenced this pull request Aug 20, 2026
…or at app.js:2409

PR #104 (peak pricing) merge 时 modelsToView 残留了一段重复的
'avail/multi/success/live' 属性块(2408-2414 行),导致
modelsToView 函数体提前闭合、后续代码语法错误(Unexpected token ':')。
删除重复块,node --check 通过。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant