会员升级结算前校验订单冻结的变更前状态

结算补差升级单前比对 settlement.plan_before / cycle_kind_before 与当前会员行,不一致直接拒绝「会员状态已变化,请重新下单」
避免用户先付更高档位升级单后,旧升级单落地把档位 / 周期覆盖回去,出现降档或「年付 + 一个月到期」的矛盾行
api-server 把该业务拒绝映射为 400
This commit is contained in:
2026-10-03 16:16:07 +08:00
parent 3e2ab3cf78
commit 3031f58875
2 changed files with 9 additions and 0 deletions
@@ -1516,6 +1516,7 @@ fn is_runtime_profile_membership_domain_error(message: &str) -> bool {
| "当前套餐已生效,无需重复购买"
| "当前会员有效期内不支持月付 / 年付转换,到期后可重新选择"
| "会员已到期,请按新购价格重新下单"
| "会员状态已变化,请重新下单"
)
}
@@ -9867,6 +9867,14 @@ fn apply_profile_membership_purchase(
if settlement.change_kind == RuntimeProfileMembershipChangeKind::Upgrade {
if let Some(row) = active_row {
// 中文注释:结算前比对订单冻结的变更前状态。若用户已先付了更高档位的升级单、
// 或到期后按不同周期重新购买,旧升级单直接落库会把档位 / 周期覆盖回去,
// 只剩原到期日,产生降档或「年付 + 一个月到期」的矛盾行,因此拒绝并要求重新下单。
if settlement.plan_before != Some(row.plan)
|| settlement.cycle_kind_before != Some(row.cycle_kind)
{
return Err("会员状态已变化,请重新下单".to_string());
}
return apply_profile_membership_upgrade(
ctx,
user_id,