Merge branch 'hugo-auto-transfer' into dev

# Conflicts:
#	backend/app/api/shipping_notice_tools.py
This commit is contained in:
hugo committed 2026-09-30 00:34:28 +08:00
commit 6cf71679b7
143 files changed
+10145 -2132

No files matched your search

+6 -1
View File
@@ -69,7 +69,8 @@ TRANSFER_DOCUMENT_STATUSES = (
)
# 未完结单状态集合(组锁生效范围,D7①/D15):同五元组存在任一未完结单时
# 复用其 doc_no+submit_timestamp,禁止新建;部分唯一索引的 WHERE 子句由该
# 元组生成,保证「常量集 ↔ DB 约束」永远一致(test_document_model.py 锁定)。
# 元组生成,保证「常量集 ↔ DB 约束」永远一致(原锁定测试 test_document_model.py
# 已删除,改动本元组时须人工核对迁移内 CHECK/WHERE 字面量同口径)。
UNRESOLVED_DOC_STATUSES = (
'pending', 'executing', 'result_unknown', 'business_failed', 'technical_failed',
)
@@ -262,6 +263,10 @@ class TransferInvoiceItem(Base):
# 数量以 Decimal 文本保存,杜绝浮点误差;比较在服务层完成。
receipt_quantity: Mapped[str] = mapped_column(String(40), nullable=False)
external_quantity: Mapped[Optional[str]] = mapped_column(String(40), nullable=True)
# [库存查得时刻] 当前 external_quantity 的 ERP 取数时间戳(stale 徽标判定时钟,
# 2026-09-29 起与行新鲜度 updated_at 分离:证据同步换戳/存续不续期本字段,
# 仅匹配评估/重查/写前复查在真实取数时写入;置空库存时同步置空)。NULL=无库存数据。
inventory_checked_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
status: Mapped[str] = mapped_column(String(32), nullable=False)
result_code: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
result_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
@@ -40,7 +40,7 @@ class ShippingReceiptReportConfig(Base):
query_parameters_json: Mapped[list[dict[str, Any]]] = mapped_column(
JSON, default=list, server_default=text("'[]'"), nullable=False,
)
# 与库存同构:Warehouse 是查询条件之一(支持多值),逐仓拆分在排程/触发时由该条件运行时派生,不单独持久化仓库清单。
# 与库存同构:查询条件原样下发 Worker;空条件表示页面默认。排程一源一单元,不按仓拆分。
config_version: Mapped[int] = mapped_column(Integer, default=1, server_default=text('1'), nullable=False)
created_by: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), nullable=True)
updated_by: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), nullable=True)
@@ -116,6 +116,10 @@ class ShippingReceiptReportFile(Base):
content_type: Mapped[Optional[str]] = mapped_column(String(128), nullable=True)
file_size: Mapped[int] = mapped_column(Integer, nullable=False)
sha256: Mapped[str] = mapped_column(String(64), nullable=False)
# 解析失败分层标记:归档文件解析失败时写入;三者全空=未失败/已清除。
parse_failed_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
parse_error_code: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
parse_error_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
archive_expires_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
archive_deleted_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
archive_delete_result_json: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False, default=dict)