feat(tip): support dynamic gift products

This commit is contained in:
2026-07-21 13:19:45 +08:00
parent 55cb98ed14
commit 37ff69020b
62 changed files with 2325 additions and 1085 deletions
+14 -19
View File
@@ -7,10 +7,13 @@ import type { IPaymentRepository } from "@/data/repositories/interfaces";
import {
CreatePaymentOrderRequestSchema,
CreatePaymentOrderResponse,
GiftProductsResponse,
PayChannel,
PaymentOrderStatusResponse,
PaymentPlansResponse,
PaymentPlansResponseSchema,
TipMessageRequestSchema,
TipMessageResponse,
} from "@/data/schemas/payment";
import { PaymentApi, paymentApi } from "@/data/services/api";
import { PaymentPlansStorage } from "@/data/storage/payment";
@@ -38,25 +41,11 @@ export class PaymentRepository implements IPaymentRepository {
});
}
/** 获取咖啡打赏套餐列表,不写入通用套餐缓存。 */
async getTipPlans(): Promise<Result<PaymentPlansResponse>> {
return Result.wrap(async () => {
const response = await this.api.getTipPlans();
return PaymentPlansResponseSchema.parse({
plans: response.plans.map((plan) => ({
...plan,
orderType: "tip",
vipDays: null,
dolAmount: null,
creditBalance: 0,
originalAmountCents: null,
dailyPriceCents: null,
isFirstRechargeOffer: false,
firstRechargeDiscountPercent: null,
promotionType: null,
})),
});
});
/** 获取当前角色的完整礼物目录,不写入订阅套餐缓存。 */
async getGiftProducts(
characterId: string,
): Promise<Result<GiftProductsResponse>> {
return Result.wrap(() => this.api.getGiftProducts(characterId));
}
/** 清除本地缓存套餐列表。 */
@@ -89,6 +78,12 @@ export class PaymentRepository implements IPaymentRepository {
): Promise<Result<PaymentOrderStatusResponse>> {
return Result.wrap(() => this.api.getOrderStatus(orderId));
}
/** 获取已支付礼物订单的角色感谢文案。 */
async getTipMessage(orderId: string): Promise<Result<TipMessageResponse>> {
const request = TipMessageRequestSchema.parse({ orderId });
return Result.wrap(() => this.api.getTipMessage(request));
}
}
/** 全局懒单例。 */