mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
37
packages/global/support/wallet/bill/api.d.ts
vendored
37
packages/global/support/wallet/bill/api.d.ts
vendored
@@ -1,18 +1,25 @@
|
||||
import { BillTypeEnum } from './constants';
|
||||
import { BillSourceEnum } from './constants';
|
||||
import { BillListItemCountType, BillListItemType } from './type';
|
||||
|
||||
export type CreateTrainingBillProps = {
|
||||
name: string;
|
||||
datasetId: string;
|
||||
};
|
||||
|
||||
export type ConcatBillProps = BillListItemCountType & {
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
billId?: string;
|
||||
total: number;
|
||||
listIndex?: number;
|
||||
};
|
||||
|
||||
export type CreateBillProps = {
|
||||
type: `${BillTypeEnum}`;
|
||||
|
||||
// balance
|
||||
balance?: number; // read
|
||||
|
||||
month?: number;
|
||||
// extra dataset size
|
||||
extraDatasetSize?: number; // 1k
|
||||
extraPoints?: number; // 100w
|
||||
};
|
||||
export type CreateBillResponse = {
|
||||
billId: string;
|
||||
codeUrl: string;
|
||||
readPrice: number;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
appName: string;
|
||||
appId?: string;
|
||||
total: number;
|
||||
source: `${BillSourceEnum}`;
|
||||
list: BillListItemType[];
|
||||
};
|
||||
|
@@ -1,57 +1,34 @@
|
||||
export enum BillTypeEnum {
|
||||
balance = 'balance',
|
||||
// model price: xxx/1k tokens
|
||||
// ¥1 = 100000.
|
||||
export const PRICE_SCALE = 100000;
|
||||
|
||||
export enum BillSourceEnum {
|
||||
fastgpt = 'fastgpt',
|
||||
api = 'api',
|
||||
shareLink = 'shareLink',
|
||||
training = 'training',
|
||||
|
||||
standSubPlan = 'standSubPlan',
|
||||
extraDatasetSub = 'extraDatasetSub',
|
||||
extraPoints = 'extraPoints'
|
||||
extraDatasetSub = 'extraDatasetSub'
|
||||
}
|
||||
export const billTypeMap = {
|
||||
[BillTypeEnum.balance]: {
|
||||
label: 'support.wallet.subscription.type.balance'
|
||||
|
||||
export const BillSourceMap = {
|
||||
[BillSourceEnum.fastgpt]: {
|
||||
label: '在线使用'
|
||||
},
|
||||
[BillTypeEnum.standSubPlan]: {
|
||||
[BillSourceEnum.api]: {
|
||||
label: 'Api'
|
||||
},
|
||||
[BillSourceEnum.shareLink]: {
|
||||
label: '免登录链接'
|
||||
},
|
||||
[BillSourceEnum.training]: {
|
||||
label: 'dataset.Training Name'
|
||||
},
|
||||
[BillSourceEnum.standSubPlan]: {
|
||||
label: 'support.wallet.subscription.type.standard'
|
||||
},
|
||||
[BillTypeEnum.extraDatasetSub]: {
|
||||
[BillSourceEnum.extraDatasetSub]: {
|
||||
label: 'support.wallet.subscription.type.extraDatasetSize'
|
||||
},
|
||||
[BillTypeEnum.extraPoints]: {
|
||||
label: 'support.wallet.subscription.type.extraPoints'
|
||||
}
|
||||
};
|
||||
|
||||
export enum BillStatusEnum {
|
||||
SUCCESS = 'SUCCESS',
|
||||
REFUND = 'REFUND',
|
||||
NOTPAY = 'NOTPAY',
|
||||
CLOSED = 'CLOSED'
|
||||
}
|
||||
export const billStatusMap = {
|
||||
[BillStatusEnum.SUCCESS]: {
|
||||
label: 'support.wallet.bill.status.success'
|
||||
},
|
||||
[BillStatusEnum.REFUND]: {
|
||||
label: 'support.wallet.bill.status.refund'
|
||||
},
|
||||
[BillStatusEnum.NOTPAY]: {
|
||||
label: 'support.wallet.bill.status.notpay'
|
||||
},
|
||||
[BillStatusEnum.CLOSED]: {
|
||||
label: 'support.wallet.bill.status.closed'
|
||||
}
|
||||
};
|
||||
|
||||
export enum BillPayWayEnum {
|
||||
balance = 'balance',
|
||||
wx = 'wx'
|
||||
}
|
||||
export const billPayWayMap = {
|
||||
[BillPayWayEnum.balance]: {
|
||||
label: 'support.wallet.bill.payWay.balance'
|
||||
},
|
||||
[BillPayWayEnum.wx]: {
|
||||
label: 'support.wallet.bill.payWay.wx'
|
||||
}
|
||||
};
|
||||
|
||||
export const SUB_DATASET_SIZE_RATE = 1000;
|
||||
export const SUB_EXTRA_POINT_RATE = 1000000;
|
||||
|
26
packages/global/support/wallet/bill/tools.ts
Normal file
26
packages/global/support/wallet/bill/tools.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/* bill common */
|
||||
import { PRICE_SCALE } from './constants';
|
||||
import { BillSourceEnum } from './constants';
|
||||
import { AuthUserTypeEnum } from '../../permission/constant';
|
||||
|
||||
/**
|
||||
* dataset price / PRICE_SCALE = real price
|
||||
*/
|
||||
export const formatStorePrice2Read = (val = 0, multiple = 1) => {
|
||||
return Number(((val / PRICE_SCALE) * multiple).toFixed(10));
|
||||
};
|
||||
export const formatModelPrice2Read = (val = 0) => {
|
||||
return Number((val / 1000).toFixed(10));
|
||||
};
|
||||
|
||||
export const getBillSourceByAuthType = ({
|
||||
shareId,
|
||||
authType
|
||||
}: {
|
||||
shareId?: string;
|
||||
authType?: `${AuthUserTypeEnum}`;
|
||||
}) => {
|
||||
if (shareId) return BillSourceEnum.shareLink;
|
||||
if (authType === AuthUserTypeEnum.apikey) return BillSourceEnum.api;
|
||||
return BillSourceEnum.fastgpt;
|
||||
};
|
56
packages/global/support/wallet/bill/type.d.ts
vendored
56
packages/global/support/wallet/bill/type.d.ts
vendored
@@ -1,29 +1,35 @@
|
||||
import { StandardSubLevelEnum, SubModeEnum, SubTypeEnum } from '../sub/constants';
|
||||
import { BillPayWayEnum, BillTypeEnum } from './constants';
|
||||
import { CreateBillProps } from './api';
|
||||
import { BillSourceEnum } from './constants';
|
||||
|
||||
export type BillSchemaType = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
createTime: Date;
|
||||
orderId: string;
|
||||
status: 'SUCCESS' | 'REFUND' | 'NOTPAY' | 'CLOSED';
|
||||
type: `${BillTypeEnum}`;
|
||||
price: number;
|
||||
metadata: {
|
||||
payWay: `${BillPayWayEnum}`;
|
||||
subMode?: `${SubModeEnum}`;
|
||||
standSubLevel?: `${StandardSubLevelEnum}`;
|
||||
month?: number;
|
||||
datasetSize?: number;
|
||||
extraPoints?: number;
|
||||
};
|
||||
export type BillListItemCountType = {
|
||||
inputTokens?: number;
|
||||
outputTokens?: number;
|
||||
charsLength?: number;
|
||||
duration?: number;
|
||||
|
||||
// sub
|
||||
datasetSize?: number;
|
||||
|
||||
// abandon
|
||||
tokenLen?: number;
|
||||
};
|
||||
|
||||
export type ChatModuleBillType = {
|
||||
totalPoints: number;
|
||||
export type BillListItemType = BillListItemCountType & {
|
||||
moduleName: string;
|
||||
model: string;
|
||||
charsLength: number;
|
||||
amount: number;
|
||||
model?: string;
|
||||
};
|
||||
|
||||
export type BillSchema = CreateBillProps & {
|
||||
_id: string;
|
||||
time: Date;
|
||||
};
|
||||
|
||||
export type BillItemType = {
|
||||
id: string;
|
||||
// memberName: string;
|
||||
time: Date;
|
||||
appName: string;
|
||||
source: BillSchema['source'];
|
||||
total: number;
|
||||
list: BillSchema['list'];
|
||||
};
|
||||
|
Reference in New Issue
Block a user