修复:限定幂等键精确业务域

This commit is contained in:
焦龙言
2026-07-27 18:54:50 +08:00
parent 4a321098f8
commit b6f3b1e1f0
18 changed files with 730 additions and 135 deletions
@@ -750,11 +750,19 @@ class ShipmentService:
) -> CrudResponseModel:
try:
warehouse_ids, site_ids = await cls._scopes(query_db, current_user)
current = await OperationDao.get_shipment_by_id(
query_db,
shipment_id,
warehouse_ids=warehouse_ids,
site_ids=site_ids,
)
if current is None:
cls._raise_shipment_not_accessible(current_user)
recovered = await OperationDao.get_shipment_by_confirm_idempotency_key(
query_db,
idempotency_key,
warehouse_ids=warehouse_ids,
site_ids=site_ids,
warehouse_ids=[current.source_warehouse_id],
site_ids=[current.target_site_id],
)
if recovered is None:
raise ServiceException(message='确认发货失败,幂等冲突')
@@ -815,8 +823,8 @@ class ShipmentService:
existing = await OperationDao.get_shipment_by_confirm_idempotency_key(
query_db,
idempotency_key,
warehouse_ids=warehouse_ids,
site_ids=site_ids,
warehouse_ids=[shipment.source_warehouse_id],
site_ids=[shipment.target_site_id],
)
if existing is not None and not cls._is_exact_confirmed(
existing,