修复会员旧档迁移与周期权益
修正旧月季年会员迁移到新同级档位的购买判定 修正 active 升级后续周期天数切换为新商品配置 修正 mock 立即结算订单先按支付前会员状态定价 修正会员商品周期泥点文案按周期天数展示 补充会员迁移升级与前端周期文案测试
This commit is contained in:
@@ -152,6 +152,42 @@ test('profile funds ViewModel formats recharge product and membership labels', (
|
||||
}),
|
||||
),
|
||||
).toBe('每月200泥点');
|
||||
expect(
|
||||
buildRechargeProductValueLabel(
|
||||
buildRechargeProduct({
|
||||
kind: 'membership',
|
||||
pointsAmount: 0,
|
||||
bonusPoints: 0,
|
||||
durationDays: 7,
|
||||
membershipPeriodPoints: 80,
|
||||
membershipPeriodDays: 7,
|
||||
}),
|
||||
),
|
||||
).toBe('每周80泥点');
|
||||
expect(
|
||||
buildRechargeProductValueLabel(
|
||||
buildRechargeProduct({
|
||||
kind: 'membership',
|
||||
pointsAmount: 0,
|
||||
bonusPoints: 0,
|
||||
durationDays: 14,
|
||||
membershipPeriodPoints: 300,
|
||||
membershipPeriodDays: 14,
|
||||
}),
|
||||
),
|
||||
).toBe('每14天300泥点');
|
||||
expect(
|
||||
buildRechargeProductValueLabel(
|
||||
buildRechargeProduct({
|
||||
kind: 'membership',
|
||||
pointsAmount: 0,
|
||||
bonusPoints: 0,
|
||||
durationDays: 90,
|
||||
membershipPeriodPoints: 1200,
|
||||
membershipPeriodDays: 90,
|
||||
}),
|
||||
),
|
||||
).toBe('每90天1200泥点');
|
||||
expect(buildMembershipLabel(buildMembership(), (value) => value)).toBe(
|
||||
'普通用户',
|
||||
);
|
||||
|
||||
@@ -86,11 +86,28 @@ export function formatRechargePrice(priceCents: number) {
|
||||
return `¥${Number.isInteger(yuan) ? yuan.toFixed(0) : yuan.toFixed(2)}`;
|
||||
}
|
||||
|
||||
function formatMembershipPeriodPrefix(periodDays: number) {
|
||||
if (periodDays === 30) {
|
||||
return '每月';
|
||||
}
|
||||
if (periodDays === 7) {
|
||||
return '每周';
|
||||
}
|
||||
if (periodDays > 0) {
|
||||
return `每${periodDays}天`;
|
||||
}
|
||||
return '每周期';
|
||||
}
|
||||
|
||||
export function buildRechargeProductValueLabel(product: ProfileRechargeProduct) {
|
||||
if (product.kind === 'membership') {
|
||||
const membershipPeriodPoints = product.membershipPeriodPoints;
|
||||
const membershipPeriodDays =
|
||||
product.membershipPeriodDays > 0
|
||||
? product.membershipPeriodDays
|
||||
: product.durationDays;
|
||||
return membershipPeriodPoints > 0
|
||||
? `每月${membershipPeriodPoints}泥点`
|
||||
? `${formatMembershipPeriodPrefix(membershipPeriodDays)}${membershipPeriodPoints}泥点`
|
||||
: `${product.durationDays}天`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user