Sales Outbound Order Sync in Practice: From WDT to MySQL
What This Strategy Solves
In one real project with a retail company, we ran into a typical problem: after the e-commerce frontend processes an outbound shipment in WDT (旺店通), the downstream BI reports, membership system, and third-party reconciliation platforms all need to see that shipment fact. But WDT itself is not an analytical database, and querying its API directly would slow down the source system.
Our final approach was to use the Qeasy Data Integration Platform to land WDT sales outbound orders into MySQL in a unified format, then let the downstream business systems subscribe to this fact table in MySQL. This decouples the systems, keeps an audit trail, and reduces pressure on the source system.
Data Flow and Field Mapping
The overall flow is WDT·企业奇门 (B) → Qeasy middle layer → MySQL (A). The source side pulls the outbound order header and line items, and after field cleaning and code conversion, writes them into the MySQL fact table.
Sample mapping of key fields (actual fields depend on the project):
| Business Meaning | WDT Source Field (illustrative) | MySQL Target Field | Handling Notes |
|---|---|---|---|
| Outbound order number | order_no | out_order_id | Primary key, unique index |
| Store code | shop_no | store_code | Requires code mapping |
| Warehouse code | warehouse_no | wh_code | Requires code mapping |
| SKU code | sku_id | sku_code | Watch for long-code truncation |
| Outbound quantity | num | out_qty | Numeric type conversion |
| Outbound time | create_time | out_time | Timezone and format unification |
| Order amount | total_amount | amount | Keep two decimal places |
Code mapping is the most error-prone part—the encoding systems for stores, warehouses, and SKUs on the two sides are usually inconsistent. In Qeasy, we maintain the mapping rules centrally in a "code mapping table." When new stores or warehouses are added later, only one place needs to be updated.
How to Configure in Qeasy
Step 1: Create a new "WDT·企业奇门" source connection, fill in the authorization information, and pull the sales outbound order API. Step 2: Create a new MySQL target connection, specifying the target database and write table. Step 3: Configure the data integration flow to complete field mapping and cleaning rules.
A few typical configuration points:
- Header and line items processed in stages: The outbound order header (order number, store, time, amount) and line items (SKU, quantity, unit price) are written to separate tables—header first, then line items—to avoid half-written transactions.
- Centralized code mapping management: The three types of code mappings for store, warehouse, and SKU are placed in the same configuration node for easy maintenance.
- Idempotent writes: Use the outbound order number + SKU as the unique key, and apply INSERT … ON DUPLICATE KEY UPDATE when writing to prevent dirty data from reruns.
- Failure retry and alerting: Qeasy's built-in retry mechanism combined with the alerting channel notifies the ops group at the first sign of trouble.
Implementation Steps
We usually split this strategy into three phases:
- Full-load initialization: At the first go-live, do a full backfill of outbound orders for the past 3 months. After it completes, verify the total order count and total amount, and only then open it up to downstream systems.
- Incremental start switch: Use the full-load end time as the incremental start point, and from then on only pull newly added and changed orders.
- Scheduling frequency: In production, schedule every 5 minutes—this ensures timeliness without overwhelming the source system. During off-peak hours, it can be relaxed to every 10 minutes.
The safe approach is dual-track incremental and full-load: keep the full-load script independent for disaster recovery and backfill; run incremental for daily scheduling. The two are isolated by the incremental start field and do not interfere with each other.
Pitfall Recap
- Inconsistent timezones: The timestamp returned by WDT is in seconds at UTC+8. When loaded directly, downstream systems parsed it as UTC, creating an 8-hour difference. We later added a unified timezone tag in Qeasy's field conversion.
- Truncated line items: One long SKU code exceeded 32 characters, and the MySQL side directly errored out on the varchar(32) column. The safe approach is to reserve field width based on the actual longest value when building the table, or use a text type as a fallback.
- Duplicate order numbers not deduplicated: WDT re-pushes the same outbound order under abnormal conditions, and without a unique key, two identical records appear in MySQL. The idempotency key must be designed at the source.
- Source system slows down during full backfill: Running full load during business peak hours caused source-side API timeouts and widespread Qeasy task failures. We later fixed full-load scheduling at 2 a.m.
- Downstream subscription latency: After landing in MySQL, downstream systems used timed polling, and latency stacked up. We recommend that downstream systems consume based on binlog or Qeasy's change notifications instead.
Applicable and Non-Applicable Scenarios
Applicable: In e-commerce or retail scenarios where WDT's sales outbound facts need to be uniformly deposited into an enterprise's own data warehouse or analytics database for BI, reconciliation, and membership system subscription use.
Not applicable: If the business volume is very small (less than a thousand orders per month), calling the WDT API directly is enough—there's no need to introduce a middle layer. If second-level real-time sync is required, this 5-minute scheduled strategy won't be enough either; you'll need to switch to a streaming channel.