Commit Graph
2388 Commits
Author SHA1 Message Date
erio 9b8317fc66 chore: bump version to 0.1.108.10 2026-04-06 16:04:20 +08:00
erio 1984a19285 chore: bump version to 0.1.108.9 2026-04-06 15:37:39 +08:00
erio f72f79f48f chore: bump version to 0.1.108.8 2026-04-06 15:21:25 +08:00
erio 329d3445fa chore: bump version to 0.1.108.7 2026-04-06 15:03:19 +08:00
erio fdc9c6d8b8 chore: bump version to 0.1.108.6 2026-04-06 14:52:16 +08:00
erio 22a3931984 chore: bump version to 0.1.108.5 2026-04-06 14:40:53 +08:00
erio fa00ad06d2 chore: bump version to 0.1.108.4 2026-04-06 14:27:10 +08:00
erio 26a2c7a364 cleanup: remove Go migration code, rely solely on SQL migration 096 2026-04-06 02:52:20 +08:00
erio 05224be249 fix: use SQL migration for legacy purchase_subscription_url migration
Replace Go startup code with SQL migration 096 to migrate
purchase_subscription_url to custom_menu_items. Database migrations
run exactly once and are tracked by the migration system.
2026-04-06 02:49:46 +08:00
erio 225e8aaa97 fix: resolve golangci-lint errors — errcheck, gofmt, deprecated stripe API, unused func 2026-04-06 02:30:14 +08:00
erio 485b843637 fix: add PaymentOrderExpiryService param to provideCleanup test 2026-04-06 02:17:42 +08:00
erio 7a77ab2d09 chore: bump version to 0.1.108.3 2026-04-06 02:12:39 +08:00
erio 3703b5c08b refactor: migrate legacy purchase subscription to custom menu item
- Restore MigrateLegacyPurchaseURL auto-call on startup: converts old
  purchase_subscription_url into a custom menu item (id: migrated_purchase_subscription)
  and clears the legacy settings
- Delete PurchaseRouter.vue and PurchaseSubscriptionView.vue (replaced
  by existing CustomPageView.vue via custom menu system)
- /purchase route now exclusively serves the new built-in payment system
- Remove purchase_subscription_enabled from sidebar, router, settings UI,
  TypeScript types, and i18n keys
- Legacy purchase URL users will see their link as a custom menu entry
  after upgrade, editable in admin custom menu settings
2026-04-06 02:09:26 +08:00
erio 4a703cb084 fix: backward compatibility for legacy purchase subscription system
- Add PurchaseRouter.vue to dynamically render PaymentView or
  PurchaseSubscriptionView based on payment_enabled vs
  purchase_subscription_enabled settings
- Fix route guard to allow access when either payment system is enabled
- Split sidebar menu: /purchase shows for both systems, /orders only
  for built-in payment
- Remove auto-migration that forcibly disabled legacy purchase system
  on first startup (MigrateLegacyPurchaseURL)
- Add payment_enabled to PublicSettings API response so frontend can
  check both systems from a single endpoint
- Restore legacy purchase link config UI controls in admin Payment tab
- Split payment settings save to use dedicated PUT /admin/payment/config
  API instead of mixing into general settings endpoint
- Add admin payment config API functions (getConfig/updateConfig)
2026-04-06 01:51:12 +08:00
erio 96b1a96cf9 refactor(payment): code quality improvements per project conventions
- payment_service: split GetDashboardStats (131→35 lines) into 4 sub-functions,
  extract applyPagination helper, replace bubble sort with sort.Slice,
  use sync.Once for EnsureProviders, define magic number constants
- providers: merge duplicate PC/Mobile functions in alipay/wxpay,
  extract loadKeyPair/queryOrderTotalFen in wxpay, add centsToYuan in stripe,
  define constants for success codes, currencies, event types
- handlers: extract requireAuth and parseIDParam helpers to eliminate
  repeated auth/ID-parsing boilerplate
- registry: remove dead seen map in GetProviderByKey
- types: centralize order status constants in payment package
- load_balancer+config_service: unify duplicated containsType into
  exported InstanceSupportsType function
