A digital marketing data collection method, system and readable storage medium

By implementing state transition mapping rules and permission verification mechanisms, the problems of inconsistent order status and lack of permission management in digital marketing systems have been solved, achieving accuracy, consistency, and security of order data and improving the reliability of data collection.

CN122152851APending Publication Date: 2026-06-05SHENZHEN YIYUAN NETWORK PLATFORM CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN YIYUAN NETWORK PLATFORM CO LTD
Filing Date
2026-02-27
Publication Date
2026-06-05

Smart Images

  • Figure CN122152851A_ABST
    Figure CN122152851A_ABST
Patent Text Reader

Abstract

The application discloses a kind of digital marketing data collection method, system and readable storage medium, belong to digital marketing data collection field, the application includes the following steps: S1, the order data corresponding to marketing order is obtained and written into database;S2, according to the state flow mapping rule of preestablished control order state flow, only when order is in the case of processing state, third-party interface is called to carry out state query, and order state is updated based on the query result;S3, in response to data query instruction, based on the mapping relationship between the user role in the tenant identification and user role information corresponding to the current request obtained and access authority, the access operation of database is verified with authority, to isolate the data access authority of different roles;S4, in response to data export instruction, read order data in database, and order data is converted into spreadsheet file and output, solve the problem of low reliability in prior art digital marketing data collection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of digital marketing data collection technology, and in particular to a digital marketing data collection method, system, and readable storage medium. Background Technology

[0002] In real-world digital marketing scenarios, collaboration among multiple parties is typically involved, including the initiator (or platform) of the marketing campaign, the merchants (suppliers) providing digital goods resources, and the end users who ultimately receive the digital goods.

[0003] To support the planning and effectiveness evaluation of such marketing campaigns, businesses need to collect a large amount of data related to marketing activities, such as: user identity information participating in the campaign, the recipients of marketing resources (such as coupons), the distribution time, usage status, associated merchants or brands, and transaction results returned by third-party platforms. This data is an important basis for subsequent user profiling, ROI analysis, and campaign strategy optimization.

[0004] Furthermore, to achieve effective management of marketing activities and efficient circulation of goods, existing digital marketing systems generally adopt an order-based management model. That is, when a marketing distribution activity occurs, the system generates a corresponding digital product order record in the database.

[0005] Existing digital marketing systems typically possess basic order management functions, enabling the input and storage of basic order information (such as order number, product name, and transaction amount). These systems also generally integrate an access control framework, controlling user access to system menus and functions by setting different user roles (such as administrators, regular users, and merchants). To facilitate subsequent data utilization, the systems usually also provide the ability to export records from the database to common formats such as Excel, supporting offline data statistics and analysis.

[0006] For example, Chinese invention patent application CN121120215A discloses a multi-scenario application aggregation intelligent business management platform, including: a tag management module, a coupon management module, a product management module, an order management module, a supplier management module, an advertising management module, a platform role management module, and a platform user management module. The tag management module manages and accurately associates product tags throughout their entire lifecycle; the coupon management module controls and dynamically optimizes coupons throughout the entire process; the product management module provides refined management across the entire chain, from classification and attributes to information, based on product characteristics; the order management module standardizes and monitors the risks of multi-source and multi-state orders based on their source and status; the supplier management module manages supplier classification, qualifications, and associated logic on a platform-based basis based on supplier characteristics; the advertising management module manages advertising placement and information based on advertising display needs; the platform role management module implements hierarchical permission control; and the platform user management module unifies and manages user information across platforms based on user needs.

[0007] For example, Chinese invention patent application CN118735637A discloses a digital integrated micro-mall order information processing system, comprising: an order information collection module, an order processing module, an order verification module, a payment gateway module, and an intelligent after-sales management module, all connected in sequence. The order information collection module captures user order information from multiple channels in real time. The order processing module automatically classifies and optimizes order processing based on artificial intelligence algorithms. The order verification module automatically verifies order information using OCR and deep learning algorithms. The payment gateway module utilizes biometric technology and smart contracts to handle payment and refund transactions. The intelligent after-sales management module introduces an intelligent customer service robot and optimizes after-sales service through big data analysis.

[0008] However, in the process of implementing the inventive technical solution in the embodiments of this application, it was found that the above-mentioned technology has at least the following technical problems: In existing technologies, current solutions manage the "dispatch status" and "verification status" of orders as two independent fields, relying on decentralized conditional judgments to implement status changes. When the system encounters network timeouts or callback delays while processing asynchronous dispatch requests from third parties, the retry mechanism may repeatedly trigger dispatch operations based on expired statuses. More seriously, when business logic requires simultaneous updates to both dispatch and verification statuses (e.g., forcibly terminating the verification process due to dispatch failure), if database transactions fail to guarantee the atomicity of these updates, logically impossible intermediate states such as "dispatch failed but verification has been completed" may occur. Such states not only violate marketing business rules but also lead to distortion in subsequent data analysis.

