-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: heheer <[email protected]>
- Loading branch information
1 parent
aab6ee5
commit 379673c
Showing
143 changed files
with
40,734 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
// The number of days left in the month is calculated as 30 days per month, and less than 1 day is calculated as 1 day | ||
export const getMonthRemainingDays = () => { | ||
const now = new Date(); | ||
const year = now.getFullYear(); | ||
const month = now.getMonth(); | ||
const date = now.getDate(); | ||
const days = new Date(year, month + 1, 0).getDate(); | ||
const remainingDays = days - date; | ||
return remainingDays + 1; | ||
export const getMonthRemainingDays = (startDate = new Date()) => { | ||
const year = startDate.getFullYear(); | ||
const month = startDate.getMonth(); | ||
const endDay = new Date(year, month + 1, 0, 0, 0, 0); | ||
return calculateDaysBetweenDates(startDate, endDay); | ||
}; | ||
|
||
export const calculateDaysBetweenDates = (date1: Date, date2: Date) => { | ||
const oneDay = 24 * 60 * 60 * 1000; | ||
const firstDate = new Date(date1).getTime(); | ||
const secondDate = new Date(date2).getTime(); | ||
|
||
const differenceInTime = Math.abs(secondDate - firstDate); | ||
const differenceInDays = Math.floor(differenceInTime / oneDay); | ||
|
||
return differenceInDays; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.user.team.subscription.type.standard' | ||
}, | ||
[PayTypeEnum.subExtraDatasetSize]: { | ||
label: 'support.user.team.subscription.type.extraDatasetSize' | ||
}, | ||
[PayTypeEnum.subExtraPoints]: { | ||
label: 'support.user.team.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' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +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; | ||
price: number; | ||
orderId: string; | ||
status: 'SUCCESS' | 'REFUND' | 'NOTPAY' | 'CLOSED'; | ||
type: `${PayType}`; | ||
|
||
price: number; | ||
payWay: 'balance' | 'wx'; | ||
|
||
subMetadata: {}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
import { SubModeEnum } from './constants'; | ||
|
||
export type SubDatasetSizeParams = { | ||
size: number; | ||
renew: boolean; | ||
}; | ||
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 | ||
newPrice: number; // the new sub price | ||
newSubStartTime: Date; | ||
newSubExpiredTime: Date; | ||
balanceEnough: boolean; // team balance is enough | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,73 @@ | ||
export enum SubTypeEnum { | ||
datasetStore = 'datasetStore' | ||
standard = 'standard', | ||
extraDatasetSize = 'extraDatasetSize', | ||
extraPoints = 'extraPoints' | ||
} | ||
|
||
export const subTypeMap = { | ||
[SubTypeEnum.datasetStore]: { | ||
label: 'support.user.team.subscription.type.datasetStore' | ||
[SubTypeEnum.standard]: { | ||
label: 'support.user.team.subscription.type.standard' | ||
}, | ||
[SubTypeEnum.extraDatasetSize]: { | ||
label: 'support.user.team.subscription.type.extraDatasetSize' | ||
}, | ||
[SubTypeEnum.extraPoints]: { | ||
label: 'support.user.team.subscription.type.extraPoints' | ||
} | ||
}; | ||
|
||
export enum SubStatusEnum { | ||
active = 'active', | ||
canceled = 'canceled' | ||
} | ||
export const subStatusMap = { | ||
[SubStatusEnum.active]: { | ||
label: 'support.user.team.subscription.status.active' | ||
}, | ||
[SubStatusEnum.canceled]: { | ||
label: 'support.user.team.subscription.status.canceled' | ||
} | ||
}; | ||
export const subSelectMap = { | ||
true: SubStatusEnum.active, | ||
false: SubStatusEnum.canceled | ||
}; | ||
|
||
export enum SubModeEnum { | ||
month = 'month', | ||
year = 'year' | ||
} | ||
|
||
export const subModeMap = { | ||
[SubModeEnum.month]: { | ||
label: 'support.user.team.subscription.mode.month' | ||
label: 'support.user.team.subscription.mode.month', | ||
durationMonth: 1 | ||
}, | ||
[SubModeEnum.year]: { | ||
label: 'support.user.team.subscription.mode.year' | ||
label: 'support.user.team.subscription.mode.year', | ||
durationMonth: 12 | ||
} | ||
}; | ||
|
||
export enum SubStatusEnum { | ||
active = 'active', | ||
expired = 'expired' | ||
export enum StandardSubLevelEnum { | ||
free = 'free', | ||
experience = 'experience', | ||
team = 'team', | ||
enterprise = 'enterprise', | ||
custom = 'custom' | ||
} | ||
|
||
export const subStatusMap = { | ||
[SubStatusEnum.active]: { | ||
label: 'support.user.team.subscription.status.active' | ||
export const standardSubLevelMap = { | ||
[StandardSubLevelEnum.free]: { | ||
label: 'support.user.team.subscription.standardSubLevel.free' | ||
}, | ||
[StandardSubLevelEnum.experience]: { | ||
label: 'support.user.team.subscription.standardSubLevel.experience' | ||
}, | ||
[StandardSubLevelEnum.team]: { | ||
label: 'support.user.team.subscription.standardSubLevel.team' | ||
}, | ||
[StandardSubLevelEnum.enterprise]: { | ||
label: 'support.user.team.subscription.standardSubLevel.enterprise' | ||
}, | ||
[SubStatusEnum.expired]: { | ||
label: 'support.user.team.subscription.status.expired' | ||
[StandardSubLevelEnum.custom]: { | ||
label: 'support.user.team.subscription.standardSubLevel.custom' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
import { SubModeEnum, SubStatusEnum, SubTypeEnum } from './constants'; | ||
import { StandardSubLevelEnum, SubModeEnum, SubStatusEnum, SubTypeEnum } from './constants'; | ||
|
||
export type TeamSubSchema = { | ||
_id: string; | ||
teamId: string; | ||
type: `${SubTypeEnum}`; | ||
mode: `${SubModeEnum}`; | ||
status: `${SubStatusEnum}`; | ||
renew: boolean; | ||
mode: `${SubModeEnum}`; | ||
startTime: Date; | ||
expiredTime: Date; | ||
price: number; | ||
|
||
currentSubLevel?: `${StandardSubLevelEnum}`; | ||
nextSubLevel?: `${StandardSubLevelEnum}`; | ||
|
||
currentExtraDatasetSize?: number; | ||
nextExtraDatasetSize?: number; | ||
|
||
currentExtraPoints?: number; | ||
nextExtraPoints?: number; | ||
|
||
maxTeamMember?: number; | ||
maxAppAmount?: number; | ||
maxDatasetAmount?: number; | ||
chatHistoryStoreDuration?: number; | ||
maxDatasetSize?: number; | ||
customApiKey?: boolean; | ||
customCopyright?: number; | ||
exportDatasetInterval?: number; | ||
websiteSyncInterval?: number; | ||
reRankWeight?: number; | ||
totalPoints?: number; | ||
|
||
surplusPoints?: number; | ||
|
||
// abandon | ||
datasetStoreAmount?: number; | ||
renew?: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.