This commit is contained in:
Archer
2023-11-09 09:46:57 +08:00
committed by GitHub
parent 661ee79943
commit 8bb5588305
402 changed files with 9899 additions and 5967 deletions

View 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[];
};

View 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]: '数据训练'
};

View 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));
};

View 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'];
};