Order number generation method based on user, commodity, timestamp and random four digits
By adopting the order number generation method based on user, product, timestamp and random four-digit numbers in the online trading system, the problems of insufficient uniqueness, poor traceability and low security in the existing system are solved, and more efficient, safe and traceable order number generation is achieved.
Patent Information
- Application Number
- CN202411464041.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-03-21
AI Technical Summary
In the existing online trading system, the generation method of order numbers has problems such as insufficient uniqueness, poor traceability, low security, and inconsistent generation rules.
The order number generation method based on user, product, timestamp and random four-digit numbers is adopted. The specific steps include converting the user ID, product ID, millisecond-level timestamp and random four-digit numbers into strings, and splicing them together in preset order to form the final order number.
By using millisecond-level timestamps and random four-digit numbers, the uniqueness and security of order numbers are improved, conflict and prediction risks are reduced, and the system's processing efficiency and data management capabilities are enhanced.
Smart Images

Figure CN119670692A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of e-commerce, and in particular to a method for generating an order number based on a user, a commodity, a timestamp and a random four-digit number. Background Art
[0002] With the rapid development of e-commerce, online transaction systems have become an indispensable part of people's daily lives. In these systems, order numbers play a vital role as the unique identifier of transaction records. The order number not only needs to be unique in the system to avoid confusion of transaction records, but also needs to have a certain degree of traceability so that problems can be quickly located and resolved. In addition, the security of the order number is also very important to prevent the order information from being illegally obtained and used.
[0003] However, in the existing online trading system, there are some problems in the method of generating order numbers, such as insufficient uniqueness, poor traceability, low security and inconsistent generation rules. To this end, in response to the above problems, a method for generating order numbers based on users, products, timestamps and random four-digit numbers is designed to better meet actual usage needs. Summary of the invention
[0004] The purpose of the present invention is to provide a method for generating an order number based on a user, a product, a timestamp and a random four-digit number, so as to solve the problems raised in the above background technology.
[0005] To achieve the above object, the present invention provides the following technical solution: a method for generating an order number based on a user, a product, a timestamp and a random four-digit number, the steps of which are as follows:
[0006] Input parameter definition:
[0007] User ID;
[0008] Product ID;
[0009] Timestamp in milliseconds;
[0010] Random four-digit number;
[0011] Steps to generate order number:
[0012] Convert the user ID into a string of fixed length. If the length of the user ID is less than the preset length, add zeros to the front to make it the preset length. If the length of the user ID is greater than the preset length, truncate or report an error.
[0013] Convert the product ID into a string of fixed length, and process it in the same way as the user ID;
[0014] Get the millisecond timestamp of the current system time and convert it into a string format;
[0015] Use a reliable random number generation algorithm to generate a four-digit random number and convert it into a string format;
[0016] The obtained strings are concatenated together in a preset order to form the final order number;
[0017] Order number format:
[0018] The format of the order number is defined as: [fixed-length user ID string][fixed-length product ID string][millisecond timestamp string][four-digit random number string].
[0019] Furthermore, the user ID is a number or a string that uniquely identifies a user.
[0020] Furthermore, the product ID is a number or a string that uniquely identifies a product.
[0021] Furthermore, the timestamp millisecond level is the system time when the current transaction occurs, accurate to milliseconds.
[0022] Furthermore, the random four-digit number is a four-digit random number used to increase the uncertainty of the order number.
[0023] Compared with the prior art, the present invention has the following beneficial effects:
[0024] 1. This method of generating order numbers based on users, products, timestamps and random four-digit numbers uses millisecond timestamps, which can more effectively avoid duplication of order numbers under high concurrency conditions compared to second timestamps, ensuring the uniqueness of order numbers under extremely high transaction frequencies. It combines user ID, product ID and timestamp, as well as random numbers, to form a more complex unique identifier, reducing the possibility of order number conflicts. The order number explicitly includes the user ID and product ID, making the order number not only an identifier, but also able to directly provide user and product information for the transaction, facilitating transaction tracking and data analysis;
[0025] 2. The method for generating an order number based on a user, a commodity, a timestamp and a random four-digit number increases the randomness of the order number by adding four random digits, making the order number more difficult to predict, thereby improving the security of the system, preventing potential malicious attacks and leakage of order information, and helping to achieve standardization of order numbers between different systems, facilitating data exchange and system integration. Due to clear rules, the method for generating an order number of the present invention is easy to implement in various online trading systems, which is conducive to rapid promotion and application;
[0026] 3. Due to the improvement of the uniqueness of the order number, the conflicts encountered by the system when processing orders will be greatly reduced, thereby improving the processing efficiency and performance of the system. Due to the enhanced traceability of the order number, the system will be more efficient in data management and query. Users can directly learn more transaction information through the order number, which improves the transparency of the transaction process. When after-sales service is needed or transaction details are inquired, the order number of the present invention can help users and service personnel locate problems more quickly, improving the efficiency of problem solving. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a schematic diagram of the work flow structure of the present invention; DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0029] See also Figure 1 The present invention provides a technical solution: a method for generating an order number based on a user, a product, a timestamp and a random four-digit number, the steps of which are as follows:
[0030] Input parameter definition:
[0031] User ID: A number or string that uniquely identifies a user.
[0032] Product ID: A number or string that uniquely identifies a product.
[0033] Timestamp millisecond level (Timestamp): The system time when the current transaction occurs, accurate to milliseconds.
[0034] RandomNum: A four-digit random number used to increase the uncertainty of the order number.
[0035] Order number generation steps: Convert the user ID to a string of fixed length. If the length of the user ID is less than the preset length, fill it with zeros to the preset length; if the length of the user ID is greater than the preset length, truncate or report an error, and convert the product ID to a string of fixed length. The processing method is the same as the user ID. Get the millisecond timestamp of the current system time and convert it to a string format. Use a reliable random number generation algorithm to generate a four-digit random number and convert it to a string format. Concatenate the strings obtained in steps one, two, and three in the preset order to form the final order number.
[0036] Order number format: The format of the order number can be defined as: [fixed-length user ID string][fixed-length product ID string][millisecond timestamp string][four-digit random number string].
[0037] For example, assuming the user ID is 123, the product ID is 45678, the current timestamp is 1638960000000, and the random four-digit number is 5678, the order number might be: 001234567816389600000005678.
[0038] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for generating an order number based on a user, a product, a timestamp and a random four-digit number, characterized in that: The steps are as follows: Input parameter definition: User ID; Product ID; Timestamp in milliseconds; Random four-digit number; Steps to generate order number: Convert the user ID into a string of fixed length. If the length of the user ID is less than the preset length, add zeros to the front to make it the preset length. If the length of the user ID is greater than the preset length, truncate or report an error. Convert the product ID into a string of fixed length, and process it in the same way as the user ID; Get the millisecond timestamp of the current system time and convert it into a string format; Use a reliable random number generation algorithm to generate a four-digit random number and convert it into a string format; The obtained strings are concatenated together in a preset order to form the final order number; Order number format: The format of the order number is defined as: [fixed-length user ID string][fixed-length product ID string][millisecond timestamp string][four-digit random number string].
2. The method for generating an order number based on a user, a product, a timestamp and a random four-digit number according to claim 1, characterized in that: A user ID is a number or string that uniquely identifies a user.
3. The method for generating an order number based on a user, a product, a timestamp and a random four-digit number according to claim 1, characterized in that: A product ID is a number or string that uniquely identifies a product.
4. The method for generating an order number based on a user, a product, a timestamp and a random four-digit number according to claim 1, characterized in that: The timestamp millisecond level is the system time when the current transaction occurs, accurate to milliseconds.
5. The method for generating an order number based on a user, a product, a timestamp and a random four-digit number according to claim 1, characterized in that: The random 4-digit number is a four-digit random number used to increase the uncertainty of the order number.