Sales Order Sync Strategy Tutorial: End-to-End Configuration from Source Query to Target Write
What This Strategy Solves
Sales order sync is the most underestimated link in supply chain integration. In one real project, a retail enterprise ran both front-end store systems and a mid-office ERP, each with its own sales order definition. Without bridging them, financial reconciliation, inventory deduction, and fulfillment all went wrong within three months. This strategy's core goal is to pull sales orders from the source system into the target system under clear business rules, so there is one canonical order definition with traceable status.
Data Flow and Field Mapping
The data flow follows a three-stage pattern: source system → middleware layer → target system. The source side handles incremental queries by time window; the middleware handles cleansing, mapping, and idempotency; the target side writes or triggers downstream.
Key field mapping (desensitized):
| Business Meaning | Source Field | Middleware Handling | Target Field |
|---|---|---|---|
| Document number | goodsDocNo / recId | Pass-through, used as idempotency key | Document number |
| Creation time | createTime | Normalized to standard datetime | Creation time |
| Pagination | pageIndex / pageSize | Default page size 50 | — |
| Time window | startDate / endDate | Anchored by {{LAST_SYNC_TIME}} and {{CURRENT_TIME}} | — |
A robust practice: use the document number as the idempotency key and place it into the Qeasy "centralized encoding mapping" module. Re-runs, backfills, and manual entries can then be blocked from duplicate writes by this single key.
How to Configure in Qeasy
We use the Qeasy data integration platform to host this pipeline. Typical configuration has four parts:
- Source API configuration: Set type to QUERY, method to POST, fill in pagination and time window parameters. Use platform variables
{{LAST_SYNC_TIME|datetime}}for startDate and{{CURRENT_TIME|datetime}}for endDate. The platform computes the window automatically, no manual offset needed. - Target API configuration: The target side is often not a direct DB write but a set of WebAPIs. When metadata type is WebAPI and effect is EXECUTE, the platform POSTs each detail row from the source response to the target API.
- Field mapping: In Qeasy's "header-body phased" configuration, separate header from line items. The header lands first; line items loop by row number. If the header fails, the entire document is not written, preventing orphan records where the header is in but the body is not.
- Scheduling strategy: The crontab field is the platform's scheduling expression, for example
1-59/5 6-23 * * *means every 5 minutes from 06:00 to 23:00 daily, avoiding the nightly archive window.
Implementation Steps
We recommend a three-phase rollout rather than a big-bang cutover.
Phase 1: Incremental Starting Point
Pick a clear time anchor, such as yesterday 00:00:00, and start the incremental run from that point. Qeasy's LAST_SYNC_TIME rolls forward automatically. After running through, observe for 24 hours to confirm no documents are missed at the window edge.
Phase 2: Full Trigger Once the incremental run is stable, use the platform's full-trigger action to backfill historical data in date slices. During full sync, shrink the page size (for example to 20) to reduce pressure on the source system. Run one slice, then move to the next.
Phase 3: Steady-State Scheduling Attach the strategy to the formal crontab. We recommend a combination of "every 5 minutes plus off-peak windows". A common Qeasy pattern is the "dual-track incremental and full": incremental handles real-time daily traffic, full sync backfills at night, and the two lines do not interfere with each other.
Pitfall Review
- Time window drift: A typical mistake is using database time as business time. The safe approach is to explicitly use the "business document creation time" as the window field. When the source time field includes a timezone, normalize to UTC+8 in the middleware before persisting.
- Pagination infinite loop: If pageIndex does not increment, or total is returned but not read, the loop runs forever. The Qeasy platform enforces idCheck; make sure it is enabled.
- Idempotency key drift: Using recId as the idempotency key today, then the meaning of recId changes after an API upgrade, and historical data gets duplicated. The fix is to bind the idempotency key to both the record ID and the business document number, managed centrally in Qeasy's encoding mapping module.
- Header-body misalignment: When the header and body are not written in the same transaction, you get "header in, body missing", and downstream reconciliation fails. We package header and body into one logical document in Qeasy, so failure rolls back the whole document.
- Nightly archive conflict: A crontab of
* * * * *runs 24/7 and collides with the source system's nightly archive, causing mass timeouts. Recommend off-peak scheduling during business hours.
Suitable and Unsuitable Scenarios
Suitable: order volumes under hundreds of thousands, near-real-time sync required, both source and target systems expose standard APIs. Unsuitable: millions of orders with sub-second latency requirements, complex state-machine writeback, or source systems that only expose direct database access without open APIs. In the latter case, do an API-ification project first, then talk about sync.