From 85dc61b07d10ddffd8ed7f3912d4f43a2da4c8e0 Mon Sep 17 00:00:00 2001
From: yys <47@gamerwa.com>
Date: Tue, 14 Apr 2026 11:01:55 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=9F=E6=88=90=E8=A7=86=E9=A2=91?=
=?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=B5=81=E6=B0=B4=E8=A1=A8=E5=86=99=E5=85=A5?=
=?UTF-8?q?=E5=A4=87=E6=B3=A8=EF=BC=8C=E6=B7=BB=E5=8A=A0tokens=E7=94=A8?=
=?UTF-8?q?=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/main/resources/i18n/messages.properties | 5 +++++
.../src/main/resources/i18n/messages_zh_HK.properties | 5 ++++-
.../src/main/java/com/ruoyi/ai/domain/AiOrder.java | 4 ++++
.../com/ruoyi/ai/service/impl/AiOrderServiceImpl.java | 8 ++++++--
.../src/main/resources/mapper/system/AiOrderMapper.xml | 7 ++++++-
5 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/web-api/ruoyi-admin/src/main/resources/i18n/messages.properties b/web-api/ruoyi-admin/src/main/resources/i18n/messages.properties
index 93de005..9490f31 100644
--- a/web-api/ruoyi-admin/src/main/resources/i18n/messages.properties
+++ b/web-api/ruoyi-admin/src/main/resources/i18n/messages.properties
@@ -36,3 +36,8 @@ no.update.permission=您没有修改数据的权限,请联系管理员添加
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
+
+# video generation
+order.number.generation.failed=订单号 {0} 生成失败,请稍后重试。
+order.number.generation.submit=订单号 {0} 生成任务已提交!
+order.number.generation.successbackfill=订单号 {0} 生成成功!金额已回补!
\ No newline at end of file
diff --git a/web-api/ruoyi-admin/src/main/resources/i18n/messages_zh_HK.properties b/web-api/ruoyi-admin/src/main/resources/i18n/messages_zh_HK.properties
index f44388a..7b2abfd 100644
--- a/web-api/ruoyi-admin/src/main/resources/i18n/messages_zh_HK.properties
+++ b/web-api/ruoyi-admin/src/main/resources/i18n/messages_zh_HK.properties
@@ -29,4 +29,7 @@ email.verification.code.error=驗證碼錯誤,請重新輸入。
user.not.found=用戶不存在。
user.password.incorrect=密碼錯誤,請重新輸入。
-order.number.generation.failed=訂單號 {0} 生成失敗,請稍後重試。
\ No newline at end of file
+# video generation
+order.number.generation.failed=訂單號 {0} 生成失敗,請稍後重試。
+order.number.generation.submit=訂單號 {0} 生成任務已提交!
+order.number.generation.successbackfill=訂單號 {0} 生成成功!金額已回補!
\ No newline at end of file
diff --git a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/AiOrder.java b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/AiOrder.java
index c0ad6f6..ee572b1 100644
--- a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/AiOrder.java
+++ b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/AiOrder.java
@@ -56,6 +56,10 @@ public class AiOrder extends BaseEntity {
@Excel(name = "金额")
private BigDecimal amount;
+ /** 模型Tokens用量 */
+ @Excel(name = "模型Tokens用量")
+ private BigDecimal totalUsage;
+
@Excel(name = "是否回补处理过: 0-否 1-是")
private Integer isBackfilled;
diff --git a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/impl/AiOrderServiceImpl.java b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/impl/AiOrderServiceImpl.java
index 6ae72c7..95bc513 100644
--- a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/impl/AiOrderServiceImpl.java
+++ b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/impl/AiOrderServiceImpl.java
@@ -197,8 +197,9 @@ public class AiOrderServiceImpl implements IAiOrderService {
aiOrderMapper.insert(aiOrder);
// 执行余额变更
if (isReduceBalance) {
+ String remark = MessageUtils.message(TASK_SUBMIT_REMARK, aiOrder.getOrderNum());
aiUserService.addUserBalance(orderno, SecurityUtils.getAiUserId()
- , NumberUtil.mul(-1, aiManager.getPrice()), getChangerType(aiType), TASK_SUBMIT_REMARK);
+ , NumberUtil.mul(-1, aiManager.getPrice()), getChangerType(aiType), remark);
}
return aiOrder;
}
@@ -312,6 +313,8 @@ public class AiOrderServiceImpl implements IAiOrderService {
}
// 设置用量
order.setAmount(realAmount);
+ // tokens用量
+ order.setTotalUsage(realAmount);
// 订单状态
order.setStatus(AiOrderStatusType.FINISH.ordinal());
// 已回补
@@ -325,8 +328,9 @@ public class AiOrderServiceImpl implements IAiOrderService {
BigDecimal addAmount = order.getPreDeductAmount().subtract(realAmount);
if (addAmount.compareTo(new BigDecimal(0)) != 0) {
// 回补
+ String remark = MessageUtils.message(TASK_SUCCESS_BACK_FILL_REMARK, order.getOrderNum());
aiUserService.addUserBalance(order.getOrderNum(), order.getUserId(), addAmount,
- BalanceChangerConstants.REFUND, TASK_SUCCESS_BACK_FILL_REMARK);
+ BalanceChangerConstants.REFUND, remark);
}
}
diff --git a/web-api/ruoyi-system/src/main/resources/mapper/system/AiOrderMapper.xml b/web-api/ruoyi-system/src/main/resources/mapper/system/AiOrderMapper.xml
index 293cf2e..5f98aed 100644
--- a/web-api/ruoyi-system/src/main/resources/mapper/system/AiOrderMapper.xml
+++ b/web-api/ruoyi-system/src/main/resources/mapper/system/AiOrderMapper.xml
@@ -12,10 +12,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
+
@@ -29,10 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
- select ao.id, ao.del_flag, ao.create_by, ao.create_time, ao.update_by, ao.update_time, ao.remark, ao.order_num, ao.user_id, ao.type, ao.amount, ao.result, ao.status, ao.source, ao.text, ao.is_top, ao.img1, ao.img2, ao.mode, ao.duration, ao.resolution, ao.ratio, ao.model, ao.video_params, au.user_id uuid, ao.ext_status from ai_order ao
+ select ao.id, ao.del_flag, ao.create_by, ao.create_time, ao.update_by, ao.update_time, ao.remark, ao.order_num, ao.third_party_order_num, ao.user_id, ao.type, ao.pre_deduct_amount, ao.amount, ao.total_usage, ao.result, ao.status, ao.source, ao.text, ao.is_top, ao.img1, ao.img2, ao.mode, ao.duration, ao.resolution, ao.ratio, ao.model, ao.video_params, au.user_id uuid, ao.ext_status, ao.is_backfilled, ao.video_gen_request_id from ai_order ao
left join ai_user au on au.id = ao.user_id