feat(affiliate): Update affiliate component to display total commission and improve data fetching

This commit is contained in:
web@ppanel
2025-01-04 16:51:03 +07:00
parent 4aea4e811f
commit cc834caa30
56 changed files with 335 additions and 114 deletions
+5 -5
View File
@@ -165,6 +165,7 @@ declare namespace API {
quantity: number;
price: number;
amount: number;
deduction: number;
discount: number;
coupon: string;
coupon_discount: number;
@@ -173,8 +174,6 @@ declare namespace API {
trade_no: string;
status: number;
subscribe_id: number;
subscription_discount_id: number;
subscription_discount_price: number;
created_at: number;
updated_at: number;
};
@@ -187,6 +186,7 @@ declare namespace API {
quantity: number;
price: number;
amount: number;
deduction: number;
discount: number;
coupon: string;
coupon_discount: number;
@@ -196,8 +196,6 @@ declare namespace API {
status: number;
subscribe_id: number;
subscribe: Subscribe;
subscription_discount_id: number;
subscription_discount_price: number;
created_at: number;
updated_at: number;
};
@@ -333,7 +331,7 @@ declare namespace API {
sell: boolean;
sort: number;
deduction_ratio: number;
purchase_with_discount: boolean;
allow_deduction: boolean;
reset_cycle: number;
renewal_reset: boolean;
created_at: number;
@@ -416,6 +414,8 @@ declare namespace API {
email: string;
avatar: string;
balance: number;
commission: number;
deduction: number;
telegram: number;
refer_code: string;
referer_id: number;
+36 -22
View File
@@ -187,6 +187,7 @@ declare namespace API {
quantity: number;
price: number;
amount: number;
deduction: number;
discount: number;
coupon: string;
coupon_discount: number;
@@ -195,8 +196,6 @@ declare namespace API {
trade_no: string;
status: number;
subscribe_id: number;
subscription_discount_id: number;
subscription_discount_price: number;
created_at: number;
updated_at: number;
};
@@ -209,6 +208,7 @@ declare namespace API {
quantity: number;
price: number;
amount: number;
deduction: number;
discount: number;
coupon: string;
coupon_discount: number;
@@ -218,8 +218,6 @@ declare namespace API {
status: number;
subscribe_id: number;
subscribe: Subscribe;
subscription_discount_id: number;
subscription_discount_price: number;
created_at: number;
updated_at: number;
};
@@ -241,23 +239,29 @@ declare namespace API {
price: number;
amount: number;
discount: number;
deduction: number;
coupon: string;
coupon_discount: number;
fee_amount: number;
subscribe_discount: number;
discount_list: SubscribeDiscountInfo[];
};
type PreRenewalOrderResponse = {
orderNo: string;
};
type PreUnsubscribeRequest = {
id: number;
};
type PreUnsubscribeResponse = {
deduction_amount: number;
};
type PurchaseOrderRequest = {
subscribe_id: number;
quantity: number;
payment: string;
coupon?: string;
discount_subscribe_id: number;
};
type PurchaseOrderResponse = {
@@ -329,8 +333,22 @@ declare namespace API {
total: number;
};
type QueryUserAffiliateResponse = {
sum: number;
type QueryUserAffiliateCountResponse = {
registers: number;
total_commission: number;
};
type QueryUserAffiliateListParams = {
page: number;
size: number;
};
type QueryUserAffiliateListRequest = {
page: number;
size: number;
};
type QueryUserAffiliateListResponse = {
list: UserAffiliate[];
total: number;
};
@@ -366,12 +384,10 @@ declare namespace API {
};
type RenewalOrderRequest = {
subscribe_id: number;
user_subscribe_id: number;
quantity: number;
payment: string;
coupon?: string;
subscribe_token: string;
discount_subscribe_id: number;
};
type RenewalOrderResponse = {
@@ -379,8 +395,7 @@ declare namespace API {
};
type ResetTrafficOrderRequest = {
subscribe_id: number;
subscribe_token: string;
user_subscribe_id: number;
payment: string;
};
@@ -485,7 +500,7 @@ declare namespace API {
sell: boolean;
sort: number;
deduction_ratio: number;
purchase_with_discount: boolean;
allow_deduction: boolean;
reset_cycle: number;
renewal_reset: boolean;
created_at: number;
@@ -504,13 +519,6 @@ declare namespace API {
discount: number;
};
type SubscribeDiscountInfo = {
id: number;
name: string;
price: number;
expire_time: string;
};
type SubscribeGroup = {
id: number;
name: string;
@@ -570,6 +578,10 @@ declare namespace API {
security_config: SecurityConfig;
};
type UnsubscribeRequest = {
id: number;
};
type UpdateUserNotifyRequest = {
enable_balance_notify: boolean;
enable_login_notify: boolean;
@@ -597,6 +609,8 @@ declare namespace API {
email: string;
avatar: string;
balance: number;
commission: number;
deduction: number;
telegram: number;
refer_code: string;
referer_id: number;
+51 -3
View File
@@ -2,10 +2,10 @@
/* eslint-disable */
import request from '@/utils/request';
/** Query User Affiliate GET /v1/public/user/affiliate */
/** Query User Affiliate Count GET /v1/public/user/affiliate/count */
export async function queryUserAffiliate(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.QueryUserAffiliateResponse }>(
'/v1/public/user/affiliate',
return request<API.Response & { data?: API.QueryUserAffiliateCountResponse }>(
'/v1/public/user/affiliate/count',
{
method: 'GET',
...(options || {}),
@@ -13,6 +13,24 @@ export async function queryUserAffiliate(options?: { [key: string]: any }) {
);
}
/** Query User Affiliate List GET /v1/public/user/affiliate/list */
export async function queryUserAffiliateList(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.QueryUserAffiliateListParams,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.QueryUserAffiliateListResponse }>(
'/v1/public/user/affiliate/list',
{
method: 'GET',
params: {
...params,
},
...(options || {}),
},
);
}
/** Query User Balance Log GET /v1/public/user/balance_log */
export async function queryUserBalanceLog(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.QueryUserBalanceLogListResponse }>(
@@ -106,3 +124,33 @@ export async function unbindTelegram(options?: { [key: string]: any }) {
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /v1/public/user/unsubscribe */
export async function unsubscribe(body: API.UnsubscribeRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/public/user/unsubscribe', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** Pre Unsubscribe POST /v1/public/user/unsubscribe/pre */
export async function preUnsubscribe(
body: API.PreUnsubscribeRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PreUnsubscribeResponse }>(
'/v1/public/user/unsubscribe/pre',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
},
);
}