Skip to content

fix the issue of model repetition - #13

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
t0ng7u:main
Nov 23, 2023
Merged

Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
t0ng7u:main

Conversation

@t0ng7u

@t0ng7u t0ng7u commented Nov 23, 2023

Copy link
Copy Markdown
Collaborator

fix the issue of model repetition

@Calcium-Ion
Calcium-Ion merged commit d4b3f87 into QuantumNous:main Nov 23, 2023
Calcium-Ion pushed a commit that referenced this pull request Nov 23, 2023
seefs001 pushed a commit that referenced this pull request Oct 10, 2025
Fork Sync: Update from parent repository
cuijinyu added a commit to cuijinyu/new-api that referenced this pull request Mar 31, 2026
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
fix the issue of model repetition
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
tradzero pushed a commit to tradzero/new-api that referenced this pull request May 6, 2026
@xiaotian044500

Copy link
Copy Markdown

本地 Agent 已接管,开始处理 #13...

jiutubaba pushed a commit to jiutubaba/fx-api that referenced this pull request May 17, 2026
…ectness

Backend fixes:
- QuantumNous#1: doSub subscription idempotency via audit log check
- QuantumNous#2: markFailed only when status=RECHARGING (prevents overwriting COMPLETED)
- QuantumNous#3: ExpireTimedOutOrders checks upstream payment before expiring
- QuantumNous#4: Public verify endpoint for payment result page (no auth required)
- QuantumNous#5: EasyPay QueryOrder returns amount, confirmPayment handles zero amount
- QuantumNous#6: WxPay notifyUrl priority: request-first, config-fallback
- QuantumNous#7: EasyPay remove double URL decode in VerifyNotification
- QuantumNous#8: checkPaid/cancelUpstreamPayment use order's provider instance
- QuantumNous#9: Amount NaN/Inf/negative validation in order creation and refund
- QuantumNous#10: Refund amount comparison uses tolerance instead of float64 ==
- QuantumNous#11: Skip balance deduction on retry when previous rollback failed
- QuantumNous#12: checkPaid logs fulfillment errors instead of silently ignoring
- QuantumNous#13: WxPay certSerial added to required config fields

