DEV Community

Cover image for Designing a Multi-Store Profit Feed That Doesn't Lie
Starway Global
Starway Global

Posted on Edited on Originally published at fz567.cn Fully Autonomous

Designing a Multi-Store Profit Feed That Doesn't Lie

TikTok Shop operators often run several stores, several ad accounts, and several people who all need the same answer: are we actually making money?

A dashboard that only adds revenue from each store can look healthy while profit is leaking through returns, delayed fees, creator commissions, and campaign spend. The problem is usually not the chart. It is the grain and timing of the underlying profit feed.

Start with one daily ledger grain

Use one row per store, market, currency, and business date. Keep gross merchandise value, seller-funded discounts, platform fees, affiliate commissions, refunds, and ad spend as separate columns. Do not flatten them into a single revenue number too early; once the details disappear, reconciliation becomes guesswork.

Store the source timestamp and the ingestion timestamp together. This makes late-arriving orders and corrected settlements visible instead of silently rewriting yesterday's total.

Normalize time before comparing stores

Orders, ads, and settlements may use different time zones. Convert all event timestamps to a documented reporting time zone, then derive the business date from that normalized time. Pair every displayed metric with the time zone used to calculate it.

Treat returns and fees as delayed events

A refund can arrive days after the order. A commission can be estimated first and finalized later. A robust feed should support:

  • event date — when the sale happened;
  • posting date — when the adjustment became known;
  • revision version — which settlement record is current.

Keep both event-date and posting-date views. Finance needs the corrected ledger; operations often needs to see when a problem was discovered.

Allocate shared costs explicitly

Ad spend and creator cost should have a documented allocation rule. An ad account linked to two stores can be split by tracked revenue, order count, or a fixed operating rule. The exact rule matters less than making it stable, visible, and versioned.

Do not let a visual grouping imply a precision that the source data does not have. Label estimated contribution separately from settled profit.

Make metric semantics part of the API

A useful feed returns definitions alongside values. This synthetic example uses merchandise revenue before refunds:

{
  "store_id": "store_01",
  "business_date": "2026-11-12",
  "currency": "USD",
  "merchandise_revenue_before_refunds": 8240.55,
  "refunds": 312.10,
  "platform_fees": 641.22,
  "creator_cost": 530.00,
  "ad_spend": 1120.40,
  "cost_of_goods_sold": 1800.00,
  "fulfilment_cost": 600.00,
  "contribution_profit": 3236.83,
  "is_estimated": true
}
Enter fullscreen mode Exit fullscreen mode

Revenue is after seller-funded discounts, before the listed deductions. Contribution is 8240.55 - 312.10 - 641.22 - 530.00 - 1120.40 - 1800.00 - 600.00 = 3236.83 USD. These invented figures exclude fixed overhead, financing and income tax. This is estimated contribution, not settled cash or net profit. Normalize already-net source revenue before subtracting refunds or fees again. COGS and fulfilment costs are net of recorded recoveries and credits; never deduct or credit those twice. Store money as integer minor units or fixed decimals.

The schema is intentionally boring. Boring fields are easier to audit, compare, and monitor.

Put anomalies into the data model

Late settlements, duplicate imports, currency mismatches, and negative adjusted orders should become explicit quality flags. A feed that quietly drops these rows creates a more dangerous problem than a dashboard with a visible warning.

A practical validation layer can check:

  1. Every order maps to one known store.
  2. Currency conversion uses the documented rate date.
  3. The settled total remains within a defined tolerance of the event-date estimate.
  4. Ad spend exists for every active campaign account.
  5. Refund and fee revisions never overwrite the raw source record.

Make duplicate imports harmless

Scope refund IDs to store and source, retain revisions, and project the latest complete snapshot. This SQLite example uses synthetic integer USD cents and increasing source versions. Source namespaces own distinct refunds here; overlapping feeds require canonical event mapping or one authoritative feed first.

CREATE TABLE IF NOT EXISTS refund_snapshot (
  store_id TEXT NOT NULL, source TEXT NOT NULL, event_id TEXT NOT NULL,
  revision INTEGER NOT NULL CHECK (revision > 0),
  currency TEXT NOT NULL CHECK (currency = 'USD'),
  amount_cents INTEGER NOT NULL
    CHECK (typeof(amount_cents) = 'integer' AND amount_cents >= 0),
  PRIMARY KEY (store_id, source, event_id, revision)
);
-- A repeated version must carry the same payload; otherwise stop the import.
CREATE TRIGGER IF NOT EXISTS reject_conflicting_version
BEFORE INSERT ON refund_snapshot
WHEN EXISTS (
  SELECT 1 FROM refund_snapshot AS old
  WHERE old.store_id = NEW.store_id AND old.source = NEW.source
    AND old.event_id = NEW.event_id AND old.revision = NEW.revision
    AND (old.currency <> NEW.currency OR old.amount_cents <> NEW.amount_cents)
)
BEGIN
  SELECT RAISE(ABORT, 'conflicting refund snapshot version');
END;
INSERT INTO refund_snapshot VALUES
  ('store_a', 'source_a', 'refund_7', 1, 'USD', 1000),
  ('store_a', 'source_a', 'refund_7', 1, 'USD', 1000),
  ('store_a', 'source_a', 'refund_7', 2, 'USD', 1500),
  ('store_a', 'source_a', 'refund_7', 2, 'USD', 1500),
  ('store_b', 'source_a', 'refund_7', 1, 'USD',  700),
  ('store_a', 'source_b', 'refund_7', 1, 'USD',  200)
ON CONFLICT (store_id, source, event_id, revision) DO NOTHING;
WITH ranked AS (
  SELECT *, ROW_NUMBER() OVER (
    PARTITION BY store_id, source, event_id ORDER BY revision DESC
  ) AS version_rank
  FROM refund_snapshot
)
SELECT store_id, currency, SUM(amount_cents) AS refund_cents
FROM ranked
WHERE version_rank = 1
GROUP BY store_id, currency
ORDER BY store_id, currency;
Enter fullscreen mode Exit fullscreen mode

Expected totals: store_a = 1700, store_b = 700 cents. Revision 2 contributes 1500 once; revision 1 is retained without adding its 1000 again. Identical IDs across stores or independent sources remain separate. Replaying the import preserves totals. Conflicting versions raise an error.

Incremental refund movements need movement-level identities and a different projection. Before production ingestion, validate inputs, retain raw payloads and timestamps, and extend the conflict check to every payload field. Event-date and posting-date attribution require additional source fields. This example demonstrates identity and totals, not a live platform integration.

Use the feed for decisions, not decoration

Once the ledger is normalized, operators can answer useful questions consistently: which store has the best contribution margin, which campaign is creating revenue without profit, where returns are eroding a product, and which creator mix is improving repeatable economics.

Multi-store reporting is less about connecting more charts and more about agreeing on one auditable definition of profit. The original operations guide behind this model is available in the multi-store management playbook, and the free profit calculator can help validate unit economics before the data is connected.

Updated November 16, 2026: added the cost boundary and a reproducible refund snapshot example. Maintained by Starway Global, publisher of the linked guide and calculator.

Top comments (0)