mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
v4.6 -1 (#459)
This commit is contained in:
25
packages/global/support/wallet/bill/api.d.ts
vendored
Normal file
25
packages/global/support/wallet/bill/api.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { BillSourceEnum } from './constants';
|
||||
import { BillListItemType } from './type';
|
||||
|
||||
export type CreateTrainingBillProps = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type ConcatBillProps = {
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
billId?: string;
|
||||
total: number;
|
||||
listIndex?: number;
|
||||
tokens?: number;
|
||||
};
|
||||
|
||||
export type CreateBillProps = {
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
appName: string;
|
||||
appId?: string;
|
||||
total: number;
|
||||
source: `${BillSourceEnum}`;
|
||||
list: BillListItemType[];
|
||||
};
|
16
packages/global/support/wallet/bill/constants.ts
Normal file
16
packages/global/support/wallet/bill/constants.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// ¥1 = 100000
|
||||
export const PRICE_SCALE = 100000;
|
||||
|
||||
export enum BillSourceEnum {
|
||||
fastgpt = 'fastgpt',
|
||||
api = 'api',
|
||||
shareLink = 'shareLink',
|
||||
training = 'training'
|
||||
}
|
||||
|
||||
export const BillSourceMap: Record<`${BillSourceEnum}`, string> = {
|
||||
[BillSourceEnum.fastgpt]: '在线使用',
|
||||
[BillSourceEnum.api]: 'Api',
|
||||
[BillSourceEnum.shareLink]: '免登录链接',
|
||||
[BillSourceEnum.training]: '数据训练'
|
||||
};
|
10
packages/global/support/wallet/bill/tools.ts
Normal file
10
packages/global/support/wallet/bill/tools.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/* bill common */
|
||||
import { PRICE_SCALE } from './constants';
|
||||
import { BillItemType, BillSchema } from './type';
|
||||
|
||||
/**
|
||||
* dataset price / PRICE_SCALE = real price
|
||||
*/
|
||||
export const formatPrice = (val = 0, multiple = 1) => {
|
||||
return Number(((val / PRICE_SCALE) * multiple).toFixed(10));
|
||||
};
|
24
packages/global/support/wallet/bill/type.d.ts
vendored
Normal file
24
packages/global/support/wallet/bill/type.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { CreateBillProps } from './api';
|
||||
import { BillSourceEnum } from './constants';
|
||||
|
||||
export type BillListItemType = {
|
||||
moduleName: string;
|
||||
amount: number;
|
||||
model?: string;
|
||||
tokenLen?: number;
|
||||
};
|
||||
|
||||
export type BillSchema = CreateBillProps & {
|
||||
_id: string;
|
||||
time: Date;
|
||||
};
|
||||
|
||||
export type BillItemType = {
|
||||
id: string;
|
||||
username: string;
|
||||
time: Date;
|
||||
appName: string;
|
||||
source: BillSchema['source'];
|
||||
total: number;
|
||||
list: BillSchema['list'];
|
||||
};
|
Reference in New Issue
Block a user