mall E-commerce Solution

repository·master·Indexed 13 days ago

https://github.com/macrozheng/mall

A comprehensive e-commerce system featuring a front-end shopping mall (mall-portal) and a back-end administration system (mall-admin). Built with Java, Spring Boot, and MyBatis, it integrates Elasticsearch for search, RabbitMQ for messaging, and Redis for caching. The project supports multiple environments, including Spring Boot 3.5+ with JDK 17 and Spring Boot 2.7 with JDK 8, and provides containerized deployment via Docker and Docker Compose.

Tokens
11.3K
Snippets
24
Records
44
Agent score
100%

What's inside mall

  1. Overview of mall Framework Integration

    master

    The mall project is a comprehensive e-commerce solution with a highly integrated technology stack. Key framework integrations include:

    • Persistence: MyBatis and MyBatisGenerator.
    • Security: SpringSecurity (Restful style) with JWT for login, registration, and token management.
    • Validation & Logging: Hibernate-Validator and SpringAOP for universal logging and validation error handling.
    • Search: Elasticsearch for product searching.
    • Messaging & Communication: RabbitMQ for asynchronous communication and RestTemplate for service-to-service calls.
    • Infrastructure: Redis for numeric ID generation, OSS for file uploads, Docker for containerization, and ELK for log collection.
  2. Overview of the mall Backend Management System

    master

    The mall project includes a comprehensive Backend Management System designed to handle the core operations of an e-commerce platform. The backend is organized into several functional modules:

    • Product Management (商品管理): Handles the lifecycle of products, including categories, attributes, and stock.
    • Order Management (订单管理): Manages customer orders, shipping, and order statuses.
    • Promotion Management (促销管理): Controls sales activities such as coupons, flash sales, and discounts.
    • Content Management (内容管理): Manages site content, including banners, categories, and other static/dynamic information.
    • User Management (用户管理): Handles member information, permissions, and user-related data.
  3. Overview of the mall project

    master

    The mall project is a complete e-commerce system consisting of a front-end shopping mall and a back-end administration system. It is built using SpringBoot and MyBatis and supports containerized deployment via Docker.

    Key features include:

    • Front-end (mall-portal): Home portal, product recommendations, product search, shopping cart, order processing, member center, customer service, and help center.
    • Back-end (mall-admin): Product management, order management, member management, promotion management, operations management, content management, statistical reports, financial management, permission management, and settings.
  4. Understand the mall project module structure

    master

    The project is organized into several core modules:

    • mall-common: Utility classes and common code used across the project.
    • mall-mbg: Database operation code generated by MyBatisGenerator.
    • mall-security: Common modules encapsulating SpringSecurity.
    • mall-admin: Interfaces for the back-end administration system.
    • mall-search: Product search system based on Elasticsearch.
    • mall-portal: Interfaces for the front-end shopping mall system.
    • mall-demo: Test code used during framework setup.
    mall
    ├── mall-common -- 工具类及通用代码
    ├── mall-mbg -- MyBatisGenerator生成的数据库操作代码
    ├── mall-security -- SpringSecurity封装公用模块
    ├── mall-admin -- 后台商城管理系统接口
    ├── mall-search -- 基于Elasticsearch的商品搜索系统
    ├── mall-portal -- 前台商城系统接口
    └── mall-demo -- 框架搭建时的测试代码
  5. Implement Product Search and Recommendations

    master

    Search Functionality

    • Comprehensive Search: Search by product title, subtitle, or keywords. Supports filtering by category and sorting by 'New', 'Sales', or 'Price'.
    • Search Results: Returns product ID, image, name, subtitle, price, sales volume, 'New' status, parameters, brand name, and category name.
    • Search Aggregation: Aggregates brands, categories, and attributes based on search results.
    • Search Suggestions: Generates hot search terms based on user search history.

    Recommendation Engine

    • Product Recommendations: Based on brand, category, name, or keywords of the current product.
    • User-Centric Recommendations: Based on a user's weekly browsing history or search history.
  6. Manage Promotions and Marketing

    master

    The system supports several marketing modules to drive sales:

    • Flash Sale (秒杀): Manage activity lists, toggle online/offline status, and set specific sale products.
    • Coupons (优惠券): Create, edit, and delete coupons, and track coupon redemption records.
    • Activity Management: General activity management including publishing to advertisements.
    • Homepage Recommendations: Control visibility and sorting for:
      • Brand recommendations
      • 'Fresh Goods' (新品)
      • Popular recommendations
      • Featured topics
      • Advertisements
  7. Setup and Use a Private Docker Registry

    master

    You can host your own private registry to store and push images.

    1. Start a Registry 2.0 instance

    Run the registry container locally on port 5000: docker run -d -p 5000:5000 --restart=always --name registry2 registry:2

    2. Tag and Push images

    To push an image to your local registry, you must first tag it with the registry's address.

    • Tag an image: docker tag <source_image> localhost:5000/<target_image>
    • Push the image: docker push localhost:5000/<target_image>
    docker run -d -p 5000:5000 --restart=always --name registry2 registry:2
    docker tag macro/eureka-server:0.0.1 localhost:5000/macro/eureka-server:0.0.1
    docker push localhost:5000/macro/eureka-server:0.0.1
  8. Manage Products and SKUs

    master

    Product management involves a hierarchical structure of categories, brands, and attributes.

    Key Product Operations:

    • Category Management: Paginated viewing by parent category ID, adding, editing, deleting, and transferring products between categories.
    • Brand Management: Search by name, add/edit/delete, and view associated products.
    • Attribute Management: Manage attribute categories and specific attributes (specifications vs. parameters) based on category.
    • Adding a Product: Requires setting category, brand, shipping template, member prices (List<PmsMemberPrice>), ladder prices (List<PmsProductLadder>), full reduction prices (List<PmsProductFullReduction>), and SKU stock information (List<PmsSkuStock>).
    • Product Search/Filtering: Filter by status (publishStatus, verifyStatus), name (%name%), product SN (productSn), category ID, or brand ID.
    • Batch Operations: Toggle status (on/off shelf), recommend, mark as new, transfer category, move to recycle bin, or audit.
  9. Install and Use Docker Compose

    master

    Docker Compose is used for defining and running multi-container applications.

    Installation

    1. Download from Docker Compose Releases.
    2. Move to /usr/local/bin/docker-compose.
    3. Make it executable: sudo chmod +x /usr/local/bin/docker-compose.
    4. Verify: docker-compose --version.

    Common Commands

    • Up: Build, create, and start containers: docker-compose up
    • List: Show running containers: docker-compose ps
    • Stop: Stop specific services: docker-compose stop <service_name>
    • Start: Start stopped services: docker-compose start <service_name>
    • Remove: Remove specific service containers: docker-compose rm <service_name>
    • Scale: Dynamically scale a service: docker-compose scale <service_name>=<count>

    SpringCloud Orchestration

    The project provides pre-configured orchestration files for SpringCloud microservices (eureka-server, hello-service, feign-consumer, api-gateway) located in:

    • eureka-server/docker-res/docker-compose.yml (Standard orchestration)
    • eureka-server/docker-res/docker-compose-simple.yml (Simplified orchestration)
    • eureka-server/docker-res/docker-compose-eureka.yml (High-availability Eureka setup)
    docker-compose up
    docker-compose ps
    docker-compose scale eureka=3
  10. Execute the Shopping and Checkout Flow

    master

    1. Shopping Cart

    • Add products, modify quantities, re-select specifications, or delete items.

    2. Order Confirmation (生成确认单)

    • Information required: Shipping info, product info, price info, invoice info, and payment method.
    • Discounts: Select available coupons and points for deduction.
    • Price Calculation: Total = (Subtotal + Shipping) - Coupon Deduction - Points Deduction - Activity Discount.

    3. Order Submission

    • Converts confirmation info into a database order.
    • Removes items from the cart.
    • Adds order to DB and locks inventory.
    • Payment Methods: Alipay, WeChat Pay, UnionPay, ApplePay.

    4. Post-Payment

    • Updates order status to Paid and deducts inventory.
    • Unpaid Orders: Automatically cancelled after timeout, releasing locked inventory and returning coupons/points.
  11. Set up RabbitMQ with Management Plugin and Delayed Message Plugin

    master

    Follow these steps to configure RabbitMQ for the mall project:

    1. Prerequisites: Install Erlang first.
    2. Install RabbitMQ: Install the RabbitMQ server.
    3. Enable Management UI: Navigate to the sbin directory in your RabbitMQ installation and run: rabbitmq-plugins enable rabbitmq_management Access the UI at http://127.0.0.1:15672/ (default credentials: guest/guest).
    4. Configure User and Virtual Host:
      • Create a user mall with password mall and assign the Administrator role.
      • Create a virtual host named /mall.
      • Grant the mall user permissions for the /mall virtual host.
    5. Enable Delayed Message Plugin (Optional):
      • Download the rabbitmq_delayed_message_exchange plugin.
      • Copy it to the plugins directory.
      • In the sbin directory, run: rabbitmq-plugins enable rabbitmq_delayed_message_exchange
    rabbitmq-plugins enable rabbitmq_management