# 联泰下单助手 Chrome MV3 unpacked extension for the LTJT ERP business-operation workflows. ## What It Does - Parses a raw Chinese order instruction or accepts the same structured JSON used by the local adapter. - Opens the LTJT `orders_add.asp` form inside the logged-in ERP page. - Resolves choice-backed fields from existing LTJT options. - Runs the product template side effect through the page's own `Find_product()`. - Rebuilds receivable rows from the supplied passenger counts and prices. - Captures the page's own `SubmitInfoForm()` branch with `DoInfoJH` blocked before network. - Allows live submit only after a passed preflight and captured submit hash. In the mock business-system flow, the background executor submits test orders automatically without opening the popup. - Verifies the saved test order through `JH_OrderList` by departure date and obvious test marker. - Returns the ERP order-entry frame to the independent-order list after verification, filtered by departure date and the obvious test marker. - Keeps the extension popup as a minimal business-system connection status panel with an ERP-operation enable switch. - Persists a server-issued `execution_id` guard before starting. A duplicate page message, page refresh, bridge reinjection, or extension service-worker restart cannot execute the same task again. - Persists `write_started` before any real ERP write. Any crash or unknown result after that boundary becomes reconciliation-required and is never retried automatically. ## Absorbed ERP Operation Rules The extension now recognizes the handoff package's complete business-operation matrix instead of treating every non-create task as an invalid order: - `team_order_create`: the existing guarded browser path; live submit remains test-only. - `team_order_batch_create`: recognizes the handoff rule that native `DoInfoJHs` is deferred and, for an explicitly marked test task, runs the verified `team_single`-per-date fallback. It stops at the first incomplete date and never claims native batch execution. - `shared_plan_create` and `shared_child_order_create`: for explicitly marked test tasks, resolve exact ERP choices, submit the native split-plan/child-order forms, and re-query the parent/list row. The current live adapter supports one date and one plan per date. - `order_update`: preserves structured `set`/`delta`/`append` actions, can preview room/remark changes against a browser-read snapshot, and never broad-overwrites or saves from the preview. - `passenger_list_import`: preserves attachment paths and traveler-upsert intent, checks that the task has an existing identifier, and keeps workbook parsing/import/count verification outside the page planner. - `confirmation_export`: normalizes Xingyou/Liantai/JOB aliases, locates the order and correct `ddid`/`tid`, fetches the Word-like source responses, and never re-saves an order during recovery. It reports source responses, not a local download or customer delivery. The pure planning rules live in `operation-plans.js`. `inpage.js` contains the guarded split create, export-source, and read-only order/traveler probes. Business rules remain testable without opening Chrome or touching ERP. ## Install Locally 1. Open Chrome and go to `chrome://extensions`. 2. Enable `Developer mode`. 3. Click `Load unpacked`. 4. Select this folder: `/Users/inmanx/Documents/lwltAPI/chrome-extension/ltjt-order-assistant` 5. Open or refresh the logged-in LTJT ERP page: `https://ltjt.yunzhi.run/System/Mainlt.asp`. 6. Click the extension icon and use the popup. ## Safe Test Flow 1. Paste the raw instruction or structured JSON. 2. Click `解析/格式化`. 3. Click `预检并拦截`. 4. Review the report. A good preflight has: - `status = raw_instruction_test_passed` - `submit_intercept.status = submit_intercept_captured` - no blockers 5. Tick the confirmation checkbox. 6. Click `确认真实保存`. 7. Click `回查标记`. ## Mock Business-System Flow The repository also contains a tiny mock business-system page: `/Users/inmanx/Documents/lwltAPI/mock-business-system` When opened through a local HTTP server, the page communicates with the extension through `business-bridge.js`. For the production-hardened control plane, use the central server at its configured HTTPS origin. The page owns the administrator session and the extension remains a session-bound ERP adapter; `chrome.storage.local` is only a temporary execution cache. The production manifest must include the real business-system origin in its `host_permissions` and `content_scripts.matches` before packaging. 1. Reload the unpacked extension after any code change. 2. Start the mock business-system server: ```bash cd /Users/inmanx/Documents/lwltAPI/mock-business-system node server.mjs ``` 3. Open the mock page at `http://127.0.0.1:8765/`. 4. Paste the raw business instruction into the single text box. 5. Configure `DEERFLOW_BASE_URL` and `DEERFLOW_OPEN_API_KEY` in the mock business-system server environment before starting it. 6. Click `解析并创建任务`. 7. The mock page creates a task card immediately. 8. The extension background executor automatically finds or opens the logged-in LTJT ERP tab, runs preflight, submits the obvious test order, and verifies the marker. 9. Track progress from the task card in the mock page. The popup remains available for manual debugging, but business users do not need to open it. The mock page calls its local `/api/parse` endpoint. The server creates one independent Open Agent Session per task, streams the request to the published external Profile, and returns the standard `operation` JSON. The external Profile prompt and API policy are managed outside this repository; the browser never receives the external API key. ## Current Guardrails - Version `0.3.1` only permits live submit for `order_nature = test` on the team and split-create routes and requires a server-issued execution ID. - Reload the unpacked extension after upgrading. The business page refuses new ERP execution when the connected extension is older than `0.3.1`. - Deleting a business task requests cancellation of its matching background task before removing the task card and stored bridge records. A browser/ERP action already in flight cannot be rolled back by deletion. - A non-empty `data.test_marker` is required. - The live submit uses the intercepted `DoInfoJH` payload hash as the approved hash. - If the actual submit payload hash differs at network-send time, the extension blocks the request. - Split create has a live test-only adapter; export is read-only source fetch with `neverResave=true`. - Order update and traveler import remain read-only at the business-system layer. Live ERP update requests returned HTTP 200 with an empty body and did not persist in the current account, so the extension fails closed instead of claiming success. - The ERP native traveler paste routine can fill test rows, but its phone-column mapping is offset by earlier same-name controls; do not reuse it for production traveler data without a row-scoped import fix. - Export recovery is `exportOnly`/`neverResave`; an export failure cannot route back into create-order. - Traveler attachments stay as paths/metadata in the task; the extension does not silently open local workbooks or put traveler PII into audit output. - The extension does not store account passwords or cookies. ## Notes This is a browser-session adapter, not an official LTJT API client. It depends on the logged-in ERP page, the existing page JavaScript, and the current form field names.