Feishu Account Deduction Fees to MySQL Sync: A Practical Qeasy Strategy Guide
What This Strategy Solves
A retail enterprise records e-commerce channel account deduction fees in a Feishu spreadsheet, and the finance team needs to aggregate these fees by store and by month in a self-built MySQL data warehouse. On the surface, it looks like just pulling a table over, but in practice, you notice that Feishu spreadsheets are collaboration tools: row numbers drift with inserts and deletes, store codes appear in both old and new forms across different months, and if the differences between two daily pulls at the start and end of the month are not handled, the account deduction figures keep drifting away from reality. This strategy aims to use a single configuration to land the Feishu account deduction fee table stably into MySQL, so that the numbers the finance team sees each morning match what is recorded in Feishu.
Data Flow and Field Mapping
The data flow is straightforward: Feishu spreadsheet → Qeasy middleware → MySQL single table tp_fs_账扣费用. There is no header-detail separation on the source side; one row equals one account deduction fee record. The target side adopts flat single-table storage without master-detail splitting. This determines that the overall shape of the strategy is "lightweight, batch-oriented, and backed by scheduling."
Key field mapping table:
| Source Field (Feishu) | Target Field (MySQL) | Mapping Type | Conversion Rule | Business Meaning |
|---|---|---|---|---|
| id | id | DIRECT | Take the row number | Primary key, used for upsert deduplication |
| 电商渠道类型 | 电商渠道类型 | DIRECT | Original value | Channel category, used for aggregation by channel |
| 店铺编码 | 店铺编码 | DIRECT | Original value | Links to store master data |
| 店铺名称 | 店铺名称 | DIRECT | Original value | Display name |
| 经营分析店铺名称 | 经营分析店铺名称 | DIRECT | Original value | Analytical dimension, may differ from store name |
| 月份 | 月份 | DIRECT | Original string, e.g. "2024-01" | Monthly aggregation |
| 账扣费用 | 账扣费用 | DIRECT | Original floating point | Amount |
| 日期 | 日期 | DIRECT | Original value | Fee occurrence/entry date |
All fields are DIRECT mappings without formula conversion or script logic. This is the typical hallmark of a "light strategy" — the thinner the mapping, the lower the long-term maintenance cost.
How to Configure on Qeasy
When configuring this strategy on Qeasy Data Integration Platform, the core is to complete three things: source read rules, target write rules, and the schedule.
Source (Feishu) configuration points:
- Choose platform code
FeiShu, interface typeWebAPI, methodGET, API path/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values/:range. - In the request parameters, fix
valueRenderOptiontoToStringanddateTimeRenderOptiontoFormattedString. If these are not set, Feishu returns formula values and dates as serial numbers, which will misread the account deduction fee fields. headers_line=1, telling the platform explicitly that the first row is the header and data parsing starts from the second row.- Configure the primary key field as
id, i.e. the row number, but be aware that Feishu row numbers shift after row deletions, so the actual deduplication logic must be enforced on the MySQL side.
Target (MySQL) configuration points:
- Choose platform code
MySQL, interface typeSQL, effectEXECUTE. - Choose
REPLACE INTOfor the write mode, implementing upsert byid. Do not useINSERT IGNOREorINSERT. A subtle point: when usingREPLACE INTO, if a record with the sameidalready exists in the target table, it will be deleted first and then inserted, causing auto-increment primary key shifts. If you do not want to touch auto-increment IDs, a safer approach is to useINSERT ... ON DUPLICATE KEY UPDATE. - Set
idCheck=trueso the platform validates primary key existence before writing, avoiding silent data loss. - Single-batch write volume
limit=200. Feishu tables easily run to thousands of rows and must be batched. If the batch is too large, the MySQL single transaction becomes long and easily locks tables.
Schedule configuration: source cron 0 1 * * *, target cron 30 1 * * *, with the two ends offset by 30 minutes. This step is often overlooked at many customer sites, resulting in the two ends running in the same minute, so the target starts writing before the source finishes pulling, leading to "upsert while still reading," and a difference of dozens of records when reconciling at month-end.
Implementation Steps
Implement in three phases. After a few pitfalls, we recommend all customers follow this sequence.
Phase 1: Full initialization. First, run a full sync to land all historical account deduction fees from the Feishu table into MySQL. This can be done on Qeasy using "manual trigger + full mode" once, with the goal of giving the target table a clean initial state. The full trigger is usually scheduled for the early morning of the first day of the month, avoiding the finance closing window.
Phase 2: Set the incremental starting point. After the full run completes, set the source "incremental starting point" to the maximum date or latest row id that has already been synced, and the daily scheduled task will only pull new/changed rows from then on. The Qeasy platform typically uses the "last successful timestamp" or "last maximum primary key" as the incremental starting point, depending on the stability of the source fields. Feishu id is a row number that rearranges after deletions, so a safer approach is to use a combination of date + store code for business deduplication, rather than trusting id alone.
Phase 3: Schedule frequency and monitoring. Pull source at 1:00 AM and write target at 1:30 AM daily. Once stable, hook up monitoring and alerts: if the daily write count is 0 or fluctuates abnormally, trigger a notification. A common Qeasy customer practice is to feed this strategy into the finance dashboard, producing a "yesterday's sync count vs. daily average" comparison before 8:00 AM each morning, so anomalies are visible at a glance.
Pitfall Review
-
Misconfigured header row count on the source. The first row of a Feishu table is not always the header; some customers insert a row of explanatory text. If you directly set
headers_line=1, the field names will be read as things like "Description" or "2024 Summary," breaking all subsequent mappings. The safe approach is to run a "preview" on Qeasy first, confirm the header field names, and then save the configuration. -
Primary key drift caused by
REPLACE INTO. A typical mistake is treatingREPLACE INTOas a universal upsert. It DELETEs first and then INSERTs, causing auto-increment primary key gaps and breaking foreign keys in related tables. The handling is described in the configuration section above: switch toINSERT ... ON DUPLICATE KEY UPDATE. -
Offset scheduling overwritten by default settings. When customers create a new strategy on Qeasy, if they directly reuse the template, the source and target crons default to the same time point, leading to "target starts writing before the source pull completes." Always manually offset by at least 20-30 minutes.
-
idrearrangement caused by Feishu row deletions. When finance deletes a row in the Feishu table, the id of row 50 immediately becomes 49, and if the incremental logic only watchesid, rows will be missed. This is a point repeatedly emphasized in "centralized encoding mapping management": collaboration tools like Feishu are not suitable as master data sources, and true deduplication must rely on business keys (store code + date). -
MySQL table locks caused by oversized batch writes. Writing thousands of account deduction fee rows at once keeps a single transaction open for too long, blocking queries on the business side.
limit=200is an empirical value that can be adjusted according to the target table's indexing, but do not blindly push it above 1000.
Applicable and Non-Applicable Scenarios
Applicable: the source is a collaboration tool like a Feishu spreadsheet, and the target is a single-table financial/expense/ledger dataset with few fields, a flat structure, and no complex transformation. It suits the standardized landing of a "light strategy + offset schedule." Non-applicable: when the target requires a master-detail table structure, fields need formula conversion or multi-source merging, or strong real-time (minute-level) sync is required. In those cases, you should use a master-data-style strategy or an event-driven pipeline rather than this daily batch configuration.