From 6d04f88f415ce20e08de5be1c09555017bcf5b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 3 Oct 2026 11:15:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A9=E5=85=85=E5=80=BC=E5=95=86=E5=93=81?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=A1=A3=E8=BF=81=E7=A7=BB=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E6=97=A7=E8=BF=81=E7=A7=BB=E9=81=97=E7=95=99=E7=9A=84=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resolve_default_point_product_migration 同时识别停用的「首充双倍」行(赠送为 0 或等于面额)与在售的「首充加赠」行 更新迁移单测:disabled_seed 按旧迁移后的真实状态构造,并补充「首充加赠」用例 Co-authored-by: Junie --- .../src/runtime/active/profile.rs | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/server-rs/crates/spacetime-module/src/runtime/active/profile.rs b/server-rs/crates/spacetime-module/src/runtime/active/profile.rs index 86aa6956b..52a153ab1 100644 --- a/server-rs/crates/spacetime-module/src/runtime/active/profile.rs +++ b/server-rs/crates/spacetime-module/src/runtime/active/profile.rs @@ -3729,9 +3729,9 @@ mod tests { assert_eq!(migration.description, "180泥点"); assert!(migration.enabled); - // 中文注释:¥128 / ¥328 两档旧版本是停用的首充行,现在改为在售且无赠送。 + // 中文注释:¥128 / ¥328 两档旧版本是停用的首充行,上一版迁移把赠送保留成面额。 let disabled_seed = ProfileRechargeProductConfig { - bonus_points: 0, + bonus_points: 1_280, badge_label: "首充双倍".to_string(), enabled: false, ..build_row(1_280) @@ -3741,6 +3741,21 @@ mod tests { assert!(migration.enabled); assert_eq!(migration.bonus_points, 0); + // 中文注释:上一版迁移已把 180 / 300 / 680 改成在售的「首充加赠」行,也要归一。 + let first_charge_bonus_seed = ProfileRechargeProductConfig { + bonus_points: 90, + badge_label: "首充加赠".to_string(), + description: "首充加赠90泥点".to_string(), + enabled: true, + ..build_row(180) + }; + let migration = resolve_default_point_product_migration(&first_charge_bonus_seed) + .expect("「首充加赠」行应被归一"); + assert!(migration.enabled); + assert_eq!(migration.bonus_points, 0); + assert_eq!(migration.badge_label, ""); + assert_eq!(migration.description, "180泥点"); + // 中文注释:后台改过的行(updated_by 已变)一律不动。 let mut admin_row = build_row(300); admin_row.updated_by = "admin-1".to_string(); @@ -8765,11 +8780,14 @@ fn resolve_default_point_product_migration( && row.bonus_points == row.points_amount && row.badge_label == "首充双倍" && row.description == format!("首充送{}泥点", row.points_amount); - // ¥128 / ¥328 两档曾是「停用的首充双倍行」,现在改为在售且无赠送。 - let is_legacy_disabled_seed = - !row.enabled && row.bonus_points == 0 && row.badge_label == "首充双倍"; + // ¥128 / ¥328 两档曾是「停用的首充双倍行」:旧迁移把赠送保留成面额,所以两种形状都要认。 + let is_legacy_disabled_seed = !row.enabled + && row.badge_label == "首充双倍" + && (row.bonus_points == 0 || row.bonus_points == row.points_amount); + // 180 / 300 / 680 三档被上一版迁移改成了在售的「首充加赠」行,也要归一。 + let is_legacy_first_charge_bonus_seed = row.enabled && row.badge_label == "首充加赠"; - if is_legacy_bonus_seed || is_legacy_disabled_seed { + if is_legacy_bonus_seed || is_legacy_disabled_seed || is_legacy_first_charge_bonus_seed { return Some(canonical); } None