Merge branch 'master' into hermes/hermes-4fd30995
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user