Intelligent verification goods exchange platform driven by goods counting codes
The smart cargo exchange platform uses GUIDs and a distributed database with Kafka messaging and RBAC to address data inconsistency and synchronization delays, ensuring accurate and efficient cargo management.
Patent Information
- Application Number
- CN202510424248.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-07
- Publication Date
- 2025-07-15
AI Technical Summary
There are problems such as cumbersome information updates, human errors, data inconsistency, and synchronization delays in traditional goods information management and exchange processes, which affect the efficient operation and accuracy of the supply chain.
The digital code generation unit, information storage unit, database storage unit, information update unit, exchange initiation and verification unit and exchange execution unit are adopted, and combined with global unique identifier algorithm, master-slave replication and multi-live architecture distributed database, Redis cache, Apache Kafka message queue, RBAC model and other technologies are used to realize the automated update and consistency management of goods information.
It improves the accuracy and consistency of cargo information management, reduces data redundancy, ensures the timeliness of information updates and the efficiency of the system, and supports the reliability and traceability of cargo exchange.
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data processing, and particularly relates to an intelligent verification goods exchange platform driven by digital goods codes. Background Art
[0002] Under the traditional operation mode of goods supply chain management, the goods information management and exchange process faces various problems, which greatly affect the efficient operation and overall efficiency of the supply chain.
[0003] Traditional systems often rely on manual operations or simple information update processes. When goods information needs to be changed, the operation steps for information update are cumbersome and prone to human errors, resulting in the inability to complete the update operation in a timely manner. For example, when the goods transportation status changes from "in transit" to "warehoused", it requires manual input and confirmation from multiple departments and systems, which may take a long time and cause delays in information update.
[0004] Lack of an effective automated information update trigger and processing mechanism, making it difficult to perceive changes in goods status in real time, resulting in a lag in goods information update and an inability to reflect the actual situation of goods in a timely manner, affecting the accuracy of inventory management and logistics arrangements.
[0005] In multiple different information storage systems or tables, goods information is often stored repeatedly. For example, different logistics nodes, warehousing systems, and sales systems may all store some of the same goods information, such as the basic description and specifications of the goods. This not only causes waste of storage resources, but also increases data maintenance costs, and when data is updated, the same operation needs to be performed at multiple locations, making it easy to have situations of untimely update or omission.
[0006] Due to the scattered data storage, data at different storage locations may be inconsistent due to various reasons (such as system update time differences, data entry errors, etc.). For example, the quantity of goods recorded in a warehousing system is inconsistent with the inventory quantity in the sales system, making it difficult to determine the accurate quantity information of goods during business decision-making, and thus affecting the accuracy of decisions such as replenishment, sales, and distribution.
[0007] In terms of data synchronization, data synchronization between different nodes or systems is a thorny issue, especially in a distributed environment. When the data of one node changes, other nodes cannot synchronize and update in a timely manner, resulting in delays in data synchronization. There is a lack of an efficient and reliable synchronization mechanism. Summary of the Invention
[0008] The purpose of the present invention is to provide an intelligent verification goods exchange platform driven by digital goods codes to solve the problems mentioned in the above background art.
[0009] To solve the above technical problems, the present invention provides the following technical solutions:
[0010] A smart verification goods exchange platform driven by digital goods codes, comprising: a digital goods code generation unit for generating digital goods codes using a globally unique identifier algorithm;
[0011] An information storage unit for storing digital goods codes and related information using a relational database. The related information includes a table for storing the basic elements of digital goods codes, a table for storing product information, a table for storing manufacturer information, and a table for storing batch information, and data integrity is ensured through foreign key constraints;
[0012] A database storage unit, a distributed database adopting a master-slave replication and multi-active architecture, for partitioning and sharding the database according to business rules, and improving the concurrent processing ability through read-write separation;
[0013] An information update unit for, when the goods status changes, notifying the update service of the update request through the Apache Kafka message queue;
[0014] An exchange initiation and verification unit for providing a user interface and a RESTful API interface to support users in inputting exchange request information; using a Redis cache mechanism to verify the validity of digital goods codes, integrating a status management service and a message queue, using a distributed lock to prevent concurrent verification errors, and performing user permission verification based on the RBAC model;
[0015] An exchange execution unit for, after verification passes, using event sourcing to record the exchange operation as an event storage and updating the goods information through event replay.
[0016] Furthermore, generating digital goods codes using a globally unique identifier algorithm specifically utilizes the GUID generation function of the operating system itself or a dedicated GUID generation service to generate unique identifiers; the generated digital goods codes are stored in a table in the digital goods code information repository.
[0017] Furthermore, the master-slave replication in the distributed database with a master-slave replication and multi-active architecture specifically is:
[0018] Select a relational database to build a master-slave replication architecture; set a master node as the core for data writing, and all write operations to the database are executed on the master node; the master node is responsible for recording data changes in the binary log;
[0019] Configure multiple slave nodes, and the slave nodes synchronize the data changes on the master node to themselves by reading the binary log of the master node; the slave nodes undertake read operations to share the read load of the master node;
[0020] The slave nodes will regularly send heartbeat messages to the master node to detect the status of the master node. If the master node fails, the Keepalived tool is used to automatically promote a slave node to the master node and continue to provide services. The specific details of the multi-active architecture in the distributed database with master-slave replication and multi-active architecture are as follows:
[0021] Based on master-slave replication, multiple nodes with read and write capabilities are deployed. The two-phase commit protocol or a distributed transaction coordinator is adopted to ensure data consistency during data read and write operations among multiple active nodes.
[0022] Furthermore, the concurrent processing ability is improved through read-write separation. Specifically:
[0023] The MyCat or Sharding-JDBC middleware is deployed between the application and the database to monitor the type of requests in real time. For write requests, the middleware routes them to the master node for processing. For read requests, the middleware uses a load balancing algorithm to distribute the read requests to the slave nodes with low load for execution. Partitioning specifically includes partitioning by time range and by region. Table sharding operations include sharding by product type and by data heat.
[0024] Furthermore, distributed locks are used to prevent concurrent verification errors. Specifically: For the verification of product numbers, the lock is associated with the product number. For resource modification operations, a coarser-grained lock is used.
[0025] The SETNX command is used to obtain the lock and set an expiration time. If it is already locked, wait, and the waiting time can be adjusted.
[0026] After the operation is completed, the lock is released through the DEL command.
[0027] When the lock cannot be obtained, "The system is busy. Please try again later." is displayed through the user interface, and the API request returns the HTTP 423 Locked status code and an error message.
[0028] Furthermore, user permission verification is carried out based on the RBAC model. Specifically:
[0029] Multiple roles and their refined permissions are defined and stored in the database or configuration file.
[0030] When a user registers or is managed, roles are assigned according to the position and stored in the user information table, which can be adjusted dynamically. Enterprise users can be automatically assigned according to the organizational structure.
[0031] After the user logs in, the permissions are obtained from the storage according to the role and stored in the session or encoded in the token.
[0032] Before operation, extract the permission list from the user session or token for verification. When there is no permission, prompt on the user interface or return an HTTP 403 Forbidden status code and error message in the API request. When the permission changes, send a message using the message queue. The message includes the user ID, original role, new role, and the changed permission list.
[0033] Furthermore, it also includes: a user registration and login unit, which is used to strictly verify the user input information, store the password using bcrypt, and issue a short-term token through JWT token authentication.
[0034] Furthermore, it also includes: a permission management unit, which is used to notify permission changes through the message queue based on the RBAC model.
[0035] Furthermore, it also includes: an information query unit, which is used to retrieve goods information using the Elasticsearch search engine according to the conditions of the digital goods code, product name, batch number, and date range, and display the results in the form of a list, table, or timeline.
[0036] Furthermore, the digital goods code-driven intelligent verification goods exchange platform also includes: a traceability path presentation unit, which is used to construct the goods traceability path through event tracing based on the event repository and workflow engine, and visualize the transfer process in the form of a flowchart or timeline using bpmn.js.
[0037] Beneficial effects: Use the GUID algorithm to generate the digital goods code to ensure its uniqueness in a distributed environment. It is only used as a unique identifier, simplifies management, avoids the problem of duplicate traditional digital goods codes, and provides a reliable basis for the accurate identification and management of goods.
[0038] The relational database combines an independent table structure and foreign key constraints to store the digital goods code and related information, ensuring data integrity and consistency.
[0039] The distributed database with a master-slave replication and multi-active architecture improves the concurrent processing and query / update performance through read-write separation, partition table operations, and uses Redis to cache the data of the slave nodes, improving the overall performance and resource utilization efficiency of the system.
[0040] Use the Apache Kafka message queue to notify the change of goods status, and process multi-table updates through distributed transactions to ensure data consistency.
[0041] Use Redis to cache and verify the digital goods code, reduce the pressure on the database, and use a distributed lock to ensure the concurrent security of the verification operation and avoid conflicts.
[0042] User permission verification based on the RBAC model ensures the legality of user operations.
[0043] Event traceability and compensation mechanism record exchange operations to achieve atomicity and traceability, ensuring that the exchange operations are accurate and reliable. Detailed implementation manners
[0044] The following will describe the technical solutions in the embodiments of the present invention clearly and completely in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0045] The present invention provides an intelligent verification goods exchange platform driven by numbered goods codes, including: a numbered goods code generation unit 100. The numbered goods code generation unit 100 is used to generate numbered goods codes by using a globally unique identifier algorithm. The length of the numbered goods code is 128 bits to ensure uniqueness in a distributed environment. It is only used as the unique identifier of the goods and does not embed other information. Specifically:
[0046] The numbered goods code generation unit uses the GUID generation function of the operating system itself or a dedicated GUID generation service to generate a unique identifier. In this way, the powerful functions of the underlying system or the advantages of dedicated services can be utilized, avoiding the possible duplication problems that may occur when using a combination of timestamps and random numbers, and ensuring the uniqueness of the numbered goods code in a distributed environment. The generated numbered goods code (GUID) is stored in the Numbered Goods Code Table (the table for storing the basic metadata table of numbered goods codes) in the numbered goods code information repository as the key data of this table. At the same time, this table will store some basic metadata of the numbered goods code, such as the creation time and the last update time. The creation time can clearly record the generation moment of the numbered goods code, which is very helpful for subsequent traceability and auditing; the last update time can reflect the latest modification situation of the information related to the numbered goods code, which is helpful for data monitoring and management. A unique index is established for the Numbered Goods Code field. When performing query operations, especially when searching for goods information, verifying goods exchanges, and tracing information, through this unique index, the system can quickly locate the corresponding numbered goods code, greatly improving the efficiency of database queries. The numbered goods code is only used as the unique identifier of the goods, and key data such as product information, manufacturer information, production date, and batch number are stored in different tables respectively, such as ProductInfoTable, ManufacturerInfoTable, and BatchInfoTable. In this way, when it is necessary to update product information, manufacturer information, or batch information, there is no need to update the numbered goods code, avoiding the complexity and potential risks that may be brought about by updating the numbered goods code, and improving the flexibility of system data management and maintenance.
[0047] Such a design of the numbered goods code generation unit ensures the uniqueness and independence of the numbered goods code across the entire platform, providing a reliable and efficient foundation for a series of subsequent operations such as storage, exchange, verification, and traceability of goods information.
[0048] The intelligent verification goods exchange platform driven by the numbered goods code further includes: an information storage unit 101, which uses a relational database to store the numbered goods code and related information, including the
[0049] NumberedGoodsCodeTable for storing the basic metadata of the numbered goods code, the ProductInfoTable for storing product information, the ManufacturerInfoTable for storing manufacturer information, and the BatchInfoTable for storing batch information, and ensures data integrity through foreign key constraints; specifically:
[0050] In addition to storing the 128-bit unique identification numbered goods code of the goods generated by the globally unique identifier (GUID) algorithm, the NumberedGoodsCodeTable also records the creation time of the numbered goods code, accurate to the second level. This helps to trace the starting time point when the goods enter the platform and provides a basis for the source analysis of the supply chain. At the same time, the last update time is recorded, which is automatically updated whenever any information related to the numbered goods code changes, facilitating the monitoring of data timeliness and operation history. A unique index is created for the NumberedGoodsCode field. Using the B-Tree index structure, during database query operations, it can quickly locate specific numbered goods code records with logarithmic time complexity. This significantly reduces the query response time in high-frequency operation scenarios such as goods exchange and information traceability, improving the overall performance of the system.
[0051] In addition, the ProductInfoTable uses the product ID as the primary key and is associated with the ProductID foreign key in the NumberedGoodsCodeTable to ensure accurate data association. The product name is recorded in detail to ensure the uniqueness and standardization of the name, avoiding problems in goods management caused by name confusion; the product specifications record the physical properties of the product in detail, such as the size accurate to millimeters and the weight accurate to grams, etc., to meet the high-precision requirements of different industries for product descriptions; the product description provides more abundant information such as product features, usage methods, applicable scenarios, etc., to help users comprehensively understand the product. Through foreign key constraints, if the associated product ID record in the NumberedGoodsCodeTable is deleted while there are associated records in the ProductInfoTable, the database will, according to the foreign key constraint configuration, prevent illegal deletion operations or adopt a cascade deletion strategy to simultaneously delete the corresponding product information in the ProductInfoTable to ensure data consistency.
[0052] In addition, the ManufacturerInfoTable uses the manufacturer ID as the primary key to establish a foreign key association with the NumberedGoodsCodeTable. The manufacturer name is ensured to be accurate and error-free, facilitating the identification and differentiation of different manufacturers; the manufacturer address is detailed to the street number, which helps with precise positioning during on-site inspections or logistics distribution when needed; the contact information includes various forms such as phone numbers and email addresses to ensure that contact with the manufacturer can be made in a timely manner at all links in the supply chain to handle issues such as product quality and replenishment. When the associated manufacturer ID information in the NumberedGoodsCodeTable changes, the foreign key constraint ensures that the corresponding records in the ManufacturerInfoTable are updated synchronously, preventing data isolation or inconsistency and maintaining the integrity of the entire information storage system.
[0053] In addition, the BatchInfoTable uses the batch number as the key identifier and is associated with the NumberedGoodsCodeTable through the foreign key BatchID. The production date is accurate to the year, month, and day, providing an important time node for the shelf life management and quality traceability of products; the expiration date is also accurate to the year, month, and day, and the system will give an early warning according to this date to prevent expired products from entering the exchange process and protect the rights and interests of consumers. When performing data insertion, update, or deletion operations, the foreign key constraint will strictly check the data correlation. For example, when inserting a new numbered goods code record into the NumberedGoodsCodeTable and associating a specific BatchID, the system will check whether there is batch information corresponding to the BatchID in the BatchInfoTable. If not, the insertion operation will be rejected to ensure the integrity and accuracy of the data.
[0054] The information storage unit utilizes the characteristics of a relational database and combines the reasonable foreign key constraint relationships between tables to provide a stable, reliable, and easy-to-manage data storage architecture for the entire intelligent verification goods exchange platform driven by numbered goods codes, strongly supporting the efficient operation of various business functions of the platform.
[0055] The intelligent verification goods exchange platform driven by numbered goods codes further includes: a database storage unit 102. The database storage unit 102 adopts a distributed database with a master-slave replication and multi-active architecture, which is used to partition and split tables of the database according to business rules, and improve the concurrent processing ability through read-write separation.
[0056] Specifically, the master-slave replication in the distributed database with a master-slave replication and multi-active architecture is as follows:
[0057] Select a mature relational database such as MySQL or PostgreSQL to build a master-slave replication architecture. Set a master node as the core for data writing. All write operations on the database, such as inserting new numbered goods code information and updating the goods status, are executed on the master node. The master node is responsible for recording data changes in the binary log (binlog).
[0058] In addition, configure multiple slave nodes. The slave nodes synchronize the data changes on the master node to themselves by reading the binary log of the master node, thus maintaining consistency with the master node data. The slave nodes mainly undertake read operations, such as querying numbered goods code information in the goods exchange module and retrieving the goods history record in the goods information traceability module, so as to share the read load of the master node and improve the overall concurrent processing ability of the system.
[0059] In addition, to ensure the reliability of data synchronization between the master and slave nodes, the slave node will periodically send heartbeat messages to the master node to detect the status of the master node. If the master node fails, the system can automatically promote a slave node to the master node through a preset failover mechanism, such as using tools like Keepalived, to continue providing services and ensure the high availability of data.
[0060] In addition, the specific multi-active architecture in the distributed database with master-slave replication and multi-active architecture is as follows:
[0061] Based on master-slave replication, a multi-active architecture is constructed, that is, multiple nodes with read and write capabilities are deployed. These nodes can be geographically distributed in different data centers to improve the fault tolerance of the system and the ability to handle regional failures.
[0062] In addition, by using distributed transaction coordination technologies, such as adopting the two-phase commit (2PC) protocol or introducing a distributed transaction coordinator (assisted by Apache ZooKeeper for implementation), data consistency during data read and write operations among multiple active nodes is ensured. For example, when the goods location information associated with the goods code is updated on one node, through the distributed transaction mechanism, it is ensured that the data on other nodes can also be updated synchronously to avoid data inconsistency.
[0063] In addition, the specific method of improving the concurrent processing ability through read-write separation is as follows:
[0064] Distribution of read and write requests: Special middleware, such as MyCat or Sharding-JDBC, is deployed between the application program and the database. The middleware monitors the type of requests in real time. For write requests (such as SQL statements like INSERT, UPDATE, DELETE, etc.), the middleware accurately routes them to the master node for processing to ensure data consistency and integrity. For read requests (such as SELECT statements), the middleware, according to the load conditions of the slave nodes, uses a load balancing algorithm (such as round-robin, weighted round-robin, or algorithm based on the minimum number of connections, etc.) to distribute the read requests to the slave node with relatively lower load for execution, thereby improving the concurrent read performance of the database.
[0065] In addition, to further improve the read performance, a caching mechanism is introduced at the slave node level. For example, Redis is used to cache frequently queried data. When the slave node receives a read request, it first checks whether the required data exists in the cache. If it exists, the data is directly returned from the cache, greatly reducing the query pressure on the database. If it does not exist, the data is queried from the database. While returning the result to the user, the data is cached in Redis and a reasonable expiration time is set to enable a quick response for the next query. At the same time, to ensure the consistency between the cached data and the database data, when the master node undergoes data changes, in addition to synchronizing to the slave node, relevant cache nodes are also notified to update or delete the corresponding cached data.
[0066] In addition, the partition and table splitting operations are as follows:
[0067] Partitioning by time range: Taking the NumberedGoodsCodeTable as an example, according to business requirements, it is partitioned by time range. For example, taking months as the unit, the data for each month is stored in an independent partition. In this way, when querying the numbered goods code information within a specific time period, the database only needs to retrieve in the corresponding partition without scanning the entire table, greatly improving the query efficiency. At the same time, the management of historical data is also more convenient. For example, the data in the expired partitions can be regularly cleared to reduce the storage pressure on the database.
[0068] Partitioning by region: Considering that goods may come from different regions or circulate in different regions, for tables involving geographical location information (such as the relevant tables recording the storage locations of goods when integrated with the warehousing system), they can be partitioned by region. For example, the whole country is divided into different regions, and the data for each region is stored in a partition. This partitioning method helps to improve the efficiency of queries and statistical operations related to regions, such as quickly querying the inventory of goods in a certain region.
[0069] Table splitting operation:
[0070] Table splitting by product type: For the ProductInfoTable, it is split by product type. For example, the product information of different types such as electronic products, clothing, and food is stored in different tables, such as
[0071] ElectronicProductInfoTable, ClothingProductInfoTable, FoodProductInfoTable, etc. The structure of each split table is similar to the original table, but only stores the information of specific types of products. In this way, when dealing with the business logic of specific types of products, such as querying the detailed information of electronic products or updating the specifications of clothing products, database operations can be concentrated on the corresponding split table, reducing the data volume of a single table and improving the query and update performance.
[0072] Table partitioning by data heat: Analyze the access frequency of business data, and store frequently accessed data and infrequently accessed data in different tables respectively. For example, for the information related to goods with frequent exchanges recently, store it in a "hot table", while for the goods information with a long history and few accesses, store it in a "cold table". In this way, when querying data, it is possible to search in the "hot table" first to improve the query response speed; at the same time, it is also convenient to adopt different storage and maintenance strategies for data with different heat levels. For example, for the "cold table", a lower frequency backup strategy can be adopted to save resources.
[0073] The intelligent verification goods exchange platform driven by digital goods codes further includes an information update unit 103. The information update unit 103 is used to notify the update service of the update request through the Apache Kafka message queue when the goods status changes. The update service uses distributed transactions to process update operations involving multiple tables to ensure data consistency, and uses strict verification logic and distributed logging services (Elasticsearch, Logstash, Kibana) to record the update operations.
[0074] The intelligent verification goods exchange platform driven by digital goods codes further includes an exchange initiation and verification unit 104. The exchange initiation and verification unit 104 is used to provide a user interface and RESTful API interfaces to support users to input exchange request information. Use the Redis cache mechanism to verify the validity of digital goods codes, integrate the status management service and the message queue to ensure timely and consistent update of status information, use distributed locks to prevent concurrent verification errors, and perform user permission verification based on the RBAC model.
[0075] Using distributed locks to prevent concurrent verification errors:
[0076] Determine the scope of the lock according to the operation and the resources involved. For digital goods code verification, the lock is associated with the digital goods code (such as
[0077] lock:validation:GUID123); for resource modification operations, use a coarser-grained lock (such as
[0078] lock:update:goods_status).
[0079] Use the SETNX command to obtain the lock and set an expiration time (such as SETNX lock:validation:GUID123 <unique-id>EX 30): If it is already locked, wait, and the waiting time can be adjusted.
[0080] After the operation is completed, release the lock through the DEL command (such as DEL lock:validation:GUID123).
[0081] When the lock cannot be acquired, the user interface displays "The system is busy. Please try again later", and the API request returns the HTTP 423 Locked status code and an error message.
[0082] User permission verification is based on the RBAC model:
[0083] Define multiple roles (such as administrator, inventory administrator, etc.) and their refined permissions (such as
[0084] create_goods, update_goods_status, etc.), and store them in the database or configuration file.
[0085] When a user registers or is managed, assign roles according to the position, store them in the user information table, which can be adjusted dynamically, and enterprise users can be automatically assigned according to the organizational structure.
[0086] After a user logs in, obtain permissions from the storage according to the role, and store them in the session or encode them in the token.
[0087] Before an operation, extract the permission list from the user session or token for verification. When there is no permission, the user interface gives a prompt or the API request returns the HTTP 403 Forbidden status code and an error message.
[0088] When permissions change, use a message queue (such as Apache Kafka) to send messages, including the user ID, the original role, the new role, and the list of changed permissions, and ensure update consistency through distributed transactions.
[0089] The intelligent verification goods exchange platform driven by the digital goods code also includes an exchange execution unit 105. The exchange execution unit 105 is used to, after verification passes, record the exchange operation as an event and store it using event sourcing, and update the goods information through event replay.
[0090] The intelligent verification goods exchange platform driven by the digital goods code also includes: a user registration and login unit 106. The user registration and login unit 106 is used to strictly verify the user input information, store the password using bcrypt, and issue a short-term token through JWT token authentication to reduce the risk of password transmission and storage.
[0091] The intelligent verification goods exchange platform driven by digital goods codes further includes: a permission management unit 107. The permission management unit 107 is used to notify permission changes through a message queue based on the RBAC model, and use a dedicated service to ensure the real-time nature of permission updates and operation permission checks to prevent unauthorized operations.
[0092] The intelligent verification goods exchange platform driven by digital goods codes further includes: an information query unit 108. The information query unit 108 is used to use the Elasticsearch search engine to retrieve goods information according to conditions such as digital goods codes, product names, batch numbers, and date ranges, and display the results in the form of a list, table, or timeline.
[0093] The intelligent verification goods exchange platform driven by digital goods codes further includes: a traceability path presentation unit 109. The traceability path presentation unit 109 is used to construct a goods traceability path through event tracing according to the event repository and the workflow engine (Activiti), and use bpmn.js visualization to display the transfer process in the form of a flowchart or timeline.
Claims
1. A smart verification goods exchange platform driven by digital goods codes, characterized in that Including: A digital goods code generation unit, which is used to generate digital goods codes by using the globally unique identifier algorithm; An information storage unit, which is used to store digital goods codes and related information using a relational database. The related information includes a table for storing the basic elements of digital goods codes, a table for storing product information, a table for storing manufacturer information, and a table for storing batch information, and ensures data integrity through foreign key constraints; A database storage unit, which is a distributed database with a master-slave replication and multi-active architecture, and is used to partition and shard the database according to business rules, and improve the concurrent processing ability through read-write separation; An information update unit, which is used to notify the update service of the update request through the Apache Kafka message queue when the goods status changes; An exchange initiation and verification unit, which is used to provide a user interface and a RESTful API interface to support users to input exchange request information; Use the Redis cache mechanism to verify the validity of digital goods codes, integrate the status management service and the message queue, use a distributed lock to prevent concurrent verification errors, and perform user permission verification based on the RBAC model; An exchange execution unit, which is used to record the exchange operation as an event storage using event sourcing after verification, and update the goods information through event replay.
2. The intelligent verification goods exchange platform driven by digital goods codes according to claim 1, wherein Generating digital goods codes by using the globally unique identifier algorithm specifically utilizes the GUID generation function of the operating system itself or a dedicated GUID generation service to generate a unique identifier; the generated digital goods codes are stored in a table in the digital goods code information repository.
3. The intelligent verification goods exchange platform driven by digital goods codes according to claim 1, characterized in that, The master-slave replication in the distributed database with a master-slave replication and multi-active architecture is specifically as follows: Select a relational database to build a master-slave replication architecture; set a master node as the core for data writing, and all write operations to the database are executed on the master node; the master node is responsible for recording data changes in the binary log; Configure multiple slave nodes, and the slave nodes synchronize the data changes on the master node to themselves by reading the binary log of the master node; The slave nodes undertake read operations to share the read load of the master node; The slave nodes will regularly send heartbeat messages to the master node to detect the status of the master node; If the master node fails, use the Keepalived tool to automatically promote a certain slave node to the master node and continue to provide services; the multi-active architecture in the distributed database with a master-slave replication and multi-active architecture is specifically: On the basis of master-slave replication, deploy multiple nodes with read-write capabilities; adopt the two-phase commit protocol or introduce a distributed transaction coordinator to ensure data consistency during data read-write operations among multiple active nodes.
4. The intelligent verification goods exchange platform driven by digital goods codes according to claim 1, characterized in that, Improving the concurrent processing ability through read-write separation is specifically as follows: Deploy MyCat or Sharding-JDBC middleware between the application and the database to monitor the type of requests in real time. For write requests, the middleware routes them to the master node for processing, while for read requests, the middleware uses a load balancing algorithm to distribute the read requests to the slave node with low load for execution; partitioning specifically includes partitioning by time range and partitioning by region; the sharding operation includes sharding by product type and sharding by data popularity.
5. The intelligent verification goods exchange platform driven by digital goods codes according to claim 1, characterized in that, Use distributed locks to prevent concurrent verification errors. Specifically: for product code verification, the lock is associated with the product code; for resource modification operations, coarser-grained locks are used. Use the SETNX command to acquire the lock and set an expiration time. If the lock is already held, wait, and the waiting time can be adjusted. Release the lock using the DEL command after the operation is completed. When unable to acquire the lock, display "The system is busy. Please try again later" through the user interface, and the API request returns the HTTP 423 Locked status code and an error message.
6. The intelligent verification goods exchange platform driven by digital goods codes according to claim 1, characterized in that Perform user permission verification based on the RBAC model. Specifically: Define multiple roles and their refined permissions, and store them in the database or configuration file. Assign roles to users according to their positions during user registration or management, store them in the user information table, which can be adjusted dynamically, and enterprise users can be automatically assigned according to the organizational structure. After the user logs in, obtain the permissions from the storage according to the role, and store them in the session or encode them in the token. Before the operation, extract the permission list from the user session or token for verification. When there is no permission, prompt through the user interface or the API request returns the HTTP 403 Forbidden status code and an error message. When the permissions are changed, send a message using the message queue. The message includes the user ID, the original role, the new role, and the list of changed permissions.
7. The intelligent verification goods exchange platform driven by digital goods codes according to claim 1, characterized in that, It also includes: A user registration and login unit, which is used to strictly verify the user input information, store the password using bcrypt, and issue a short-term token through JWT token authentication.
8. The intelligent verification goods exchange platform driven by digital goods codes according to claim 1, characterized in that It also includes: A permission management unit, which is used to notify permission changes through the message queue based on the RBAC model.
9. The intelligent verification goods exchange platform driven by digital goods codes according to claim 1, characterized in that, It also includes: An information query unit, which is used to use the Elasticsearch search engine to retrieve goods information according to the product code, product name, batch number, and date range conditions, and display the results in the form of a list, table, or timeline.
10. The intelligent verification goods exchange platform driven by digital goods codes according to claim 1, characterized in that, The product code-driven intelligent verification goods exchange platform also includes: a traceability path presentation unit, which is used to construct the goods traceability path through event sourcing according to the event repository and workflow engine, and use bpmn.js to visualize and display the transfer process in the form of a flowchart or timeline.