|
@@ -37,6 +37,11 @@ def _dump_transfer_body(body: MarketPresignTransferBody) -> dict:
|
|
|
return body.model_dump(by_alias=False, exclude_unset=True)
|
|
return body.model_dump(by_alias=False, exclude_unset=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def _reject_direct_conversion(fields: dict) -> None:
|
|
|
|
|
+ if str(fields.get('order_status') or '').strip() == 'converted':
|
|
|
|
|
+ raise ValueError('预签约订单必须通过转正式操作进入已转正式状态')
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def _assert_transfer_order_writable(order: BizPresignOrder) -> None:
|
|
def _assert_transfer_order_writable(order: BizPresignOrder) -> None:
|
|
|
if (order.order_status or '').strip() not in ('', 'draft', 'active'):
|
|
if (order.order_status or '').strip() not in ('', 'draft', 'active'):
|
|
|
raise ValueError('当前状态的预签约订单不可操作转账记录')
|
|
raise ValueError('当前状态的预签约订单不可操作转账记录')
|
|
@@ -266,6 +271,7 @@ def create_presign_order(
|
|
|
user_info: dict,
|
|
user_info: dict,
|
|
|
) -> dict:
|
|
) -> dict:
|
|
|
fields = _dump_body(body)
|
|
fields = _dump_body(body)
|
|
|
|
|
+ _reject_direct_conversion(fields)
|
|
|
sample_type_ids = fields.pop("sample_type_ids", None)
|
|
sample_type_ids = fields.pop("sample_type_ids", None)
|
|
|
transfers = fields.pop("transfers", None)
|
|
transfers = fields.pop("transfers", None)
|
|
|
if transfers and (
|
|
if transfers and (
|
|
@@ -361,6 +367,7 @@ def update_presign_order(
|
|
|
if (current.order_status or '').strip() == 'converted':
|
|
if (current.order_status or '').strip() == 'converted':
|
|
|
raise ValueError('当前状态的预签约订单不可修改')
|
|
raise ValueError('当前状态的预签约订单不可修改')
|
|
|
fields = _dump_body(body)
|
|
fields = _dump_body(body)
|
|
|
|
|
+ _reject_direct_conversion(fields)
|
|
|
sample_type_ids = fields.pop("sample_type_ids", None)
|
|
sample_type_ids = fields.pop("sample_type_ids", None)
|
|
|
fields.pop("transfers", None)
|
|
fields.pop("transfers", None)
|
|
|
resulting_region_id = fields.get("region_id", current.region_id)
|
|
resulting_region_id = fields.get("region_id", current.region_id)
|
|
@@ -402,13 +409,16 @@ def update_presign_order(
|
|
|
fields=fields,
|
|
fields=fields,
|
|
|
sample_type_ids=sample_type_ids,
|
|
sample_type_ids=sample_type_ids,
|
|
|
create_dept_id=_current_dept_id(user_info),
|
|
create_dept_id=_current_dept_id(user_info),
|
|
|
|
|
+ commit=False,
|
|
|
)
|
|
)
|
|
|
row = assert_presign_access(
|
|
row = assert_presign_access(
|
|
|
db, row.id, ctx, user_info=user_info
|
|
db, row.id, ctx, user_info=user_info
|
|
|
)
|
|
)
|
|
|
- return presign_crud.order_to_dict(
|
|
|
|
|
|
|
+ result = presign_crud.order_to_dict(
|
|
|
db, row, ctx.tenant_no, with_children=True
|
|
db, row, ctx.tenant_no, with_children=True
|
|
|
)
|
|
)
|
|
|
|
|
+ db.commit()
|
|
|
|
|
+ return result
|
|
|
except Exception:
|
|
except Exception:
|
|
|
db.rollback()
|
|
db.rollback()
|
|
|
raise
|
|
raise
|