Marketing activity reward calculation method and system based on state machine
Through the modular design based on state machine, the problems such as low processing efficiency and insufficient functional expansion of traditional marketing activities are solved, and a more efficient, flexible and reliable reward calculation and distribution system is achieved.
Patent Information
- Application Number
- CN202411758357.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-04-11
AI Technical Summary
Traditional marketing activity reward distribution plans have low processing efficiency, insufficient function expansion, poor code maintenance, and insufficient operation and maintenance flexibility, making it difficult to quickly respond to the needs of diverse marketing scenarios.
The state machine-based marketing activity reward calculation method and system is adopted to decouple key transaction nodes through modular splitting and state control, and realize independent scheduling and execution of each module, supporting vertical expansion and exception handling.
It improves processing efficiency and function expansion, reduces code maintenance costs and operation and maintenance complexity, and enhances the flexibility and reliability of the system.
Smart Images

Figure CN119809710A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a state machine-based marketing activity reward calculation method and system. Background Art
[0002] In the context of increasingly fierce market competition and diversified needs, enterprises have adopted a variety of digital marketing activities to reward customers, which has become the main means of product marketing. This requires a complete system and solution as technical support. The traditional marketing activity reward distribution plan is to analyze marketing data one by one and directly distribute rewards, that is, the calculation is immediate, and data analysis and reward distribution are completed in one process. There are the following shortcomings:
[0003] 1. Low processing efficiency. Without prior data cleaning, the amount of data to be processed in scenarios with multiple activities, multiple products, and multiple customers is large, making it difficult to complete the reward distribution in a short period of time. The processing process requires frequent reading and writing of data, which will also cause great pressure on the application and database levels.
[0004] 2. Insufficient functional scalability. Different marketing activities have different rules, and it is difficult to achieve compatibility in a batch processing process. The implementation cycle is long and it is impossible to quickly respond to the needs of flexible and diverse marketing scenarios.
[0005] 3. Poor code maintainability. Mixing the already complex marketing data analysis and processing logic for different activities with the reward distribution logic will affect the entire system. The code reading and maintenance costs are high and defects are prone to occur.
[0006] 4. Insufficient operation and maintenance flexibility. The key nodes of the entire batch processing process are coupled together. Once a node reports an error and causes the process to be blocked, it is impossible to redo the breakpoint. The data must be reset and the entire processing process must be executed from the beginning. The problem handling flexibility is poor, and the process takes a long time to complete. At the same time, it is also difficult to identify and monitor abnormalities in the process. Summary of the invention
[0007] The purpose of the present invention is to provide a state machine-based marketing activity reward calculation method and system to solve the problems raised in the above background technology.
[0008] To achieve the above-mentioned object of the invention, one aspect of the present invention provides a method for calculating a marketing activity reward based on a state machine, comprising the following steps:
[0009] Step S1, initializing the data file download status, file data storage status, data analysis and calculation status, reward pre-issuance data generation status, reward issuance status, and the batch record overall status is the batch record in process, which is saved in the database table;
[0010] Step S2, download the marketing data files one by one to the local computer and generate a file download log record, save it to the database table, and update the data file download status of the batch record according to whether the overall download is successful;
[0011] Step S3, writing the local marketing data files into the corresponding database table in batches and generating data entry log records at the same time, saving them into the database table, and updating the data file entry status of the batch records according to whether the overall entry is successful;
[0012] Step S4, traverse all activity information, read the required marketing data according to the activity type and generate trial calculation details. The trial calculation status and issuance status of the trial calculation details are both pending and saved in the database table. After successful execution, the data analysis trial calculation status of the batch record is updated to waiting for trial calculation, and the reward pre-issuance data generation status is waiting for generation;
[0013] Step S5: For each type of activity, the trial calculation details are analyzed according to different activity rules. Details that do not meet the rules are updated with a trial calculation status of no trial calculation required, and details that meet the rules are updated with a trial calculation status of successful trial calculation and reward. The trial calculation status of the data analysis of the batch record is updated according to whether the overall trial calculation is successful.
[0014] Step S6, summarize and compile the trial calculation details with trial calculation status of successful and payment status of pending according to the activity and rule dimensions to generate reward pre-issuance data, save it in the database table, and update the reward pre-issuance data generation status of the batch record;
[0015] Step S7, after the reward pre-issuance data is generated, rewards are issued to customers and the actual issuance data of rewards is updated according to the trial calculation details with the trial calculation success status as trial calculation success and the issuance status as pending. After the issuance is completed, the reward pre-issuance and actual issuance data are compared and verified, and the execution status of the reward issuance module of the batch record and the total status of the batch record are updated.
[0016] Furthermore, in step S2, if the data file download status is not a successful download, the corresponding marketing data file on the file server is connected and downloaded to the local specified path. Each time a file is downloaded, a file download log record with the download status is written to the database table according to the download status. After all files are downloaded, the data file download status of the batch record is updated based on whether the overall download is successful.
[0017] Furthermore, in step S3, if the data file download status is successful download and the file data warehousing status is not successful warehousing, the file data warehousing log records of the batch are cleared, the corresponding file data table data is cleared, and the corresponding file data on the local specified path is read and inserted into the corresponding file data table in batches. After the warehousing is completed, the piece data warehousing log record with the warehousing status is written to the database table, and the data file warehousing status of the batch record is updated according to whether the overall warehousing is successful.
[0018] Furthermore, in step S4, if the file data storage status is successful and the data analysis trial calculation status is unprocessed, traverse all activity information to obtain the required marketing data one by one according to the activity type, generate and write the trial calculation details with the trial calculation status and issuance status both pending to be processed into the database table, and after successful execution, update the data analysis trial calculation status of the batch record to waiting for trial calculation, and update the reward pre-issuance data generation status of the batch record to waiting for generation.
[0019] Furthermore, in step S5, if the data analysis trial calculation status is waiting for trial calculation or trial calculation failure, the activity trial calculation details of each activity type after the split are analyzed according to different activity rules, and the trial calculation status of the details that do not meet the rules is updated to no trial calculation required, and the trial calculation status of the details that meet the rules is updated to successful trial calculation and reward. The data analysis trial calculation status of the batch records is updated based on whether the overall trial calculation is successful.
[0020] Furthermore, in step S6, if the data analysis trial calculation status is trial calculation success and the reward pre-issuance data generation status is waiting for generation or generation failure, and there is no reward pre-issuance data for this batch, then the trial calculation details with trial calculation status of trial calculation success and issuance status of pending are summarized and counted according to activity and rule dimensions to generate reward pre-issuance data, which are saved in the database table for use in the reward issuance module for comparison and checking, and the reward pre-issuance data generation status of the batch records is updated according to whether the generation execution is successful.
[0021] Furthermore, if the generation status of the reward pre-issuance data in step S7 is successful generation and the overall status is in processing, the reward pre-issuance data is traversed, and rewards are issued one by one according to the trial calculation details of each activity with a trial calculation status of successful trial calculation and an issuance status of pending processing. After each successful issuance, the issuance status of the trial calculation details is updated to successful issuance, and the actual issuance data of the corresponding reward pre-issuance data is updated. Activities that do not need to be issued or have insufficient inventory of activity rewards will not be processed. After the overall issuance is completed, the reward pre-issuance data and the actual issuance data are compared, and the reward issuance status and the total status of the batch record are updated based on whether the comparison results are consistent.
[0022] Another aspect of the present invention provides a state machine-based marketing activity reward calculation system, including a batch task session generation module, a data file download module, a file data storage module, a data preprocessing module, a data analysis and calculation module, a reward pre-issued data generation module and a reward issuance module, each module can be independently scheduled for execution, wherein:
[0023] The batch task sequence generation module is used to generate batch records with the execution status of each module, and control the execution operation and sequence of the corresponding modules according to the execution status of each module in the batch record;
[0024] The data file download module is used to connect to the corresponding marketing data file on the download file server to the local specified path, generate a file download log record with the download status, and finally update the data file download module execution status of the batch record;
[0025] The file data storage module is used to read the downloaded marketing data files in the local specified path and write them into the corresponding database tables, generate file storage log records with storage status, and finally update the file data storage module execution status of the batch record;
[0026] The data preprocessing module is used to generate trial calculation details with trial calculation status and payment status according to different types of activities and corresponding rules for various marketing data. Activities that do not require the issuance of rewards are filtered out during the process. After completion, the execution status of the data analysis trial calculation module and the execution status of the reward pre-issuance data generation module of the batch record are updated;
[0027] The data analysis and trial calculation module is used to filter and update the trial calculation status and other information such as rewards after analyzing the trial calculation details of each activity of the corresponding type according to the rules. The activity trial calculations of different types of activities are split into separate sub-modules for execution, and the execution status of the data analysis and trial calculation module of the batch records is updated;
[0028] The reward pre-issuance data generation module is used to generate reward pre-issuance data by summarizing and counting the trial calculation details with trial calculation status of successful and payment status of pending according to activity and rule dimensions, and update the execution status of the reward pre-issuance data generation module of the batch record;
[0029] The reward distribution module is used to distribute rewards to customers and update the actual reward distribution data after the reward pre-distribution data is generated, based on the trial calculation details with a trial calculation success status and a distribution status of pending. After the distribution is completed, the reward pre-distribution and actual distribution data are compared and verified, and the reward distribution module execution status and batch record total status of the batch record are updated.
[0030] Compared with the prior art, the present system and method have the following advantages:
[0031] 1. The present invention realizes the decoupling of key transaction nodes by modularizing and state controlling the complex processing process of batch distribution of marketing activity rewards, which is beneficial to the vertical expansion of the process.
[0032] 2. Each module of the present invention can be executed independently through state control. When a module is executed abnormally and causes process blocking, the module only needs to be re-executed after the exception is handled, which is beneficial to the timeliness and flexibility of event processing in production operation and maintenance.
[0033] 3. The reasonable division of labor in realizing the functions of each module of the present invention is conducive to code development and maintenance.
[0034] 4. The data preprocessing module and data analysis and calculation module of the present invention support the horizontal expansion of multiple activities, which is conducive to the flexible and rapid implementation of the business.
[0035] 5. The present invention can realize data cleaning and marking by generating trial calculation details and pre-issuance data, thus saving time for processing invalid data when issuing rewards and avoiding frequent access to the database due to invalid data. It can also use these data for self-balancing checks to improve the reliability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 The present invention is a flow chart of a method for calculating rewards for marketing activities based on a state machine. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] like Figure 1 The flowchart of the method of the present invention is shown. The present invention proposes a method for batch calculation and distribution of marketing activity rewards based on a state machine, and the steps include:
[0039] Step S1, initialize the data file download status, file data storage status, data analysis trial calculation status, reward pre-issue data generation status, reward issuance status, the status is unprocessed, the total status of the batch record is the batch record in processing, and save it in the database table. The data structure is shown in Table 1:
[0040] Table 1: Batch control structure table
[0041]
[0042]
[0043] Step S2, download the marketing data files one by one to the local computer and generate a file download log record at the same time, save it to the database table, the data structure is shown in Table 2, and the data file download status of the batch record of step S1 is updated according to whether the overall download is successful. When the download status of the data files of the same batch is not a successful download, connect and download the corresponding marketing data files on the file server to the local specified path. Each time a file is downloaded, a file download log record with the download status is written to the database table according to the download status. After all files are downloaded, the data file download status of the batch record is updated according to whether the overall download is successful.
[0044] Table 2: File download and storage log structure table
[0045]
[0046]
[0047] After step S2 is successfully executed, the download status of the data file of the batch record of step S1 changes to download successful, and the process proceeds to step S3.
[0048] Step S3, write the local marketing data files into the corresponding database table in batches one by one and generate a data entry log record at the same time, save it in the database table, and the data structure is the same as the file download entry log structure table. Update the data file entry status of the batch record in step S1 according to whether the overall entry is successful. When the download status of the data files of the same batch is successful download and the file data entry status is not successful entry, the file data entry log record of the batch is cleared, and the corresponding file data table data is cleared one by one, and then the corresponding file data on the local specified path is read and inserted into the corresponding file data table in batches. After the entry is completed, write the data entry log record with the entry status into the database table, and update the data file entry status of the batch record according to whether the overall entry is successful.
[0049] After step S3 is successfully executed, the storage status of the data file of the batch record of step S1 is transferred to storage success, and step S4 is entered.
[0050] Step S4, traverse all activity information and obtain the required marketing data one by one according to the activity type to generate trial calculation details. The trial calculation status and issuance status of the trial calculation details are both pending and saved in the database table. The data structure is shown in Table 3. After successful execution, the data analysis trial calculation status of the batch record of step S1 is updated to waiting for trial calculation, and the reward pre-issuance data generation status is waiting for generation. When the storage status of the file data of the same batch is successful storage and the data analysis trial calculation status is unprocessed, traverse all activity information and obtain the required marketing data one by one according to the activity type, generate and write trial calculation details with trial calculation status and issuance status pending into the database table, and after successful execution, update the data analysis trial calculation status of the batch record to waiting for trial calculation, and update the reward pre-issuance data generation status of the batch record to waiting for generation.
[0051] Table 3: Trial Calculation Detail Structure Table
[0052]
[0053]
[0054] After step S4 is successfully executed, the data analysis calculation status of the batch record of step S1 flows to waiting for calculation, and the reward pre-issuance data generation status flows to waiting for generation, and then enters step S5.
[0055] Step S5: Analyze the trial calculation details of step S4 according to different activity rules for each type of activity. The trial calculation status of the details that do not meet the rules is updated to no trial calculation is needed, and the trial calculation status of the details that meet the rules is updated to trial calculation success and other information such as rewards. Finally, the data analysis trial calculation status of the batch record of step S1 is updated according to whether the overall trial calculation is successful. When the data analysis trial calculation status of the same batch is waiting for trial calculation or trial calculation failure, the activity trial calculation details of each activity type after the split are analyzed according to different activity rules. The trial calculation status of the details that do not meet the rules is updated to no trial calculation is needed, and the trial calculation status of the details that meet the rules is updated to trial calculation success and other information such as rewards. Finally, the data analysis trial calculation status of the batch record is updated according to whether the overall trial calculation is successful.
[0056] After step S5 is successfully executed, the data analysis trial calculation status of the batch record of step S1 is transferred to trial calculation success, and the process proceeds to step S6.
[0057] Step S6, execute the reward pre-issue data generation module, summarize and count the trial calculation details of step S4 with a trial calculation status of trial calculation success and a payment status of pending according to the activity and rule dimensions to generate reward pre-issue data, and save it in the database table. The data structure is shown in Table 4. Finally, the reward pre-issue data generation status of the batch record of step S1 is updated according to whether the generation execution is successful. When the trial calculation status of the data analysis of the same batch is trial calculation success and the reward pre-issue data generation status is waiting for generation or generation failure, and the batch does not have reward pre-issue data, the trial calculation details with a trial calculation status of trial calculation success and a payment status of pending are summarized and counted according to the activity and rule dimensions to generate reward pre-issue data, and saved in the database table for comparison and inspection in the reward issuance module. Finally, the reward pre-issue data generation status of the batch record is updated according to whether the generation execution is successful.
[0058] Table 4: Reward pre-issuance data structure table
[0059]
[0060] After step S6 is successfully executed, the reward pre-issuance data generation status of the batch record of step S1 flows to generation success, and enters step S7.
[0061] Step S7, execute the reward issuance module, traverse the reward pre-issuance data of step S6, and issue rewards one by one according to the trial calculation details of step S4 where the trial calculation status of each activity is successful and the issuance status is pending. After each successful issuance, the issuance status of the trial calculation details is updated to successful issuance and the actual issuance data of the corresponding reward pre-issuance data is updated. Activities that do not need to be issued or have insufficient inventory of activity rewards will not be processed. After the overall issuance is completed, the reward pre-issuance data and the actual issuance data are compared, and the reward issuance status and batch total status of the batch record of step S1 are updated based on whether the comparison results are consistent. When the generation status of the reward pre-issuance data of the same batch is successful generation and the total status is unprocessed, the reward pre-issuance data is traversed, and the rewards are issued one by one according to the trial calculation details of each activity whose trial calculation status is successful and the issuance status is pending. After each successful issuance, the issuance status of the trial calculation details is updated to successful issuance and the actual issuance data of the corresponding reward pre-issuance data is updated. Activities that do not need to be issued or have insufficient inventory of activity rewards will not be processed. After the overall issuance is completed, the reward pre-issuance data and the actual issuance data are compared, and the reward issuance status and the total status of the batch record are updated based on whether the comparison results are consistent.
[0062] After step S7 is successfully executed, the reward issuance status of the batch record of step S1 flows to issuance success, and the overall status of the batch record flows to processing success, and the process ends.
[0063] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for calculating marketing activity rewards based on a state machine, characterized in that: The following steps are involved: Step S1, initializing the data file download status, file data storage status, data analysis and calculation status, reward pre-issuance data generation status, reward issuance status, and the batch record overall status is the batch record in process, which is saved in the database table; Step S2, download the marketing data files one by one to the local computer and generate a file download log record, save it to the database table, and update the data file download status of the batch record according to whether the overall download is successful; Step S3, writing the local marketing data files into the corresponding database table in batches and generating data entry log records at the same time, saving them into the database table, and updating the data file entry status of the batch records according to whether the overall entry is successful; Step S4, traverse all activity information, read the required marketing data according to the activity type and generate trial calculation details. The trial calculation status and issuance status of the trial calculation details are both pending and saved in the database table. After successful execution, the data analysis trial calculation status of the batch record is updated to waiting for trial calculation, and the reward pre-issuance data generation status is waiting for generation; Step S5: For each type of activity, the trial calculation details are analyzed according to different activity rules. Details that do not meet the rules are updated with a trial calculation status of no trial calculation required, and details that meet the rules are updated with a trial calculation status of successful trial calculation and reward. The trial calculation status of the data analysis of the batch record is updated according to whether the overall trial calculation is successful. Step S6, summarize and compile the trial calculation details with trial calculation status of successful and payment status of pending according to the activity and rule dimensions to generate reward pre-issuance data, save it in the database table, and update the reward pre-issuance data generation status of the batch record; Step S7, after the reward pre-issuance data is generated, rewards are issued to customers and the actual issuance data of rewards is updated according to the trial calculation details with the trial calculation success status as trial calculation success and the issuance status as pending. After the issuance is completed, the reward pre-issuance and actual issuance data are compared and verified, and the execution status of the reward issuance module of the batch record and the total status of the batch record are updated.
2. A method for calculating marketing activity rewards based on a state machine according to claim 1, characterized in that: In step S2, if the data file download status is not successful, connect to and download the corresponding marketing data file on the file server to the local specified path. Every time a file is downloaded, a file download log record with the download status is written to the database table according to the download status. After all files are downloaded, the data file download status of the batch record is updated based on whether the overall download is successful.
3. The method for calculating marketing activity rewards based on a state machine according to claim 1, characterized in that: In step S3, if the data file download status is successful download and the file data storage status is not successful storage, the file data storage log records of this batch are cleared, the corresponding file data table data is cleared, and the corresponding file data on the local specified path is read and inserted into the corresponding file data table in batches. After the storage is completed, the piece data storage log record with the storage status is written to the database table, and the data file storage status of the batch record is updated according to whether the overall storage is successful.
4. The method for calculating marketing activity rewards based on a state machine according to claim 1, characterized in that: In step S4, if the file data storage status is successful and the data analysis trial calculation status is unprocessed, traverse all activity information to obtain the required marketing data one by one according to the activity type, generate and write the trial calculation details with the trial calculation status and issuance status both pending to be processed into the database table, and after successful execution, update the data analysis trial calculation status of the batch record to waiting for trial calculation, and update the reward pre-issuance data generation status of the batch record to waiting for generation.
5. The method for calculating marketing activity rewards based on a state machine according to claim 1, characterized in that: In step S5, if the data analysis trial calculation status is waiting for trial calculation or trial calculation failed, the activity trial calculation details of each activity type after splitting are analyzed according to different activity rules. The trial calculation status of the details that do not meet the rules is updated to no trial calculation required, and the trial calculation status of the details that meet the rules is updated to successful trial calculation and reward. The data analysis trial calculation status of the batch records is updated based on whether the overall trial calculation is successful.
6. A method for calculating marketing activity rewards based on a state machine according to claim 1, characterized in that: In step S6, if the data analysis trial calculation status is trial calculation success and the reward pre-issuance data generation status is waiting for generation or generation failure, and there is no reward pre-issuance data for this batch, then the trial calculation details with trial calculation status of trial calculation success and issuance status of pending are summarized and counted according to activity and rule dimensions to generate reward pre-issuance data, which are saved in the database table for use in the reward issuance module for comparison and inspection. The reward pre-issuance data generation status of the batch records is updated based on whether the generation execution is successful.
7. The method for calculating marketing activity rewards based on a state machine according to claim 1, characterized in that: If the generation status of the reward pre-issuance data in step S7 is successful generation and the overall status is in processing, the reward pre-issuance data is traversed, and rewards are issued one by one according to the trial calculation details of each activity with a trial calculation status of successful trial calculation and an issuance status of pending processing. After each successful issuance, the issuance status of the trial calculation details is updated to successful issuance, and the actual issuance data of the corresponding reward pre-issuance data is updated. Activities that do not need to be issued or have insufficient inventory of activity rewards will not be processed. After the overall issuance is completed, the reward pre-issuance data is compared with the actual issuance data, and the reward issuance status and batch total status of the batch record are updated based on whether the comparison results are consistent.
8. A marketing activity reward calculation system based on a state machine, characterized in that: It includes batch task generation module, data file download module, file data storage module, data preprocessing module, data analysis and calculation module, reward pre-issuance data generation module and reward issuance module. Each module can be independently scheduled and executed, including: The batch task sequence generation module is used to generate batch records with the execution status of each module, and control the execution operation and sequence of the corresponding modules according to the execution status of each module in the batch record; The data file download module is used to connect to the corresponding marketing data file on the download file server to the local specified path, generate a file download log record with the download status, and finally update the data file download module execution status of the batch record; The file data storage module is used to read the downloaded marketing data files in the local specified path and write them into the corresponding database tables, generate file storage log records with storage status, and finally update the file data storage module execution status of the batch record; The data preprocessing module is used to generate trial calculation details with trial calculation status and payment status according to different types of activities and corresponding rules for various marketing data. Activities that do not require the issuance of rewards are filtered out during the process. After completion, the execution status of the data analysis trial calculation module and the execution status of the reward pre-issuance data generation module of the batch record are updated; The data analysis and trial calculation module is used to filter and update the trial calculation status and other information such as rewards after analyzing the trial calculation details of each activity of the corresponding type according to the rules. The activity trial calculations of different types of activities are split into separate sub-modules for execution, and the execution status of the data analysis and trial calculation module of the batch records is updated; The reward pre-issuance data generation module is used to generate reward pre-issuance data by summarizing and counting the trial calculation details with trial calculation status of successful and payment status of pending according to activity and rule dimensions, and update the execution status of the reward pre-issuance data generation module of the batch record; The reward distribution module is used to distribute rewards to customers and update the actual reward distribution data after the reward pre-distribution data is generated, based on the trial calculation details with a trial calculation success status and a distribution status of pending. After the distribution is completed, the reward pre-distribution and actual distribution data are compared and verified, and the reward distribution module execution status and batch record total status of the batch record are updated.