chore(shipping-notice): 统一货代发货生命周期阶段命名并优化全链路业务逻辑

This commit is contained in:
hugo committed 2026-08-17 19:56:51 +08:00
1 parent 5ef8329bd8
commit 4ec4e57005
183 files changed
+14653 -3936

No files matched your search

@@ -398,7 +398,7 @@ def test_list_my_todos_includes_open_review_case_with_run_deep_link(app):
from tests.test_shipping_order_review_service import _materialized_run
from tests.test_shipping_order_extraction_runs import _seed_run_input
user, agent, session, intake, _document = _seed_run_input(suffix='TODO-REV-DL')
user, agent, session, intake, document = _seed_run_input(suffix='TODO-REV-DL')
run = _materialized_run(user=user, agent=agent, session=session, intake=intake)
unit = run.extraction_plan.units[0]
unit.result_json = {
@@ -408,6 +408,15 @@ def test_list_my_todos_includes_open_review_case_with_run_deep_link(app):
'conflicts': [],
}],
}
from app.models import ShippingOrderCandidate
db.session.add(ShippingOrderCandidate(
candidate_no='CAND-TODO-REV-DL',
intake_id=intake.id,
primary_document_id=document.id,
candidate_key='todo-review-deep-link',
order_extraction_run_id=run.id,
))
db.session.commit()
cases = ensure_run_review_cases(run=run)
assert cases
@@ -423,12 +432,38 @@ def test_list_my_todos_includes_open_review_case_with_run_deep_link(app):
assert hit['conversation_id'] == session.session_id
assert hit['can_handle'] is True
assert hit['ui_state']['summary']['entry_surface'] == 'review_workbench'
assert hit['ui_state']['lifecycle_stage'] == 'order_review'
assert [entry['state'] for entry in hit['ui_state']['lifecycle_entries']] == [
'available', 'current', 'unavailable', 'unavailable',
]
counts = count_my_todos(user.id)
assert counts['pending'] >= 1
assert counts['total_pending_badge'] == counts['pending']
def test_open_review_case_without_current_candidate_has_no_lifecycle_entry(app):
"""历史空 Review Case 可以处置,但不能被待办页默认授权进入订单生命周期。"""
with app.app_context():
from app import db
from app.services.shipping_notice.order_review_service import ensure_run_review_cases
from app.services.shipping_notice.query_service import list_my_todos
from tests.test_shipping_order_review_service import _materialized_run
from tests.test_shipping_order_extraction_runs import _seed_run_input
user, agent, session, intake, _document = _seed_run_input(suffix='TODO-EMPTY-CASE')
run = _materialized_run(user=user, agent=agent, session=session, intake=intake)
unit = run.extraction_plan.units[0]
unit.result_json = {'orders': []}
db.session.commit()
case = ensure_run_review_cases(run=run)[0]
pending = list_my_todos(user.id, bucket='pending', page=1, page_size=50)
hit = next(item for item in pending['items'] if item.get('review_case_no') == case.case_no)
assert hit['ui_state']['lifecycle_stage'] is None
assert hit['ui_state']['lifecycle_entries'] == []
def test_list_my_todos_includes_orphan_parse_failed_intake(app):
"""
未建 OT 且解析失败的 Intake 须进入 pending,并暴露 conversation 深链字段。
@@ -483,6 +518,8 @@ def test_list_my_todos_includes_orphan_parse_failed_intake(app):
assert hit['source_file_name'] == 'orphan-fail.pdf'
assert hit['can_handle'] is True
assert hit['ui_state']['summary']['entry_surface'] == 'conversation_processing'
assert hit['ui_state']['lifecycle_stage'] == 'intake_parse'
assert hit['ui_state']['lifecycle_entries'] == []
filtered = list_my_todos(
user.id, bucket='pending', page=1, page_size=50, todo_category='intake_parse',