[0009] In the main order table query, basic data isolation is achieved by concatenating merchant ID conditions. However, in complex reports or anomaly investigation queries involving related entities such as user tables and activity tables, since the related tables themselves do not have tenant identifier fields and the permission filtering logic relies on developers to manually add filtering conditions, it is very easy for the SQL optimizer to indirectly obtain sensitive related data of other merchants (such as unauthorized users' mobile phone numbers or activity budgets) through a full table scan due to oversight.

[0010] Inconsistent order statuses force the system to perform more complex cross-tenant relational queries for diagnostics, significantly increasing the probability of permission penetration. Furthermore, incorrect business contexts obtained through permission penetration may be misused for status decisions, further exacerbating data inconsistencies and highlighting the low reliability of digital marketing data collection. Summary of the Invention

[0011] To address the technical problem of low reliability in existing digital marketing data collection technologies, embodiments of the present invention provide a digital marketing data collection method, system, and readable storage medium. The technical solution is as follows: On the one hand, a digital marketing data collection method is provided, which includes: S1, acquiring order data corresponding to marketing orders and writing the order data into a database, the order data including: identification information, time information, status information, and third-party interface response information; S2, controlling the flow of order status according to preset status transition mapping rules, the order status including created status, processing status, dispatched successfully status, and dispatched failed status, monitoring the current status of the order, and only calling the third-party interface to query the status when the current status is processing status, and updating the order status to the target status corresponding to the query result based on the query result returned by the third-party interface; S3, responding to the data query instruction, acquiring the tenant identifier and user role information corresponding to the current request, and performing permission verification on the database access operation based on the mapping relationship between user role information and access permissions to isolate the data access permissions of different roles; S4, responding to the data export instruction, reading the order data in the database, and converting the order data into an electronic spreadsheet file for output.

[0012] On the other hand, a digital marketing data collection system is provided, comprising: a data acquisition module for responding to marketing order generation, execution, or status change events, acquiring order data corresponding to the marketing order, and writing the order data into a database; the order data includes: identification information, time information, status information, and third-party interface response information; a status transition module for controlling the flow of order status according to preset status transition mapping rules; the order status includes created status, processing status, successful dispatch status, and failed dispatch status; monitoring the current status of the order; and only calling the third-party interface to query the status when the current status is processing status, and updating the order status to the target status corresponding to the query result based on the query result returned by the third-party interface; an access control module for responding to data query instructions, acquiring the tenant identifier and user role information corresponding to the current request, and performing access permission verification on the database access operation based on the mapping relationship between user role information and access permissions to isolate data access permissions for different roles; and a data export module for responding to data export instructions, reading order data from the database, and converting the order data into a spreadsheet file for output.

[0013] On the other hand, a computer-readable storage medium is provided, which stores a computer program or instructions that, when executed, cause a digital marketing data collection method to be performed.

[0014] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: 1. This invention provides a digital marketing data collection method that comprehensively records detailed information of marketing orders, providing a data foundation for subsequent order processing, querying, and analysis. By storing configuration snapshot data, compared to existing technologies that only store basic order information and current activity configuration information, this invention ensures the accuracy of order data and activity configuration. Then, it achieves standardized management of order status according to preset state transition mapping rules, making the state transition logic clear and easy to maintain. It accurately switches order status based on third-party interface responses, and can promptly reflect the processing status of orders in external systems. Next, when a data query command is received, it verifies the database access operation based on the mapping relationship between the obtained role attribute information and access permissions, ensuring that users of different roles can only access data within their authorized scope, meeting the requirements of data security and privacy protection. It also facilitates the management of data access behavior of different users, achieving isolation of data access permissions for different roles. Finally, it reads order data from the database and converts it into an electronic spreadsheet file for output, improving data usability and facilitating data analysis and decision-making for managers.

[0015] 2. This invention constructs a state transition topology diagram, defining the transition rules between order status and verification status. This provides a clear basis for subsequent state transition judgments. Compared to existing technologies that control state transitions through code logic or simple configuration, this invention reduces errors caused by unclear state transition rules, improves the effectiveness of digital marketing data collection, and then quickly and accurately determines whether the transition from the current order status to the target order status conforms to business rules by judging whether the transition path is valid. This avoids invalid state update operations, ensures the accuracy and consistency of order data, detects unreasonable state transition requests in advance, and reduces unnecessary system resource consumption. Next, it determines whether it is a multi-state related change, distinguishes different types of state change operations, and adopts a transaction processing mode based on resource reservation and compensation for complex situations such as multi-state related changes. This can better handle multi-state related changes and improve the targeting and effectiveness of processing. Compared to traditional transaction processing methods in existing technologies, this invention ensures resource availability during transaction processing through resource reservation and restores the state when the transaction fails through a compensation mechanism, thereby improving the reliability and data consistency of digital marketing transaction processing.

[0016] 3. By constructing a mapping relationship between data table names and tenant fields, the corresponding tenant fields of each data table can be accurately located. Simultaneously, the tenant identifier corresponding to the current request is obtained, effectively avoiding data confusion and conflicts between tenants. If the tenant identifier is not obtained, user information is read from the distributed cache based on the current session identifier to obtain the tenant identifier, improving the reliability of tenant identifier retrieval and avoiding the problem of single-point failure leading to the inability to obtain the tenant identifier, thus affecting the normal operation of digital marketing data collection. Then, the database operation statements to be processed are parsed into corresponding abstract syntax trees, converting them from string form to a structured tree structure, avoiding syntax errors caused by string concatenation, and improving the accuracy and reliability of statement processing. Next, tenant filtering conditions for specific data tables are generated, ensuring that query or update operations only apply to the current tenant's data. The target condition clause node is located in the abstract syntax tree structure, and a tenant filtering expression is added, improving the reliability of database operation statements and enabling automatic filtering of tenant data during execution. Finally, the modified abstract syntax tree is converted back into database operation statements to realize query or update operations on specific tenant data. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying 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.

[0018] Figure 1 A flowchart illustrating a digital marketing data collection method provided in this application embodiment; Figure 2 A screenshot of the voucher order list page provided in an embodiment of this application; Figure 3 An interface diagram of the role management list page provided in an embodiment of this application; Figure 4 A flowchart of order status transition provided in this application embodiment; Figure 5 A flowchart for order status confirmation provided in an embodiment of this application. Detailed Implementation

[0019] Embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of the present disclosure are shown in the drawings, it should be understood that embodiments of the present disclosure may be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure.

[0020] It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure. In the description of the embodiments of this disclosure, the term "comprising" and similar terms should be understood as open-ended inclusion, i.e., "including but not limited to". The term "based on" should be understood as "at least partially based on". The term "one embodiment" or "this embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc., may refer to different or the same objects.

[0021] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.

[0022] like Figure 1 The diagram shown is a flowchart of a digital marketing data collection method provided in an embodiment of this application. The method includes the following steps: like Figure 2The screenshot of the voucher order list page shows the voucher distribution and redemption status. It provides quick operation buttons for "Distribute Vouchers," "Export," and "Search for Vouchers with Empty Redemption Time." The data table lists specific order information, including order serial number, merchant order number, product code, order status, and redemption status. S1: When events such as marketing order generation, execution, or status change occur, the corresponding order data is retrieved and persistently stored in the database. Order data includes: merchant identifier, product code, configuration snapshot data containing activity configuration identifier and version information, target user login identifier, order creation timestamp, order unique identifier, order status identifier, redemption status identifier, and distribution response data returned by the third-party interface. This comprehensive recording of marketing order details provides a data foundation for subsequent order processing, querying, and analysis. The storage of configuration snapshot data ensures the accuracy of order data and activity configuration, ensuring that changes in activity configuration do not affect the correct processing of existing orders. The distribution response data returned by the third-party interface enriches the order information and helps to fully understand the order processing status in external systems.

[0023] Among them, marketing orders represent orders generated under marketing campaign scenarios, which are different from ordinary orders and are related to specific marketing strategies and promotional activities, such as discount campaign orders and gift campaign orders; the merchant identifier is extracted from the context information of the currently logged-in user and represents the supplier that initiated the marketing campaign; the product code is automatically generated by concatenating the first letter of each product name with the batch amount and date. If the product names are the same, the system automatically appends a random number to the end to ensure the uniqueness of the product code, for example, "PWLBYJYQ_200_1224_123"; the campaign configuration identifier is a code used to uniquely identify a marketing campaign configuration, which facilitates the identification and management of different marketing campaigns; the version information records the iteration of the campaign configuration. When the campaign configuration is modified or updated, the version number will change accordingly to ensure that the campaign configuration version corresponding to the order can be accurately tracked; snapshot data is a complete record of the state of the marketing campaign configuration at a certain moment, which includes all parameters and settings details of the campaign configuration. For example, the configuration snapshot data will record specific information such as the amount threshold, discount amount, and validity period of the discount campaign. This ensures that even if subsequent activity configurations change, order data can still accurately reflect the activity rules at the time of creation; the target user's login identifier is used to uniquely identify the target user who initiated the marketing order. This identifier allows for accurate retrieval of the corresponding user information and interaction with the user during order processing, such as sending order status notifications; the order creation timestamp records the specific time the order was created, presented in a time format accurate to milliseconds; the unique order identifier (i.e., the order number) is generated by combining a seventeen-digit timestamp (format: yyyyMMddHHmmssSSS) with a six-digit random number, ensuring global uniqueness; the order status identifier indicates the current status of the order, such as "created" meaning the order has just been generated but has not yet started processing, "processing" meaning the order is undergoing related operations, such as distributing coupons, preparing for shipment, etc., "successful distribution" meaning the order-related operations have been completed successfully in the third-party system, and "failed distribution" meaning the operation was not successfully completed; the redemption status identifier is used to track the actual usage of the order to prevent issues such as reuse; the distribution response data returned by the third-party interface is used to query the processing status of the marketing order in the third-party system. For example, when distributing coupons to a third-party platform, this interface can be used to obtain information on whether the coupons have been successfully distributed to the user's account.

[0024] S2 controls the flow of order states using the state dictionary pattern. It defines various order states and the rules for transitioning between them in dictionary form. Based on the current order state and specific events, state switching occurs according to the rules in the dictionary, making state management more standardized and orderly. Order states include created, processing, successfully dispatched, and failed dispatched. The system monitors the current order state and only calls a third-party interface to query the state when the current state is processing. Based on the query result returned by the third-party interface, the order state is updated to the target state corresponding to the query result. For example, to transition from processing to successfully dispatched, the third-party interface must return a successful dispatch response. The state dictionary pattern achieves standardized management of order states, making the state flow logic clear and easy to maintain. Calling the third-party interface only when the order is processing avoids unnecessary interface calls and ensures timely and accurate updates to the order state.

[0025] like Figure 3 The interface diagram of the role management list page shown includes four function buttons: "Add," "Modify," "Delete," and "Export." Role information is displayed in a list format, including role number, role name, permission characters, display order, role status, and creation time. S3, when a data query command is received, retrieves the tenant identifier and user role information corresponding to the current request. Based on the pre-defined mapping relationship between user role information and access permissions, it verifies the user's database access permissions. Only verified users can access the corresponding database data according to their permissions, achieving isolation of data access permissions for different roles. Simultaneously, the tenant identifier is used to associate with the merchant identifier, ensuring that data queries are performed within the correct tenant scope. This effectively ensures the security of database data, preventing sensitive data from being illegally accessed or tampered with; through the permission verification mechanism, it ensures that users of different roles can only access data within their authorized scope, meeting data security and privacy protection requirements; and through the association between the tenant identifier and the merchant identifier, it achieves data isolation and management in a multi-tenant system.

[0026] S4, when receiving a data export instruction, reads the order data from the database and converts it into a spreadsheet file, such as Excel, for output. Users can select the data range and fields to export as needed, making it convenient for users to view, analyze, and share the order data. Spreadsheet files are highly versatile and easy to edit and process. Users can use common office software to further process the exported data, such as creating reports and performing data analysis.

[0027] This application provides a digital marketing data collection system, including: The data acquisition module responds to marketing order generation, execution, or status change events, acquiring the corresponding order data and writing it into the database. Order data includes: merchant identifier, product code, configuration snapshot data containing activity configuration identifiers and version information, target user login identifier, order creation timestamp, order unique identifier, order status identifier, redemption status identifier, and dispatch response data returned by third-party interfaces. By responding to various marketing order events, it acquires rich order data covering merchant, product, activity configuration, user, and time information, providing a comprehensive and detailed data foundation for subsequent data analysis and marketing decisions. Timely writing of the acquired data into the database ensures data timeliness.

[0028] The state transition module controls the flow of order states using a state dictionary pattern. Order states include created, processing, successfully dispatched, and failed dispatch. It monitors the current order status and only calls a third-party interface to query the status when the current status is "processing." Based on the query results returned by the third-party interface, the order status is updated to the target status corresponding to the query result. Using the state dictionary pattern to control order state transitions makes the state transition rules clear and explicit, avoiding confusion and arbitrariness in state management. Calling the third-party interface to query the status only when the order is in the "processing" state reduces unnecessary interface calls and ensures timely updates to the order status based on accurate query results, guaranteeing consistency between the order status and the actual situation.

[0029] The access control module responds to data query commands, retrieves the tenant identifier and user role information corresponding to the current request, and performs permission verification on database access operations based on the mapping relationship between user role information and access permissions to isolate data access permissions for different roles. The tenant identifier is used to associate with the merchant identifier. By verifying data access permissions through tenant identifier and user role information, data from different roles and different merchants is effectively isolated, preventing data leakage and unauthorized access. Permission verification based on the mapping relationship between user roles and access permissions makes access management more flexible and granular.

[0030] The data export module is used to respond to data export commands, read order data from the database, and convert the order data into a spreadsheet file for output.

[0031] Based on the above embodiments, this application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a computer, it causes the computer to perform any of the methods provided in the above embodiments. The storage medium can be any available medium that can be accessed by a computer. By way of example, but not limited to, a computer-readable medium may include RAM, ROM, electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code having the form of instructions or data structures and that can be accessed by a computer.

[0032] Example 2: Based on Example 1, the flow of order status is controlled through a status dictionary pattern, and further includes: like Figure 4 The flowchart shown illustrates the order status transition. Based on a finite state machine model, a state transition topology diagram is constructed, which helps to identify potential status transition problems in a timely manner, allowing for early optimization and adjustments, and improving the quality and stability of digital marketing data collection. The state transition topology diagram includes order status and verification status from the status information. The finite state machine model is used to describe the transitions between different order statuses. The state transition topology diagram graphically displays the flow relationship between order status and verification status, where nodes represent different order statuses and verification statuses, and directed edges represent valid flow paths from one status to another.

[0033] Specifically, a state transition topology graph is constructed based on a finite state machine model. This involves determining all possible values ​​for the order and verification states. Order states include created, processing, successfully dispatched, and failed dispatch. Verification states include pending verification and verified. Based on business rules, valid transition paths between order and verification states are analyzed. For example, an order can transition from the created state to the processing state, and after processing, it can transition to the successfully dispatched or failed dispatched state. When an order meets the verification conditions, its verification state can change from pending verification to verified. Using graphical tools (such as flowchart software), these states are treated as nodes, and valid transition paths are treated as directed edges, to create the state transition topology graph.

[0034] Retrieve the current order status and cancellation status from the database, as well as the target order status and target cancellation status that this business operation is expected to achieve. View the status transition topology graph and check if there is a directed edge from the combination of the current order status and cancellation status to the combination of the target order status and cancellation status. If it exists, the transition path is valid; otherwise, it is invalid.

[0035] If the transition path from the current order status to the target order status is valid, then it is determined whether the current business operation belongs to a multi-state related change; multi-state related changes increase the complexity of status management. By determining whether the transition path is valid, it is possible to quickly and accurately determine whether the transition from the current order status to the target order status complies with business rules, avoid invalid status update operations, and ensure the accuracy and consistency of order status data.

[0036] If the change is determined to be a multi-state related change, meaning that a single business operation needs to update multiple status dimensions of the order simultaneously (e.g., the order status changes from "processing" to "dispatch failed," and the verification status changes from "pending verification" to "verified"), then the multi-state related change processing flow is triggered to ensure eventual data consistency. Otherwise, the current order status is directly updated to the target order status. By determining whether the current business operation is a multi-state related change, different types of status change operations are distinguished to avoid inefficient processing or data inconsistency caused by using a general processing method.

[0037] If the transition path from the current order status to the target order status is invalid, the status update operation is terminated to prevent data corruption caused by erroneous status changes. A status transition exception record is generated and written to the order status log, thereby identifying unreasonable status transition requests in advance and reducing unnecessary system resource consumption. The status transition exception record includes information such as the time of the exception, the current order status, the target order status, and the reason for the exception.

[0038] Specifically, the process for triggering multi-state association change handling includes: The system receives order status change requests and extracts the transaction identifier and operation type from them. This provides foundational data for subsequent duplicate request detection and transaction processing, ensuring the correct identification and processing of different types of order status change requests. For example, when a user initiates an order cancellation request, the request carries a unique transaction identifier and the cancellation operation type. The transaction identifier uniquely identifies an order status change transaction, accurately distinguishing different order status change requests and facilitating the retrieval of relevant transaction records in the database. The operation type refers to the specific operation involved in the order status change request, such as order dispatch or cancellation, further clarifying the specific content of the transaction.

[0039] Based on the extracted transaction identifier and operation type, a query is performed in the database to check whether a target record matching the transaction identifier and operation type already exists; this effectively avoids duplicate processing of the same transaction and improves the processing efficiency and resource utilization of digital marketing data collection.

[0040] If a matching target record exists, it means that the order status change request has been processed before. The order status change request is determined to be a duplicate request, and the processing result recorded when the transaction was previously processed is directly output to the requester without further processing. This allows for a quick response to duplicate requests, provides consistent processing results, and avoids data inconsistency caused by duplicate processing.

[0041] If the target record does not exist, a transaction processing mode based on resource reservation and compensation, namely the TCC (Try-Confirm-Cancel, Compensation Transaction Model) compensation mechanism, is executed. Specifically, this includes: In the first transaction processing phase, order data is locked, and a transaction record with a status of "pending confirmation" is inserted into the transaction log, while a locked record with a status of "pending cancellation" is inserted into the marketing asset log. By locking order data and inserting a locked record with a status of "pending cancellation" into the marketing asset log, resource reservation is reflected, preventing order data from being tampered with or marketing assets from being misused during subsequent processing, thus ensuring data consistency and integrity. Recording changes in order status and transaction information facilitates subsequent tracking and auditing.

[0042] After the first transaction processing phase is completed, if the call to the third-party interface returns a preset success code, the second transaction processing phase begins. This phase updates the locked records in the marketing asset log that are in a pending cancellation state to a cancelled state, updates the cancellation status of marketing orders to cancelled, updates the order status of marketing orders to successfully dispatched, and updates the transaction record status to confirmed. If the pre-transaction operations are successful, the cancellation of marketing assets and the update of order status are completed, ensuring the final successful completion of the transaction. The transaction record status is then updated to reflect the actual processing result of the transaction.

[0043] Otherwise, the system proceeds to the third transaction processing stage to check if there are any pending transaction records. If so, the marketing assets locked in the first transaction processing stage are released, the order status of the marketing order is updated to "dispatch failed," and the transaction record status is updated to "cancelled." If not, the marketing assets locked in the first transaction processing stage are not released. Releasing the marketing assets locked in the first transaction processing stage and updating the transaction record status to "cancelled" reflects a compensation operation. By releasing the locked marketing assets and updating the transaction record status, the system is restored to its state before the transaction processing, avoiding resource consumption and state inconsistency issues caused by transaction processing failure.

[0044] Example 3: Based on Example 1 or Example 2, it further includes: like Figure 5 The flowchart shown illustrates that a query message is sent to a delayed message queue only when a marketing order is in the "processing" state. The query message includes a first query message with a first predetermined delay duration, a second query message with a second predetermined delay duration, and a third query message with a third predetermined delay duration. The delayed message queue represents a mechanism that delays according to a pre-set delay time, triggering message processing only after the delay time has elapsed. In this application, query messages are sent according to different delay durations; specifically, the values ​​of the first, second, and third predetermined delay durations represent progressively increasing values ​​set by a pre-defined administrator based on experience. For example, the first predetermined delay duration could be set to 10 seconds, the second to 1 minute, and the third to 24 hours. The purpose of the query message is to trigger a query on the order status at different times. By limiting the query message to orders in the "processing" state, unnecessary query operations are avoided. Furthermore, by utilizing the characteristics of the delayed message queue, multiple queries on the order status can be performed at different times, improving the accuracy and comprehensiveness of the status query.

[0045] When a query message in the delayed message queue is triggered at the scheduled time, a third-party interface is invoked. This interface sends a request to the third-party system to obtain the real-time status information of the target marketing order, such as whether the order has been successfully dispatched or failed. By obtaining the real-time status through the third-party interface, the actual processing status of the marketing order in the third-party system can be understood in a timely manner, ensuring that the recorded order status is synchronized with the actual situation, and providing an accurate basis for subsequent status synchronization and anomaly handling.

[0046] Based on the difference between the real-time status of the target order and the current order status, perform at least one of the following operations: status synchronization and exception marking. In response to the first query message, if the real-time status of the target order is either successfully dispatched or failed to dispatch, the current order status is corrected according to the real-time status of the target order to ensure that the order status recorded by the system is consistent with the actual status. Otherwise, the current status is maintained and the system waits for further confirmation from subsequent query messages. In the early stages of order processing, the current status is corrected in a timely manner according to the real-time status to ensure the accuracy of digital marketing data.

[0047] In response to the second query message, if the real-time status of the target order is either successful or failed, the current order status is corrected according to the real-time status of the target order. If the real-time status is neither successful nor failed, the marketing order is marked as an abnormal order, and the status change permission for the marketing order is locked to prevent inappropriate processing operations from continuing before the problem is resolved.

[0048] In response to the third query message, if the real-time status of the target order is delivery successful or delivery failed, the current order status is corrected according to the real-time status of the target order, and the status change permission of the marketing order is unlocked (if it was previously locked), so that the marketing order can resume normal processing flow. Otherwise, an abnormal alarm message is generated to prompt the administrator to intervene manually. This can solve complex or difficult-to-process order problems in a timely manner and improve the reliability and stability of digital marketing data.

[0049] Example 4: Building upon Example 1, this example further includes verifying database access permissions based on the mapping relationship between user role information and access permissions, and also includes: The tenant field names for each data table are clearly defined. A mapping relationship is hard-coded in the code using a Map structure to construct the mapping relationship between data table names and tenant fields. In a Spring Boot environment, the pre-defined tenant interceptors are registered to the MyBatis plugin chain via `@Bean` (or by adding a plugin in the MyBatis configuration file in a non-Spring Boot environment). This provides the basic configuration for subsequent tenant filtering operations, ensuring that the interceptors can intervene in the SQL statement processing at the appropriate time. The tenant interceptors are configured to intercept the update and query methods of the executor. MyBatis is a Java persistence layer framework, and the plugin chain is an extension mechanism provided by MyBatis. By creating plugins and registering them in the plugin chain, MyBatis executes Structured Query Language (SCL). Custom logic is inserted into each stage of MyBatis (such as parameter processing, SQL execution, result mapping, etc.) of the SQL statement (i.e., the database operation statement below) to extend and customize the behavior of MyBatis; the tenant interceptor is a custom MyBatis plugin specifically designed to handle tenant-related logic. In this application, it is configured to intercept the update and query methods of the executor and modify them before the SQL statement is executed to add tenant filtering conditions to ensure that different tenants can only access their own data.

[0050] When a database operation request is received, the corresponding tenant identifier is retrieved from the current request, such as by including it in the request header or parameters. If the tenant identifier is not retrieved, the user information is read from a distributed cache, such as Redis, based on the current session identifier, such as session_id. The tenant identifier is then retrieved from the user information to ensure that the tenant information to which the current request belongs can be accurately obtained. This provides a basis for subsequent tenant filtering. Using a distributed cache can improve the efficiency and reliability of user information retrieval and avoid frequent database queries. The session identifier refers to the user login status to which a series of requests belong. The session identifier is extracted from the header or parameters of the current request.

[0051] The database operation statement to be processed is obtained from the current request, and the parsing tool provided by MyBatis or a custom parsing logic is used to parse the database operation statement to be processed into the corresponding abstract syntax tree. The abstract syntax tree is an abstract representation of the syntax structure of the source code, which shows the structure of the code and the relationship between the elements in a tree form. In this application, the database operation statement to be processed is parsed into an abstract syntax tree, which makes it easy to analyze and modify the structure of the statement, and provides convenience for adding tenant filtering conditions later.

[0052] The process involves traversing the source nodes in the abstract syntax tree (AST) structure to obtain the target table name. Based on the pre-built mapping between table names and tenant fields, the target tenant field corresponding to the target table name is determined. A tenant filtering expression is then constructed using the target tenant field and the tenant identifier. In the AST, the source nodes represent the database table names. By traversing these nodes, all table names involved in the SQL statement can be obtained. In digital marketing scenarios, multiple tenants are typically involved (e.g., different companies or customers using the same marketing platform). The tenant filtering expression is a logical expression used to filter data related to a specific tenant. For example, a conditional statement containing a tenant identifier is used to extract only data that meets the requirements of a specific tenant from a large amount of data. The process involves identifying the table to be filtered and the corresponding tenant field, and constructing the filtering expression to provide the foundation for adding the tenant filtering expression to the SQL statement.

[0053] The process involves locating the target condition clause node within the abstract syntax tree (API) structure and determining if it exists. If it does, the tenant filtering expression is added to the target condition clause node using a logical AND relation. If it doesn't exist, a new condition clause node is created, and the tenant filtering expression is incorporated into it as the root condition. This allows for tenant filtering of queries and update operations. In the API, the target condition clause node represents a condition clause in an SQL statement, such as the WHERE clause. Logical AND is a logical operator, typically represented by the symbol AND. In this application, adding the tenant filtering expression to the target condition clause node via a logical AND relation means that the tenant filtering condition must simultaneously satisfy the existing conditions in the target condition clause node for data to be collected. Adding the tenant filtering condition to the SQL statement ensures that database operations only access the current tenant's data, achieving access control for digital marketing data.

[0054] The database operation statement generation interface calls the abstract syntax tree structure to reconstruct the modified abstract syntax tree into SQL statements. The generated SQL statements now include tenant filtering conditions, resulting in SQL statements that have been processed by the tenant filter. These SQL statements can then be submitted to the database for execution, ensuring data security and isolation. The database operation statement generation interface is used to regenerate (generate / render) the syntax tree structure in memory into grammatically correct SQL strings, typically implemented using an SQL generator (Generator / Builder) or the Visitor Pattern.

[0055] Specifically, the process of parsing the database operation statements to be processed into corresponding abstract syntax trees is as follows: If the syntax features of the database operation statement to be processed are not in the preset whitelist, it indicates that the statement may be non-compliant or potentially risky. A syntax error message is generated, and subsequent processing is terminated to prevent erroneous or unsafe statements from continuing to execute. Otherwise, the SQL parser parses the database operation statement into an abstract syntax tree. The syntax features of the database operation statement indicate its statement type (e.g., SELECT, UPDATE). The whitelist represents a pre-defined set of allowed syntax features. Only database operation statements with syntax features included in the whitelist will be further processed; otherwise, they will be judged as having syntax errors. This whitelist mechanism effectively filters out non-compliant or potentially risky database operation statements, improving the security and stability of digital marketing data and avoiding data security issues caused by processing abnormal statements.

[0056] When parsing SQL statements, if the parsing of the database operation statement fails (i.e., a parser error message appears or a null pointer exception is triggered while traversing the abstract syntax tree structure), the database operation statement is added to a blacklist for subsequent identification and processing. This prevents invalid parsing from happening again, improving overall processing efficiency. The blacklist mechanism also aids in the analysis and troubleshooting of the reasons for parsing failures. The blacklist represents a list of database operation statements that have failed to be parsed; statements on the blacklist may not be parsed again to avoid unnecessary resource waste and processing errors.

[0057] If the database operation statement to be processed is successfully parsed, a cache key is generated based on the structure of the statement. The local memory cache is then checked to see if a matching key exists. If a matching key exists, it means the statement has already been parsed and the corresponding abstract syntax tree (API) structure has been stored; the pre-stored API structure is then directly read. Otherwise, the parsed API structure is stored in the local memory cache for future use when the same statement reappears. The cache key is a unique identifier generated based on the structure of the database operation statement, used to quickly find the corresponding API structure in the local memory cache. By generating cache keys and querying the cache, the same statements can be quickly reused, avoiding repeated parsing operations and significantly improving the processing speed and responsiveness of digital marketing data collection. Reading the pre-stored structure allows for immediate retrieval of parsing results, reducing processing time. Storing new structures enriches the cache content, facilitating the processing of subsequent identical statements.

[0058] Example 5: Obtaining order data corresponding to marketing orders, which previously included: Determine whether the current operating environment is the preset operating environment; the preset operating environment refers to the pre-set system operating environment that meets specific requirements, including: specific operating system version, software dependency version, network configuration, etc., with the aim of ensuring operation in a stable and controllable environment and avoiding problems caused by environmental differences; eliminate potential problems caused by incompatible operating environments in advance, reduce errors and anomalies caused by environmental factors, and improve the success rate of interface calls.

[0059] If the current operating environment is the preset operating environment, it verifies whether the current server's Internet Protocol address belongs to the preset Internet Protocol address whitelist and whether the application domain name matches the preset application domain name specification. This prevents unauthorized servers or non-compliant applications from accessing system resources and performing operations, effectively resisting external attacks and unauthorized access, and protecting the security of digital marketing data. The Internet Protocol address whitelist is a predefined list of Internet Protocol addresses. Only servers or devices corresponding to Internet Protocol addresses in this list are allowed to perform specific operations or access specific resources, which is used to restrict access sources and prevent unauthorized access. The application domain name specification is a series of rules and requirements for the domain name used by the application, such as the format, length, and characters contained in the domain name. Ensuring that the application domain name conforms to the specification helps to unify management, improve security, and avoid business failures caused by domain name issues.

[0060] If the verification fails, subsequent operations are terminated, and the preset personnel are notified that the verification failed. If the verification passes and the current operation is determined to be a critical business operation, a two-factor authentication process is triggered. Critical business operations include distributing marketing assets exceeding the single-distribution threshold or distributing more marketing assets than the single-distribution quantity threshold. The preset personnel refers to preset security management personnel or preset system maintenance personnel. The single-distribution marketing asset threshold refers to the upper limit of the total points of marketing assets allowed to be distributed in a single marketing asset distribution operation. The single-distribution quantity threshold refers to the upper limit of the number of marketing assets allowed to be distributed in a single marketing asset distribution operation. The upper limit; the threshold for single distribution of marketing assets and the threshold for single distribution quantity are preset by the pre-set personnel based on at least one of the following: marketing campaign budget, risk control level, or historical data; the two-factor authentication process refers to an additional authentication step performed after the user has completed one authentication, such as logging in with a username and password, in order to further confirm the authenticity of the user's identity. Common two-factor authentication methods include SMS verification codes, fingerprint recognition, facial recognition, etc.; for critical business operations, two-factor authentication further confirms the authenticity and legitimacy of the user's identity, greatly reducing the risk of critical business operations being illegally operated.

[0061] If the verification passes and it is determined that the current operation is not a critical business operation, then the atomic deduction operation is executed in conjunction with the remote dictionary service and the script. The remote dictionary service, such as Redis, represents a memory-based data structure storage system that supports various data structures, such as strings, hashes, lists, sets, etc. In this application, the remote dictionary service is used to store and manage activity configuration information and inventory data. The atomic deduction operation means that the inventory deduction operation either succeeds completely or does not succeed at all, and there will be no partial execution.

[0062] The atomic deduction operation involves: sending the written script to a remote dictionary service; using the activity configuration identifier in the identification information as the key to look up the corresponding inventory information in the remote dictionary service; reading the current inventory; and determining whether the current inventory meets the preset inventory deduction condition, i.e., the current inventory quantity is greater than the requested deduction quantity. If the condition is met, the inventory deduction operation is performed; otherwise, the subsequent operation is terminated. This ensures the atomicity of the inventory deduction operation and avoids inconsistencies in inventory data caused by multiple operations running simultaneously in a high-concurrency environment, such as overselling, thus guaranteeing the accuracy and reliability of inventory data.

[0063] Through the above description of the implementation methods, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the above functions can be divided into different functional modules to complete all or part of the functions described above.

[0064] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between devices or units, and may be electrical, mechanical, or other forms.

[0065] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units, located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0066] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0067] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the solution, or all or part of the technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0068] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for collecting digital marketing data, characterized in that, Includes the following steps: S1, obtain the order data corresponding to the marketing order and write the order data into the database. The order data includes: identification information, time information, status information and third-party interface response information; S2, control the flow of order status according to preset status transition mapping rules. The order status includes created status, processing status, dispatch successful status and dispatch failed status. Monitor the current status of the order. Only when the current status is the processing status, call the third-party interface to query the status. Based on the query result returned by the third-party interface, update the order status to the target status corresponding to the query result. S3, in response to a data query command, obtains the tenant identifier and user role information corresponding to the current request, and performs permission verification on the database access operation based on the mapping relationship between user role information and access permissions, so as to isolate the data access permissions of different roles; S4, in response to the data export command, read the order data from the database and convert the order data into a spreadsheet file for output.

