Design and Implementation of a Pricing Calculation Engine for E-commerce Promotions
The article details the design and implementation of a dedicated pricing calculation engine that decouples complex e‑commerce promotion logic from transaction services, using componentized rules, configurable pipelines, multi‑level caching, and lane‑based simulations to achieve high extensibility, low latency, and accurate pricing across browsing and checkout scenarios.
The article introduces the challenges of price calculation in large‑scale e‑commerce promotions and presents the design of a dedicated pricing engine to simplify and decouple the pricing logic from transaction and mall services.
Background : Price calculation for promotions involves user identity, assets, coupons, red packets, etc., and appears as the actual payment price in transaction scenarios (shopping cart, checkout, order) and as an estimated price in browsing scenarios (product detail, list). With the rapid expansion of business and channels, the variety of promotional activities has made the existing pricing system unable to support new rules efficiently, necessitating an independent pricing service.
Challenges and Solutions :
Different activity rules are maintained by various teams, leading to inconsistencies. Solution: Componentize each activity calculation and standardize inputs/outputs.
High extensibility required for quick adjustments in browsing scenarios. Solution: Either hard‑code the ordering logic or make the calculation order configurable via external files.
Complex priority matrix and mutual exclusion between activities. Solution: Configure mutual exclusion and select the lowest price when multiple activities of equal priority apply.
Core transaction pricing must be highly accurate to avoid losses. Solution: Multi‑level caching for hot activities, monitoring and alerts for risky calculations, and a degradation mechanism at the component level.
Birth of the Pricing Engine : The new service aims to support rapid addition of marketing tactics, seamless removal of activities, fast reordering, high performance for browsing (low latency, high throughput), and stability for transaction scenarios, while improving development efficiency.
Specific Implementation :
1. Pricing Pipeline : Nodes execute sequentially; within a node, calculation units run in order. The pipeline selects the highest‑priority activity result and discards non‑optimal snapshots.
2. Pricing Lane Processor : Simulates the lowest price over a time interval by defining a “lane” for each user identity, determining which activities are active in each time slice.
3. Pricing Driver : Handles real‑time calculation (directly fetches applicable discounts) and simulation calculation (uses lanes to compute prices for each time slice).
4. Configuration Management : Activity ordering and other settings are stored in JSON files loaded at service startup, allowing runtime adjustments without code changes.
Example configuration (illustrative, not production):
[
[
{
"componentType": 1,
"componentName": "限时购计价组件",
"conflictInfo": ["5"]
},
{
"componentType": 2,
"componentName": "特价计价组件"
}
],
[
{
"componentType": 3,
"componentName": "N元任选计价组件"
}
],
[
{
"componentType": 4,
"componentName": "全场类满额减计价组件"
}
],
[
{
"componentType": 5,
"componentName": "邮费计价组件"
}
]
]The configuration defines components, their types, names, and mutual‑exclusion information, forming calculation units and nodes.
Overall Design : An input adaptation layer converts request parameters into engine inputs; the engine processes them through the pipeline; the result adaptation layer formats the output for external consumption.
Summary and Outlook : The pricing engine now serves shopping cart, order grouping, and order placement scenarios. Integration with browsing scenarios (detail pages, lists, recommendations) is in progress, with full support expected for major sales events. Future work includes sharing concurrency and caching designs, and evolving the rule engine to better fit the promotion domain.
Author Bio : Li Li, backend developer, joined NetEase Yanxuan in 2019, focusing on promotion domain development and technical evolution, responsible for promotion management system, shopping cart, and pricing service construction.
NetEase Yanxuan Technology Product Team
The NetEase Yanxuan Technology Product Team shares practical tech insights for the e‑commerce ecosystem. This official channel periodically publishes technical articles, team events, recruitment information, and more.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.