fix: 对齐首充双倍展示状态

This commit is contained in:
2026-05-15 03:59:37 +08:00
parent 6672867c6f
commit 7972661d1e
5 changed files with 123 additions and 59 deletions

View File

@@ -77,6 +77,21 @@ pub fn runtime_profile_recharge_point_products() -> Vec<RuntimeProfileRechargePr
]
}
/// 中文注释:充值中心展示当前账号本次实际可生效的首充赠送状态。
pub fn resolve_runtime_profile_recharge_point_products(
has_points_recharged: bool,
) -> Vec<RuntimeProfileRechargeProductSnapshot> {
let mut products = runtime_profile_recharge_point_products();
if has_points_recharged {
for product in &mut products {
product.bonus_points = 0;
product.badge_label.clear();
product.description = product.title.clone();
}
}
products
}
pub fn runtime_profile_recharge_membership_products() -> Vec<RuntimeProfileRechargeProductSnapshot>
{
vec![
@@ -706,6 +721,22 @@ mod tests {
);
}
#[test]
fn recharge_point_products_resolve_effective_first_bonus_display() {
let first_recharge_products = resolve_runtime_profile_recharge_point_products(false);
assert_eq!(first_recharge_products[0].bonus_points, 60);
assert_eq!(first_recharge_products[0].badge_label, "首充双倍");
assert_eq!(first_recharge_products[0].description, "首充送60泥点");
let repeated_recharge_products = resolve_runtime_profile_recharge_point_products(true);
assert_eq!(repeated_recharge_products[0].bonus_points, 0);
assert_eq!(repeated_recharge_products[0].badge_label, "");
assert_eq!(repeated_recharge_products[0].description, "60泥点");
assert_eq!(repeated_recharge_products[5].bonus_points, 0);
assert_eq!(repeated_recharge_products[5].badge_label, "");
assert_eq!(repeated_recharge_products[5].description, "3280泥点");
}
#[test]
fn build_recharge_order_input_rejects_unknown_product() {
let error = build_runtime_profile_recharge_order_create_input(

View File

@@ -2915,16 +2915,18 @@ fn build_profile_recharge_center_snapshot(
.map(|row| row.wallet_balance)
.unwrap_or(0);
let has_points_recharged = has_profile_points_recharged(ctx, user_id);
RuntimeProfileRechargeCenterSnapshot {
user_id: user_id.to_string(),
wallet_balance,
membership: build_profile_membership_snapshot(ctx, user_id),
point_products: runtime_profile_recharge_point_products(),
point_products: resolve_runtime_profile_recharge_point_products(has_points_recharged),
membership_products: runtime_profile_recharge_membership_products(),
benefits: runtime_profile_membership_benefits(),
latest_order: latest_profile_recharge_order(ctx, user_id)
.map(|row| build_profile_recharge_order_snapshot_from_row(&row)),
has_points_recharged: has_profile_points_recharged(ctx, user_id),
has_points_recharged,
}
}