2. The digital marketing data collection method as described in claim 1, characterized in that: The method of controlling the flow of order status according to a preset state transition mapping rule also includes: A state transition topology graph is constructed based on a finite state machine model. The state transition topology graph includes order status and verification status in the state information. The verification status includes pending verification status and verified status. Obtain the current order status and the target order status, and determine whether the transition path from the current order status to the target order status is valid based on the status transition topology graph; If the flow path from the current order status to the target order status is valid, then determine whether the current business operation belongs to a multi-state related change; If it is determined to be a multi-state related change, the multi-state related change processing flow is triggered to ensure the eventual consistency of the data; otherwise, the current order status is directly updated to the target order status. If the transition path from the current order status to the target order status is invalid, the status update operation is terminated, a status transition exception record is generated, and the status transition exception record is written to the order status log.

3. The digital marketing data collection method as described in claim 2, characterized in that: The triggering of the multi-state association change processing flow specifically includes: Receive an order status change request and extract the transaction identifier and operation type from the order status change request; Query the database to see if a target record containing the transaction identifier and the operation type exists; If a target record exists, the order status change request is determined to be a duplicate request, and the processing result corresponding to the target record is output. If the target record does not exist, a transaction processing mode based on resource reservation and compensation is executed, specifically including: In the first transaction processing phase, the order data is locked, a transaction record with a status of pending confirmation is inserted into the transaction log, and a locked record with a status of pending cancellation is inserted into the marketing asset log. After the first transaction processing phase is completed, if the call to the third-party interface returns a preset success code, the second transaction processing phase will begin. The locked records in the marketing asset log that are in the pending cancellation state will be updated to the cancelled state, the cancellation state of the marketing order will be updated to the cancelled state, the order status of the marketing order will be updated to the dispatched successfully state, and the status of the transaction record will be updated to the confirmed state. Otherwise, proceed to the third transaction processing stage to check if there are any pending transaction records. If so, release the marketing assets locked in the first transaction processing stage, update the order status of the marketing order to the dispatch failure status, and update the status of the transaction record to the cancelled status.

