Commit Graph
72 Commits
Author SHA1 Message Date
QiuSWandClaude Opus 5 7edb4e7b9f feat(#48): add SYB sync orchestration, import endpoint and page entry
Stage 2. Completes the path from the SYB API to the archive.

sybimport.Sync pages a date range day by day and folds each detail line
through the existing idempotent ApplyDetail. The paging loop is driven by
listTotal, never by the list response's own total, which live data
confirmed is the page's row count rather than the filtered total. A day
whose completeness cannot be proven — a short page, a total that drifted
while paging, a detail response missing an order — stops the run instead
of reporting a partial import as a whole one. Rows already written stay:
they are idempotent on (order_code, detail_id), so a re-run overwrites.

sybimport.Connect reuses the cached session and only discards it when SYB
explicitly says it is invalid. Caching the numeric user id alongside the
cookies is required, not incidental: session validation calls
/am/user/get?id=, and a wrong id comes back as a business error rather
than a logout, so cookies alone can never be revalidated.

The import endpoint is single-flight and detached from the request
context, so closing the tab cannot abandon a half-finished range. It
reads only; no SYB write endpoint is reachable from GoAuto.

The page swaps its "no import entry" warning for a date-range dialog that
warns when the span is wide — a single week held over 7000 orders — and
reports partial progress when a run fails midway.

Verified: go build, go vet, go test ./... all pass. The drift check was
mutation-tested. Not verified: the MySQL migration for syb_session, and
any browser walkthrough.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 16:56:00 +08:00
QiuSWandClaude Opus 5 4886e0d0a4 test(#48): add opt-in live verification against the real SYB API
Guarded by the syblive build tag, so `go test ./...` still runs entirely
against httptest fakes. Credentials come from the environment; the file
contains none, calls only read endpoints, and logs shapes and counts
rather than order codes, titles or amounts.

Verified against the live API. Confirmed from real data:
  - login via OCR works unattended; session is exactly 24h
  - §3.1 auth is cookie-based: the jar is populated after login
  - §4.3 listTotal is the filtered total (7404 over 7 days) while
    list.total is the current page size (20) — a paging loop that
    treats the latter as the total stops after one page
  - §5.1 productPrice is in yuan, not cents (max observed 403.00)
  - §6.1 one order carries nested items, not repeated rows
  - details[].id was unique across the batch, closing a gap #41
    recorded as unverified

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 16:40:04 +08:00
QiuSWandClaude Opus 5 a31c4776c4 feat(#48): port SYB ERP client, session store and config (Stage 1)
Port the SYB ERP HTTP client from the upstream cmautobuy project. The
package is stdlib-only (no DB, no gin), so client.go, columns.go, ocr.go
and their httptest suites carry over almost verbatim; only the package
name and doc references changed.

Add on top of the port:
  - models.SYBSession + gorm SessionStore, so a restart does not force a
    fresh captcha. Cookies are credential-equivalent and carry json:"-".
    Expired sessions read as absent because SYB has no rolling renewal.
  - config.Extend.SYB. Non-secret settings live in settings.yml;
    username and password come only from GOAUTO_SYB_* environment
    variables, so no credential lands in a tracked file.
  - docs/12-syb-erp-interface.md, the ported interface contract.

The guard tests were mutation-checked: reverting json:"-" and renaming a
settings.yml key each make their test fail.

No import endpoint yet — that needs real credentials and live network
verification, which is Stage 2 of #48.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 16:30:35 +08:00
QiuSWandClaude Opus 5 b4861f5073 docs(#48): scope OCR prohibition to Agent side, allow SYB login captcha OCR
The blanket "no OCR/VLM" rule was written for Android Agent collection.
Server-side SYB ERP login is a different domain and needs captcha OCR to
run unattended. Scope the prohibition to the Agent side and record the
SYB carve-out, including that captcha images leave the project.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 16:17:16 +08:00
QiuSWandClaude Opus 5 136f5c94cb style(#40,#41): collapse page headings into search toolbar
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 15:32:50 +08:00
QiuSWandClaude Opus 5 f53e6ba05b docs(#41): sync architecture, business rules and API contract for syb import
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 15:11:03 +08:00
QiuSWandClaude Opus 5 03a56565ef feat(#41): add syb product admin page
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 14:49:12 +08:00
QiuSWandClaude Opus 5 e6c8b52164 fix(#41): add missing json tags to ReparseOutcome
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 14:49:10 +08:00
QiuSWandClaude Opus 5 f72c24b5da fix(#41): expose rawJson in detail response, not just storage
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 14:42:46 +08:00
QiuSWandClaude Opus 5 3b27d19aa8 feat(#41): add syb product admin API (list, detail, reparse, manual correction)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 14:40:09 +08:00
QiuSWandClaude Opus 5 d7f7420431 feat(#41): add syb_product CLI migration file
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 14:31:55 +08:00
QiuSWandClaude Opus 5 d67629808f feat(#41): add syb_product model, productSpec parser and shopee import merge
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 14:31:38 +08:00
QiuSWandClaude Opus 5 45e8c1285d fix(#40): remove illegal literal default on TEXT column image_url
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 14:10:24 +08:00
QiuSWandClaude Opus 5 40d2862c1a feat(#40): add shopee product admin page
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 13:53:51 +08:00
QiuSWandClaude Opus 5 03f44a0dd2 docs(#40): sync architecture, business rules and API contract for shopee product
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 13:45:35 +08:00
QiuSWandClaude Opus 5 658ffd5d15 feat(#40): add shopee product admin API
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 10:12:03 +08:00
QiuSWandClaude Opus 5 f9cb1945ab feat(#40): add shopee_product archive model, spec mapping and migration
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 10:03:21 +08:00
QiuSWandClaude Opus 5 1cd32a4b8c docs(#44): correct prototype ownership labels from #35 to #44
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 09:44:34 +08:00
QiuSWandClaude Opus 5 0d623d8e7b docs(#47): unify harness command references
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 09:23:02 +08:00
QiuSWandClaude Opus 5 f8d0011057 docs(#47): mirror harness command entry changes
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 09:20:32 +08:00
QiuSWandClaude Opus 5 b3430637d8 docs(#47): upgrade DevHarness baseline to bfdf648
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 09:19:38 +08:00
QiuSWandClaude Opus 5 80434ecb56 docs(#40,#41): record stage A prototype acceptance
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 08:53:52 +08:00
QiuSWandClaude Opus 5 231a604143 docs(#40,#41): shorten batch labels and resolve clear/reset overlap
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 08:49:16 +08:00
QiuSWandClaude Opus 5 b9da50ef12 docs(#41): add purchase task creation flow to prototype
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 17:57:18 +08:00
QiuSWandClaude Opus 5 acaa6c090b docs(#41): unify SYB terminology in issue and delivery index
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 17:51:36 +08:00
QiuSWandClaude Opus 5 953ce55e3f docs(#40,#41): rename 货运宝 to SYB in display terms
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 17:45:03 +08:00
QiuSWandClaude Opus 5 c25f6bbc83 docs(#41): align batch action placement with #40 toolbar
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 17:24:49 +08:00
QiuSWandClaude Opus 5 25b160c4d7 docs(#40,#41): support multiline batch search in list prototypes
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 17:06:29 +08:00
QiuSWandClaude Opus 5 5e2d4607e1 docs(#41): add row selection and split columns in list prototype
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 16:51:37 +08:00
QiuSWandClaude Opus 5 3d72af9c1f docs(#41): revise prototype for AI matching per #46
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 16:26:24 +08:00
QiuSWandClaude Opus 5 88e45060ac docs(#40): revise prototype for AI matching per #46
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 16:22:44 +08:00
QiuSWandClaude Opus 5 faecd90d2b docs(#46): revise spec matching rules for AI matching
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 15:47:38 +08:00
QiuSWandClaude Opus 5 57e8a7397c docs(#41): clarify syb does not gate procurement
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 14:28:10 +08:00
QiuSWandClaude Opus 5 b314109ce8 docs(#41): mirror stage A prototype status
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 14:18:42 +08:00
QiuSWandClaude Opus 5 7f6bee3ba8 docs(#41): add stage A syb import prototype
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 14:13:51 +08:00
QiuSWandClaude Opus 5 8dbac5ddf6 docs(#40): record stage A prototype acceptance
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 11:43:59 +08:00
QiuSWandClaude Opus 5 d5b279f81f docs(#40): use ISO 4217 currency from system config in prototype
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 11:40:18 +08:00
QiuSWandClaude Opus 5 61e742d0b2 docs(#40): add shopee sale price to prototype list, detail and create
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 11:32:49 +08:00
QiuSWandClaude Opus 5 8551256c3c docs(#40): add optional pdd product picker on create page
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 11:20:03 +08:00
QiuSWandClaude Opus 5 abd6984ef3 docs(#40): allow spec value entry on create page in prototype
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 10:55:34 +08:00
QiuSWandClaude Opus 5 1b6c83acc3 docs(#40): add manual spec value creation to prototype
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 10:45:40 +08:00
QiuSWandClaude Opus 5 2a18c80a71 docs(#40): rename to 虾皮 and add batch soft delete in prototype
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 10:34:58 +08:00
QiuSWandClaude Opus 5 2fcd012575 docs(#40): revise shopee list columns in stage A prototype
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 10:04:35 +08:00
QiuSWandClaude Opus 5 38dbaed05b docs(#40): add stage A shopee product prototype
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 09:48:43 +08:00
QiuSWandClaude Opus 5 23464ecd50 docs(#32): record procurement prototype acceptance
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 09:30:01 +08:00
QiuSWandClaude Opus 5 a3ef9cbcb4 docs(#40,#41): mirror stage A prototype gate
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 09:29:11 +08:00
QiuSW 3718ce8dc6 docs: record issue 45 acceptance mirror 2026-08-18 08:49:26 +08:00
QiuSW ceecb5855e feat(#45): add batch collection task creation 2026-08-17 17:17:20 +08:00
QiuSW f6bada9f86 docs(#31): archive accepted product module 2026-08-17 17:02:41 +08:00
QiuSW da7c02cbeb docs(#26): archive accepted traversal fix 2026-08-17 16:57:57 +08:00