Qeasy Cloud
Get Started

Distribution Sales Return Sync in Practice: Encoding Lookup and Org Attribution from WMS to Kingdee Cloud

· 钟家寿· Integration Solutions· 10 views· 4 min read

What This Strategy Solves

In distribution scenarios, the return party is no longer the end buyer but the distributor itself. Each distributor sits under a different sales organization and maps to different customer master data, so the ERP document attribution depends entirely on resolving the distributor code. The core value of this strategy is to unify, in one pass, document header-to-organization, header-to-customer, and line-to-material mapping for distribution sales returns.

Data Flow and Field Mapping

Data flows from the e-commerce WMS (return-inbound order) → the middle layer (Qeasy integration platform handling encoding lookups and mapping) → the ERP (distribution sales return KD_DSSAL_RTNSTOCK).

Key field mapping:

Target FieldMapping TypeConversion RuleBusiness Meaning
FBillTypeIDCONSTANTDSXSTHD07Distribution sales return type
FBillNoDIRECT{{order_no}}Inbound order number as document number
FDateDIRECT{{modified}}Last modified time as document date
FSaleOrgIdCOLLECTIONLookup by fenxiao_nick_no against distributor mapping table, return FUseOrgIDSales organization
FRetcustIdCOLLECTIONSame lookup, return FCustIDReturn customer
FStockOrgIdCONSTANT106Inventory organization
FSettleCurrIdCONSTANTPRE001Settlement currency: CNY
FHeadNoteDIRECT{{shop_remark}}Remarks
FreamountDIRECT{{actual_refund_amount}}Return amount
FThirdBillNoDIRECT{{refund_no}}Original return order number
FEntityCOLLECTIONvalue=details_listLine entries, generated row by row

Line-level (inferred mapping, to be confirmed against actual API response): spec_no → material code, num → actual return qty, price → tax-inclusive price, amount → total amount, warehouse_no → warehouse code, remark → line note.

How to Configure on Qeasy

On the Qeasy data integration platform, this strategy runs as a "source QUERY + target EXECUTE" combination — no scripts required.

  1. Source metadata: Select the interface wdt.wms.stockin.refund.querywithdetail. Put the pagination parameter pager and business parameter params into the request body. Use order_no as the primary key, with idCheck enabled to prevent duplicate fetches.
  2. Target metadata: Select Kingdee Cloud batchSave, set FormId to KD_DSSAL_RTNSTOCK, Operation=Save, IsAutoSubmitAndAudit=true, IsVerifyBaseDataField=false, SubSystemId=21.
  3. Centralized encoding mapping: Both distributor→customer and distributor→organization lookups point to the same "distributor-customer correspondence" table (hashed strategy ID), using _findCollection syntax with the FWDTDCNumber condition, returning FCustID and FUseOrgID. This "centralized encoding mapping" pattern is very common among Qeasy customers — when a distributor is added or an organization changes later, only that one table needs editing, not every strategy.
  4. Header and body staged mapping: The document header uses _findCollection to resolve the distributor code and fill in the organization and customer. The document body uses FEntity to reference details_list as a whole; the platform expands it row by row without hardcoding each field in the strategy.
  5. Scheduling: Source runs */15 * * * *, target runs */20 * * * * — source faster than target to avoid backpressure downstream.

Implementation Steps

Recommended phased scheduling:

  • Incremental starting point: Use source modified (last modified time) as the incremental cursor. Before the first sync, run a baseline of "data after today's 00:00" to avoid a flood of historical baggage.
  • Full trigger: Run only on first go-live or after the mapping table is rebuilt. Page backward by created_time in descending order, stop when done, and immediately switch back to incremental.
  • Schedule frequency: Source every 15 minutes, target every 20 minutes. Distribution channel document volume is usually moderate — no need to push to 5-minute intervals. Leave Kingdee time for auditing and inventory write-back.
  • Failure retry and alerting: Qeasy retries failed requests by default, but unmatched distributor code lookups should trigger separate alerts — they are the root cause of attribution chaos.

Lessons Learned

  1. Distributor code field-name confusion: Source metadata says fenxiao_nick (nickname), but the lookup needs fenxiao_nick_no (code). If the upstream API only returns nicknames, the lookup returns empty, and both organization and customer go wrong. The safe practice is to capture the real response with Postman before going live and confirm whether fenxiao_nick_no exists; if not, add a mapping script in the source extension.
  2. shop_remark and remark are not the same field: The target template uses {{remark}}, but the source main table actually has shop_remark. A typical mistake is copying the template name directly, leaving FHeadNote empty forever. Grep for same-named fields in source metadata before configuring.
  3. Logistics number and company are "ghost fields": The template references logistics_no and logistics_name, but the source main table only has logistics_type. Either confirm they come from line items or extension fields, or simply leave them blank until the business side confirms — don't fabricate values just to fill fields.
  4. Don't hardcode line-level fields: Set FEntity's value to details_list as a whole reference; the row-level spec_no → material correspondence relies on material master data existing in Kingdee. Make sure SKU master data is fully set up on the Kingdee side before integration, otherwise the entire document will fail at save.
  5. IsVerifyBaseDataField=false is a double-edged sword: Disabling base data validation lets the save go through, but errors in organization, customer, or material codes won't be reported. We recommend actively throwing an error when the lookup fails, rather than silently passing it — this is exactly why the "incremental and full dual-track" pattern needs periodic reconciliation.

Applicable and Non-Applicable Scenarios

Applicable: Distribution channels where the distributor is the return party, with multi-organization, multi-customer retail or FMCG enterprises; document volume in the low thousands per day with stable return frequency. Not applicable: ToB/ToC direct sales returns (use the corresponding sales return strategy); organizations where distributor codes are not yet mapped in the ERP master data; or large chains that need complex split-by-store or split-by-platform handling.

Original content. Please credit the source when reposting: https://www.qeasy.cloud/insights/solutions/strat-wdt-kingdee-cloud-5343-n5c616569-b31d2041

Comments