feat(shipping-notice): 增加发货通知建单幂等性支持及内容哈希校验

This commit is contained in:
hugo committed 2026-07-14 00:28:52 +08:00
1 parent 0a9bd6415d
commit 143e054d86
39 files changed
+1750 -80

No files matched your search

+1 -1
View File
@@ -152,7 +152,7 @@ def tool_create_batch():
batch = get_batch_by_no(batch_no)
if batch:
return jsonify({'status': 'ok', 'batch_no': batch.batch_no, 'message': f'已复用批次 {batch.batch_no}', 'data': serialize_batch_summary(batch)})
batch = shipping_tools.create_batch(payload)
batch, _created = shipping_tools.create_batch(payload)
db.session.commit()
return jsonify({'status': 'ok', 'batch_no': batch.batch_no, 'message': f'已创建批次 {batch.batch_no}', 'data': serialize_batch_summary(batch)})
@@ -101,8 +101,17 @@ def workspace_create_shipping_batch_from_notices():
create_shipping_batch_from_notice_items,
intake_notice_uploads_for_batch,
)
from app.services.shipping_notice.batch_create_idempotency import (
normalize_create_idempotency_key,
warn_missing_create_idempotency_key,
)
from app.services.shipping_notice.notice_upload import cleanup_temp_notice_uploads
conversation_id = str(request.form.get('conversation_id') or '').strip()
idempotency_key = normalize_create_idempotency_key(
request.headers.get('Idempotency-Key') or request.form.get('idempotency_key')
)
if not idempotency_key:
warn_missing_create_idempotency_key(source='workspace_create_shipping_batch_from_notices')
temp_request_id = str(getattr(g, 'request_id', None) or uuid.uuid4().hex)
try:
notice_items, file_summary = intake_notice_uploads_for_batch(temp_request_id, uploads)
@@ -114,6 +123,7 @@ def workspace_create_shipping_batch_from_notices():
conversation_id=conversation_id or None,
notice_items=notice_items,
file_summary=file_summary,
create_idempotency_key=idempotency_key,
)
return _ok(created)