4. The digital marketing data collection method as described in claim 1, characterized in that: Also includes: A query message is sent to the delayed message queue only when the marketing order is in the processing state. The query message includes a first query message with a first predetermined delay duration, a second query message with a second predetermined delay duration, and a third query message with a third predetermined delay duration. In response to a query message, a third-party interface is called to obtain the real-time status of the target order; Based on the difference between the real-time status of the target order and the current order status, perform status synchronization and exception marking operations, specifically: In response to the first query message, if the real-time status of the target order is delivery successful or delivery failed, the current order status is corrected according to the real-time status of the target order; otherwise, the current status remains unchanged. In response to the second query message, if the real-time status of the target order is delivery successful or delivery failed, the current order status is corrected according to the real-time status of the target order; otherwise, the marketing order is marked as an abnormal order and the status change permission of the marketing order is locked. In response to the third query message, if the real-time status of the target order is delivery successful or delivery failed, the current order status is corrected according to the real-time status of the target order, and the status change permission of the marketing order is unlocked; otherwise, an abnormal alarm message is generated to prompt the administrator to intervene manually. The first predetermined delay duration, the second predetermined delay duration, and the third predetermined delay duration increase sequentially.

5. The digital marketing data collection method as described in claim 1, characterized in that: The permission verification for database access operations based on the mapping relationship between user role information and access permissions also includes: Construct a mapping relationship between data table names and tenant fields, and register the preset tenant interceptor to the MyBatis plugin chain. The tenant interceptor is configured to intercept the update method and query method of the executor. Obtain the tenant identifier corresponding to the current request. If the tenant identifier is not obtained, read the user information from the distributed cache based on the current session identifier to obtain the tenant identifier. Obtain the database operation statement to be processed, and parse the database operation statement to be processed into the corresponding abstract syntax tree; Traverse the source nodes in the abstract syntax tree structure to obtain the target data table name, and determine the target tenant field corresponding to the target data table name based on the constructed mapping relationship between the data table name and the tenant field. Construct a tenant filtering expression using the target tenant field and the tenant identifier. Locate the target conditional clause node in the abstract syntax tree structure, and add the tenant filtering expression to the target conditional clause node; The database operation statement generation interface of the abstract syntax tree structure is invoked to generate the rewritten database operation statements.

