-
Notifications
You must be signed in to change notification settings - Fork 6.8k
adjust commercial plans #6008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
adjust commercial plans #6008
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f1d36d5
plan frontend
newfish-cmyk 309e635
plan limit
newfish-cmyk 2a69988
coupon
newfish-cmyk ebbca47
discount coupon
newfish-cmyk 8656f8f
fix
newfish-cmyk c6870fe
type
newfish-cmyk 1cf83e6
fix audit
newfish-cmyk f745f72
type
newfish-cmyk eab47a9
plan name
newfish-cmyk ea19a26
legacy plan
newfish-cmyk f1b2b6d
track
newfish-cmyk 838dae9
feat: add discount coupon
newfish-cmyk 253cba1
fix
newfish-cmyk e4f0094
fix discount coupon
newfish-cmyk 451219f
openapi
newfish-cmyk 8c70001
type
newfish-cmyk e29fa05
type
newfish-cmyk 9cb019c
env
newfish-cmyk 0e98af6
api type
newfish-cmyk a598994
fix
newfish-cmyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,81 @@ | ||
| import { z } from 'zod'; | ||
| import { ObjectIdSchema } from '../../../../common/type/mongo'; | ||
| import { | ||
| BillTypeEnum, | ||
| BillStatusEnum, | ||
| BillPayWayEnum | ||
| } from '../../../../support/wallet/bill/constants'; | ||
| import { StandardSubLevelEnum, SubModeEnum } from '../../../../support/wallet/sub/constants'; | ||
| import { PaginationSchema } from '../../../api'; | ||
| import { BillSchema } from '../../../../support/wallet/bill/type.d'; | ||
|
|
||
| export const BillListQuerySchema = PaginationSchema.extend({ | ||
| type: z.enum(Object.values(BillTypeEnum)).optional().meta({ description: '订单类型筛选' }) | ||
| }); | ||
| export type GetBillListQueryType = z.infer<typeof BillListQuerySchema>; | ||
|
|
||
| export const BillListResponseSchema = z.object({ | ||
| total: z.number(), | ||
| list: z.array(BillSchema) | ||
| }); | ||
| export type GetBillListResponseType = z.infer<typeof BillListResponseSchema>; | ||
|
|
||
| export const CreateStandPlanBillSchema = z.object({ | ||
| type: z.literal(BillTypeEnum.standSubPlan).meta({ description: '订单类型:标准订阅套餐' }), | ||
| level: z.enum(Object.values(StandardSubLevelEnum)).meta({ description: '标准订阅等级' }), | ||
| subMode: z.enum(Object.values(SubModeEnum)).meta({ description: '订阅周期' }), | ||
| discountCouponId: z.string().optional().meta({ description: '优惠券 ID' }) | ||
| }); | ||
| export const CreateExtractPointsBillSchema = z.object({ | ||
| type: z.literal(BillTypeEnum.extraPoints).meta({ description: '订单类型:额外积分' }), | ||
| extraPoints: z.number().meta({ description: '额外积分数量' }), | ||
| duration: z.number().meta({ description: '有效期(月)' }), | ||
| discountCouponId: z.string().optional().meta({ description: '优惠券 ID(未使用)' }) | ||
| }); | ||
| export const CreateExtractDatasetBillSchema = z.object({ | ||
| type: z.literal(BillTypeEnum.extraDatasetSub).meta({ description: '订单类型:额外数据集存储' }), | ||
| extraDatasetSize: z.number().meta({ description: '额外数据集大小' }), | ||
| month: z.number().meta({ description: '订阅月数' }), | ||
| discountCouponId: z.string().optional().meta({ description: '优惠券 ID(未使用)' }) | ||
| }); | ||
| export const CreateBillPropsSchema = z.discriminatedUnion('type', [ | ||
| CreateStandPlanBillSchema, | ||
| CreateExtractPointsBillSchema, | ||
| CreateExtractDatasetBillSchema | ||
| ]); | ||
| export type CreateBillPropsType = z.infer<typeof CreateBillPropsSchema>; | ||
|
|
||
| export const CreateOrderResponseSchema = z.object({ | ||
| qrCode: z.string().optional().meta({ description: '支付二维码 URL' }), | ||
| iframeCode: z.string().optional().meta({ description: '支付 iframe 代码' }), | ||
| markdown: z.string().optional().meta({ description: 'Markdown 格式的支付信息' }) | ||
| }); | ||
| export type CreateOrderResponseType = z.infer<typeof CreateOrderResponseSchema>; | ||
| export const CreateBillResponseSchema = CreateOrderResponseSchema.extend({ | ||
| billId: z.string().meta({ description: '订单 ID' }), | ||
| readPrice: z.number().meta({ description: '实际支付价格' }), | ||
| payment: z.enum(Object.values(BillPayWayEnum)).meta({ description: '支付方式' }) | ||
| }); | ||
| export type CreateBillResponseType = z.infer<typeof CreateBillResponseSchema>; | ||
|
|
||
| export const CheckPayResultResponseSchema = z.object({ | ||
| status: z.enum(Object.values(BillStatusEnum)), | ||
| description: z.string().optional() | ||
| }); | ||
| export type CheckPayResultResponseType = z.infer<typeof CheckPayResultResponseSchema>; | ||
|
|
||
| export const UpdatePaymentPropsSchema = z.object({ | ||
| billId: ObjectIdSchema, | ||
| payWay: z.enum(Object.values(BillPayWayEnum)) | ||
| }); | ||
| export type UpdatePaymentPropsType = z.infer<typeof UpdatePaymentPropsSchema>; | ||
|
|
||
| export const BillDetailResponseSchema = BillSchema.extend({ | ||
| couponName: z.string().optional() | ||
| }); | ||
| export type BillDetailResponseType = z.infer<typeof BillDetailResponseSchema>; | ||
|
|
||
| export const CancelBillPropsSchema = z.object({ | ||
| billId: ObjectIdSchema.meta({ description: '订单 ID' }) | ||
| }); | ||
| export type CancelBillPropsType = z.infer<typeof CancelBillPropsSchema>; |
This file contains hidden or 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,164 @@ | ||
| import { z } from 'zod'; | ||
| import type { OpenAPIPath } from '../../../type'; | ||
| import { | ||
| CreateBillPropsSchema, | ||
| CreateBillResponseSchema, | ||
| UpdatePaymentPropsSchema, | ||
| CreateOrderResponseSchema, | ||
| CheckPayResultResponseSchema, | ||
| BillDetailResponseSchema, | ||
| BillListQuerySchema, | ||
| CancelBillPropsSchema | ||
| } from './api'; | ||
| import { TagsMap } from '../../../tag'; | ||
| import { ObjectIdSchema } from '../../../../common/type/mongo'; | ||
|
|
||
| export const BillPath: OpenAPIPath = { | ||
| '/support/wallet/bill/create': { | ||
| post: { | ||
| summary: '创建订单', | ||
| description: '创建订单订单,支持标准订阅套餐、额外积分、额外数据集存储三种类型', | ||
| tags: [TagsMap.walletBill], | ||
| requestBody: { | ||
| content: { | ||
| 'application/json': { | ||
| schema: CreateBillPropsSchema | ||
| } | ||
| } | ||
| }, | ||
| responses: { | ||
| 200: { | ||
| description: '成功创建订单', | ||
| content: { | ||
| 'application/json': { | ||
| schema: CreateBillResponseSchema | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| '/support/wallet/bill/detail': { | ||
| get: { | ||
| summary: '获取订单详情', | ||
| description: '根据订单 ID 获取订单详细信息,包括优惠券名称等', | ||
| tags: [TagsMap.walletBill], | ||
| requestParams: { | ||
| query: z.object({ | ||
| billId: ObjectIdSchema.meta({ | ||
| description: '订单 ID' | ||
| }) | ||
| }) | ||
| }, | ||
| responses: { | ||
| 200: { | ||
| description: '成功获取订单详情', | ||
| content: { | ||
| 'application/json': { | ||
| schema: BillDetailResponseSchema.nullable() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| '/support/wallet/bill/list': { | ||
| post: { | ||
| summary: '获取订单列表', | ||
| description: '分页获取团队的订单列表,支持按类型筛选', | ||
| tags: [TagsMap.walletBill], | ||
| requestBody: { | ||
| content: { | ||
| 'application/json': { | ||
| schema: BillListQuerySchema | ||
| } | ||
| } | ||
| }, | ||
| responses: { | ||
| 200: { | ||
| description: '成功获取订单列表', | ||
| content: { | ||
| 'application/json': { | ||
| schema: z.object({ | ||
| list: z.array(BillDetailResponseSchema), | ||
| total: z.number().meta({ description: '总数' }) | ||
| }) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| '/support/wallet/bill/cancel': { | ||
| post: { | ||
| summary: '取消订单', | ||
| description: '取消未支付的订单,如果使用了优惠券会自动返还', | ||
| tags: [TagsMap.walletBill], | ||
| requestBody: { | ||
| content: { | ||
| 'application/json': { | ||
| schema: CancelBillPropsSchema | ||
| } | ||
| } | ||
| }, | ||
| responses: { | ||
| 200: { | ||
| description: '成功取消订单', | ||
| content: { | ||
| 'application/json': { | ||
| schema: z.null() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| '/support/wallet/bill/pay/updatePayment': { | ||
| post: { | ||
| summary: '更新支付方式', | ||
| description: '为未支付的订单更新支付方式,返回新的支付二维码或链接', | ||
| tags: [TagsMap.walletBill], | ||
| requestBody: { | ||
| content: { | ||
| 'application/json': { | ||
| schema: UpdatePaymentPropsSchema | ||
| } | ||
| } | ||
| }, | ||
| responses: { | ||
| 200: { | ||
| description: '成功更新支付方式', | ||
| content: { | ||
| 'application/json': { | ||
| schema: CreateOrderResponseSchema | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| '/support/wallet/bill/pay/checkPayResult': { | ||
| get: { | ||
| summary: '检查支付结果', | ||
| description: '检查订单的支付状态,用于轮询支付结果', | ||
| tags: [TagsMap.walletBill], | ||
| requestParams: { | ||
| query: z.object({ | ||
| payId: ObjectIdSchema.meta({ | ||
| description: '订单 ID' | ||
| }) | ||
| }) | ||
| }, | ||
| responses: { | ||
| 200: { | ||
| description: '成功获取支付结果', | ||
| content: { | ||
| 'application/json': { | ||
| schema: CheckPayResultResponseSchema | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }; |
33 changes: 33 additions & 0 deletions
33
packages/global/openapi/support/wallet/discountCoupon/api.ts
This file contains hidden or 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,33 @@ | ||
| import { z } from 'zod'; | ||
| import { ObjectIdSchema } from '../../../../common/type/mongo'; | ||
| import { | ||
| DiscountCouponStatusEnum, | ||
| DiscountCouponTypeEnum | ||
| } from '../../../../support/wallet/sub/discountCoupon/constants'; | ||
|
|
||
| export const DiscountCouponSchema = z.object({ | ||
| _id: ObjectIdSchema.meta({ description: '优惠券 ID' }), | ||
| teamId: ObjectIdSchema.meta({ description: '团队 ID' }), | ||
| type: z.enum(Object.values(DiscountCouponTypeEnum)).meta({ description: '优惠券类型' }), | ||
| startTime: z.coerce.date().optional().meta({ description: '生效时间' }), | ||
| expiredTime: z.coerce.date().meta({ description: '过期时间' }), | ||
| usedAt: z.coerce.date().optional().meta({ description: '使用时间' }), | ||
| createTime: z.coerce.date().meta({ description: '创建时间' }) | ||
| }); | ||
|
|
||
| export type DiscountCouponSchemaType = z.infer<typeof DiscountCouponSchema>; | ||
|
|
||
| export const DiscountCouponItemSchema = DiscountCouponSchema.extend({ | ||
| name: z.string().meta({ description: '优惠券名称' }), | ||
| description: z.string().meta({ description: '优惠券描述' }), | ||
| discount: z.number().meta({ description: '折扣率' }), | ||
| iconZh: z.string().meta({ description: '中文图标路径' }), | ||
| iconEn: z.string().meta({ description: '英文图标路径' }), | ||
| status: z.enum(Object.values(DiscountCouponStatusEnum)).meta({ description: '优惠券状态' }), | ||
| billId: ObjectIdSchema.optional().meta({ | ||
| description: '关联的订单 ID' | ||
| }) | ||
| }); | ||
| export const DiscountCouponListResponseSchema = z.array(DiscountCouponItemSchema); | ||
|
|
||
| export type DiscountCouponListResponseType = z.infer<typeof DiscountCouponListResponseSchema>; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.