Return Order Sync in Practice: From Marketing Cloud to Kingdee YXC
What This Strategy Solves
In retail and FMCG businesses, return documents are the link between frontline stores, the marketing middle office, and the back-office ERP. In one real project, the customer reported: when approved returns in the marketing cloud were entered manually into Kingdee YXC, dozens per store per day piled up into hundreds within three days, and inventory and finance soon drifted apart. The return-inbound sync strategy automates pulling approved returns from the marketing cloud and writing them as inbound documents into Kingdee YXC, so returns hit the books the same day.
Data Flow and Field Mapping
Data flows from the source (marketing cloud) through the Qeasy integration layer for cleansing and mapping, and is then written into the target (Kingdee YXC).
Key field mapping:
| Business meaning | Source (Marketing Cloud) | Middle layer | Target (Kingdee YXC) |
|---|---|---|---|
| Distributor dimension | tenantId | Pass-through | Used as bill source marker |
| Document number | number | Pass-through | Written into remark: from Marketing Cloud-{number} |
| Audit time | auditTime | Date-trimmed | bill_date |
| Customer name | organName | Resolved to internal ID via customer master | customer_id |
| Shipping address | shippingAddress | Pass-through | contact_address |
| Contact person | contactLinkman | Pass-through | contact_linkman |
| Document status | status=1 | Filter condition, only approved | Triggers write |
The middle layer's core responsibility is centralised code-mapping management: customer, item, and warehouse masters are all maintained in Qeasy lookup tables, rather than scattered across each document.
How to Configure It in Qeasy
On the Qeasy data integration platform, this strategy has four typical configuration blocks:
- Source API: WebAPI query endpoint
/erp/api/order/query/saleReturnOrder, POST. MandatorytenantId(distributor id) and time window; optionalstatus=1to restrict to approved documents.idCheck=trueenables idempotency to avoid duplicates on rerun. - Target API: Write into Kingdee YXC
/jdy/v2/scm/sal_in_bound, POST, withbill_sourcefixed atISV; primary keyidis used for idempotent write-back. - Field mapping and scripts: date fields use templates such as
{{auditTime|date}}for formatting; the customer field uses_findCollection find id from … where name={{organName}}for resolution. This is the typical Qeasy "centralised code-mapping" pattern—change the customer master once, and every dependent strategy picks it up automatically. - Scheduling and dependencies: The strategy depends on upstream customer and item master syncs (sequence A, B); masters must complete before return orders run.
Implementation Steps
We rolled this out on the customer site in three phases:
Phase 1: One-shot full load. Stop manual entry, then run a one-shot backfill over the last seven days of approved returns to validate mapping and lookups. A typical pitfall here: some historical organName values had been renamed in the customer master, so _findCollection returns nothing. The safe practice is to run a "customer master completeness check" before the full load.
Phase 2: Incremental anchor. After the full load, switch the start cursor to {{LAST_SYNC_TIME}} and only pull increments afterwards. Confirm whether the source's beginTime field is based on update time or create time for approved documents—the marketing cloud source supports a timeType switch, defaulting to create time, which is a common gotcha.
Phase 3: Scheduling cadence. Source runs every 8 minutes (*/8 7-23 * * *), target every 7 minutes (*/7 7-23 * * *), staggered to avoid upstream and downstream contending. Active window is 7:00–23:00, aligned with store opening hours; no overnight ingestion reduces dirty data.
Lessons Learned
- Time-window field semantics flipped. The marketing cloud defaults to create time, but returns are usually "create first, audit later."Pulling by create time drags in dirty, unapproved rows. Switch
timeTypeto 1 (update time) and addstatus=1as a second guard. - Customer code not found. When
_findCollectionreturns nothing, the whole document fails with a generic "customer does not exist" error that doesn't identify the offending record. Configure "failure-reason backfill" in Qeasy so the raworganNameis included in the error context for fast triage. - Idempotency key not effective → duplicates. If
idCheck=truebut the sourceidchanges on incremental rerun (e.g., a return is unaudited then re-audited), duplicate inbound documents appear on the target side. Bind the idempotency key tonumber+auditTimeinstead ofidalone. - Embedding business info into remarks causes ambiguity. We initially concatenated
{{remark}}-from Marketing Cloud-{{number}}straight into the target remark, but the upstreamremarkoccasionally contained line breaks, which truncated the Kingdee-side remark. Clean it in a script first, then concatenate. - Faster scheduling isn't always better. At one point we pushed the interval down to 2 minutes; during return peaks, upstream and downstream queues waited on each other and overall latency actually rose. Returning to a 7/8-minute staggered cadence kept steady-state latency at the minute level.
When It Fits and When It Doesn't
Fits: Marketing cloud → ERP return inbound where document structure is stable, there is a clear approved status, and near-real-time booking is needed for retail/FMCG businesses; customer and item masters already mapped centrally in Qeasy. Does not fit: Source systems without a clear approved status, returns that are frequently unaudited and re-booked, or returns that must be split across bins with detailed body handling—the latter needs stronger staged header/body processing than this lightweight header-body model can support.