Design and Implementation of L‑Coin Cost Tracing in Lianjia’s Microservice Architecture

This article describes the L‑Coin virtual currency used by Lianjia, explains the Spring Cloud micro‑service architecture that supports it, outlines the need for precise cost‑source tracing for each transaction, and presents a detailed backend design and technical implementation to achieve reliable, asynchronous cost attribution and refund handling.

Beike Product & Technology
Beike Product & Technology
Beike Product & Technology
Design and Implementation of L‑Coin Cost Tracing in Lianjia’s Microservice Architecture

L‑Coin is an internal virtual currency (now called Beike Coin) used by Lianjia agents to earn rewards, purchase services, and increase exposure; it functions as a points‑based token whose consumption must be traced back to its issuing budget for financial settlement.

The system adopts a Spring Cloud (Eureka + Feign) micro‑service architecture, comprising three stateless service clusters: a payment core service handling API security, idempotency, and concurrency; an L‑Coin service providing issuance, query, and refund APIs; an accounting service managing accounts and transaction logs; and a membership service managing user levels based on accumulated L‑Coin.

Cost‑source tracing is required because L‑Coin can be issued from multiple subsidiary budgets, and each consumption must record which budget batch the spent tokens originated from, enabling accurate inter‑company financial reconciliation.

The proposed solution introduces a stock record table that logs every issuance batch, transfers, and deductions, and an allocation detail table that records the cost source for each order and refund. A historical node is defined to initialize existing balances, and subsequent balance changes are recorded in the stock table. Consumption selects cost sources sequentially by batch age, while refunds reverse the corresponding allocations.

Technical choices include asynchronous processing via a message queue to avoid impacting core order flow, a switch‑controlled full‑data initialization script for zero‑downtime migration, periodic validation and compensation for failed traces, data archiving for completed historical records, and idempotent message handling with unique identifiers and distributed locks.

The design demonstrates how a seemingly small business requirement can be systematically broken down, modeled, and implemented within a robust backend infrastructure.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendpaymentSpring Cloudcost tracingvirtual currency
Beike Product & Technology
Written by

Beike Product & Technology

As Beike's official product and technology account, we are committed to building a platform for sharing Beike's product and technology insights, targeting internet/O2O developers and product professionals. We share high-quality original articles, tech salon events, and recruitment information weekly. Welcome to follow us.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.