Revert "sub plan page (#885)" (#886)

This reverts commit 443ad37b6a.
This commit is contained in:
Archer
2024-02-23 17:48:15 +08:00
committed by GitHub
parent 443ad37b6a
commit fd9b6291af
246 changed files with 4281 additions and 6286 deletions

View File

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

View File

@@ -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;

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

View File

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

View File

@@ -1,3 +0,0 @@
// model price: xxx/1k tokens
// ¥1 = 100000.
export const PRICE_SCALE = 100000;

View File

@@ -0,0 +1,41 @@
export enum PayTypeEnum {
balance = 'balance',
subStandard = 'subStandard',
subExtraDatasetSize = 'subExtraDatasetSize',
subExtraPoints = 'subExtraPoints'
}
export const payTypeMap = {
[PayTypeEnum.balance]: {
label: 'support.user.team.pay.type.balance'
},
[PayTypeEnum.subStandard]: {
label: 'support.wallet.subscription.type.standard'
},
[PayTypeEnum.subExtraDatasetSize]: {
label: 'support.wallet.subscription.type.extraDatasetSize'
},
[PayTypeEnum.subExtraPoints]: {
label: 'support.wallet.subscription.type.extraPoints'
}
};
export enum PayStatusEnum {
SUCCESS = 'SUCCESS',
REFUND = 'REFUND',
NOTPAY = 'NOTPAY',
CLOSED = 'CLOSED'
}
export const payStatusMap = {
[PayStatusEnum.SUCCESS]: {
label: 'support.user.team.pay.status.success'
},
[PayStatusEnum.REFUND]: {
label: 'support.user.team.pay.status.refund'
},
[PayStatusEnum.NOTPAY]: {
label: 'support.user.team.pay.status.notpay'
},
[PayStatusEnum.CLOSED]: {
label: 'support.user.team.pay.status.closed'
}
};

View File

@@ -0,0 +1,18 @@
import { SubModeEnum, SubTypeEnum } from '../sub/constants';
import { PayTypeEnum } from './constants';
export type PaySchema = {
_id: string;
userId: string;
teamId: string;
tmbId: string;
createTime: Date;
orderId: string;
status: 'SUCCESS' | 'REFUND' | 'NOTPAY' | 'CLOSED';
type: `${PayType}`;
price: number;
payWay: 'balance' | 'wx';
subMetadata: {};
};

View File

@@ -1,14 +1,26 @@
import { StandardSubLevelEnum, SubModeEnum } from './constants';
import { TeamSubSchema } from './type.d';
export type SubDatasetSizeParams = {
size: number;
};
export type StandardSubPlanParams = {
level: `${StandardSubLevelEnum}`;
mode: `${SubModeEnum}`;
};
export type SubDatasetSizePreviewCheckResponse = {
payForNewSub: boolean; // Does this change require payment
newSubSize: number; // new sub dataset size
alreadySubSize: number; // old sub dataset size
payPrice: number; // this change require payment
newPlanPrice: number; // the new sub price
newSubStartTime: Date;
newSubExpiredTime: Date;
balanceEnough: boolean; // team balance is enough
};
export type StandardSubPlanUpdateResponse = {
balanceEnough: boolean; // team balance is enough
teamBalance: number;
payPrice?: number;
planPrice: number;
planPointPrice: number;

View File

@@ -1,3 +1,5 @@
export const POINTS_SCALE = 10000;
export enum SubTypeEnum {
standard = 'standard',
extraDatasetSize = 'extraDatasetSize',
@@ -17,16 +19,20 @@ export const subTypeMap = {
export enum SubStatusEnum {
active = 'active',
expired = 'expired'
canceled = 'canceled'
}
export const subStatusMap = {
[SubStatusEnum.active]: {
label: 'support.wallet.subscription.status.active'
},
[SubStatusEnum.expired]: {
[SubStatusEnum.canceled]: {
label: 'support.wallet.subscription.status.canceled'
}
};
export const subSelectMap = {
true: SubStatusEnum.active,
false: SubStatusEnum.canceled
};
export enum SubModeEnum {
month = 'month',
@@ -34,11 +40,11 @@ export enum SubModeEnum {
}
export const subModeMap = {
[SubModeEnum.month]: {
label: 'support.wallet.subscription.mode.Month',
label: 'support.wallet.subscription.mode.month',
durationMonth: 1
},
[SubModeEnum.year]: {
label: 'support.wallet.subscription.mode.Year',
label: 'support.wallet.subscription.mode.year',
durationMonth: 12
}
};
@@ -57,7 +63,7 @@ export const standardSubLevelMap = {
},
[StandardSubLevelEnum.experience]: {
label: 'support.wallet.subscription.standardSubLevel.experience',
desc: ''
desc: 'support.wallet.subscription.standardSubLevel.experience desc'
},
[StandardSubLevelEnum.team]: {
label: 'support.wallet.subscription.standardSubLevel.team',

View File

@@ -2,19 +2,19 @@ import { StandardSubLevelEnum, SubModeEnum, SubStatusEnum, SubTypeEnum } from '.
// Content of plan
export type TeamStandardSubPlanItemType = {
price: number; // read price / month
pointPrice: number; // read price/ one thousand
totalPoints: number; // n
price: number; // read price
pointPrice: number; // read price/ one ten thousand
maxTeamMember: number;
maxAppAmount: number; // max app or plugin amount
maxDatasetAmount: number;
chatHistoryStoreDuration: number; // n day
maxDatasetSize: number;
customApiKey: boolean;
customCopyright: boolean; // feature
websiteSyncInterval: number; // n hours
trainingWeight: number; // 1~4
permissionCustomApiKey: boolean;
permissionCustomCopyright: boolean; // feature
permissionWebsiteSync: boolean;
permissionReRank: boolean;
reRankWeight: number; // 1~4
totalPoints: number; // n ten thousand
};
export type StandSubPlanLevelMapType = Record<
@@ -27,9 +27,6 @@ export type SubPlanType = {
[SubTypeEnum.extraDatasetSize]: {
price: number;
};
[SubTypeEnum.extraPoints]: {
price: number;
};
};
export type TeamSubSchema = {
@@ -37,32 +34,40 @@ export type TeamSubSchema = {
teamId: string;
type: `${SubTypeEnum}`;
status: `${SubStatusEnum}`;
currentMode: `${SubModeEnum}`;
nextMode: `${SubModeEnum}`;
startTime: Date;
expiredTime: Date;
price: number;
currentMode: `${SubModeEnum}`;
nextMode: `${SubModeEnum}`;
currentSubLevel: `${StandardSubLevelEnum}`;
nextSubLevel: `${StandardSubLevelEnum}`;
pointPrice: number;
totalPoints: number;
surplusPoints: number;
currentExtraDatasetSize: number;
nextExtraDatasetSize: number;
currentExtraPoints: number;
nextExtraPoints: number;
surplusPoints: number;
// abandon
datasetStoreAmount?: number;
renew?: boolean;
};
export type FeTeamPlanStatusType = {
export type FeTeamSubType = {
[SubTypeEnum.standard]?: TeamSubSchema;
standardConstants?: TeamStandardSubPlanItemType;
[SubTypeEnum.extraDatasetSize]?: TeamSubSchema;
[SubTypeEnum.extraPoints]?: TeamSubSchema;
standardMaxDatasetSize: number;
totalPoints: number;
usedPoints: number;
standardMaxDatasetSize?: number;
standardMaxPoints?: number;
// standard + extra
standardMaxPoints: number;
datasetMaxSize: number;
usedDatasetSize: number;
};

View File

@@ -1,26 +0,0 @@
import { UsageSourceEnum } from './constants';
import { UsageListItemCountType, UsageListItemType } from './type';
export type CreateTrainingUsageProps = {
name: string;
datasetId: string;
};
export type ConcatUsageProps = UsageListItemCountType & {
teamId: string;
tmbId: string;
billId?: string;
totalPoints: number;
listIndex?: number;
};
export type CreateUsageProps = {
teamId: string;
tmbId: string;
appName: string;
appId?: string;
totalPoints: number;
// inputTokens: number;
source: `${UsageSourceEnum}`;
list: UsageListItemType[];
};

View File

@@ -1,21 +0,0 @@
export enum UsageSourceEnum {
fastgpt = 'fastgpt',
api = 'api',
shareLink = 'shareLink',
training = 'training'
}
export const UsageSourceMap = {
[UsageSourceEnum.fastgpt]: {
label: '在线使用'
},
[UsageSourceEnum.api]: {
label: 'Api'
},
[UsageSourceEnum.shareLink]: {
label: '免登录链接'
},
[UsageSourceEnum.training]: {
label: 'dataset.Training Name'
}
};

View File

@@ -1,23 +0,0 @@
/* bill common */
import { PRICE_SCALE } from '../constants';
import { UsageSourceEnum } 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 getUsageSourceByAuthType = ({
shareId,
authType
}: {
shareId?: string;
authType?: `${AuthUserTypeEnum}`;
}) => {
if (shareId) return UsageSourceEnum.shareLink;
if (authType === AuthUserTypeEnum.apikey) return UsageSourceEnum.api;
return UsageSourceEnum.fastgpt;
};

View File

@@ -1,26 +0,0 @@
import { CreateUsageProps } from './api';
import { UsageSourceEnum } from './constants';
export type UsageListItemCountType = {
charsLength?: number;
duration?: number;
};
export type UsageListItemType = UsageListItemCountType & {
moduleName: string;
amount: number;
model?: string;
};
export type UsageSchemaType = CreateUsageProps & {
_id: string;
time: Date;
};
export type UsageItemType = {
id: string;
time: Date;
appName: string;
source: UsageSchemaType['source'];
totalPoints: number;
list: UsageSchemaType['list'];
};