2026-04-06 01:13:30 +08:00
erio c69929bbb7 Merge feature/payment into release/custom-0.1.108
集成支付系统(EasyPay、Alipay、WxPay、Stripe),包含完整的订单管理、
Webhook 回调、管理后台仪表盘和用户充值/订阅流程。
2026-04-06 00:53:57 +08:00
erio cb56b96cd1 chore: bump version to 0.1.108.2 2026-04-06 00:00:31 +08:00
erio f9369aa46d fix: remove duplicate isUpstreamModelRestrictedByChannel check from merge 2026-04-06 00:00:07 +08:00
erio c45b0f2238 fix: gofmt formatting after merge 2026-04-05 23:14:23 +08:00
erio db6413039a Merge tag 'v0.1.108' into release/custom-0.1.108
彻底移除 Sora 平台功能,精简代码库约 24000 行;修复渠道平台定价隔离问题。

- 完全移除 Sora 平台:删除所有 Sora 相关的后端服务、前端组件、数据库 Schema 和 ent 代码
- 移除 Sora 相关的 S3 存储、媒体管理、配额管理、生成服务等模块
- 清理前端 Sora 视图、组件、composables、API 调用和国际化文本
- 移除 Sora OAuth 选项,简化 OpenAI OAuth 流程
- 更新 antigravity User-Agent 版本号至 1.21.9

- 修复 antigravity 分组错误匹配其他平台(anthropic/gemini)定价和模型映射的问题
- 修复渠道未映射模型时 BillingModel 被错误还原导致零计费的问题

# Conflicts:
#	backend/cmd/server/VERSION
#	backend/cmd/server/wire_gen.go
#	backend/ent/group.go
#	backend/ent/mutation.go
#	backend/ent/runtime/runtime.go
#	backend/ent/schema/group.go
#	backend/internal/handler/admin/channel_handler.go
#	backend/internal/handler/admin/channel_handler_test.go
#	backend/internal/handler/gateway_handler.go
#	backend/internal/pkg/antigravity/stream_transformer.go
#	backend/internal/server/api_contract_test.go
#	backend/internal/service/billing_service.go
#	backend/internal/service/channel_service.go
#	backend/internal/service/channel_service_test.go
#	backend/internal/service/gateway_service.go
#	backend/internal/service/openai_account_scheduler.go
#	backend/internal/service/openai_gateway_chat_completions.go
#	backend/internal/service/openai_gateway_service.go
#	backend/internal/service/openai_oauth_service.go
2026-04-05 23:11:04 +08:00
erio 4030c5192d fix: split dashboard stats, mutex provider init, CRITICAL logging for fulfillment 2026-04-05 22:52:07 +08:00
erio 5d63dfb0d1 style: minor formatting in registry.go 2026-04-05 22:30:22 +08:00
erio 9af4a53fe9 fix: structured errors, slog logging, snake_case JSON tags
- Registry uses infraerrors.NotFound instead of fmt.Errorf
- Webhook handler uses slog instead of log.Printf
- PaymentConfigService JSON tags unified to snake_case
- PaymentOrderExpiryService uses slog
- Remove duplicate declarations in registry.go
2026-04-05 22:25:51 +08:00
erio 5cde1bcc59 fix: code quality audit — critical bugs + convention compliance
Critical:
- Refund idempotency keys now include UnixNano timestamp (alipay/wxpay)
- PaymentView passes qr/pay_url params to QR code page
- Fix dead code branch in order result handling

Quality:
- Currency symbol $ → ¥ in admin stats and refund dialog
- StripePaymentView setTimeout cleanup on unmount
- Webhook body size limited to 1MB (io.LimitReader)
- SubscriptionPlan features type documented
2026-04-05 22:17:56 +08:00
erio 897244b832 refactor(channel): split long functions, extract shared validation, move billing validation to service
- Split Update (98→25 lines), buildCache (54→20 lines), Create (51→25 lines)
  into focused sub-functions: applyUpdateInput, checkGroupConflicts,
  fetchChannelData, populateChannelCache, storeErrorCache, getOldGroupIDs,
  invalidateAuthCacheForGroups
- Extract validateChannelConfig to eliminate duplicated validation calls
  between Create and Update
- Move validatePricingBillingMode from handler to service layer for
  proper separation of concerns
- Add error logging to IsModelRestricted (was silently swallowing errors)
- Add 12 new tests: ToUsageFields, billing mode validation, antigravity
  wildcard mapping isolation, Create/Update mapping conflict integration
