fix(payment): consume first recharge offer after payment

This commit is contained in:
2026-07-03 10:54:46 +08:00
parent bb6ebbae7e
commit 489554cd78
13 changed files with 137 additions and 27 deletions
@@ -157,17 +157,17 @@ export function getDefaultSubscriptionPlanId(input: {
export function getFirstRechargeOfferView(input: {
isFirstRecharge: boolean;
discountPercent?: number | null;
vipPlans: readonly VipOfferPlanView[];
coinPlans: readonly CoinsOfferPlanView[];
}): FirstRechargeOfferView | null {
if (!input.isFirstRecharge) return null;
const promotedPlan = [...input.vipPlans, ...input.coinPlans].find(
(plan) => plan.isFirstRechargeOffer,
);
if (!input.isFirstRecharge && !promotedPlan) return null;
const discountPercent =
promotedPlan?.firstRechargeDiscountPercent ?? input.discountPercent ?? 50;
promotedPlan?.firstRechargeDiscountPercent ?? 50;
const badgeText = `${discountPercent}% OFF`;
return {
badgeText,