A method, device and storage medium for maintaining inventory data consistency
By using blockchain technology and smart contracts in the e-commerce platform, the problem of differences in inventory data in various application systems is solved, the disclosure and immutability of inventory data is realized, the consistency and accuracy of data are ensured, and the improvement of the data is improved. Operational efficiency.
Patent Information
- Application Number
- CN201910230715.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-03-26
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2039-03-26
AI Technical Summary
In e-commerce platforms, inventory data records between various application systems are prone to differences, resulting in data confusion and troubles caused by merchant sales.
Blockchain technology is introduced to obtain and update inventory data in the blockchain network through smart contracts, ensuring that all data changes are updated and publicly prevented private tampering, thereby achieving consistency of inventory data.
It effectively avoids the differences in inventory data, ensures the accuracy and immutability of data, and improves the operational efficiency and data consistency of the e-commerce platform.
Smart Images

Figure CN111738639B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a method, device and storage medium for maintaining inventory data consistency. Background Art
[0002] With the development of e-commerce, more and more merchants will use e-commerce platforms to sell goods. In each link of commodity sales, different systems may be used. For example, a merchant uses warehousing system A to be responsible for the storage and custody of goods, and uses sales system B to be responsible for the sales of goods. In different systems, it is necessary to record the inventory data of goods and update them according to actual changes. For example: the inventory data recorded in warehousing system A will affect the delivery of customer orders, while the inventory data recorded in sales system B directly affects whether the goods are sold. Since each system exists independently, it is difficult to completely avoid the differences in inventory data records, which leads to confusion. For example, the inventory data recorded in warehousing system A is displayed as empty, while the inventory data recorded in sales system B still exists, which brings trouble to the merchant's sales. Summary of the invention
[0003] Aiming at the phenomenon of inventory data differences among various application systems of an e-commerce platform, this application proposes a method for maintaining inventory data consistency, which can avoid the differences.
[0004] A method for maintaining inventory data consistency proposed in an embodiment of the present application is specifically as follows:
[0005] When the inventory data changes, the inventory data change value is used as a parameter to call the smart contract; the smart contract is the rule logic of the blockchain network, and the blockchain network is a network established in advance using blockchain technology;
[0006] The smart contract obtains original inventory data from the blockchain network, and calculates new inventory data based on the obtained original inventory data and the inventory data change value;
[0007] The calculated new inventory data is pushed to the blockchain network using the smart contract.
[0008] Aiming at the phenomenon of inventory data differences among various application systems of an e-commerce platform, the present application also proposes a device for maintaining inventory data consistency, which can avoid the differences.
[0009] An embodiment of the present application provides a device for maintaining inventory data consistency, specifically comprising:
[0010] The inventory data maintenance unit is used to call the smart contract with the inventory data change value as a parameter when the inventory data changes;
[0011] The smart contract unit is used to obtain the original inventory data from the blockchain network, calculate the new inventory data based on the obtained original inventory data and the inventory data change value, and push the calculated new inventory data to the blockchain network; the smart contract is the rule logic of the blockchain network, and the blockchain network is a network established in advance using blockchain technology.
[0012] In response to the phenomenon of differences in inventory data among various application systems of an e-commerce platform, the present application also proposes a computer-readable storage medium that can avoid the differences after execution.
[0013] A computer-readable storage medium proposed in an embodiment of the present application is specifically:
[0014] A computer-readable storage medium stores instructions, which, when executed by a processor, cause the processor to perform the steps in the method for maintaining inventory data consistency as described above.
[0015] In response to the phenomenon of inventory data differences among various application systems of an e-commerce platform, the present application also proposes an electronic device, which includes the computer-readable storage medium as described above and also includes a processor capable of executing the computer-readable storage medium.
[0016] In summary, in the embodiments of the present application, due to the introduction of blockchain technology, the inventory data is stored in the blockchain network, all changes and updates to the inventory data are in a public state, and the application systems of the e-commerce platform cannot tamper with it privately, thereby achieving the purpose and effect of maintaining the consistency of inventory data. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0018] Figure 1 It is a schematic diagram of the system structure of the application scenario 100 of the embodiment of the present application.
[0019] Figure 2 It is a flowchart of a method 200 for maintaining inventory data consistency according to an embodiment of the present application.
[0020] Figure 3 It is a structural diagram of the device 300 for maintaining inventory data consistency according to an embodiment of the present application.
[0021] Figure 4 It is a schematic diagram of the system structure of the application scenario 400 of the embodiment of the present application.
[0022] Figure 5 It is a flowchart of a method 500 for maintaining inventory data consistency according to an embodiment of the present application.
[0023] Figure 6 It is a structural diagram of an apparatus 600 for maintaining inventory data consistency according to an embodiment of the present application.
[0024] Figure 7 It is a schematic diagram of the system structure of the application scenario 700 of the embodiment of the present application.
[0025] Figure 8 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0027] In order to avoid differences in the records of the same inventory data in various e-commerce systems, the embodiment of the present application introduces blockchain technology, and utilizes the decentralized and tamper-proof characteristics of blockchain technology to maintain the consistency of inventory data.
[0028] Figure 1 1 is a schematic diagram of the system structure of an application scenario 100 of some embodiments of the present application. Figure 1 As shown, the system includes n application systems 101 of a certain e-commerce platform, where n is a natural number greater than 1. Among them, each application system 101 of the e-commerce platform is a system that needs to record inventory data. For example, in a certain e-commerce platform, a certain application system 101 may be a warehousing system A, another application system 101 may be a sales system B, and so on. As long as it is a system that needs to record inventory data and needs to maintain consistency with the inventory data recorded by other systems, it can be used as the application system 101 of the e-commerce platform in the embodiment of the present application, without paying attention to the actual use of the application system.
[0029] exist Figure 1In the example, the application system 101 of each e-commerce platform interacts with the blockchain network 103 through the smart contract 102, and the interaction protocol can adopt HTTP protocol, GRPC protocol or TCP protocol, etc. Among them, the blockchain network 103 is a network established using blockchain technology, and the smart contract 102 is the rule logic for the interaction between each system 101 and the blockchain network 103. Specifically, the blockchain is a chain data structure that combines data blocks in a sequential manner in chronological order, and a decentralized, tamper-proof distributed ledger guaranteed by cryptography. In a broad sense, the principle of blockchain technology is to use a block chain data structure to verify and store data, use a distributed node consensus algorithm to generate and update data, use cryptography to ensure the security of data transmission, and use smart contracts to operate the distributed infrastructure and computing methods of data.
[0030] Based on the above application scenario, an application system 101 of an e-commerce platform may adopt the following method 200 for maintaining inventory data consistency. The application system 101 of the e-commerce platform described here may be any system that requires inventory data, such as a warehousing system or a sales system. Figure 2 As shown, the method 200 for maintaining inventory data consistency includes:
[0031] Step 201: When the inventory data changes, the inventory data change value is used as a parameter to call the smart contract 102. The smart contract 102 is the rule logic for the interaction between the system 101 and the blockchain network 103, and the blockchain network 103 is a network established using blockchain technology.
[0032] In actual applications, inventory data may include but is not limited to: spot quantity, locked quantity, internal allocation, internal allocation, number of defective products, etc. Among them, the spot quantity refers to the number of goods currently in the warehouse, the locked quantity refers to the number of goods in the spot whose sales progress is controlled, the internal allocation refers to the number of goods transferred from other warehouses, the internal allocation refers to the number of goods transferred to other warehouses, and the number of defective products refers to the number of goods with quality defects. When the inventory data of an application system of the e-commerce platform changes, the system needs to update these changes in time so that the application systems of other e-commerce platforms use the latest inventory data, thereby maintaining the consistency of inventory data.
[0033] As mentioned above, the smart contract 102 is the rule logic exchanged between each system 101 and the blockchain network 103, and the code of these rule logics can be encapsulated in a functional module, such as in this embodiment. Figure 3The smart contract unit 302 in the embodiment of the present application can trigger the implementation of its functions by calling the smart contract at runtime, and the specific implementation of these rule logics is related to the actual application. After calling the smart contract 102, the smart contract 102 can be implemented in the following steps 202 and 203.
[0034] Step 202: The smart contract 102 obtains the original inventory data from the blockchain network 103, and calculates the new inventory data based on the obtained original inventory data and the inventory data change value.
[0035] Step 203: Use the smart contract 102 to push the calculated new inventory data to the blockchain network 103.
[0036] That is, in this embodiment, the inventory data is passed into the smart contract 102 as a parameter, triggering the implementation steps 202 and 203 of the smart contract 102. The smart contract 102 obtains the original inventory data from the blockchain network 103 and pushes the new inventory data to the blockchain network 103, all of which are accomplished by using blockchain technology, which will be described in detail in the subsequent preferred embodiments.
[0037] Based on the above method, this embodiment also provides an apparatus 300 for implementing the method in the application system 101. Figure 3 As shown, the device at least includes: an inventory data maintenance unit 301 and a smart contract unit 302. Among them:
[0038] The inventory data maintenance unit 301 is used to call the smart contract 302 with the inventory data change value as a parameter when the inventory data changes.
[0039] The smart contract unit 302 is used to obtain the original inventory data from the blockchain network 103, calculate the new inventory data according to the obtained original inventory data and the inventory data change value, and push the calculated new inventory data to the blockchain network 103.
[0040] From above Figure 1 to Figure 3 As can be seen from the description, the above embodiment proposes a new technical solution for maintaining the consistency of inventory data. The solution introduces blockchain technology, stores inventory data in the blockchain network, and implants smart contracts in the original application system that needs to record and maintain inventory data. By calling the smart contract to interact with the blockchain network, the inventory data is obtained from the blockchain network and the new inventory data after the change is pushed to the blockchain network. In other words, there is no application system dedicated to storing inventory data, nor is there an application system that can privately tamper with inventory data. All changes and updates to inventory data are in a public state, thereby achieving the purpose and effect of maintaining the consistency of inventory data.
[0041] In other embodiments, the smart contract 102 can obtain the original inventory data from the blockchain network 103 in the following manner. For example, since the blockchain technology uses a chain data structure to store data, a block node can be generated in the blockchain network, and each block node is used to store inventory data. That is, each time the inventory data changes, a new block node is generated, and the changed inventory data is stored in the new block node. Of course, when obtaining inventory data from the blockchain network, it can be obtained from the latest block node.
[0042] Figure 4 400 is a schematic diagram of the system structure of application scenarios of other embodiments of the present application. Figure 4 As shown, the system Figure 1 Similarly, it also includes n application systems 101 of a certain e-commerce platform, where n is a natural number greater than 1. The blockchain network 103 is a network established using blockchain technology, including m established block nodes, the first block node is the first established node, and the mth block node is the most recently established node, serving as the current node.
[0043] based on Figure 4 In combination with the above-mentioned solution for obtaining or generating nodes, other embodiments propose a method 500 for achieving inventory data consistency. Figure 5 As shown, the method includes:
[0044] Step 501: When the inventory data changes, the inventory data change value is used as a parameter to call the smart contract 102. The smart contract 102 is the rule logic for the interaction between the system 101 and the blockchain network 103, and the blockchain network 103 is a network established using blockchain technology.
[0045] Step 502: Determine the current blockchain node in the blockchain network 103. The current blockchain node is the node most recently established in the blockchain. All established nodes are in a chain structure to form a blockchain.
[0046] From this step, the smart contract 102 can know that the current node is the mth node.
[0047] Application scenarios of the present application Figure 4 It is assumed that m nodes have been established in the blockchain network. In actual applications, when the blockchain network has not yet established nodes and a system needs to request inventory data initialization, the following method can be used:
[0048] a. Using smart contract 102 to obtain original inventory data from the blockchain network, and the obtained original inventory data does not exist.
[0049] b. Create a first blockchain node in the blockchain network and use the first blockchain node as the current blockchain node.
[0050] c. Save the set initial value of inventory data to the first blockchain node.
[0051] The above initialization process can create the first block node in the blockchain network, and the inventory data that has changed for the first time can be saved as the initial value. If there is no change, 0 can also be saved as the initial value to complete the initialization process.
[0052] Step 503: Obtain the original inventory data in the current blockchain node, that is, obtain the saved original inventory data from the mth node.
[0053] The above steps 502 and 503 describe a specific method for obtaining original inventory data from the blockchain network.
[0054] Step 504: Calculate new inventory data based on the acquired original inventory data and the inventory data change value.
[0055] As mentioned above, inventory data may include but is not limited to spot quantity, locked quantity, internal allocation in, internal allocation out, and defective quantity, etc. This step will update these data according to changes.
[0056] In actual application, in order to better ensure the accuracy of inventory data, a verification process may be further added after step 504 is executed, and the verification process includes the following steps 505 to 507. Of course, if verification is not required, step 508 may be directly executed after step 504 is executed.
[0057] Step 505: Smart contract 102 obtains the existing inventory data in all blockchain nodes from the blockchain network, that is, obtains a total of m inventory data stored in the 1st to mth nodes.
[0058] Step 506: Calculate the inventory data to be verified based on the existing inventory data and inventory data change values in all blockchain nodes.
[0059] In actual applications, if each inventory data change value and inventory data are saved one by one in the blockchain node, this step can be calculated one by one from the 1st node to the mth node, and the calculated results are used as the inventory data to be verified. For example: the inventory data saved in each blockchain node includes the change value and spot quantity of a certain commodity, the change value is represented by a, and the spot quantity is represented by A. If the inventory data is correct, except for the first node, other nodes should have a corresponding relationship such as current change value + original inventory data = new inventory data. Then, assuming that the inventory data saved by the first node is (a1, A1), the inventory data saved by the second node is (a2, A2)..., the inventory data saved by the mth node is (a m , A m ), if the inventory data is correct, there should be a1 = A1, A1 + a2 = A2, A2 + a3 = A3...A m-1 +a m =A m , A m +a m+1 =A m+1 Such a relationship, then according to this method to calculate one by one, the calculated result A m+1 As inventory data to be verified.
[0060] Step 507: compare the inventory data to be verified with the calculated new inventory data, and use the comparison result as the verification result, that is, compare the inventory data to be verified calculated in step 506 with the new inventory data calculated in step 504. If the verification result passes, continue to step 508, otherwise, report through step 511 and exit.
[0061] Step 508: Create a new blockchain node in the blockchain network, that is, create the m+1th node.
[0062] Step 509: Save the calculated new inventory data to the newly created blockchain node.
[0063] Taking the calculation in step 506 as an example, the calculated A m+1 Save to the newly created m+1th node, or save the inventory data change value a at the same time m+1 , that is: save (a m+1 , A m+1 ).
[0064] Step 510: Use the newly created blockchain node as the current blockchain node, that is, use the m+1th node as the current node.
[0065] The above steps 508 to 510 describe a specific method for pushing the calculated new inventory data to the blockchain network.
[0066] Step 511: Report the verification result and exit.
[0067] Similarly, this embodiment passes the inventory data as a parameter into the smart contract 102, triggering the implementation steps 502 to 511 of the smart contract 102. The smart contract 102 obtains the original inventory data from the mth node of the blockchain network 103, establishes the m+1th node and pushes the new inventory data to the blockchain network 103, and stores it in the m+1th node.
[0068] Based on the above method 500, the embodiment of the present application also provides an apparatus 600 for implementing the method in the application system 101. For the convenience of clear description, the figure also shows a blockchain network. Figure 6 As shown, the device 600 includes at least: an inventory data maintenance unit 61 and a smart contract unit 62.
[0069] in,
[0070] The inventory data maintenance unit 61 is mainly used to call the smart contract unit 62 with the inventory data change value as a parameter when the inventory data changes. When initialization is required, the smart contract unit 62 can also be used to request inventory data initialization.
[0071] The smart contract unit 62 is mainly used to obtain the original inventory data from the blockchain network, calculate the new inventory data based on the original inventory data and the inventory data change value, and push the calculated new inventory data to the blockchain network. The smart contract is the rule logic for the interaction between the system and the blockchain network, and the blockchain network is a network established in advance using blockchain technology.
[0072] The smart contract unit 62 may specifically include: a data acquisition / push unit 621, a data calculation unit 622, and a verification unit 623. If verification is not required, the verification unit 623 may also be omitted.
[0073] The data acquisition / push unit 621 is mainly used to acquire the original inventory data in the current blockchain node and is responsible for pushing the calculated new inventory data to the blockchain network. It may include a node operation unit 6211 and a data operation unit 6212.
[0074] The data calculation unit 622 is mainly used to calculate new inventory data based on the acquired original inventory data and inventory data change values, and is also responsible for calculating the inventory data to be verified based on the existing inventory data in all blockchain nodes and the acquired inventory data change values.
[0075] The verification unit 623 is mainly used to compare the existing inventory data in all blockchain nodes with the calculated new inventory data, use the comparison results to verify the new inventory data, and report the verification results if the verification fails.
[0076] The data acquisition / pushing unit 621 may also specifically include: a node operation unit 6211 and a data operation unit 6212.
[0077] The node operation unit 6211 is mainly used to create the first blockchain node in the blockchain network during initialization, and use the first blockchain node as the current blockchain node; after initialization, it is responsible for determining the current blockchain node in the blockchain network; it is also used to create a new blockchain node in the blockchain network, and use the new blockchain node as the current blockchain node; during verification, it is responsible for determining all blockchain nodes from the blockchain network.
[0078] The data operation unit 6212 is mainly used to obtain the original inventory data from the blockchain network during the initialization process. When the original inventory data does not exist, the set initial value of the inventory data is saved in the first blockchain node. After initialization, it is responsible for obtaining the original inventory data in the current blockchain node and saving the calculated new inventory data in the newly created blockchain node. During verification, it is responsible for obtaining the existing inventory data from all blockchain nodes.
[0079] That is to say, during the initialization process, the inventory data maintenance unit 61 uses the smart contract unit 62 to request inventory data initialization. The data operation unit 6212 obtains the original inventory data from the blockchain network and finds that the original inventory data does not exist. The node operation unit 6211 creates a new first blockchain node (the first node) in the blockchain network and uses the first blockchain node as the current blockchain node. The data operation unit 6212 saves the set initial value of the inventory data to the first blockchain node. After initialization, when the inventory data changes, the inventory data maintenance unit 61 calls the smart contract unit 62 with the inventory data change value as a parameter. The node operation unit 6211 determines the current blockchain node (the mth node) in the blockchain network, and the data operation unit 6212 obtains the original inventory data in the current blockchain node. The data calculation unit 622 calculates the new inventory data based on the obtained original inventory data and the inventory data change value. The node operation unit 6211 creates a new blockchain node (the m+1th node) in the blockchain network, and the newly created blockchain node is used as the current blockchain node. The data operation unit 6212 saves the new inventory data calculated by the data calculation unit 622 to the newly created blockchain node (the m+1th).
[0080] If further verification is required, the node operation unit 6211 determines all blockchain nodes from the blockchain network, and the data operation unit 6212 obtains the existing inventory data from all blockchain nodes. The data calculation unit 622 calculates the inventory data to be verified based on the existing inventory data in all blockchain nodes and the obtained inventory data change value. The verification unit 623 compares the existing inventory data in all blockchain nodes with the calculated new inventory data, verifies the new inventory data using the comparison results, and reports the verification results if the verification fails.
[0081] From above Figures 4 to 6 As can be seen from the description, the above embodiment also proposes a new technical solution for maintaining inventory data consistency. In addition to storing inventory data in the blockchain network, all changes and updates of inventory data are in a public state, which can maintain inventory data consistency. In addition, this embodiment can also be further verified to better prevent tampering with inventory data.
[0082] The above embodiments all describe the solutions provided by the present application from the perspective of a single application system. The following describes the interaction between different application systems on a certain e-commerce platform. Figure 7 There are two application systems on an e-commerce platform, one is the sales inventory system X, and the other is the warehouse inventory system Y. Among them, the sales inventory system X records the changes in inventory data during the sales process, and the warehouse inventory system Y records the changes in inventory data during the goods entering and leaving the warehouse. This requires that the inventory data of the sales inventory system X and the warehouse inventory system Y are consistent, otherwise it will affect the operational decisions of the e-commerce platform or cause confusion in data records.
[0083] like Figure 7 As shown, this embodiment has the following steps in this scenario:
[0084] Step 701: Sales inventory system X uses a smart contract to request inventory data initialization.
[0085] This step can be implemented using the initialization steps a to c of the above embodiment. It is assumed here that the first node is established, the change value is set to 0, the spot quantity is 0, the change value and the spot quantity are inventory data, and the set initial value of the inventory data is saved in the first node in the blockchain network.
[0086] Step 702: Warehouse inventory system Y adds 5 pieces of the product, and the inventory data changes, so the smart contract is called with the inventory data change value 5 as a parameter.
[0087] The method implemented in this step can adopt any of the above-mentioned implementation schemes, and the result will be that the change value 5 and the new inventory data 5 are saved in the second node of the blockchain network.
[0088] Step 703: Sales inventory system X sells 3 pieces of the product, and the inventory data changes, so the smart contract is called with the inventory data change value -3 as a parameter.
[0089] Similarly, the method implemented in this step can also adopt any of the above-mentioned implementation schemes, and the result will be that the change value -3 and the new inventory data 2 are saved in the third node of the blockchain network.
[0090] And so on, until the blockchain network is established. Figure 7 Of course, during the whole process, each time the inventory data is updated, the original inventory data can be verified. The method can be adopted Figure 5 The verification process shown.
[0091] The embodiment of the present application also provides a computer-readable medium, wherein the computer-readable storage medium stores instructions, and when the instructions are executed by a processor, the processor executes the steps in the method for maintaining inventory data consistency as described above. In practical applications, the computer-readable medium may be a RAM, a ROM, an EPROM, a magnetic disk, an optical disk, etc., and is not intended to limit the scope of protection of the present application.
[0092] like Figure 8 As shown, the embodiment of the present application also provides an electronic device, which includes the above-mentioned computer-readable medium 801 and a processor 802 capable of executing the computer-readable storage medium. In practical applications, the electronic device can be one or more computers, as long as it includes the above-mentioned computer-readable medium and processor.
[0093] It can be seen from the above embodiments of the present application that the e-commerce platform has different independent application systems, each of which needs to record inventory data and use blockchain technology to save the inventory data and each change in the blockchain network. Since the changes made by each application system to the inventory data are public in the blockchain network, they cannot be tampered with privately, thus ensuring the consistency of the inventory data.
[0094] The above description is only an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for maintaining inventory data consistency, characterized in that: The method includes: When the inventory data changes, the inventory data change value is used as a parameter to call the smart contract; the smart contract is the rule logic of the blockchain network, and the blockchain network is a network established in advance using blockchain technology; the smart contract interacts with the blockchain network; The smart contract obtains original inventory data from the blockchain network, and calculates new inventory data based on the obtained original inventory data and the inventory data change value; The calculated new inventory data is pushed to the blockchain network using the smart contract.
2. The method according to claim 1, characterized in that The steps to obtain the original inventory data from the blockchain network include: Determine a current blockchain node in the blockchain network, wherein the current blockchain node is a node most recently established in the blockchain, and all established nodes are in a chain structure to constitute the blockchain; The original inventory data is obtained in the current blockchain node.
3. The method according to claim 2, characterized in that The method of pushing the calculated new inventory data to the blockchain network includes: Create a new blockchain node in the blockchain network; Saving the calculated new inventory data to the newly created blockchain node; The newly created blockchain node is used as the current blockchain node.
4. The method according to claim 3, characterized in that When inventory data initialization is requested, the method further comprises: Using the smart contract to obtain original inventory data from the blockchain network, and the obtained original inventory data does not exist; Create a new first blockchain node in the blockchain network, and use the first blockchain node as the current blockchain node; The set initial value of the inventory data is saved in the first blockchain node.
5. The method according to claim 3, characterized in that: Between the step of calculating the new inventory data based on the acquired original inventory data and the inventory data change value, and the step of pushing the calculated new inventory data to the blockchain network using a smart contract, the method further comprises: The smart contract obtains existing inventory data in all blockchain nodes from the blockchain network; Calculate the inventory data to be verified based on the existing inventory data in all the blockchain nodes and the inventory data change value; Comparing the inventory data to be verified with the calculated new inventory data, and using the comparison result as the verification result; If the verification result is passed, continue to execute the step of using the smart contract to push the calculated new inventory data to the blockchain network, otherwise report and exit.
6. A device for maintaining inventory data consistency, characterized in that: The device includes: The inventory data maintenance unit is used to call the smart contract with the inventory data change value as a parameter when the inventory data changes; The smart contract unit is used to obtain original inventory data from the blockchain network, calculate new inventory data based on the obtained original inventory data and the change value of the inventory data, and push the calculated new inventory data to the blockchain network; the smart contract is the rule logic of the blockchain network, and the blockchain network is a network established in advance using blockchain technology; the smart contract interacts with the blockchain network.
7. The device according to claim 6, characterized in that The smart contract unit includes: A data acquisition / push unit, used to acquire original inventory data in the current blockchain node and push the calculated new inventory data to the blockchain network; The data calculation unit is used to calculate new inventory data based on the acquired original inventory data and the inventory data change value.
8. The device according to claim 7, characterized in that The data acquisition / pushing unit comprises: A node operation unit, used to determine a current blockchain node in the blockchain network, wherein the current blockchain node is a node most recently established in the blockchain, and all established nodes are in a chain structure to constitute the blockchain; A data operation unit is used to obtain original inventory data in the current blockchain node.
9. The device according to claim 8, characterized in that The node operation unit is further used to create a new blockchain node in the blockchain network, and the new blockchain node serves as the current blockchain node; The data operation unit is further used to save the calculated new inventory data into the newly created blockchain node.
10. The device according to claim 9, characterized in that The inventory data maintenance unit is further used to request inventory data initialization using the smart contract; The data operation unit is further used to obtain original inventory data from the blockchain network when the inventory data is initialized, and the obtained original inventory data does not exist; and save the set initial value of the inventory data to the first blockchain node; The node operation unit is further used to create a first blockchain node in the blockchain network when the inventory data is initialized, and use the first blockchain node as the current blockchain node.
11. The device according to claim 9, characterized in that The node operation unit is further used to determine all blockchain nodes from the blockchain network when verification is required; The data operation unit is further used to obtain the existing inventory data in all the blockchain nodes when verification is required; The data calculation unit is further used to calculate the inventory data to be verified based on the existing inventory data in all blockchain nodes and the inventory data change value when verification is required; Furthermore, the smart contract unit further includes: The verification unit is used to compare the existing inventory data in all the blockchain nodes with the calculated new inventory data, verify the new inventory data using the comparison result, and report the verification result when the verification fails.
12. A computer-readable storage medium storing instructions, characterized in that: When the instructions are executed by a processor, the processor is caused to execute the steps in the method for maintaining consistency of inventory data according to any one of claims 1 to 5.
13. An electronic device, characterized in that: The electronic device comprises the computer-readable storage medium of claim 12, and further comprises a processor capable of executing the computer-readable storage medium.
Citation Information
Patent Citations
Multi-storehouse data management method based on block chain and related device
CN108470265A
Low-delay inventory deduction service system and method
CN108629653A
Inventory management
US20030204450A1