Many people have bought things on Taobao, and the basic process is consistent.

(I) Orders

  • The shopping cart

For example, JD is divided into self-owned and multi-store, and its shopping cart is more complex. If the shopping cart is stored in the session, Tomcat cannot bear the large number of users. The more reasonable way is to save in Redis, let’s talk about redis data format. Targeting shopping cart structure

  1. CartGroup (one shop one CartGroup)
  2. CartPkg (An order is a package)
  3. An order contains a List

There are two kinds of shopping carts, pre-login shopping cart and post-login shopping cart

  1. Redis internal save before login, key= IP_ type (PC,ios, Android)
  2. After login, the user’s userID is used. Key = userID
  3. They are compared by Redis before and after login to obtain the latest merge result.

  • Place the order

Buy a SONY TV, Canon camera, these are two stores, the distribution method is different, the warehouse is different, each merchant’s discount level is different, some 50% off, some 30% off. For example: apples are 50% off, I buy 10 apples, the address is in Zhengzhou, and the delivery is from Wuhan. There are only 9 apples in the warehouse in Wuhan, but there are 2 apples in Hebei and 3 apples in Changsha. According to the order theory, if there are 11 in Wuhan, buying 10 is just enough for you to buy. But now there are only 9 in Wuhan, so I directly sent you 9 in Wuhan, 1 in Hebei, enough for you 10, this is the principle of proximity. But there is a problem how to return the order, the overall return order to be returned together, and vice versa. Design to order split and merge.

Order number generation? Order weight prevention. As long as there is no duplication in distribution

  1. The redis incr
  2. Timestamp + increment variable
  3. UUID
  • Process sorting of e-commerce orders

T_order orders table

T_orderdetail Order details

T_orderpay Payment record table

T_ordership Order delivery table

T_orderlog Order log table

T_express Express delivery table

  • MQ implementation features: asynchronous decoupling. (Payment, order status, release status)

(2) unified configuration file artifact -Disconf

Baidu Disconf is a complete unified distributed configuration solution based on ZooKeeper.

In a distributed environment, many instances of the same type of service are deployed. These instances use a number of configurations, and configuration management services are created to better maintain these configurations. This service makes it easy to manage configuration issues for hundreds of service instances.

  • website

Github.com/knightliao/… It has not been maintained for 3 years, but it is still very powerful

  • The document

Disconf. Readthedocs. IO/zh_CN/lates…

  • introduce

  • Module architecture diagram for Disconf

  • Quick start

Here is the poM configuration, see the disconf document more clearly

<dependency>
    <groupId>com.baidu.disconf</groupId>
    <artifactId>disconf-client</artifactId>
    <version>2.6.36</version>
</dependency>
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.5</version>
</dependency>
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcore</artifactId>
    <version>4.4.6</version>
</dependency>

Copy the code

PS: the process of order transactions and how to deal with multiple items through unified configuration files in Web development.