First, the minimum model of the order system
| = = = order information = = = = = = = = = = = = | | commodity information = = = = = = = = = = = = = = = = = = = = = = = = = = = | = = = = = = payment information = = = = = = = = | | | order no. | | order state order time user ID ID ID | | design | goods | merchant ID price | | purchase quantity freight payment time | | | payment amount paid state |Copy the code
The above contains the most basic information of an order, and we see that the basic information contains several elements and extension ideas
1. User information
The user ID is used to correlate the purchase information or purchase limit of the user
Order verification: record the mobile phone number of the user. Order_contact table can be built to record the contact information filled by the user when placing an order
Logistics order: record the address information and contact information selected by users when placing an order. Order_address table can be built to record the address information of users placing an order. These are subject to the information at the time of placing an order, and ID cannot be associated
2. Product style information
The vast majority of logistics goods support multi-item orders across merchants, so need to be removed in the order form
Order form number | | order order status | | order time user ID | merchant ID | | goods | total amount of freight total amount payment amount payment time | | | payment stateCopy the code
Order goods table | order ID ID ID | | design | goods | merchant ID price | | | | the freight amount paid amount purchase quantityCopy the code
3. Snapshot problems
Order snapshot is generally corresponds to the order of a certain commodity a snapshot of the record, the latitude is commodity information, that is to say, if you place the order with an order to buy the same goods in different styles, you just need to record a commodity snapshot, generally use mongo to store information, but different database, also caused the query table of trouble, a lot of practical experience shows that, Commodity information and price information are the most commonly used fields for query. We redundant them into the commodity table of the order. After transformation, they are as follows:
Order goods commodity information table | = = = = = = = = = = = = = = | = = = = design information = = = = = = = = = = | | order ID ID | | goods | merchant ID name of commodity goods | head figure name | design | design | style ID head figure original cost price | sales | | | | purchase quantity order price | | the freight amount paid amountCopy the code
- Another way to think about it:
The process of product editing introduces the concept of version. Each time you edit, you update a version number field. When storing snapshots, you check whether there is a snapshot of the product of this version
4. Payment information
Most order systems have only one payment mode, wechat pay, Alipay and so on. We need to record the callback information
| | | order ID pay type number order third-party merchants | order transaction serial number | | amount paid by a third partyCopy the code
Merchant number records may use merchant statistical problems, such as multiple merchant number payment patterns, to record the flow of funds
5. Price information
Possible prices of goods: purchase price, market price, sales price, unit price at the time of actual payment, settlement price
The order shall be saved as follows: total payment amount of goods (excluding freight, sales price of all goods * purchase quantity), total freight amount of goods, total adjustment amount of goods (i.e. discount amount of various plug-in coupons and other preferential amounts), total amount of goods to be settled
6. Settlement information
In SAAS platforms, there is often a need for a settlement of goods sold, and we need to record the settlement price at which we placed the order
Orders for goods table | order ID ID | | goods | merchant ID name of commodity goods | head figure name | design | design | style ID head figure original cost price | sales | | | | purchase quantity order price settlement price | | | the freight amount paid amountCopy the code
7. After-sale information
The after-sales configuration is generally saved in the snapshot of the product. If you take real-time information, it is the after-sales configuration information of the product
8. Discount information
Participation in activities is a very common demand of commodities. Various combinations also bring about a variety of complex logic designs. However, all changes are related to price changes, which are defined as pricing system and will be described later.
Order price adjustment ID | | order amount adjustment type | | | associated activity ID associated activity information whether | | participate in valuationCopy the code
For activity and the extension of plug-ins: we are in general trading in an order, we often need to be in order, to calculate how much this order use the privilege, as well as the order placing a product design is how much discount, at this point we need to get the order, the amount of adjustment and redundancy to order table and order goods in the table, so the final table design as follows:
Order form number | | order order status | | order time user ID | business ID | goods | total amount of freight preferential | | | amount paid total amount of the total amount to pay state | | payment timeCopy the code
Order goods table | order ID ID | | goods | merchant ID name of commodity goods | head figure name | design | design | style ID head figure original cost price | sales | | | | purchase quantity order price | | the freight amount to the payment amount settlement price | | | discount amount order the unit priceCopy the code
conclusion
Here we discuss what needs to be stored and what just needs to be associated with the primary key, depending on whether the product requirements themselves require the following one-hour information or live configuration information. Order in which we can see, in fact table can be thought of as the businessman – latitude information, order goods form is the information of commodity style – latitude, so when the concrete to the merchant’s some configuration, about the order can be redundant to order table, such as businesses, such as the configuration of the purchase discount, and information about the goods, such as distribution configuration, cancel after verification configuration, clearing the configuration, After-sale configuration and other information associated with goods can be considered for redundancy in the order list