Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
25d6bb7d
authored
Mar 24, 2026
by
Archer
Committed by
GitHub
Mar 24, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update coupon type (#6623)
parent
76c2d30a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
35 deletions
+53
-35
packages/global/support/wallet/sub/coupon/constants.ts
+1
-0
packages/global/support/wallet/sub/coupon/type.ts
+41
-33
packages/service/support/wallet/coupon/schema.ts
+11
-2
No files found.
packages/global/support/wallet/sub/coupon/constants.ts
View file @
25d6bb7d
export
const
COUPON_PREFIX
=
'coupon-'
;
export
const
COUPON_PREFIX
=
'coupon-'
;
export
const
BANK_PREFIX
=
'bank-'
;
export
enum
CouponTypeEnum
{
export
enum
CouponTypeEnum
{
bank
=
'bank'
,
bank
=
'bank'
,
...
...
packages/global/support/wallet/sub/coupon/type.ts
View file @
25d6bb7d
import
type
{
SubTypeEnum
,
StandardSubLevelEnum
}
from
'../constants'
;
import
z
from
'zod'
;
import
type
{
CouponTypeEnum
}
from
'./constants'
;
import
{
SubTypeEnum
,
StandardSubLevelEnum
}
from
'../constants'
;
import
{
CouponTypeEnum
}
from
'./constants'
;
export
type
CustomSubConfig
=
{
const
CustomSubConfigSchema
=
z
.
object
({
requestsPerMinute
:
number
;
requestsPerMinute
:
z
.
number
(),
maxTeamMember
:
number
;
maxTeamMember
:
z
.
number
(),
maxAppAmount
:
number
;
maxAppAmount
:
z
.
number
(),
maxDatasetAmount
:
number
;
maxDatasetAmount
:
z
.
number
(),
chatHistoryStoreDuration
:
number
;
chatHistoryStoreDuration
:
z
.
number
(),
maxDatasetSize
:
number
;
maxDatasetSize
:
z
.
number
(),
websiteSyncPerDataset
:
number
;
websiteSyncPerDataset
:
z
.
number
(),
appRegistrationCount
:
number
;
appRegistrationCount
:
z
.
number
(),
auditLogStoreDuration
:
number
;
auditLogStoreDuration
:
z
.
number
(),
ticketResponseTime
:
number
;
ticketResponseTime
:
z
.
number
(),
customDomain
:
number
;
customDomain
:
z
.
number
(),
};
enableSandbox
:
z
.
boolean
().
optional
()
});
export
type
CustomSubConfig
=
z
.
infer
<
typeof
CustomSubConfigSchema
>
;
export
type
TeamCouponSub
=
{
const
TeamCouponSubSchema
=
z
.
object
({
type
:
`
${
SubTypeEnum
}
`
;
// Sub type
type
:
z
.
enum
(
SubTypeEnum
).
meta
({
description
:
'套餐类型'
}),
durationDay
:
number
;
// Duration day
durationDay
:
z
.
number
().
meta
({
description
:
'套餐时长'
}),
level
?:
`
${
StandardSubLevelEnum
}
`
;
// Standard sub level
level
:
z
.
enum
(
StandardSubLevelEnum
).
optional
().
meta
({
description
:
'套餐等级'
}),
extraDatasetSize
?:
number
;
// Extra dataset size
extraDatasetSize
:
z
.
number
().
optional
().
meta
({
description
:
'额外数据集大小'
}),
totalPoints
?:
number
;
// Total points(Extrapoints or Standard sub)
totalPoints
:
z
.
number
().
optional
().
meta
({
description
:
'总积分'
}),
customConfig
?:
CustomSubConfig
;
// Custom config for custom level (only required when level=custom)
customConfig
:
CustomSubConfigSchema
.
optional
().
meta
({
description
:
'自定义配置'
})
};
});
export
type
TeamCouponSub
=
z
.
infer
<
typeof
TeamCouponSubSchema
>
;
export
type
TeamCouponSchema
=
{
const
TeamCouponSchema
=
z
.
object
({
key
:
string
;
key
:
z
.
string
(),
subscriptions
:
TeamCouponSub
[];
subscriptions
:
z
.
array
(
TeamCouponSubSchema
).
meta
({
description
:
'套餐列表'
}),
redeemedAt
?:
Date
;
redeemedAt
:
z
.
date
().
optional
().
meta
({
description
:
'使用时间'
}),
expiredAt
?:
Date
;
expiredAt
:
z
.
date
().
optional
().
meta
({
description
:
'过期时间'
}),
redeemedTeamId
?:
string
;
redeemedTeamId
:
z
.
string
().
optional
().
meta
({
description
:
'使用团队 ID'
}),
type
:
CouponTypeEnum
;
type
:
z
.
enum
(
CouponTypeEnum
).
meta
({
description
:
'优惠券类型'
}),
price
?:
number
;
price
:
z
.
number
().
optional
().
meta
({
description
:
'价格'
}),
description
?:
string
;
paidAmount
:
z
.
number
().
optional
().
meta
({
description
:
'实付金额'
}),
};
transactionId
:
z
.
string
().
optional
().
meta
({
description
:
'交易 ID'
}),
description
:
z
.
string
().
optional
().
meta
({
description
:
'描述'
}),
createdAt
:
z
.
date
().
meta
({
description
:
'创建时间'
})
});
export
type
TeamCouponSchemaType
=
z
.
infer
<
typeof
TeamCouponSchema
>
;
packages/service/support/wallet/coupon/schema.ts
View file @
25d6bb7d
import
{
addDays
}
from
'date-fns'
;
import
{
addDays
}
from
'date-fns'
;
import
{
connectionMongo
,
getMongoModel
}
from
'../../../common/mongo'
;
import
{
connectionMongo
,
getMongoModel
}
from
'../../../common/mongo'
;
const
{
Schema
}
=
connectionMongo
;
const
{
Schema
}
=
connectionMongo
;
import
type
{
TeamCouponSchema
}
from
'@fastgpt/global/support/wallet/sub/coupon/type'
;
import
type
{
TeamCouponSchema
Type
}
from
'@fastgpt/global/support/wallet/sub/coupon/type'
;
import
{
TeamCollectionName
}
from
'@fastgpt/global/support/user/team/constant'
;
import
{
TeamCollectionName
}
from
'@fastgpt/global/support/user/team/constant'
;
import
{
CouponTypeEnum
}
from
'@fastgpt/global/support/wallet/sub/coupon/constants'
;
import
{
CouponTypeEnum
}
from
'@fastgpt/global/support/wallet/sub/coupon/constants'
;
import
{
getLogger
,
LogCategories
}
from
'../../../common/logger'
;
import
{
getLogger
,
LogCategories
}
from
'../../../common/logger'
;
...
@@ -18,11 +18,17 @@ const CouponSchema = new Schema({
...
@@ -18,11 +18,17 @@ const CouponSchema = new Schema({
enum
:
Object
.
values
(
CouponTypeEnum
)
enum
:
Object
.
values
(
CouponTypeEnum
)
},
},
price
:
Number
,
price
:
Number
,
paidAmount
:
Number
,
transactionId
:
String
,
description
:
String
,
description
:
String
,
subscriptions
:
{
subscriptions
:
{
type
:
[
Object
],
type
:
[
Object
],
required
:
true
required
:
true
},
},
createdAt
:
{
type
:
Date
,
default
:
()
=>
new
Date
()
},
redeemedAt
:
{
redeemedAt
:
{
type
:
Date
,
type
:
Date
,
default
:
undefined
default
:
undefined
...
@@ -44,4 +50,7 @@ try {
...
@@ -44,4 +50,7 @@ try {
logger
.
error
(
'Failed to build coupon indexes'
,
{
error
});
logger
.
error
(
'Failed to build coupon indexes'
,
{
error
});
}
}
export
const
MongoTeamCoupon
=
getMongoModel
<
TeamCouponSchema
>
(
couponCollectionName
,
CouponSchema
);
export
const
MongoTeamCoupon
=
getMongoModel
<
TeamCouponSchemaType
>
(
couponCollectionName
,
CouponSchema
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment