feat(payment): support user-bound seven-discount offers
Docker Image / Build and Push Docker Image (push) Successful in 1m55s

This commit is contained in:
Codex
2026-07-23 16:11:20 +08:00
parent 02f6964484
commit 4dae805a88
39 changed files with 418 additions and 28 deletions
@@ -13,7 +13,7 @@ import type { Result } from "@/utils/result";
export interface IPaymentRepository {
/** 获取套餐列表。 */
getPlans(): Promise<Result<PaymentPlansResponse>>;
getPlans(commercialOfferId?: string): Promise<Result<PaymentPlansResponse>>;
/** 获取本地缓存套餐列表。 */
getCachedPlans(): Promise<Result<PaymentPlansResponse | null>>;
@@ -30,6 +30,7 @@ export interface IPaymentRepository {
payChannel: PayChannel,
autoRenew: boolean,
recipientCharacterId?: string,
commercialOfferId?: string,
): Promise<Result<CreatePaymentOrderResponse>>;
/** 查询支付订单状态。 */
+5 -3
View File
@@ -24,10 +24,10 @@ export class PaymentRepository implements IPaymentRepository {
constructor(private readonly api: PaymentApi) {}
/** 获取套餐列表。 */
async getPlans(): Promise<Result<PaymentPlansResponse>> {
async getPlans(commercialOfferId?: string): Promise<Result<PaymentPlansResponse>> {
return Result.wrap(async () => {
const response = await this.api.getPlans();
await PaymentPlansStorage.setPlans(response);
const response = await this.api.getPlans(commercialOfferId);
if (!commercialOfferId) await PaymentPlansStorage.setPlans(response);
return response;
});
}
@@ -62,12 +62,14 @@ export class PaymentRepository implements IPaymentRepository {
payChannel: PayChannel,
autoRenew: boolean,
recipientCharacterId?: string,
commercialOfferId?: string,
): Promise<Result<CreatePaymentOrderResponse>> {
const request = CreatePaymentOrderRequestSchema.parse({
planId,
payChannel,
autoRenew,
...(recipientCharacterId ? { recipientCharacterId } : {}),
...(commercialOfferId ? { commercialOfferId } : {}),
});
return Result.wrap(() => this.api.createOrder(request));
}