WDT Goods Master Sync to MySQL: Incremental Pull + Main and Spec Tables Landing
What This Strategy Solves
The goods master is the foundation of supply-chain integration—downstream inventory, orders, purchasing, and pricing all depend on it. In one real engagement, a retail enterprise used WDT (Wangdiantong) as the front-end ERP and MySQL as the data warehouse. After three months the goods masters on the two sides could not be reconciled, and physical counts never matched the books. The sync strategy had not clearly addressed three things: the incremental starting point, the pagination cursor, and the relationship between the main table and the spec child table. Once we onboarded this on the Qeasy Data Integration Platform, the two sides aligned within a week using the approach below.
Data Flow and Field Mapping
The source is WDT QiMen, API wdt.goods.query, a POST QUERY call. The target is MySQL via the execute SQL action. The key field mapping is:
| Dimension | WDT (Source) | MySQL Main Table jry_wdt_goods | MySQL Spec Child Table jry_wdt_goods_spec_list |
|---|---|---|---|
| Primary key | goods_id | goods_id | spec_id (FK to goods_id) |
| Business number | goods_no | goods_no | spec_no |
| Name | goods_name | goods_name | spec_name |
| Barcode | – | – | barcode |
| Pricing | – | – | retail_price, wholesale_price, member_price |
| Timestamps | modified, created | modified, created, goods_created, goods_modified | spec_created, spec_modified |
| Relationship | – | 1 | N (extend_params_2 = spec_list) |
The main table uses REPLACE INTO, and so does the spec child table. Both rely on goods_id and spec_id for natural deduplication, which gives us a solid idempotency guarantee.
How to Configure This on Qeasy
In Qeasy's Data Integration Strategy editor, configure a single strategy for the whole flow:
- Source configuration: Select WebAPI, enter
wdt.goods.queryas the API name, POST as the method. Bind the incremental window tostart_timeandend_time. Use the platform variable{{LAST_SYNC_TIME|datetime}}for the start, and{{CURRENT_TIME|datetime}}for the end. Defaultdeletedto0so that only non-deleted goods are returned. - Target configuration: Select MySQL with type SQL.
main_paramsmaps to the dynamic parameters of the main SQL, andextend_params_2is set tospec_list. The platform automatically splits the 1:N relation, writing the main row first and then the spec child rows. - Centralized encoding mapping: This is a common pattern among Qeasy customers—put all enumerations (units, categories, brands, etc.) into a platform-level mapping table, and reuse the same set across many strategies. Change once, apply everywhere, instead of letting each strategy maintain its own script.
- Auto-fill response: Enable
autoFillResponseon the source side; the platform maps the returned array to target fields, eliminating the manual binding work.
Implementation Steps
- Incremental starting point: Before the first run, create the two target tables in MySQL and initialize
LAST_SYNC_TIMEto1970-01-01 00:00:00for a full historical pull. - Full trigger: After the historical pull completes, advance
LAST_SYNC_TIMEto the moment the full run started. Subsequent runs use incremental mode. - Schedule frequency: Set the source crontab to
*/13 * * * *. Stagger the target by about 10 minutes with3-59/13 * * * *to avoid read/write contention on the same table. - Page size: Push
page_sizetoward the platform's upper limit to reduce HTTP round trips. - Header and detail phased write: The classic "header-then-detail phased" pattern shows up here as "main table first, spec child table second." Qeasy enforces this order via
main_params→extend_params_2. If one main row fails, you do not lose the entire spec batch.
Pitfall Review
start_timewithout timezone handling: WDT returns timestamps as strings. Passing them directly to MySQL can collapse to the year zero. A safe approach is to attach the|datetimeconverter in the platform variable so the value is normalized toyyyy-MM-dd HH:mm:ss.- Hardcoding
page_sizeto 100: A typical mistake is to start at 100, which triggers interface timeouts. A safer approach is to start at 40, validate end-to-end, and only then nudge to 80. - Mistaking
REPLACE INTOforINSERT:REPLACEperforms a delete-then-insert, which changes auto-increment IDs and triggers cascading FK effects. Confirm that no downstream reports depend on stable auto-increment IDs. - Memory blow-up after 1:N expansion: Goods with many specs can blow up memory if the full payload is expanded in one go. Qeasy expands by
goods_idin batches by default—do not turn that off. LAST_SYNC_TIMEnot persisted: After each successful run, the platform writes the currentend_timeback toLAST_SYNC_TIME. If the run is interrupted and retried, verify that this variable has been persisted correctly; otherwise you will replay the same historical window.
Applicable and Non-applicable Scenarios
Applicable: WDT is the single source of truth for goods master, and a downstream MySQL mirror is needed for BI, labeling, or promotional systems, with goods volume at or below the hundred-thousand level. Not applicable: bi-directional sync, large semantic differences between fields (such as tax rates or unit-of-measure conventions) that require conversion rule editing, or scenarios where multiple sources of goods master need to be merged and deduplicated—those need a separate master-data governance strategy rather than a single sync.