Backend Development 8 min read

Mastering End-to-End Shopping Cart to Order Flow in a SpringBoot E‑Commerce System

This article walks through the complete shopping‑cart‑to‑order workflow of the open‑source Mall project—built with SpringBoot, Vue and uni‑app—detailing database schema, cart promotion logic, confirm‑order generation, order creation, cancellation, and payment‑success callbacks, while highlighting key design considerations and code references.

macrozheng
macrozheng
macrozheng
Mastering End-to-End Shopping Cart to Order Flow in a SpringBoot E‑Commerce System

Mall Project Overview

The Mall project is an open‑source e‑commerce system based on SpringBoot, Vue and uni‑app, featuring Docker container deployment, a front‑end shop and a back‑end admin system that support a full order lifecycle including products, carts, orders, permissions, coupons, members and payments.

Project address: https://github.com/macrozheng/mall

Video tutorial: https://www.macrozheng.com/video/

Feature Design

The following sections describe the complete process from adding a product to the cart through to successful payment, with flow diagrams and screenshots.

Cart Addition

After a user adds a product to the cart, the cart stores the selected items and calculates cart‑level discounts.

Cart promotion calculation flow

Discount amounts are not shown in the cart; they appear on the confirm order page.

Discounts are calculated per product, not per SKU.

Implementation reference:

OmsPromotionServiceImpl

class,

calcCartPromotion

method.

Confirm Order Generation

When the user clicks “Proceed to Checkout” in the cart, the confirm order page displays product details, discounts, total price, shipping address selection, coupon usage and point redemption.

Confirm order flow

Total amount = sum of product prices in the cart.

Promotion discount = sum of cart‑level discount amounts.

Payable amount = total amount – promotion discount.

Implementation reference:

OmsPortalOrderServiceImpl

class,

generateConfirmOrder

method.

Order Generation

After confirming the order, the user clicks “Submit Order” to create the order, which processes cart information and user data.

Order creation flow

Stock locking: stock is fetched from

pms_sku_stock

table;

lock_stock

indicates locked quantity.

Coupon amount distribution: full‑site coupons are evenly split across all cart items; category‑specific coupons across items of that category; product‑specific coupons across the designated products.

Actual payment per item = original price – promotion discount – coupon deduction – point deduction.

Order number generation uses Redis with format: 8‑digit date + 2‑digit platform code + 2‑digit payment method + incremental ID.

Coupon status is updated after use.

Implementation reference:

OmsPortalOrderServiceImpl

class,

generateOrder

method.

Order Cancellation

A delayed task cancels orders that exceed the payment timeout; users can also cancel unpaid orders manually.

Cancellation flow

Implementation reference:

OmsPortalOrderServiceImpl

class,

cancelOrder

method.

Payment Success Callback

After the user completes payment, the third‑party payment platform calls back the payment‑success endpoint.

Callback flow

Implementation reference:

OmsPortalOrderServiceImpl

class,

paySuccess

method.

Conclusion

The Mall project provides a comprehensive, well‑designed shopping flow that can serve as a reference for building robust e‑commerce systems. Readers interested in the detailed implementation can explore the source code linked above.

e-commercebackend designorder processingSpringBootshopping cart
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

login 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.