让充值商品默认档迁移识别旧迁移遗留的行
resolve_default_point_product_migration 同时识别停用的「首充双倍」行(赠送为 0 或等于面额)与在售的「首充加赠」行 更新迁移单测:disabled_seed 按旧迁移后的真实状态构造,并补充「首充加赠」用例 Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user