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
94bf654c
authored
Aug 10, 2026
by
Archer
Committed by
GitHub
Aug 10, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: localize invalid coupon errors (#7483)
parent
17317ba4
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
70 additions
and
6 deletions
+70
-6
packages/global/common/error/code/coupon.ts
+22
-0
packages/global/common/error/errorCode.ts
+3
-1
packages/global/openapi/support/wallet/coupon/api.ts
+12
-0
packages/global/openapi/support/wallet/coupon/index.ts
+20
-0
packages/global/openapi/support/wallet/index.ts
+3
-1
packages/web/i18n/en/common.json
+1
-0
packages/web/i18n/zh-CN/common.json
+1
-0
packages/web/i18n/zh-Hant/common.json
+1
-0
pro
+1
-1
projects/app/src/components/Layout/hooks/checkCoupon.ts
+2
-1
projects/app/src/pageComponents/account/info/RedeemCouponModal.tsx
+1
-1
projects/app/src/web/support/marketing/utils.ts
+3
-1
No files found.
packages/global/common/error/code/coupon.ts
0 → 100644
View file @
94bf654c
import
{
i18nT
}
from
'../../i18n/utils'
;
import
type
{
ErrType
}
from
'../errorCode'
;
/* coupon: 512000 */
export
enum
CouponErrEnum
{
invalid
=
'invalidCoupon'
}
const
couponErr
=
[{
statusText
:
CouponErrEnum
.
invalid
,
message
:
i18nT
(
'common:coupon_invalid'
)
}];
export
default
couponErr
.
reduce
(
(
acc
,
cur
,
index
)
=>
({
...
acc
,
[
cur
.
statusText
]:
{
code
:
512000
+
index
,
statusText
:
cur
.
statusText
,
message
:
cur
.
message
,
data
:
null
}
}),
{}
as
ErrType
<
`
${
CouponErrEnum
}
`
>
);
packages/global/common/error/errorCode.ts
View file @
94bf654c
...
@@ -11,6 +11,7 @@ import s3Err from './code/s3';
...
@@ -11,6 +11,7 @@ import s3Err from './code/s3';
import
SystemErrEnum
from
'./code/system'
;
import
SystemErrEnum
from
'./code/system'
;
import
agentSkillErr
from
'./code/skill'
;
import
agentSkillErr
from
'./code/skill'
;
import
sandboxErr
from
'./code/sandbox'
;
import
sandboxErr
from
'./code/sandbox'
;
import
couponErr
from
'./code/coupon'
;
import
{
i18nT
}
from
'../i18n/utils'
;
import
{
i18nT
}
from
'../i18n/utils'
;
export
const
ERROR_CODE
:
{
[
key
:
number
]:
string
}
=
{
export
const
ERROR_CODE
:
{
[
key
:
number
]:
string
}
=
{
...
@@ -131,5 +132,6 @@ export const ERROR_RESPONSE: Record<
...
@@ -131,5 +132,6 @@ export const ERROR_RESPONSE: Record<
...
s3Err
,
...
s3Err
,
...
SystemErrEnum
,
...
SystemErrEnum
,
...
agentSkillErr
,
...
agentSkillErr
,
...
sandboxErr
...
sandboxErr
,
...
couponErr
};
};
packages/global/openapi/support/wallet/coupon/api.ts
0 → 100644
View file @
94bf654c
import
z
from
'zod'
;
export
const
RedeemCouponQuerySchema
=
z
.
object
({
key
:
z
.
string
().
trim
().
min
(
1
).
meta
({
description
:
'兑换码'
,
example
:
'AbCdEfGhIjKlMnOpQrStUvWx'
})
});
export
type
RedeemCouponQueryType
=
z
.
infer
<
typeof
RedeemCouponQuerySchema
>
;
export
const
RedeemCouponResponseSchema
=
z
.
undefined
().
meta
({
description
:
'兑换成功'
});
export
type
RedeemCouponResponseType
=
z
.
infer
<
typeof
RedeemCouponResponseSchema
>
;
packages/global/openapi/support/wallet/coupon/index.ts
0 → 100644
View file @
94bf654c
import
type
{
OpenAPIPath
}
from
'../../../type'
;
import
{
DevApiTagsMap
}
from
'../../../tag'
;
import
{
RedeemCouponQuerySchema
,
RedeemCouponResponseSchema
}
from
'./api'
;
export
const
CouponPath
:
OpenAPIPath
=
{
'/support/wallet/coupon/redeem'
:
{
get
:
{
summary
:
'兑换兑换码'
,
description
:
'使用团队兑换码兑换订阅、积分或数据集容量'
,
tags
:
[
DevApiTagsMap
.
walletDiscountCoupon
],
requestParams
:
{
query
:
RedeemCouponQuerySchema
},
responses
:
{
200
:
{
description
:
'兑换成功'
,
content
:
{
'application/json'
:
{
schema
:
RedeemCouponResponseSchema
}
}
}
}
}
}
};
packages/global/openapi/support/wallet/index.ts
View file @
94bf654c
import
type
{
OpenAPIPath
}
from
'../../type'
;
import
type
{
OpenAPIPath
}
from
'../../type'
;
import
{
BillPath
}
from
'./bill'
;
import
{
BillPath
}
from
'./bill'
;
import
{
DiscountCouponPath
}
from
'./discountCoupon'
;
import
{
DiscountCouponPath
}
from
'./discountCoupon'
;
import
{
CouponPath
}
from
'./coupon'
;
export
const
WalletPath
:
OpenAPIPath
=
{
export
const
WalletPath
:
OpenAPIPath
=
{
...
BillPath
,
...
BillPath
,
...
DiscountCouponPath
...
DiscountCouponPath
,
...
CouponPath
};
};
packages/web/i18n/en/common.json
View file @
94bf654c
...
@@ -696,6 +696,7 @@
...
@@ -696,6 +696,7 @@
"core.workflow.tool.Select Tool"
:
"Select Tool"
,
"core.workflow.tool.Select Tool"
:
"Select Tool"
,
"core.workflow.variable"
:
"Variable"
,
"core.workflow.variable"
:
"Variable"
,
"coupon_expired"
:
"Coupon has expired"
,
"coupon_expired"
:
"Coupon has expired"
,
"coupon_invalid"
:
"Invalid coupon"
,
"coupon_not_exist"
:
"Coupon does not exist"
,
"coupon_not_exist"
:
"Coupon does not exist"
,
"coupon_not_start"
:
"Coupon is not yet effective"
,
"coupon_not_start"
:
"Coupon is not yet effective"
,
"coupon_redeem_failed"
:
"Coupon redeemed failed"
,
"coupon_redeem_failed"
:
"Coupon redeemed failed"
,
...
...
packages/web/i18n/zh-CN/common.json
View file @
94bf654c
...
@@ -696,6 +696,7 @@
...
@@ -696,6 +696,7 @@
"core.workflow.tool.Select Tool"
:
"选择工具"
,
"core.workflow.tool.Select Tool"
:
"选择工具"
,
"core.workflow.variable"
:
"变量"
,
"core.workflow.variable"
:
"变量"
,
"coupon_expired"
:
"优惠券已过期"
,
"coupon_expired"
:
"优惠券已过期"
,
"coupon_invalid"
:
"兑换码无效"
,
"coupon_not_exist"
:
"优惠券不存在"
,
"coupon_not_exist"
:
"优惠券不存在"
,
"coupon_not_start"
:
"优惠券未生效"
,
"coupon_not_start"
:
"优惠券未生效"
,
"coupon_redeem_failed"
:
"优惠券核销失败"
,
"coupon_redeem_failed"
:
"优惠券核销失败"
,
...
...
packages/web/i18n/zh-Hant/common.json
View file @
94bf654c
...
@@ -691,6 +691,7 @@
...
@@ -691,6 +691,7 @@
"core.workflow.tool.Select Tool"
:
"選擇工具"
,
"core.workflow.tool.Select Tool"
:
"選擇工具"
,
"core.workflow.variable"
:
"變數"
,
"core.workflow.variable"
:
"變數"
,
"coupon_expired"
:
"優惠券已過期"
,
"coupon_expired"
:
"優惠券已過期"
,
"coupon_invalid"
:
"兌換碼無效"
,
"coupon_not_exist"
:
"優惠券不存在"
,
"coupon_not_exist"
:
"優惠券不存在"
,
"coupon_not_start"
:
"優惠券未生效"
,
"coupon_not_start"
:
"優惠券未生效"
,
"coupon_redeem_failed"
:
"優惠券核銷失敗"
,
"coupon_redeem_failed"
:
"優惠券核銷失敗"
,
...
...
pro
@
eb388829
Subproject commit
97d9bb623b33ff23d76810a873c3c90168254e36
Subproject commit
eb388829552c8a95ef926f86f0b7d815ea0d3a91
projects/app/src/components/Layout/hooks/checkCoupon.ts
View file @
94bf654c
...
@@ -2,6 +2,7 @@ import { useEffect } from 'react';
...
@@ -2,6 +2,7 @@ import { useEffect } from 'react';
import
{
getCouponCode
,
removeCouponCode
}
from
'@/web/support/marketing/utils'
;
import
{
getCouponCode
,
removeCouponCode
}
from
'@/web/support/marketing/utils'
;
import
{
redeemCoupon
}
from
'@/web/support/user/team/api'
;
import
{
redeemCoupon
}
from
'@/web/support/user/team/api'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
CouponErrEnum
}
from
'@fastgpt/global/common/error/code/coupon'
;
export
const
useCheckCoupon
=
()
=>
{
export
const
useCheckCoupon
=
()
=>
{
const
{
userInfo
}
=
useUserStore
();
const
{
userInfo
}
=
useUserStore
();
...
@@ -15,7 +16,7 @@ export const useCheckCoupon = () => {
...
@@ -15,7 +16,7 @@ export const useCheckCoupon = () => {
redeemCoupon
(
couponCode
)
redeemCoupon
(
couponCode
)
.
then
(
removeCouponCode
)
.
then
(
removeCouponCode
)
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
if
(
err
?.
message
===
'Invalid coupon'
)
{
if
(
err
?.
statusText
===
CouponErrEnum
.
invalid
)
{
removeCouponCode
();
removeCouponCode
();
}
}
});
});
...
...
projects/app/src/pageComponents/account/info/RedeemCouponModal.tsx
View file @
94bf654c
...
@@ -46,7 +46,7 @@ const RedeemCouponModal = ({
...
@@ -46,7 +46,7 @@ const RedeemCouponModal = ({
<
Button
variant=
{
'whiteBase'
}
onClick=
{
onClose
}
>
<
Button
variant=
{
'whiteBase'
}
onClick=
{
onClose
}
>
{
t
(
'account_info:cancel'
)
}
{
t
(
'account_info:cancel'
)
}
</
Button
>
</
Button
>
<
Button
ml=
{
2
}
isLoading=
{
loading
}
onClick=
{
()
=>
redeemCouponAsync
(
couponCode
)
}
>
<
Button
ml=
{
2
}
isLoading=
{
loading
}
onClick=
{
()
=>
redeemCouponAsync
(
couponCode
.
trim
()
)
}
>
{
t
(
'account_info:confirm'
)
}
{
t
(
'account_info:confirm'
)
}
</
Button
>
</
Button
>
</
ModalFooter
>
</
ModalFooter
>
...
...
projects/app/src/web/support/marketing/utils.ts
View file @
94bf654c
...
@@ -121,7 +121,9 @@ export const initFastGPTSemSourceDomain = (sourceDomain?: string) => {
...
@@ -121,7 +121,9 @@ export const initFastGPTSemSourceDomain = (sourceDomain?: string) => {
export
const
setCouponCode
=
(
couponCode
?:
string
)
=>
{
export
const
setCouponCode
=
(
couponCode
?:
string
)
=>
{
if
(
!
couponCode
)
return
;
if
(
!
couponCode
)
return
;
localStorage
.
setItem
(
'couponCode'
,
couponCode
);
const
normalizedCouponCode
=
couponCode
.
trim
();
if
(
!
normalizedCouponCode
)
return
;
localStorage
.
setItem
(
'couponCode'
,
normalizedCouponCode
);
};
};
export
const
getCouponCode
=
()
=>
{
export
const
getCouponCode
=
()
=>
{
...
...
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