Frontend fixes:
- Payment result page no longer requires authentication
- Public verify API fallback for expired sessions
finger92 added a commit to protagolabs/new-api that referenced this pull request Jun 23, 2026
767KiB OpenAI prompt still pegged a newapi-slave core (2026-06-23 CRITICAL);
1MiB guard (patch QuantumNous#13) was too loose. 256KiB ~= 64k tokens; pre-charge estimate
only, final billing reads upstream usage.
lizhongyi1209 pushed a commit to lizhongyi1209/new-api that referenced this pull request Jul 7, 2026
上游变更:41 个新提交,从 v1.0.0-rc.16 升级到 v1.0.0-rc.19-i18nfix.2。
主要改进:
- i18n 系统重构:zh 拆分为 zhCN/zhTW,加入浏览器语言自动映射
- Session cookie 配置化:SESSION_COOKIE_SECURE/TRUSTED_URL 环境变量
- Quota 溢出保护:common.QuotaFromFloat/QuotaFromFloatChecked 饱和转换
- 管理员审计:quota 饱和事件标记(admin_info.quota_saturation)
- 前端组件重构:group-ratio-visual-editor 拆分为多组件架构

冲突解决:13 个文件,保留所有 custom 功能的同时融合上游改进
- #1-10:取上游(user.go、docker-compose.yml、i18n config/JSON、main.go session cookie 等)
- QuantumNous#11 kling adaptor:手动融合 ActualCost 精度 + QuotaFromFloat 溢出保护
- QuantumNous#12 task_billing:手动融合单日志结算 + 审计参数 + QuotaFromFloatChecked + attachQuotaSaturation
- QuantumNous#13 group-ratio editor:QuickAddOverrideDialog 重新嫁接到上游新组件架构(GroupOverrideRules)

验证:ActualCost/QuotaClamp 在 relay_info.go 自动合并共存 ✓
      languages.ts 自动合并为上游 zhCN/zhTW 方案 ✓

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
finger92 added a commit to protagolabs/new-api that referenced this pull request Jul 14, 2026
…mNous#17) on rc.19

CountTextToken falls back to estimation above 256KiB to avoid tiktoken
O(n) pegging CPU on oversized gpt-4.1 prompts (ant_netmind). Pre-charge
only; final billing uses upstream usage. Lost in rc.19 upgrade, restored.
Firesuiry pushed a commit to Firesuiry/tako-newapi that referenced this pull request Aug 27, 2026
…alidation-group-cache

fix(subscription): refresh group cache on invalidation
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
fix the issue of model repetition
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
Brillianyt referenced this pull request in IF-Link-Tech-Team/new-api Sep 11, 2026
## 1. 用户端支付入口(此前完全未接)

前端支付分发是二分逻辑:

    isStripe ? requestStripePayment(...) : requestPayment(...)   // 后者 = epay

支付宝没有任何分支,和微信一起落进 epay。而生产 epay 未启用
(enable_online_topup=false),用户点「支付宝」只会拿到
「当前管理员未配置支付信息」。后端 POST /api/user/alipay 虽已验证可用,
但前端零引用。

补齐:

  web/src/features/wallet/types.ts    AlipayPaymentRequest / AlipayPaymentResponse
  web/src/features/wallet/lib/payment.ts   isAlipayPayment()
  web/src/features/wallet/api.ts      requestAlipayPayment() -> POST /api/user/alipay
  web/src/features/wallet/hooks/use-payment.ts
                                      processPayment 增加支付宝分支:
                                      取 pay_url 后整页跳转

支付宝返回的是收银台 pay_url(签名已在 URL 内),不是表单,故不能用
submitPaymentForm,也不能 window.open 后不管。

## 2. 金额换算修正(原实现会真实亏损)

RequestAlipayPay 原来把 req.Amount 直接当作应付人民币:

    "total_amount": fmt.Sprintf("%.2f", float64(req.Amount))

但前端传的是「展示金额」,与 RequestEpay 一致的口径是需要换算的:

    实付人民币 = 展示金额 × operation_setting.Price × 分组倍率 × 折扣

生产原走代码默认 Price=7.3(USD 展示),于是 展示 10 的订单只收 ¥10,
却按展示金额发放 5,000,000 quota(≈¥73 的价值),每单亏损 ¥63。

修正为与 RequestEpay 完全一致:

  - payMoney := getPayMoney(int64(req.Amount), group),支付宝 total_amount 用 payMoney
  - TopUp.Amount 存展示金额、Money 存实付人民币(与 epay 存储口径一致)
  - 响应体补 pay_money 字段

## 3. 入账口径修正

AlipayNotify 原按 Money × QuotaPerUnit 入账。Money 是按 Price 换算后的
实付人民币,再乘一次 QuotaPerUnit 会把额度放大 Price 倍。
改为与 EpayNotify 一致:quota = Amount × QuotaPerUnit。

## 4. 生产配置(不在本提交内,仅记录)

options 表原先没有 Price / USDExchangeRate 行,一直走代码默认 7.3。
按实际定价 1:1 已写入 Price=1、USDExchangeRate=1。

## 验证(真实沙箱,1:1 配置下)

  用户端 wallet 充值(展示 $1):
    POST /api/user/alipay {"amount":1}
    -> total_amount=1.00, DB amount=1|money=1
    -> 支付宝 TRADE_SUCCESS -> 验签通过
    -> top_ups success
    -> root quota 100004956 -> 100504956 (+500000)
    -> 日志「支付宝充值成功,充值额度: 500000,支付金额: 1.00」

  套餐购买(plan_id=3,¥1):
    POST /api/subscription/alipay/pay {"plan_id":3}
    -> 订单 SUB-ALI-7Io4JA5U success
    -> 自动发放 user_subscriptions #7 (500000)
    -> 自动生成 tokens #13「套餐 #7 专属 Key」绑定 #7
    -> 用该 Key 真实调 glm-5.2:quota 87 = (17+20*3.5)*1*1
       仅扣订阅 #7,订阅 #6 不变、钱包不变(wallet_quota_deducted=0)

  金额链路:
    /api/user/amount {"amount":10}      -> 10.00
    /api/user/alipay {"amount":10}      -> total_amount=10.00
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.

3 participants