2026-04-05 22:05:13 +08:00
Wesley Liddick c71b1d63e5 Merge pull request #1460 from imfusheng/main
解决issue#1453提到的反重力不可用问题
2026-04-05 22:01:08 +08:00
Wesley Liddick 8154575d70 Merge pull request #1464 from touwaeriol/fix/channel-platform-isolation
fix(channel): remove cross-platform pricing/mapping leakage for antigravity groups
2026-04-05 21:09:10 +08:00
Wesley Liddick d757df8a4b Merge pull request #1463 from touwaeriol/feat/remove-sora
revert: completely remove Sora platform
2026-04-05 21:08:48 +08:00
erio c5688fef9a fix: remove cross-platform pricing/mapping leakage for antigravity groups
Antigravity groups were incorrectly matching pricing and model mapping
entries from anthropic/gemini platform tabs. Each platform should be
strictly isolated — antigravity groups only use antigravity-tagged pricing.
2026-04-05 20:42:24 +08:00
erio 19655a15f1 fix: gofmt formatting 2026-04-05 18:56:40 +08:00
erio 1b215c88b5 test: add payment system unit tests (69 test cases)
- fee_test.go: 14 cases for CalculatePayAmount precision/rounding
- crypto_test.go: 9 cases for AES-256-GCM encrypt/decrypt round-trip
- registry_test.go: 10 cases including concurrent thread safety
- easypay_sign_test.go: 9 cases for MD5 signing/verification
- load_balancer_test.go: 10 cases for containsType utility
- payment_config_service_test.go: 17 cases for config parsing
2026-04-05 18:48:51 +08:00
erio f345b0f595 fix: use upstream versions of shared files and remove only Sora code
Restore gateway_service.go, setting_handler.go, routes/admin.go,
dto/settings.go, group_repo.go, api_key_repo.go, wire_gen.go to
upstream/main versions and surgically remove only Sora references.

This preserves upstream-only features (RequireOauthOnly, RequirePrivacySet,
GroupResolution, etc.) that were missing when using release branch versions.
2026-04-05 18:48:41 +08:00
erio aa151ef0e1 fix: resolve all audit findings — registry init, expiry task, dashboard, i18n, stripe
C1: Add EnsureProviders() lazy initialization to populate Registry
    from PaymentProviderInstance DB rows at first use
