refactor(api): remove unused network endpoints
This commit is contained in:
@@ -10,9 +10,7 @@ import {
|
||||
CreatePaymentOrderResponse,
|
||||
PayChannel,
|
||||
PaymentOrderStatusResponse,
|
||||
PaymentPlan,
|
||||
PaymentPlansResponse,
|
||||
PaymentVipStatusResponse,
|
||||
} from "@/data/dto/payment";
|
||||
import { PaymentApi, paymentApi } from "@/data/services/api";
|
||||
import { PaymentPlansStorage } from "@/data/storage/payment";
|
||||
@@ -49,22 +47,6 @@ export class PaymentRepository implements IPaymentRepository {
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取会员套餐列表。 */
|
||||
async getVipPlans(): Promise<Result<PaymentPlan[]>> {
|
||||
return Result.wrap(async () => {
|
||||
const response = await this.api.getPlans();
|
||||
return response.plans.filter(isVipPaymentPlan);
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取积分套餐列表。 */
|
||||
async getCreditPlans(): Promise<Result<PaymentPlan[]>> {
|
||||
return Result.wrap(async () => {
|
||||
const response = await this.api.getPlans();
|
||||
return response.plans.filter(isCreditPaymentPlan);
|
||||
});
|
||||
}
|
||||
|
||||
/** 创建支付订单。 */
|
||||
async createOrder(
|
||||
planId: string,
|
||||
@@ -86,21 +68,9 @@ export class PaymentRepository implements IPaymentRepository {
|
||||
return Result.wrap(() => this.api.getOrderStatus(orderId));
|
||||
}
|
||||
|
||||
/** 查询当前用户 VIP 状态。 */
|
||||
async getVipStatus(): Promise<Result<PaymentVipStatusResponse>> {
|
||||
return Result.wrap(() => this.api.getVipStatus());
|
||||
}
|
||||
}
|
||||
|
||||
/** 全局懒单例。 */
|
||||
export const getPaymentRepository = createLazySingleton<IPaymentRepository>(
|
||||
() => new PaymentRepository(paymentApi),
|
||||
);
|
||||
|
||||
export function isVipPaymentPlan(plan: PaymentPlan): boolean {
|
||||
return plan.vipDays !== null;
|
||||
}
|
||||
|
||||
export function isCreditPaymentPlan(plan: PaymentPlan): boolean {
|
||||
return plan.dolAmount !== null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user