Qeasy Cloud
Get Started

Practical Configuration Guide: Syncing Wangdian Shop Master Data to MySQL

· 何金辉· Integration Solutions· 15 views· 4 min read

What this strategy solves

A retail customer maintains a centralized "shop master view" in MySQL, shared by the order hub, inventory router, and reconciliation center. The source shop records live in Wangdian (旺店通) and are constantly being created, renamed, or disabled by each business unit. The problem: the MySQL view is updated manually via export-and-import, lagging by one to two days, and during that gap, orders from newly opened shops fail to flow back because no record exists.

We used the Qeasy data integration platform to pull a standardized shop list through the wdt.shop.query API, then land it into the MySQL target table tp_wdt_shop keyed on shop_no. REPLACE INTO guarantees idempotency, disabled shops are filtered out, and operations is finally free from manual exports.

Data flow and field mapping

The source side calls wdt.shop.query (WebAPI / POST / QUERY), keyed on shop_no, with page_size and page_no driven by pagination variables. The target side is a MySQL execute action (SQL / EXECUTE) whose main statement is a REPLACE INTO tp_wdt_shop with :field placeholders.

Key field mapping (source → target):

Source field (Wangdian)Target field (MySQL tp_wdt_shop)Notes
shop_noshop_noUnique code, part of the key
shop_idshop_idInternal numeric ID
shop_nameshop_nameShop display name
platform_idplatform_idPlatform code
platformsub_platform_idPlatform enum value
account_nickaccount_nickShop account nickname
province / city / districtprovince / city / district + *_nameBoth code and name are stored
is_disabled(filter condition)Only write when = 0
modified / createdmodified / createdTimestamps pass through
auth_state / prop1 / prop2 / is_undownload_trade / group_id / cust_data / invoice_payee_idsame namesExtension attributes pass through

REPLACE INTO uses (shop_no, platform_id) as the conflict key, so a second sync of the same shop will not produce duplicate rows.

How to configure it on Qeasy

At the strategy layer, attach the source to "Wangdian · Qimen" and the target to "MySQL". Set source number/id to shop_no with idCheck disabled; set target id to shop_no with idCheck enabled so the platform pre-checks duplicates before writing.

In the source "Request Parameters", hard-code platform=1 and is_disabled=0 to drop disabled shops at the source. Use {{PAGINATION_PAGE_SIZE}} for page_size and {{PAGINATION_START_PAGE}} for page_no so Qeasy paginates automatically. Keep autoFillResponse on so response fields auto-bind to the target placeholders.

On the target side, paste the tp_wdt_shop INSERT into main_sql and convert every ? into :field_name. Leave main_params as an empty object—source response fields will bind in automatically. "REPLACE INTO" is the safest pattern for this kind of master-data sync: re-running it will not multiply your rows.

Implementation steps

Step 1: Full initial load. Temporarily set the source crontab to 3-59/13 * * * * (every 13 minutes, offset from the top of the hour) and let it run overnight to pull every active shop. In parallel, capture the set of shop_no values written into MySQL for the next step's reconciliation.

Step 2: Locate the incremental starting point. On the source side, use the modified field to determine the cutoff time at which the full load finished, then store it as Qeasy's "incremental start" parameter. From this point on the strategy enters steady-state scheduling.

Step 3: Steady-state scheduling. Restore the source crontab to */13 * * * *. Because the source uses 3-59/13 (a 3-minute offset) and the target uses */13, the two sides never hit MySQL at exactly the same instant. Qeasy's console shows row counts and duration per run.

Step 4: Reconciliation and alerting. Do a daily end-of-day check: SELECT COUNT(*) on MySQL versus the paginated total from wdt.shop.query. Configure a webhook on exception events in Qeasy so duplicate keys or SQL errors alert immediately.

Lessons learned

  1. Forgetting the is_disabled=0 filter. The first run did not filter disabled shops, so the target table contained closed shops that downstream reconciliation scripts kept flagging as "ghost shops". The safe move is to hard-code is_disabled=0 on the source side and cut them off there.
  2. REPLACE silently degraded to duplicate INSERTs. We assumed REPLACE was enough, then discovered that some clients also include platform_id in the unique key, so a single shop on multiple platforms was inserted over and over. Add a composite unique index on (shop_no, platform_id) in MySQL.
  3. Misspelled pagination variable. Writing page_index instead of page_no produced no error, but the pull always returned page one. Qeasy's placeholders are case- and spelling-sensitive—copy variable names verbatim from the source API docs.
  4. Whole-hour concurrency avalanche. Setting both source and target to 0 */1 * * * made them hammer MySQL at the top of every hour and exhaust the connection pool. A 3-minute offset between source and target crontabs is the safe pattern.
  5. Skipping idCheck. Disabling idCheck on the target meant the platform did not intercept temporary duplicate shop_no values from the source, relying on REPLACE to clean up. Keep the pre-check on so problems surface before the write.

When to use it and when not to

Use it for: master data such as shops, customers, or warehouses that needs to be unified from a business system into a middle-platform relational store; low-frequency, total volume under tens of thousands; MySQL target that supports REPLACE.

Do not use it for: high-frequency, rapidly changing streams such as orders or inventory movements—those should ride change-event streams or binlog subscriptions, not a 13-minute full re-pull. If the target is a distributed or columnar warehouse, the cost of REPLACE INTO is too high and you should switch to MERGE / UPSERT instead.

Original content. Please credit the source when reposting: https://www.qeasy.cloud/insights/solutions/strat-mysql-wdt-5427-mysql-50f80335

Comments