6. The digital marketing data collection method as described in claim 5, characterized in that: The specific process of parsing the database operation statement to be processed into the corresponding abstract syntax tree is as follows: If the syntax features of the database operation statement to be processed are not in the preset whitelist, a syntax error message is generated and subsequent processing is terminated; otherwise, the database operation statement to be processed is parsed into an abstract syntax tree, where the syntax features of the database operation statement to be processed represent the statement type of the database operation statement to be processed. If the parsing of the database operation statement to be processed fails, the database operation statement to be processed will be added to the blacklist. If the database operation statement to be processed is successfully parsed, a cache key is generated based on the structure of the database operation statement to be processed, and the cache key is queried in the local memory cache. If a matching cache key exists, the pre-stored abstract syntax tree structure is read; otherwise, the parsed abstract syntax tree structure is stored in the local memory cache.

7. The digital marketing data collection method as described in claim 5, characterized in that: The specific process for adding the tenant filtering expression to the target condition clause node is as follows: Determine whether the target conditional clause node exists in the abstract syntax tree; If the target condition clause node exists, the tenant filtering expression is added to the target condition clause node using a logical AND relation; If the target conditional clause node does not exist, a new conditional clause node is created, and the tenant filtering expression is incorporated into the new conditional clause node as the root condition.

8. The digital marketing data collection method as described in claim 1, characterized in that: The process of obtaining the order data corresponding to the marketing order also includes: Determine if the current operating environment is the preset operating environment; If the current operating environment is the preset operating environment, then check whether the Internet Protocol address of the current server belongs to the preset Internet Protocol address whitelist and whether the application domain name matches the preset application domain name specification. If the verification fails, the subsequent operation will be terminated, and a message will be displayed indicating that the verification for the preset personnel has failed. If the verification passes and the current operation is determined to be a critical business operation, a secondary identity verification process is triggered. The critical business operation includes distributing marketing assets in a single instance exceeding a preset threshold for distributing marketing assets in a single instance or distributing a quantity in a single instance exceeding a preset threshold for distributing quantity in a single instance. If the verification passes and it is determined that the current operation is not a critical business operation, then the atomic deduction operation is executed in conjunction with the remote dictionary service and the script. The atomic deduction operation includes: sending the script to the remote dictionary service, using the activity configuration identifier in the identification information as the key, executing the read current inventory within the remote dictionary service, determining whether the current inventory meets the preset inventory deduction conditions, and if so, performing the inventory deduction operation; otherwise, terminating the subsequent operation.

9. A digital marketing data collection system, characterized in that, include: The data acquisition module is used to respond to marketing order generation, execution or status change events, acquire the order data corresponding to the marketing order, and write the order data into the database. The order data includes: identification information, time information, status information and third-party interface response information. The status transition module is used to control the flow of order status according to preset status transition mapping rules. The order status includes created status, processing status, dispatch successful status and dispatch failed status. It monitors the current status of the order and only calls a third-party interface to query the status when the current status is the processing status. Based on the query result returned by the third-party interface, the order status is updated to the target status corresponding to the query result. The access control module is used to respond to data query commands, obtain the tenant identifier and user role information corresponding to the current request, and perform access permission verification on database access operations based on the mapping relationship between user role information and access permissions, so as to isolate the data access permissions of different roles. The data export module is used to respond to data export instructions, read order data from the database, and convert the order data into a spreadsheet file for output.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program or instructions that, when executed, cause the method according to any one of claims 1 to 8 to be performed.

Citation Information

Patent Citations

  • Digital integrated WeChat shopping mall order information processing system

    CN118735637A

  • Intelligent operation management platform for multi-scene application aggregation

    CN121120215A