C2: Delete stale payment/provider_factory.go dead code
C3: Add PaymentOrderExpiryService background ticker (60s interval)
C4: Expand DashboardStats with daily_series, payment_methods, top_users
C5+C6: Add 152 payment i18n keys (en + zh) for admin and settings pages
C7: Fix Stripe global key race — use per-instance client.API
I1: Remove old purchase_subscription_enabled/url from settings form
I2: Add MigrateLegacyPurchaseURL to auto-convert old URL to custom menu
I3: Add migration 092 no-op placeholder for numbering continuity
2026-04-05 18:32:24 +08:00
erio 58707f8a2a fix: restore upstream api_contract_test and remove Sora fields 2026-04-05 18:18:58 +08:00
erio c6089ccb33 fix: remove Sora DI from wire_gen.go and clean remaining upstream Sora references 2026-04-05 17:50:01 +08:00
shaw f585a15eff fix(billing): prevent channel_mapped override from reverting BillingModel when channel did not map
When a channel has no model mapping for the requested model, ChannelMappedModel
equals OriginalModel (the user's arbitrary input). Combined with the default
BillingModelSource="channel_mapped", this incorrectly overrides the BillingModel
set by the OpenAI format conversion layer (e.g., gpt-5.4 from DefaultMappedModel)
back to the unmapped original model (e.g., glm) which has no pricing — resulting
in zero-cost billing.

Add guard condition so the channel_mapped override only fires when the channel
actually changed the model (ChannelMappedModel != OriginalModel).
2026-04-05 17:31:18 +08:00
erio a29f5a4849 fix: gofmt formatting 2026-04-05 17:22:22 +08:00
erio 1b1c08f7fb fix: remove media_type from usage_log SQL queries and test stubs
- Remove media_type column from all INSERT/SELECT/SCAN in usage_log_repo
- Remove media_type mock arg from request_type and integration tests
- Adjust scan stub value arrays from 47 to 46 elements
2026-04-05 17:22:22 +08:00
erio 0c72be0403 fix: gofmt alignment and remove media_type from usage_log repo queries 2026-04-05 17:22:22 +08:00
erio b4bd89b96b fix: remove media_type from usage_log SQL queries + gofmt + inline test helpers 2026-04-05 17:22:22 +08:00
erio 5bb8b2add6 fix: resolve CI failures — gofmt, unused functions, test parameter mismatches
- gofmt: user.go, config_test.go, group_handler.go, smart_retry_test.go
- Remove unused: mergeGroupIDs, resolveProxyURL, "time" import
- Fix api_contract_test.go: remove extra Sora args from NewAdminService,
  NewSettingHandler, NewAccountHandler; remove Sora field expectations
- Fix account_test_service_openai_test.go: restore test helpers
2026-04-05 17:22:22 +08:00
erio 93b42ccfea fix: resolve CI failures — gofmt, unused functions, missing test helpers
- Run gofmt on user schema, config test, group handler
- Remove unused mergeGroupIDs function
- Restore shared test helpers (newJSONResponse, queuedHTTPUpstream)
  that were in deleted Sora test file
2026-04-05 17:21:36 +08:00
erio 9c514c9808 chore: drop Sora database schema and regenerate ent code 2026-04-05 17:19:07 +08:00
erio 62e80c602d revert: completely remove all Sora functionality 2026-04-05 17:11:01 +08:00
erio 8cb2409ea5 refactor: remove PaymentChannel, reuse upstream Channel with features field
- Delete payment_channels table and PaymentChannel Ent schema
- Add `features` column to upstream channels table (migration 095)
- Add Features field to Channel struct, input types, handler request/response
- Payment user/admin handlers now use ChannelService directly
- Remove Channel CRUD from PaymentConfigService and admin payment routes
- Remove "渠道管理" tab from admin orders page (use /admin/channels)
2026-04-05 16:39:24 +08:00
erio 90134c72ed fix: remove cross-platform pricing/mapping leakage for antigravity groups
Antigravity groups were incorrectly matching pricing and model mapping
entries from anthropic/gemini platform tabs. Each platform should be
strictly isolated — antigravity groups only use antigravity-tagged pricing.
2026-04-05 16:17:30 +08:00
erio 64c4495ae5 feat: integrate payment system (EasyPay, Alipay, WxPay, Stripe)
Replace iframe-based external payment with native implementation:

Backend (Go):
- 5 new Ent schemas: PaymentOrder, PaymentAuditLog, PaymentChannel,
  SubscriptionPlan, PaymentProviderInstance
- 5 SQL migrations (090-094)
- Payment provider interface + registry + load balancer
- 4 provider implementations (EasyPay, Alipay, WxPay, Stripe)
- PaymentService (order lifecycle, fulfillment, refund 3-phase)
- PaymentConfigService (settings, instance/channel/plan CRUD)
- 31 API endpoints (9 user + 4 webhook + 18 admin)
- Wire DI integration

Frontend (Vue3):
- Payment types, API modules, store, router changes
- Sidebar: payment_enabled controls visibility, new menu items
- User pages: PaymentView (replace iframe), QR payment, Stripe,
  result page, order list
- Admin pages: Order management (4 tabs), provider instance mgmt
- Settings: new payment tab, removed old purchase iframe config
- i18n: full payment namespace (en + zh)

Docs:
- PAYMENT_FRONTEND_MIGRATION_PLAN.md
- PAYMENT_BACKEND_MIGRATION_PLAN.md
- PAYMENT_IMPLEMENTATION_ROADMAP.md
2026-04-05 15:06:05 +08:00
erio e2047c35f6 fix: gofmt formatting 2026-04-05 14:37:21 +08:00
erio 47f6eab526 fix: remove media_type from usage_log SQL queries and test stubs
- Remove media_type column from all INSERT/SELECT/SCAN in usage_log_repo
- Remove media_type mock arg from request_type and integration tests
- Adjust scan stub value arrays from 47 to 46 elements
2026-04-05 14:31:33 +08:00
erio 75d9fe2c7b fix: gofmt alignment and remove media_type from usage_log repo queries 2026-04-05 14:25:29 +08:00