feat(subscription): Refactor subscription handling and update imports for better organization

This commit is contained in:
web@ppanel
2025-03-08 12:34:23 +07:00
parent 3222016799
commit 2215c7f2b9
27 changed files with 1042 additions and 180 deletions
+3 -1
View File
@@ -1,11 +1,12 @@
// @ts-ignore
/* eslint-disable */
// API 更新时间:
// API 唯一标识:
import * as announcement from './announcement';
import * as document from './document';
import * as order from './order';
import * as payment from './payment';
import * as portal from './portal';
import * as subscribe from './subscribe';
import * as ticket from './ticket';
import * as user from './user';
@@ -14,6 +15,7 @@ export default {
document,
order,
payment,
portal,
subscribe,
ticket,
user,
-15
View File
@@ -2,21 +2,6 @@
/* eslint-disable */
import request from '@/utils/request';
/** Checkout order POST /v1/public/order/checkout */
export async function checkoutOrder(
body: API.CheckoutOrderRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.CheckoutOrderResponse }>('/v1/public/order/checkout', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** Close order POST /v1/public/order/close */
export async function closeOrder(body: API.CloseOrderRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/public/order/close', {
+91
View File
@@ -0,0 +1,91 @@
// @ts-ignore
/* eslint-disable */
import request from '@/utils/request';
/** Purchase Checkout POST /v1/public/portal/order/checkout */
export async function purchaseCheckout(
body: API.CheckoutOrderRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.CheckoutOrderResponse }>(
'/v1/public/portal/order/checkout',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
},
);
}
/** Query Purchase Order GET /v1/public/portal/order/status */
export async function queryPurchaseOrder(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.QueryPurchaseOrderParams,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.QueryPurchaseOrderResponse }>(
'/v1/public/portal/order/status',
{
method: 'GET',
params: {
...params,
},
...(options || {}),
},
);
}
/** Get available payment methods GET /v1/public/portal/payment-method */
export async function getAvailablePaymentMethods(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.GetAvailablePaymentMethodsResponse }>(
'/v1/public/portal/payment-method',
{
method: 'GET',
...(options || {}),
},
);
}
/** Pre Purchase Order POST /v1/public/portal/pre */
export async function prePurchaseOrder(
body: API.PrePurchaseOrderRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PrePurchaseOrderResponse }>('/v1/public/portal/pre', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** Purchase subscription POST /v1/public/portal/purchase */
export async function purchase(body: API.PortalPurchaseRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.PortalPurchaseResponse }>(
'/v1/public/portal/purchase',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
},
);
}
/** Get Subscription GET /v1/public/portal/subscribe */
export async function getSubscription(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.GetSubscriptionResponse }>(
'/v1/public/portal/subscribe',
{
method: 'GET',
...(options || {}),
},
);
}
+84 -1
View File
@@ -187,7 +187,7 @@ declare namespace API {
};
type GetAvailablePaymentMethodsResponse = {
list: PaymentConfig[];
list: PaymenMethod[];
};
type GetLoginLogParams = {
@@ -224,6 +224,24 @@ declare namespace API {
total: number;
};
type GetSubscriptionResponse = {
list: Subscribe[];
};
type GetUserSubscribeTrafficLogsRequest = {
page: number;
size: number;
user_id: number;
subscribe_id: number;
start_time: number;
end_time: number;
};
type GetUserSubscribeTrafficLogsResponse = {
list: TrafficLog[];
total: number;
};
type GetUserTicketDetailRequest = {
id: number;
};
@@ -351,6 +369,16 @@ declare namespace API {
updated_at: number;
};
type PaymenMethod = {
id: number;
name: string;
mark: string;
icon: string;
fee_mode: number;
fee_percent: number;
fee_amount: number;
};
type PaymentConfig = {
id: number;
name: string;
@@ -364,6 +392,21 @@ declare namespace API {
enable: boolean;
};
type PortalPurchaseRequest = {
identifier: string;
platform: string;
password?: string;
payment: string;
subscribe_id: number;
quantity: number;
coupon?: string;
turnstile_token?: string;
};
type PortalPurchaseResponse = {
order_no: string;
};
type PreOrderResponse = {
price: number;
amount: number;
@@ -374,6 +417,22 @@ declare namespace API {
fee_amount: number;
};
type PrePurchaseOrderRequest = {
payment: string;
subscribe_id: number;
quantity: number;
coupon?: string;
};
type PrePurchaseOrderResponse = {
price: number;
amount: number;
discount: number;
coupon: string;
coupon_discount: number;
fee_amount: number;
};
type PreRenewalOrderResponse = {
orderNo: string;
};
@@ -467,6 +526,30 @@ declare namespace API {
list: OrderDetail[];
};
type QueryPurchaseOrderParams = {
order_no: string;
};
type QueryPurchaseOrderRequest = {
order_no: string;
};
type QueryPurchaseOrderResponse = {
order_no: string;
subscribe: Subscribe;
quantity: number;
price: number;
amount: number;
discount: number;
coupon: string;
coupon_discount: number;
fee_amount: number;
payment: string;
status: number;
created_at: number;
token?: string;
};
type QuerySubscribeGroupListResponse = {
list: SubscribeGroup[];
total: number;