Snapshot generation method and device for order goods, computer device and storage medium
Patent Information
- Application Number
- CN202611194637.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-06
- Publication Date
- 2026-10-30
AI Technical Summary
[0004]本发明提供一种订单商品的快照生成方法、装置、计算机设备及存储介质,以解决现有技术中快照与订单可能不一致,且存储空间浪费的技术问题
[0009]上述订单商品的快照生成方法、装置、计算机设备及存储介质,所述订单商品的快照生成方法,通过在用户下单完成后主动触发快照生成请求,并结合异步双通道发送机制,实现了快照生成与订单主流程的解耦,确保了在订单系统高并发场景下,快照生成请求的高可用性,还解决了数据变更而导致的快照延迟与状态不一致问题,保证了快照数据与用户下单时刻商品状态的一致性。通过计算商品数据模型的哈希值作为内容唯一标识,并在生成快照前进行缓存检测,有效识别并复用内容相同的商品快照,减少了数据库中冗余快照记录的存储,降低了存储成本。同时,通过订单标识、商品标识与快照标识的关联存储,既保证了订单与快照关系的准确映射,又实现了快照数据的高效管理与快速检索,提升了整体运行效率。
Smart Images

Figure CN123015127A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method, apparatus, computer device, and storage medium for generating snapshots of order goods. Background Technology
[0002] In electronic transactions, the product information seen by the user when an order is generated forms the basis of the order contract. However, after the order is completed, the merchant may modify the online product information. When the user subsequently views their order history, if the latest online product information is displayed, the order details seen by the user may differ from the product status at the time of their purchase, potentially leading to transaction disputes.
[0003] Existing product snapshot generation solutions typically suffer from the following drawbacks: they rely on monitoring database change logs or change messages from the product service to trigger snapshot updates, leading to discrepancies between the generated snapshot and the actual state at the time the user placed the order, thus failing to guarantee absolute snapshot consistency. Furthermore, each order stores a separate copy of the product snapshot data. When a large number of users purchase the same unchanged product, numerous redundant snapshot records with identical content are generated, significantly wasting storage resources and increasing database query and maintenance costs. Summary of the Invention
[0004] This invention provides a method, apparatus, computer device, and storage medium for generating snapshots of order products, in order to solve the technical problem that snapshots may not match orders and that storage space is wasted in the prior art.
[0005] Firstly, a method for generating snapshots of order items is provided, including: Receive a snapshot generation request sent via asynchronous dual channels, and determine the current product and the product data model corresponding to the current product based on the product identifier in the snapshot generation request; Based on the product data model, determine the product hash value corresponding to the current product; When it is detected that there is no snapshot identifier corresponding to the current product in the preset cache based on the product hash value, a snapshot identifier corresponding to the current product is generated according to the product data model; The order identifier, the product identifier, and the snapshot identifier in the snapshot generation request are associated to obtain a first snapshot record corresponding to the current product, and the first snapshot record is stored in the order snapshot relationship table.
[0006] Secondly, a snapshot generation device for order goods is provided, comprising: The product determination module is used to receive a snapshot generation request sent through asynchronous dual channels, and determine the current product and the product data model corresponding to the current product based on the product identifier in the snapshot generation request. The product hash module is used to determine the product hash value corresponding to the current product based on the product data model. The snapshot identifier module is used to generate a snapshot identifier corresponding to the current product based on the product data model when it is detected that there is no snapshot identifier corresponding to the current product in the preset cache according to the product hash value. The record storage module is used to associate the order identifier, the product identifier, and the snapshot identifier in the snapshot generation request to obtain a snapshot record corresponding to the current product, and to persistently store the snapshot record in the order snapshot relationship table.
[0007] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described method for generating snapshots of order goods.
[0008] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described method for generating snapshots of order goods.
[0009] The aforementioned method, apparatus, computer equipment, and storage medium for generating snapshots of order products, specifically the method for generating snapshots of order products, decouples snapshot generation from the main order process by actively triggering a snapshot generation request after the user places an order and combining it with an asynchronous dual-channel sending mechanism. This ensures high availability of the snapshot generation request in high-concurrency scenarios of the order system and also solves the problems of snapshot delay and state inconsistency caused by data changes, guaranteeing the consistency of snapshot data with the product state at the time the user places the order. By calculating the hash value of the product data model as a unique identifier for the content and performing cache detection before generating the snapshot, product snapshots with the same content are effectively identified and reused, reducing the storage of redundant snapshot records in the database and lowering storage costs. Simultaneously, the associated storage of order identifiers, product identifiers, and snapshot identifiers ensures accurate mapping between orders and snapshots and achieves efficient management and fast retrieval of snapshot data, improving overall operational efficiency. Attached Figure Description
[0010] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a schematic diagram of an application environment for a snapshot generation method for order goods in one embodiment of the present invention; Figure 2 This is a flowchart illustrating a method for generating a snapshot of order goods according to an embodiment of the present invention; Figure 3 This is a flowchart illustrating a method for generating a snapshot of order goods in another embodiment of the present invention; Figure 4 This is a schematic diagram of a snapshot generation device for order goods in one embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. Detailed Implementation
[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0013] The method for generating snapshots of order products provided in this embodiment of the invention can be applied to, for example... Figure 1In this application environment, the client communicates with the server via a network. The server can receive snapshot generation requests sent asynchronously through dual channels. Based on the product identifier in the snapshot generation request, it determines the current product and the corresponding product data model. Based on the product data model, it determines the product hash value corresponding to the current product. When the product hash value indicates that there is no snapshot identifier corresponding to the current product in the preset cache, it generates a snapshot identifier corresponding to the current product based on the product data model. It associates the order identifier, the product identifier, and the snapshot identifier in the snapshot generation request to obtain a first snapshot record corresponding to the current product and stores the first snapshot record in the order snapshot relationship table. In this invention, by actively triggering the snapshot generation request after the user places an order and combining it with the asynchronous dual-channel sending mechanism, the snapshot generation and the main order process are decoupled. This ensures the high availability of the snapshot generation request in high-concurrency scenarios of the order system and also solves the problem of snapshot delay and state inconsistency caused by data changes, ensuring the consistency of snapshot data with the product state at the time the user places the order. By calculating the hash value of the product data model as a unique identifier for the content and performing cache detection before generating a snapshot, the invention effectively identifies and reuses product snapshots with identical content, reducing the storage of redundant snapshot records in the database and lowering storage costs. Simultaneously, through the associated storage of order identifiers, product identifiers, and snapshot identifiers, it ensures accurate mapping between orders and snapshots, and achieves efficient management and rapid retrieval of snapshot data, improving overall operational efficiency. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The invention will be described in detail below through specific embodiments.
[0014] Please see Figure 2 As shown, Figure 2 A flowchart illustrating the method for generating snapshots of order products provided in an embodiment of the present invention includes the following steps: S101. Receive a snapshot generation request sent via asynchronous dual channels, and determine the current product and the product data model corresponding to the current product based on the product identifier in the snapshot generation request.
[0015] In essence, asynchronous dual-channel refers to sending requests simultaneously through two independent methods: one-way RPC calls and message queues (such as Kafka). A snapshot generation request is an instruction proactively triggered to generate a product snapshot after a user places an order. A product identifier is an ID used to uniquely identify a specific product. The current product refers to the product ordered by the user. The product data model is a structured data object that aggregates product service and attribute service data at the time of order placement, carrying complete business information about the product.
[0016] Specifically, after a user places an order for a product, the order system proactively triggers a snapshot generation request. Then, the snapshot generation request, including a product identifier and an order identifier, is sent to the snapshot service via asynchronous dual-channel communication. In one embodiment, one channel is an RPC oneway call; the second channel is a message queue (such as Kafka) sending a message. The subsequent process is triggered upon arrival of either channel. Then, based on the product identifier in the snapshot generation request, the current product and its corresponding product data model are determined. That is, using the product identifier in the snapshot generation request, the current product ordered by the user and its product data model are obtained from the product service and attribute service, respectively.
[0017] S102. Determine the product hash value corresponding to the current product based on the product data model.
[0018] Understandably, a product hash value is a unique identifier calculated using a digest algorithm on a serialized product data model, used to determine whether snapshot content is duplicated.
[0019] Specifically, based on the product data model, the product hash value corresponding to the current product is determined, that is, the product data model is serialized, and the hash value of the serialized product is calculated using a digest algorithm, and the calculated hash value is determined as the product hash value corresponding to the current product.
[0020] In one embodiment, the product data model is serialized to obtain product sequence data; the product sequence data is converted into binary data and filled to obtain complete filled data; the complete filled data is divided into blocks to obtain at least one independent message block; all the independent message blocks are iteratively hashed to obtain the product hash value corresponding to the current product.
[0021] S103. When it is detected that there is no snapshot identifier corresponding to the current product in the preset cache based on the product hash value, a snapshot identifier corresponding to the current product is generated according to the product data model.
[0022] Understandably, the preset cache refers to a pre-defined Redis cache space used to accelerate snapshot deduplication, relational queries, and detailed data retrieval. The snapshot identifier is an ID assigned to represent the current product snapshot when a new product snapshot record is generated.
[0023] Specifically, the system checks if a corresponding snapshot identifier exists in the preset cache using the product hash value. When the system detects that no snapshot identifier for the current product exists in the preset cache based on the product hash value, it generates a snapshot identifier for the current product based on the product data model. In other words, the product data model is determined as the snapshot identifier for the current product.
[0024] S104. Associate the order identifier, the product identifier, and the snapshot identifier in the snapshot generation request to obtain a first snapshot record corresponding to the current product, and store the first snapshot record in the order snapshot relationship table.
[0025] In essence, an order identifier is an ID used to uniquely identify a specific transaction order within the system. A first snapshot record is a snapshot record obtained by associating a new snapshot identifier with the order identifier and product identifier. The order snapshot relationship table is a database table used to persistently store the mapping relationships between order identifiers, product identifiers, and snapshot identifiers.
[0026] Specifically, the order identifier, product identifier, and snapshot identifier in the snapshot generation request are associated, and all associated identifiers are identified as the first snapshot record corresponding to the current product. Then, the first snapshot record corresponding to the current product is persistently stored in the order snapshot relationship table.
[0027] In one embodiment, within the financial sector, a dual-channel system—a main trading channel and a backup risk control channel—receives snapshot generation requests triggered by user-ordered transactions, product subscriptions and redemptions, and fund transfers. Based on the financial product identifier in the request, the system accurately locates the current trading product and retrieves the corresponding sub-data models, including stock trading models, wealth management risk control models, and fund clearing models. Based on the full transaction data model corresponding to the current product, a unique transaction data hash value is generated using an encrypted hash algorithm. The system iterates through the financial distributed preset cache to check for a matching snapshot identifier for the current product and transaction node. If a valid snapshot exists in the cache (with consistent hash values, indicating no changes to transaction parameters or risk control rules), the historical snapshot is directly reused. If no matching snapshot exists in the cache or the hash values are inconsistent (data has dynamically changed), a new and unique transaction snapshot ID is immediately generated based on the latest financial data model. The transaction serial number (order identifier), financial product identifier, and new / reused snapshot identifier are associated to generate a standardized first snapshot record for the financial transaction, which is then synchronously persisted to the financial order transaction snapshot relationship table.
[0028] In one embodiment, within the medical field, snapshot generation requests triggered by scenarios such as outpatient consultations, inpatient treatments, prescription issuance, laboratory tests, and medical record updates are received asynchronously through both clinical business channels and medical insurance audit channels. Based on the treatment item identifier in the request, the current treatment item is located, and the corresponding medical-specific data model is retrieved. Based on the full medical data model of the current treatment item, a hash value for the treatment data is generated using encryption. The medical compliance cache is retrieved to verify whether a matching snapshot identifier for the current visit number and treatment item exists. If the treatment data remains unchanged and the hash value matches, the existing snapshot is directly reused; if no matching record is found in the cache, a new and unique treatment snapshot identifier is immediately generated to accurately distinguish each iteration of the treatment status. The visit number (order identifier), treatment item identifier, and treatment snapshot identifier are associated to generate the first medical treatment snapshot record, which is then stored in batches to a medical treatment snapshot relationship table.
[0029] The order product snapshot generation method in this embodiment of the invention actively triggers a snapshot generation request after the user places an order, and combines it with an asynchronous dual-channel sending mechanism. This decouples snapshot generation from the main order process, ensuring high availability of the snapshot generation request in high-concurrency scenarios of the order system. It also solves the problems of snapshot delay and state inconsistency caused by data changes, ensuring the consistency of snapshot data with the product state at the time the user places the order. By calculating the hash value of the product data model as a unique identifier for the content and performing cache detection before generating the snapshot, it effectively identifies and reuses product snapshots with the same content, reducing the storage of redundant snapshot records in the database and lowering storage costs. At the same time, through the associated storage of order identifiers, product identifiers, and snapshot identifiers, it not only ensures the accurate mapping between orders and snapshots, but also achieves efficient management and fast retrieval of snapshot data, improving overall operating efficiency.
[0030] In one embodiment, step S101, determining the current product and the product data model corresponding to the current product based on the product identifier in the snapshot generation request, includes: S1011, Based on the product identifier, obtain product information corresponding to the product identifier from the product service, and determine the current product based on the product information.
[0031] S1012, based on the product identifier, obtain the attribute information corresponding to the product identifier from the attribute service, and determine the product data model corresponding to the current product based on the attribute information and the product information.
[0032] In essence, product services refer to the underlying service modules responsible for providing and managing basic product data (such as product name, images, etc.). Product information refers to the basic descriptive content about a product. Attribute services refer to the underlying service modules responsible for providing and managing detailed attribute data such as product specifications and parameters. Attribute information refers to detailed characteristic data about a product, such as its specific specifications, parameters, and tags.
[0033] Specifically, the product identifier is sent to the product service. Using the product identifier as a query condition, the product service matches and retrieves the product information corresponding to the product identifier. Based on the retrieved product information, the current product at the time of order placement is determined. Then, the product identifier is sent to the attribute service. Using the product identifier as a query condition, the attribute service matches and retrieves the attribute information corresponding to the product identifier. Next, based on the attribute information and the product information, a product data model corresponding to the current product is determined. That is, the retrieved product information (such as basic data like product name and image) and attribute information (such as detailed features like specifications, parameters, and tags) are integrated and assembled to construct a structured data set containing all complete information about the current product at the time of order placement, and this set is determined as the product data model corresponding to the current product.
[0034] In this embodiment, product information is obtained from the product service through product identification, thereby enabling the determination of the current product. Attribute information is also obtained from the attribute service through product identification, thereby enabling the determination of the product data model.
[0035] In one embodiment, step S102, determining the product hash value corresponding to the current product based on the product data model, includes: S1021, The commodity data model is serialized to obtain commodity sequence data.
[0036] S1022, the product sequence data is converted into binary data and filled to obtain complete filled data.
[0037] S1023, the complete filling data is divided into blocks to obtain at least one independent message block.
[0038] S1024, perform iterative hashing on all the independent message blocks to obtain the product hash value corresponding to the current product.
[0039] In essence, product sequence data refers to data obtained by serializing a product data model, such as a JSON string. Completely padded data refers to pre-processed data that has been padded to reach a preset length. Independent message blocks refer to fixed-length data slices.
[0040] Specifically, the product data model undergoes serialization processing. This involves sequentially reading all fields involved in serialization within the product data model, directly extracting and converting the basic data, recursively traversing nested objects and collection data within the model, and repeatedly performing field reading and format conversion operations on substructures such as product tags and category information. All converted field information is then concatenated and integrated according to the serialization format specification to form a continuous linear structure. The concatenated data undergoes format verification and compression as needed to generate product sequence data. Next, the structured product sequence data is converted into a computer-processable binary byte stream. After obtaining the binary data, a 1 bit is appended to the end, followed by several 0 bits until the data length meets a specific formula (e.g., the length modulo 512 is 448). Finally, a 64-bit original message length information is appended to obtain the complete filled data. Then, according to a pre-set single-block data capacity threshold, the complete filled data is segmented, producing one or more independent message blocks that do not overlap and can be processed separately. Finally, all independent message blocks undergo iterative hashing, i.e., a fixed set of initial hash values is initialized. Each independent message block is input into the hash compression function in sequence. After the first message block undergoes multiple rounds of complex logical bit operations with the initial value, an intermediate hash value is generated. The intermediate hash value is used as the input state for the next independent message block and is passed on sequentially until the last message block is processed. The final fixed-length binary digest output can be determined as the product hash value corresponding to the current product.
[0041] In this embodiment, serialization eliminates the differences caused by different data formats, ensuring the uniformity of the underlying data. Based on this, binary conversion, fixed-length padding, and block processing mechanisms are used to transform product data of arbitrary length into a standardized data stream. Furthermore, iterative hashing of independent message blocks generates unique and irreversible product hash values, effectively preventing malicious tampering of product data during transmission and storage.
[0042] In one embodiment, such as Figure 3 As shown, after step S102, after determining the product hash value corresponding to the current product based on the product data model, the method further includes: S1051, based on the product identifier and the order identifier, query whether there is a cache record corresponding to the current product in the first cache of the preset cache.
[0043] S1052, when a cache record corresponding to the current product exists in the first cache, query whether a snapshot identifier corresponding to the current product exists in the second cache of the preset cache according to the product identifier and the product hash value.
[0044] S1053, when a snapshot identifier corresponding to the current product exists in the second cache, retrieve the snapshot identifier corresponding to the current product from the second cache.
[0045] S1054, associate the order identifier, the product identifier and the snapshot identifier to obtain a second snapshot record corresponding to the current product, and store the second snapshot record in the order snapshot relationship table.
[0046] Understandingly, the first cache refers to the cache space used to cache key-value pairs from product ID, order ID to snapshot ID. It is primarily used to check whether a snapshot has already been generated for the order during snapshot generation, thus achieving order-level deduplication. A cache record is a key-value pair data entry stored in a pre-defined cache, used to accelerate the process of snapshot deduplication, relational queries, and detailed data retrieval. The second cache refers to the cache space used to cache key-value pairs from product ID, product hash value to snapshot ID. It is primarily used for deduplication based on content hash to identify and reuse existing snapshots with the same content. A second snapshot record is a snapshot record obtained by reusing the snapshot identifier to associate the order identifier and product identifier.
[0047] Specifically, after determining the product hash value corresponding to the current product, the system first iterates through the first cache using the product identifier and order identifier to check if a corresponding cache record exists for the current product. If a cache record for the current product exists in the first cache, the system then checks the second cache (a preset cache) for a snapshot identifier corresponding to the current product, using the product identifier and product hash value. In other words, the system iterates through the second cache using the product identifier and product hash value to check if a snapshot identifier for the current product exists. If a snapshot identifier for the current product exists in the second cache, it is retrieved from the second cache. Next, the order identifier, product identifier, and snapshot identifier from the snapshot generation request are associated, and all associated identifiers are identified as the second snapshot record corresponding to the current product. Finally, the second snapshot record corresponding to the current product is persistently stored in the order snapshot relationship table.
[0048] In one embodiment, in the scenario of financial product subscription business, the system first queries the first-level basic product cache in the preset hierarchical cache based on the financial product code (i.e., product identifier) and the financial product subscription transaction order number (i.e., order identifier). It verifies whether there is a valid basic cache record for the current financial product. If there is no corresponding record in the first-level cache, the current subscription order process is directly intercepted. If there is a corresponding financial product cache record in the first-level cache, the system combines the financial product code with the product hash value generated after serialization, binary filling, and block iterative hashing of the instantaneous complete data of the product to query the second-level snapshot cache. It determines whether there is a snapshot identifier for the instantaneous state of the financial product in the second-level snapshot cache. If the second-level snapshot cache hits the corresponding snapshot identifier, the snapshot identifier is read. Then, the financial product subscription order number, financial product code, and snapshot identifier are associated and encapsulated to generate a second snapshot record, and the record is persistently written to the transaction order product snapshot association table.
[0049] In one embodiment, in the scenario of medical outpatient prescription drug payment, the system queries the primary drug cache based on the in-hospital drug code (product identifier) and the outpatient prescription payment number (order identifier) to verify whether the drug is a valid in-hospital drug. If no cache record is found, the payment process is intercepted. If a basic drug cache record exists, the system then searches the secondary drug snapshot cache by combining the drug code and the drug data at the time of prescription, which are serialized, binary-filled, and iteratively hashed in blocks. This checks whether a corresponding instantaneous drug information snapshot identifier exists. If the snapshot identifier exists in the cache, it reads the identifier, associates the prescription payment number, the in-hospital drug code, and the snapshot identifier to generate a second snapshot record, and stores it in the prescription drug snapshot relationship table. Both scenarios rely on the primary cache to verify the validity of business entities, the hash value to lock the instantaneous complete data of business objects, the secondary cache to reuse snapshot resources, and the associated data table to permanently bind orders and corresponding snapshot identifiers, thereby achieving fixed tracking of business historical data, change isolation, and high-performance query processing.
[0050] In this embodiment, by introducing a multi-level caching mechanism (first cache and second cache) for dual deduplication and association judgment, when an order snapshot is generated, duplicate requests can be quickly intercepted from the cache and existing snapshot identifiers can be reused directly. This effectively avoids the duplicate storage of the same product content and frequent database write operations, thus saving storage resources.
[0051] In one embodiment, after step S103, after generating a snapshot identifier corresponding to the current product based on the product data model, the method further includes: S1031, the snapshot identifier and the snapshot details data corresponding to the current product are stored in the product snapshot master table, which is used to store snapshot details data of all different content versions.
[0052] Understandably, snapshot details data refers to a collection of specific information used to fully restore the product's status at the time of order placement, including at least the product name, image, attributes, and tags. The product snapshot master table is a database table used to persistently store product snapshot details for all different content versions. Its table structure includes at least a primary key identifier, a product identifier, a snapshot identifier, and a product hash value field.
[0053] Specifically, first, a key-value pair is created between the snapshot identifier and snapshot details data corresponding to the same current product; that is, the snapshot identifier is used as the key and the snapshot details data is used as the value. Then, the associated snapshot identifier and snapshot details data are stored in the product snapshot master table.
[0054] In this embodiment, the snapshot identifier and snapshot details are stored independently in the main table, which realizes the physical isolation between order transaction data and product dynamic data, ensures that the user's state at the time of placing the order is fixed, and effectively prevents customer complaints and compliance risks.
[0055] In one embodiment, after step S104, after storing the first snapshot record in the order snapshot relationship table, the method further includes: S1061, Receive a snapshot query request, the snapshot query request including query product identifier and query snapshot identifier.
[0056] S1062, based on the queried product identifier and the queried snapshot identifier, query whether there is corresponding preset snapshot details data in the third cache.
[0057] S1063, when the third cache contains preset snapshot details data corresponding to the queried product identifier and the queried snapshot identifier, the returned preset snapshot details data is determined as the target snapshot details data.
[0058] Understandingly, a snapshot query request refers to a query instruction initiated to view the status of products in historical orders. The query product identifier is the ID carried in the snapshot query request, used to identify the specific product whose snapshot details need to be queried. The query snapshot identifier is the snapshot ID carried in the snapshot query request, used to uniquely identify the specific product snapshot version to be queried. The third cache refers to a pre-defined cache space used to accelerate snapshot queries, used to cache complete snapshot details data with the product ID and snapshot ID as keys. Pre-defined snapshot details data refers to the complete snapshot content pre-stored in the third cache or the main product snapshot table, including at least the product name, image, attributes, tags, and other information used to restore the product status at the time of order placement. The target snapshot details data refers to the snapshot details data determined and returned after a cache hit or a database origin query.
[0059] Specifically, a snapshot query request is received. Then, by querying the product identifier and the snapshot identifier, the system checks if corresponding preset snapshot detail data exists in the third cache. That is, the product identifier and snapshot identifier in the snapshot query request are traversed and matched against the two identifiers in the third cache corresponding to each preset snapshot detail data. If both the product identifier and the snapshot identifier match both identifiers corresponding to the preset snapshot detail data, a successful match is confirmed, and the corresponding preset snapshot detail data exists in the third cache. If only one matches or neither matches, a match is confirmed, and the corresponding preset snapshot detail data does not exist in the third cache. When preset snapshot detail data corresponding to the product identifier and the snapshot identifier exists in the third cache, this preset snapshot detail data is retrieved and returned, and this preset snapshot detail data is identified as the target snapshot detail data.
[0060] In this embodiment, a query mechanism that prioritizes caching and uses the database as a fallback is constructed by introducing a third cache. When querying the details of an order's product snapshot, the data can be quickly retrieved from the cache and returned, thereby effectively avoiding the database pressure caused by frequently reading the main product snapshot table.
[0061] In one embodiment, after step S1062, after querying whether corresponding snapshot details data exists in the third cache based on the queried product identifier and the queried snapshot identifier, the method further includes: S1064, when the corresponding preset snapshot details data is not found in the third cache, the preset snapshot details data is obtained from the product snapshot main table according to the query product identifier and the query snapshot identifier.
[0062] S1065, the preset snapshot details data is stored in the third cache, and the returned preset snapshot details data is determined as the target snapshot details data.
[0063] Specifically, when no corresponding preset snapshot details data is found in the third cache, the product snapshot master table is retrieved, and the queried product identifier and the queried snapshot identifier are matched with the two identifiers in the product snapshot master table that correspond to the preset snapshot details data, respectively. When both identifiers match successfully, the successfully matched preset snapshot details data is retrieved, then the preset snapshot details data is stored in the third cache, the preset snapshot details data is retrieved and returned, and this preset snapshot details data is determined as the target snapshot details data.
[0064] In this embodiment, when a cache miss occurs, the system automatically queries the source database and fills the results back into the cache, which not only ensures high concurrency and low latency in query response, but also improves the overall query performance and user experience of the system.
[0065] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0066] In one embodiment, a snapshot generation device for order goods is provided, which corresponds one-to-one with the snapshot generation method for order goods in the above embodiments. For example... Figure 4 As shown, the snapshot generation device for the order items includes an item determination module 101, an item hash module 102, a snapshot identification module 103, and a record storage module 104. Detailed descriptions of each functional module are as follows: The product determination module 101 is used to receive a snapshot generation request sent through an asynchronous dual channel, and determine the current product and the product data model corresponding to the current product based on the product identifier in the snapshot generation request. The product hash module 102 is used to determine the product hash value corresponding to the current product based on the product data model. The snapshot identifier module 103 is used to generate a snapshot identifier corresponding to the current product according to the product data model when it is detected that there is no snapshot identifier corresponding to the current product in the preset cache based on the product hash value. The record storage module 104 is used to associate the order identifier, the product identifier and the snapshot identifier in the snapshot generation request to obtain a snapshot record corresponding to the current product, and to persistently store the snapshot record in the order snapshot relationship table.
[0067] In one embodiment, the product determination module 101 includes: The product information unit is used to obtain product information corresponding to the product identifier from the product service based on the product identifier, and to determine the current product based on the product information; The product data unit is used to obtain attribute information corresponding to the product identifier from the attribute service based on the product identifier, and to determine the product data model corresponding to the current product based on the attribute information and the product information.
[0068] In one embodiment, the product hash module 102 includes: A serialization unit is used to serialize the product data model to obtain product sequence data; A data filling unit is used to convert the product sequence data into binary data and fill it to obtain complete filled data; The block processing unit is used to divide the complete padding data into blocks to obtain at least one independent message block; An iterative hash unit is used to perform iterative hashing on all the independent message blocks to obtain the product hash value corresponding to the current product.
[0069] In one embodiment, the device further includes: The cache query module is used to query whether there is a cache record corresponding to the current product in the first cache of the preset cache based on the product identifier and the order identifier; The identifier query module is used to query whether a snapshot identifier corresponding to the current product exists in the second cache of the preset cache when there is a cache record corresponding to the current product in the first cache, based on the product identifier and the product hash value; The identifier acquisition module is used to acquire the snapshot identifier corresponding to the current product from the second cache when a snapshot identifier corresponding to the current product exists in the second cache; The second snapshot recording module is used to associate the order identifier, the product identifier and the snapshot identifier to obtain a second snapshot record corresponding to the current product, and to store the second snapshot record in the order snapshot relationship table.
[0070] In one embodiment, the device further includes: The details data storage unit is used to store the snapshot identifier and the snapshot details data corresponding to the current product into the product snapshot master table, which is used to store snapshot details data of all different content versions.
[0071] In one embodiment, the device further includes: The snapshot query request module is used to receive snapshot query requests, which include querying product identifiers and querying snapshot identifiers; The detailed data query module is used to query whether there is corresponding preset snapshot detailed data in the third cache based on the query product identifier and the query snapshot identifier; The details data acquisition module is used to determine the returned preset snapshot details data as the target snapshot details data when the third cache contains preset snapshot details data corresponding to the queried product identifier and the query snapshot identifier.
[0072] In one embodiment, the device further includes: The snapshot details acquisition module is used to retrieve the preset snapshot details data from the product snapshot main table based on the query product identifier and the query snapshot identifier when the corresponding preset snapshot details data is not found in the third cache. The details data storage module is used to store the preset snapshot details data in the third cache and determine the returned preset snapshot details data as the target snapshot details data.
[0073] Specific limitations regarding the snapshot generation device for order products can be found in the limitations of the snapshot generation method for order products described above, and will not be repeated here. Each module in the aforementioned snapshot generation device for order products can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0074] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 5 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When executed by the processor, the computer program implements client-side functions or steps of a method for generating snapshots of order goods.
[0075] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: Receive a snapshot generation request sent via asynchronous dual channels, and determine the current product and the product data model corresponding to the current product based on the product identifier in the snapshot generation request; Based on the product data model, determine the product hash value corresponding to the current product; When it is detected that there is no snapshot identifier corresponding to the current product in the preset cache based on the product hash value, a snapshot identifier corresponding to the current product is generated according to the product data model; The order identifier, the product identifier, and the snapshot identifier in the snapshot generation request are associated to obtain a first snapshot record corresponding to the current product, and the first snapshot record is stored in the order snapshot relationship table.
[0076] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor: Receive a snapshot generation request sent via asynchronous dual channels, and determine the current product and the product data model corresponding to the current product based on the product identifier in the snapshot generation request; Based on the product data model, determine the product hash value corresponding to the current product; When it is detected that there is no snapshot identifier corresponding to the current product in the preset cache based on the product hash value, a snapshot identifier corresponding to the current product is generated according to the product data model; The order identifier, the product identifier, and the snapshot identifier in the snapshot generation request are associated to obtain a first snapshot record corresponding to the current product, and the first snapshot record is stored in the order snapshot relationship table.
[0077] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0078] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0079] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0080] It should be noted that any AI models, software tools, or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with the knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.
[0081] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for generating snapshots of order products, characterized in that, include: Receive a snapshot generation request sent via asynchronous dual channels, and determine the current product and the corresponding product data model based on the product identifier in the snapshot generation request; the product data model refers to a structured data object that aggregates product service and attribute service data at the time of order placement and carries the complete business information of the product; Based on the product data model, determine the product hash value corresponding to the current product; When it is detected that there is no snapshot identifier corresponding to the current product in the preset cache based on the product hash value, a snapshot identifier corresponding to the current product is generated according to the product data model; The order identifier, the product identifier, and the snapshot identifier in the snapshot generation request are associated to obtain a first snapshot record corresponding to the current product, and the first snapshot record is stored in the order snapshot relationship table.
2. The method for generating snapshots of order goods as described in claim 1, characterized in that, The step of determining the product hash value corresponding to the current product based on the product data model includes: The product data model is serialized to obtain product sequence data; The product sequence data is converted into binary data and then filled to obtain complete filled data; The complete fill data is divided into blocks to obtain at least one independent message block; Perform iterative hashing on all the independent message blocks to obtain the product hash value corresponding to the current product.
3. The method for generating snapshots of order goods as described in claim 1, characterized in that, After determining the product hash value corresponding to the current product based on the product data model, the process further includes: Based on the product identifier and the order identifier, query whether there is a cache record corresponding to the current product in the first cache of the preset cache; When a cache record corresponding to the current product exists in the first cache, query whether a snapshot identifier corresponding to the current product exists in the second cache of the preset cache based on the product identifier and the product hash value; If a snapshot identifier corresponding to the current product exists in the second cache, retrieve the snapshot identifier corresponding to the current product from the second cache; The order identifier, the product identifier, and the snapshot identifier are associated to obtain a second snapshot record corresponding to the current product, and the second snapshot record is stored in the order snapshot relationship table.
4. The method for generating snapshots of order goods as described in claim 1, characterized in that, After generating a snapshot identifier corresponding to the current product based on the product data model, the process further includes: The snapshot identifier and the snapshot details data corresponding to the current product are stored in the product snapshot master table, which is used to store snapshot details data for all different content versions.
5. The method for generating snapshots of order goods as described in claim 1, characterized in that, The step of determining the current product and the corresponding product data model based on the product identifier in the snapshot generation request includes: Based on the product identifier, obtain product information corresponding to the product identifier from the product service, and determine the current product based on the product information; Based on the product identifier, obtain the attribute information corresponding to the product identifier from the attribute service, and determine the product data model corresponding to the current product based on the attribute information and the product information.
6. The method for generating snapshots of order goods as described in claim 1, characterized in that, After storing the first snapshot record in the order snapshot relationship table, the method further includes: Receive a snapshot query request, the snapshot query request including query product identifier and query snapshot identifier; Based on the queried product identifier and the queried snapshot identifier, query whether there is corresponding preset snapshot details data in the third cache; When the third cache contains preset snapshot details data corresponding to the queried product identifier and the queried snapshot identifier, the returned preset snapshot details data will be determined as the target snapshot details data.
7. The method for generating snapshots of order goods as described in claim 6, characterized in that, After querying whether corresponding preset snapshot details data exists in the third cache based on the queried product identifier and the queried snapshot identifier, the method further includes: When the corresponding preset snapshot details data is not found in the third cache, the preset snapshot details data is obtained from the main product snapshot table based on the query product identifier and the query snapshot identifier. The preset snapshot details data is stored in the third cache, and the returned preset snapshot details data is determined as the target snapshot details data.
8. A snapshot generation device for order goods, characterized in that, include: The product determination module is used to receive a snapshot generation request sent via asynchronous dual channels, and determine the current product and the product data model corresponding to the current product based on the product identifier in the snapshot generation request; the product data model refers to a structured data object that aggregates product service and attribute service data at the time of order placement and carries the complete business information of the product. The product hash module is used to determine the product hash value corresponding to the current product based on the product data model. The snapshot identifier module is used to generate a snapshot identifier corresponding to the current product based on the product data model when it is detected that there is no snapshot identifier corresponding to the current product in the preset cache according to the product hash value. The record storage module is used to associate the order identifier, the product identifier, and the snapshot identifier in the snapshot generation request to obtain a snapshot record corresponding to the current product, and to persistently store the snapshot record in the order snapshot relationship table.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the snapshot generation method for order goods as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the snapshot generation method for order goods as described in any one of claims 1 to 7.
