fix: 严格校验日计划领取版本

This commit is contained in:
zhouz
2026-08-14 14:53:09 +08:00
parent a9a2b868df
commit 646bba8893

View File

@@ -180,6 +180,10 @@ public class DailyPlanScheduleServiceImpl implements DailyPlanScheduleService {
if (plan == null) {
throw exception(DAILY_PLAN_NOT_EXISTS);
}
if (!plan.getVersion().equals(claim.getPlanVersion())) {
// 领取后的任何计划变更都会使旧领取失效;不确认 claim调用方可处理冲突后主动释放或续租。
throw exception(DAILY_PLAN_VERSION_CONFLICT);
}
Integer workStatus = type == DailyPlanStrategyTypeEnum.STOCKING
? plan.getStockingStatus() : plan.getSleevingStatus();
if (!DailyPlanOrderStatusEnum.IN_PROGRESS.getCode().equals(plan.getOrderStatus())
@@ -193,8 +197,8 @@ public class DailyPlanScheduleServiceImpl implements DailyPlanScheduleService {
throw exception(DAILY_PLAN_COMPLETED_QTY_EXCEEDS_TOTAL);
}
int affected = type == DailyPlanStrategyTypeEnum.STOCKING
? dailyPlanMapper.increaseStockedQuantity(dailyPlanId, quantity, plan.getVersion(), normalizedOperator(operator))
: dailyPlanMapper.increaseSleevedQuantity(dailyPlanId, quantity, plan.getVersion(), normalizedOperator(operator));
? dailyPlanMapper.increaseStockedQuantity(dailyPlanId, quantity, version, normalizedOperator(operator))
: dailyPlanMapper.increaseSleevedQuantity(dailyPlanId, quantity, version, normalizedOperator(operator));
if (affected != 1) {
throw exception(DAILY_PLAN_VERSION_CONFLICT);
}