Cost accounting method and system for online advertisement putting
By setting up independent cost accounting processes for each channel and using structured data and testing frameworks to monitor costs, the problem of low efficiency in traditional SQL aggregation queries was solved, enabling fast and accurate cost accounting and anomaly monitoring.
Patent Information
- Application Number
- CN202510834327.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-11-18
AI Technical Summary
Traditional SQL aggregation queries are inefficient for cost accounting in multi-channel advertising and require script modification capabilities, increasing the accounting threshold and making them unsuitable for complex scenarios where performance advertising is attributed to users.
Each channel is assigned an independent calculation process. The theoretical cost of acquiring users is calculated by monitoring the number of new users and the preset unit price. The actual cost is compared with the theoretical cost, and structured data records are generated. The pytest testing framework and Allure reporting framework are used for quick verification and anomaly monitoring.
It improves cost accounting efficiency, ensures the accuracy and independence of customer acquisition cost per person in each channel, enables rapid identification of anomalies, and lowers the accounting threshold.
Smart Images

Figure CN120975813A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of Internet advertisement delivery, and in particular to a cost accounting method and system for online advertisement delivery. BACKGROUND
[0002] In the field of Internet advertisement delivery, the cost accounting of buying volume is a core link of business refinement operation. In the traditional mode, the advertiser only needs to monitor the total consumption cost in the channel or advertisement plan dimension, and such demand can be realized by basic SQL aggregation query.
[0003] However, with the evolution of effect advertisement to user-level attribution, the business party requires to accurately allocate the total consumption cost to each new user to form the "per capita customer acquisition cost" index, which complicates the allocation logic. At the same time, different channels usually have different billing rules, such as CPM (thousand exposures), CPC (single click), CPA (single conversion) and other mutually exclusive billing models, and the same channel may have a mixed billing strategy. If advertisement delivery is carried out in multiple channels at the same time, the cost allocation logic becomes more complex compared with the traditional mode. At this time, if the SQL aggregation query is continued, the script of the SQL needs to be modified, and the cost accounting of buying volume is realized by the modified SQL.
[0004] However, the efficiency of realizing the cost accounting of buying volume by constantly modifying the script is not only low, but also requires the user to have the ability to modify the script, which increases the threshold of the cost accounting of buying volume, resulting in that the traditional SQL aggregation query is not suitable for the current cost accounting scenario. SUMMARY
[0005] In order to solve the above technical problems, the present application provides a cost accounting method and system for online advertisement delivery, which sets an independent calculation process for each channel, so that the allocation logic of "per capita customer acquisition cost" in each channel does not interfere with each other, and the efficiency of cost accounting is improved. The technical solution is as follows:
[0006] In a first aspect, a cost accounting method for online advertisement delivery is provided, comprising:
[0007] Obtaining the number of new users of each channel in a specified time period;
[0008] Based on the preset unit price of each channel and the obtained number of new users, the theoretical buying volume cost of each channel in the specified time period is calculated;
[0009] Obtaining the actual buying volume cost of each channel in the specified time period;
[0010] By comparing the actual buying volume cost with the theoretical buying volume cost, the cost accounting result of each channel is obtained.
[0011] In a possible implementation, the specified time period is divided into a plurality of continuous hour periods, and the acquiring of the number of new users includes:
[0012] counting the number of new users of each channel in each hour period;
[0013] if there is no new user in one of the hour periods, the consumption cost in the hour period is accumulated in the next hour period with new users; and the sum of the consumption cost in each of the plurality of continuous hour periods is the theoretical buying cost.
[0014] In a possible implementation, a structured data record is generated for each channel, and each structured data record includes: channel identification, hour period identification, user ID, number of new users, and corresponding consumption cost.
[0015] The structured data records of the plurality of channels are stored in a dictionary data structure.
[0016] In a possible implementation, a test case is generated using each structured data record, and the test case is executed using a pytest test framework.
[0017] In a possible implementation, a non-blocking assertion mechanism is set in the test case, and the non-blocking assertion mechanism is used to continue executing subsequent test cases when the pytest test framework fails to execute the test case.
[0018] In a possible implementation, an absolute difference between the actual buying cost and the theoretical buying cost is calculated, and when the absolute difference exceeds a difference threshold, an exception identifier is generated, and the difference value is marked in the cost accounting result.
[0019] In a possible implementation, when the absolute difference exceeds the difference threshold, the method further includes:
[0020] a plurality of continuous hour periods constituting the specified time period are called, and the consumption cost and the cost to be checked of each hour period are acquired; and the sum of the cost to be checked in each of the plurality of continuous hour periods is the actual buying cost.
[0021] The cost to be checked and the consumption cost in the same hour period are subtracted, and the absolute value of the difference obtained by subtraction is taken.
[0022] The cost to be checked with an absolute value greater than a preset value is taken as an abnormal cost, and the hour period with the abnormal cost is taken as an abnormal hour period.
[0023] In a possible implementation, the difference value with the exception identifier is displayed by using an allure test report framework.
[0024] In a possible implementation, the method further includes:
[0025] The LAN cost accounting result sharing service is configured, and the generated cost accounting result is published to the intranet environment through a port mapping tool.
[0026] In a second aspect, a cost accounting system for online advertisement delivery is provided, and includes:
[0027] The first obtaining module is configured to obtain the number of new users of each channel in a specified time period;
[0028] The data calculation module is configured to calculate the theoretical buying cost of each channel in the specified time period based on the preset unit price of each channel and the obtained number of new users.
[0029] The second obtaining module is configured to obtain the actual buying cost of each channel in the specified time period.
[0030] The data generation module is configured to obtain the cost accounting result of each channel by comparing the actual buying cost with the theoretical buying cost.
[0031] The technical scheme provided by the embodiments of the present application can achieve the following technical effects:
[0032] (1) In the present application, the number of new users of each channel in a specified time period is first monitored, and then the theoretical buying cost is calculated based on the number of new users and the preset unit price. Then, the actual buying cost of each channel in the specified time period is obtained, and the actual buying cost is compared with the theoretical buying cost to determine whether the actual buying cost is reasonable. Therefore, in the cost accounting process of the present application, each specified time period is used as an accounting node, and an independent calculation process is set for each channel. Compared with the traditional cost accounting method using SQL aggregation query, the script does not need to be modified, the accounting efficiency is improved, and the "per capita customer acquisition cost" of each channel is not cross-distributed and does not interfere with each other, which ensures the accuracy of cost accounting and makes the cost accounting method of the present application more suitable for actual scenarios.
[0033] (2) Further, the present application uses pytest test framework to execute multiple test cases at the same time, which further improves the efficiency of cost accounting.
[0034] (3) In addition, when the absolute difference between the actual buying cost and the theoretical buying cost exceeds the difference threshold, in order to monitor specific abnormal hours, the application further calls multiple continuous hours that constitute the specified time period, obtains the consumption cost of each hour, and obtains the distribution of the actual buying cost in the multiple continuous hours. The buying cost of the actual buying cost falling into each hour is called to-be-verified cost. Then, the to-be-verified cost and the consumption cost in the same hour are subtracted, the absolute value of the difference obtained by the subtraction is taken, the to-be-verified cost whose absolute value is greater than the preset value is regarded as abnormal cost, and the hour segment in which the abnormal cost occurs is regarded as an abnormal hour segment. In this way, the buying cost in each hour segment can be verified one by one, and the abnormal hour segment can be quickly located. BRIEF DESCRIPTION OF DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required to be used in the description of the embodiments of the present application will be briefly introduced. In the drawings:
[0036] Figure 1 is a flowchart of an online advertising cost accounting method provided by the embodiments of the present application;
[0037] Figure 2 is a block diagram of an online advertising cost accounting system provided by the embodiments of the present application;
[0038] Figure 3 is a structural diagram of an electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0039] The exemplary embodiments of the present application will be described in detail with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided so that the present application can be more thoroughly understood and the scope of the present application can be accurately conveyed to those skilled in the art.
[0040] It should be noted that the terms "first", "second", and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that such use can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the term "comprising" and its variants are to be interpreted as meaning "including but not limited to" an open term.
[0041] The present application provides an online advertising cost accounting method, as shown in Figure 1 the method can include the following steps S101-S104.
[0042] Step S101, obtain the number of new users of each channel in a specified time period.
[0043] The channel refers to a short video platform that can perform advertisement placement. In the embodiment, a user with an advertisement placement demand is referred to as a buyer, and different channels represent different short video platforms.
[0044] For each buyer, the channels in which the buyer has performed advertisement placement are collected, and then the number of new users of each channel in a specified time period is obtained. The length of the specified time period can be set as needed, for example, the length of one day, one week, or one month. In actual setting, the length of the specified time period can also be determined according to the growth rate of the number of new users, for example, the greater the growth rate of the number of new users, the shorter the length of the specified time period, so as to timely perform cost accounting in the time period in which the number of new users increases rapidly, and achieve the purpose of monitoring the buying cost.
[0045] The new user mentioned above can be a user who clicks on an advertisement placed in a channel, or a user who downloads a corresponding online product through an advertisement placed in a channel. Therefore, the number of new users refers to the number of users who click on an advertisement placed in a channel, or the number of users who download a corresponding online product through an advertisement placed in a channel in a specified time period.
[0046] Step S102, based on the preset unit price of each channel and the obtained number of new users, the theoretical buying cost of each channel in the specified time period is calculated.
[0047] First, the preset unit price of each channel is obtained, which is provided by the business party and used to represent the promotion fee that the business party charges for each new user, also referred to as the buying cost. The business party refers to a merchant who operates and manages a short video platform.
[0048] Then, the number of new users of each channel in a specified time period is multiplied by the preset unit price of the channel to obtain the theoretical buying cost of the channel in the specified time period. The theoretical buying cost refers to the promotion fee that the buyer needs to pay to the business party for the new users attracted by the advertisement placed in the channel.
[0049] For each channel, the corresponding theoretical buying cost needs to be calculated according to the above calculation method.
[0050] Step S103, obtain the actual buying cost of each channel in the specified time period.
[0051] The actual buying cost can be provided by the business party, and is calculated by the business party according to the number of new users of the purchasing party in the short video platform operated by the business party and the number of new users in the specified time period. The calculation method is still to multiply the number of new users by the preset unit price. The actual buying cost can also be calculated by the purchasing party itself after the business party provides the number of new users and the preset unit price. That is, the business party can directly send the actual buying cost (invoice) to the purchasing party, or send the number of new users and the preset unit price (consumption details) to the purchasing party, and the actual buying cost is calculated by the purchasing party or a third party entrusted by the purchasing party according to the number of new users and the preset unit price.
[0052] In step S104, the cost accounting result of each channel is obtained by comparing the actual buying cost with the theoretical buying cost.
[0053] Based on the obtained actual buying cost and theoretical buying cost, the absolute difference between the actual buying cost and the theoretical buying cost is calculated. When the absolute difference exceeds the difference threshold, an abnormality identifier is generated, and the specific difference value is marked in the cost accounting result.
[0054] The cost accounting result mainly includes channel, specified time period, actual buying cost and theoretical buying cost in the specified time period, absolute difference between the actual buying cost and the theoretical buying cost, and other data information. By marking the difference exceeding the difference threshold as an abnormality identifier, the purchasing party can quickly lock the abnormal buying cost, and can perform secondary accounting on the abnormal buying cost or feed it back to the business party to assist the business party to recalculate the actual buying cost.
[0055] In summary, the embodiment first monitors the number of new users of each channel in the specified time period, and then calculates the theoretical buying cost according to the number of new users and the preset unit price. Then, the actual buying cost of each channel in the specified time period is obtained, and the actual buying cost is quickly checked by comparing the actual buying cost with the theoretical buying cost. At the same time, in the cost accounting process of the embodiment, each specified time period is taken as an accounting node, and an independent calculation process is set for each channel. Therefore, the allocation logic of "per capita customer acquisition cost" in each channel does not cross and interfere with each other, which ensures the accuracy of cost accounting and makes the cost accounting method of the application more suitable for actual scenarios.
[0056] In a possible implementation, the method in step S101 further includes:
[0057] The specified time period is also composed of a plurality of continuous unit time periods. For example, when the specified time period is one day, the unit time period can be one hour; when the specified time period is one week, the unit time period can be one day or one hour; when the specified time period is one month, the unit time period can be one week, one day, or one hour. Hereinafter, the unit time period is taken as one hour, i.e., the specified time period is composed of a plurality of continuous hour periods.
[0058] For each hour period, the number of new users of each channel in each hour period is counted.
[0059] In order to facilitate the management of the number of new users in the hour period of the plurality of channels obtained, the embodiment sets a user ID, a channel identifier, and an hour period identifier for each buyer, each channel on which the buyer launches an advertisement, and each hour period. Then, the new users with the same channel identifier, hour period identifier, and user ID are placed in a structured data record, so as to generate a plurality of structured data records in the specified time period.
[0060] The embodiment uses a dictionary data structure to store the structured data records of the plurality of channels, so as to facilitate subsequent query and management.
[0061] In a possible implementation, the method in step S102 further includes:
[0062] For the number of new users in each structured data record, the buy cost of each hour period is obtained by multiplying the preset unit price and the number of new users. The embodiment uses the consumption cost to represent the buy cost of each hour period. The calculated consumption cost is put into the corresponding structured data record, so that each structured data record is more complete.
[0063] In a possible implementation, the method in step S104 further includes:
[0064] When the absolute difference between the actual buy cost and the theoretical buy cost exceeds the difference threshold, in order to monitor the specific abnormal hour period, the plurality of continuous hour periods constituting the specified time period are called, and the consumption cost of each hour period is obtained. At the same time, the distribution of the actual buy cost in the plurality of continuous hour periods is obtained. The buy cost of the actual buy cost falling into each hour period is called to-be-verified cost. Then, the to-be-verified cost and the consumption cost in the same hour period are subtracted, the absolute value of the difference obtained by the subtraction is taken, the to-be-verified cost with an absolute value greater than a preset value is taken as an abnormal cost, and the hour period in which the abnormal cost appears is taken as an abnormal hour period. In this way, the buy cost in each hour period is verified one by one, and the abnormal hour period can be quickly located.
[0065] When calculating the difference between the to-be-verified cost and the consumption cost in the hour segment, if one of the hour segments has no new user, the consumption cost in the hour segment is accumulated to the next hour segment with new user, and the to-be-verified cost and value between the hour segment without new user and the next hour segment with new user is obtained, and then the to-be-verified cost and value is subtracted from the consumption cost, so as to avoid the deviation caused by the consumption cost of 0 in one of the hour segments and the abnormal hour segment.
[0066] In a possible implementation, the embodiment also generates a test case for each structured data record, and executes each test case by using a pytest test framework. The pytest test framework is a test framework written in Python language, and is mainly used for writing and running various types of software tests. The embodiment uses the extensibility and rich function set of the pytest test framework to implement parallel or sequential execution of multiple test cases.
[0067] In order to prevent the pytest test framework from interrupting the execution of the test case and causing the subsequent test case to be unable to continue to be executed, the embodiment sets a non-blocking assertion mechanism in each test case, for example, sets a "@pytest.assume" statement in the test case. The statement has a non-blocking assertion mechanism, so that when the statement is executed, even if the execution fails, the interruption does not occur, so that the subsequent test case can continue to be executed.
[0068] In the embodiment, the position where the number of test case execution failures is higher than the predetermined number of times can be located according to the historical test results, and then a statement with a non-blocking assertion mechanism is set at the position, so that the execution failure does not occur again when the test case is executed to the position, and the risk of execution interruption is reduced. Of course, the statement with the non-blocking assertion mechanism can also be set at the position where the absolute difference between the actual buying cost and the theoretical buying cost is calculated in the test case, so that when the calculation result has a large deviation, the subsequent test case is not interrupted.
[0069] In addition, in order to be able to display the difference value with an abnormal identifier in the cost accounting result, or display the abnormal cost in the abnormal hour segment, or display other types of data, the field where the data to be displayed is located can be marked as a key field, and after the key field is executed, the key field is called by a display statement to perform display. In the embodiment, the display statement is, for example, @allure.step.
[0070] In this embodiment, the allure test report framework is used to display the cost accounting result. The allure test report framework is an open source test report framework that focuses on generating beautiful, interactive, and highly customizable test reports. The allure test report framework in this embodiment supports the pytest test framework, enabling the conversion of cost accounting results into intuitive visual reports. For example, in the allure test report, key fields are highlighted, such as using high-light background, bold, and border, to make it easier for buyers to view the cost accounting results and the key fields they are interested in.
[0071] The following is an example of the process of executing a test case.
[0072] Suppose a structured data record contains:
[0073] Designated time period: 2025-03-03;
[0074] Channel identifier: baidupz-2;
[0075] User ID: 10092533650;
[0076] A test case is generated for this structured data record, including:
[0077] Priority: nomal;
[0078] Time-consuming: 6s-409ms;
[0079] Description: The cost of buying in the designated time period / the number of new users in the designated time period + the cost of buying per new user deviation value = the cost of buying per new user. Only the absolute difference between the actual buying cost and the theoretical buying cost that exceeds the difference threshold value is considered;
[0080] Parameters: channel: baidupz-2; Date: 2025-03-03; group-id: 10092533650;
[0081] When executing the above test case:
[0082] First, set the preconditions, such as setting an execution condition for calling the test case. When the execution condition is met, the test case is called and executed;
[0083] Then, after testing, the cost accounting result displayed is: at 10:00 on the day, the absolute difference is 0, i.e. the actual buying cost is equal to the theoretical buying cost, then click to view the parameters and detailed results.
[0084] If the purchaser selects to click to view the parameters, the parameters displayed in the allure test report are as follows:
[0085] channel: baidupz-2
[0086] group-id: 10092533650
[0087] Hour: 10
[0088] self_calculation: 322.33
[0089] dev_calculation: 322.33
[0090] Difference: 0
[0091] In the above parameter display, baidupz-2 represents the channel identifier, 10092533650 represents the user ID, 10 represents 10 o'clock on March 3, 2025, and the actual and theoretical buying costs are both 322.33, so the calculated absolute difference is 0.
[0092] If the purchaser selects to click to view the parameters between 10 o'clock and 11 o'clock, the parameters displayed in the allure test report are as follows:
[0093] channel: baidupz-2
[0094] group-id: 10092533650
[0095] Hour: 11
[0096] self_calculation: 91.0333
[0097] dev_calculation: 91.0333
[0098] Difference: 0
[0099] That is, the actual and theoretical buying costs are also the same in the one-hour period between 10 o'clock and 11 o'clock, so the calculated absolute difference is also 0.
[0100] Therefore, the embodiment can execute multiple test cases simultaneously or in sequence through the pytest test framework, and compared with the traditional cost accounting using SQL aggregation queries, the script does not need to be modified, and the accounting efficiency is improved. The embodiment also displays the cost accounting results or the key fields of interest of the purchaser through the allure test report, which facilitates the purchaser to quickly check whether the actual buying cost provided by the business party is reasonable.
[0101] In a possible implementation, the cost accounting method described above can be deployed in a third party, and the third party is configured with a cost accounting result sharing service in a local area network, that is, the generated cost accounting result is published in a intranet environment in real time through a port mapping tool, and then the buyer in the same local area network can view the cost accounting result through a specified port, so that the buyer entrusts the third party to perform the buying cost accounting, and the buyer views the final cost accounting result.
[0102] It should be noted that the size of the serial number of each step in the above embodiments does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. In actual application, all possible implementation manners described above can be combined in any combination to form possible embodiments of the present application, which will not be described one by one here.
[0103] Based on the online advertising cost accounting method provided in each of the above embodiments, based on the same inventive concept, the embodiments of the present application also provide an online advertising cost accounting system.
[0104] Figure 2 is a block diagram of an online advertising cost accounting system provided by the embodiments of the present application. As shown in the figure, the system can specifically include a first acquisition module, a data calculation module, a second acquisition module and a data generation module. Figure 2
[0105] The first acquisition module is configured to acquire the number of new users of each channel in a specified time period.
[0106] The data calculation module is configured to calculate the theoretical buying cost of each channel in the specified time period based on the preset unit price of each channel and the acquired number of new users.
[0107] The second acquisition module is configured to acquire the actual buying cost of each channel in the specified time period.
[0108] The data generation module is configured to obtain the cost accounting result of each channel by comparing the actual buying cost with the theoretical buying cost.
[0109] The online advertising cost accounting system provided by the embodiments of the present application is used to execute the online advertising cost accounting method provided by the above embodiments, and the implementation manner and principle are the same, and the implementation manner of each module is described in detail in the related description of the above method embodiments, which will not be described here
[0110] Based on the same inventive concept, the embodiment of the present application further provides an electronic device comprising a processor and a memory, the memory storing a computer program, and the processor being configured to execute the computer program to perform the online advertisement delivery cost accounting method of any one of the above embodiments.
[0111] In an exemplary embodiment, an electronic device is provided, such as Figure 3 as shown in the drawings, Figure 3 The electronic device 300 shown in the drawings comprises a processor 301 and a memory 303. The processor 301 and the memory 303 are connected, such as through a bus 302. Optionally, the electronic device 300 can further comprise a transceiver 304. It should be noted that the transceiver 304 is not limited to one in actual application, and the structure of the electronic device 300 does not constitute a limitation on the embodiments of the present application.
[0112] The processor 301 can be a CPU (Central Processing Unit), a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), a FPGA (Field Programmable Gate Array) or other programmable logic device, transistor logic device, hardware component or any combination thereof. It can implement or execute various exemplary logical blocks, modules and circuits described in combination with the disclosure of the present application. The processor 301 can also be a combination of computing functions, such as one or more microprocessor combinations, combinations of DSP and microprocessor, etc.
[0113] The bus 302 can comprise a path for transmitting information between the above-mentioned components. The bus 302 can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 302 can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience, Figure 3 In the drawings, only one thick line is used to represent the bus, but it does not mean that there is only one bus or only one type of bus.
[0114] The memory 303 can be a ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, a RAM (Random Access Memory) or other type of dynamic storage device that can store information and instructions, an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, a magnetic disk storage or other magnetic storage devices, or any other medium capable of storing desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
[0115] The memory 303 is configured to store computer program codes for implementing the solutions of the present application, and the processor 301 is configured to execute the computer program codes stored in the memory 303.
[0116] The electronic device includes, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet Personal Computer), a PMP (Portable Multimedia Player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. Figure 3 The electronic device shown is merely an example, and should not impose any limitation on the functions and use range of the embodiments of the present application.
[0117] Based on the same inventive concept, the embodiments of the present application also provide a storage medium having a computer program stored therein, wherein the computer program is configured to execute the online advertisement delivery cost accounting method of any one of the above embodiments when running.
[0118] Those skilled in the art can clearly understand the specific working process of the above-described system, device and module, and can refer to the corresponding process in the above method embodiments for brevity, which will not be described here.
[0119] Those skilled in the art can understand that the technical solutions of the present application can be embodied in the form of software product essentially or partially, and the computer software product is stored in a storage medium, and includes a plurality of program instructions to make an electronic device (such as a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in the embodiments of the present application when the program instructions are run. The storage medium mentioned above includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0120] Alternatively, all or part of the steps of the foregoing method embodiments can be completed by program instruction related hardware (such as an electronic device of a personal computer, a server, or a network device, etc.), and the program instructions can be stored in a computer readable storage medium, and when the program instructions are executed by the processor of the electronic device, the electronic device executes all or part of the steps of the method described in the embodiments of the present application.
[0121] The above embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that within the spirit and principle of the present application, the technical solutions recorded in the foregoing embodiments can still be modified, or part or all of the technical features can be replaced equivalently; and these modifications or replacements do not make the corresponding technical solutions deviate from the protection scope of the present application.
Claims
1. A method for cost accounting of online advertising, characterized in that, include: Get the number of new users for each channel within a specified time period; Based on the preset unit price of each channel and the number of new users acquired, the theoretical user acquisition cost of each channel within the specified time period is calculated. Obtain the actual user acquisition cost for each channel within the specified time period; By comparing the actual user acquisition cost with the theoretical user acquisition cost, the cost accounting results for each channel are obtained.
2. The method according to claim 1, characterized in that, The specified time period is divided into multiple consecutive hour segments, and obtaining the number of new users includes: Count the number of new users for each channel within each hour. If no new users are added in one hourly period, the cost incurred in that hourly period is carried over to the next hourly period with new users; wherein, the sum of the cost incurred in each of the multiple consecutive hourly periods is the theoretical user acquisition cost.
3. The method according to claim 2, characterized in that, Generate structured data records for each channel. Each structured data record includes: channel identifier, hour segment identifier, user ID, number of new users, and corresponding consumption cost. Structured data records from multiple channels are stored using a dictionary data structure.
4. The method according to claim 3, characterized in that, A test case is generated using each structured data record, and the test cases are executed using the pytest testing framework.
5. The method according to claim 4, characterized in that, The test cases are equipped with a non-blocking assertion mechanism, which is used to continue executing subsequent test cases when the pytest testing framework fails to execute the test cases.
6. The method according to claim 1, characterized in that, Calculate the absolute difference between the actual user acquisition cost and the theoretical user acquisition cost. When the absolute difference exceeds the difference threshold, generate an anomaly flag and mark the difference value in the cost accounting result.
7. The method according to claim 6, characterized in that, When the absolute difference exceeds the difference threshold, the method further includes: Retrieve multiple consecutive hourly segments that make up the specified time period, and obtain the consumption cost and the cost to be verified for each hourly segment; wherein, the sum of the costs to be verified in each of the multiple consecutive hourly segments is the actual purchase cost; Subtract the costs to be verified and the costs consumed within the same hour period, and take the absolute value of the difference. Costs whose absolute value exceeds the preset value are considered abnormal costs, and the short periods in which abnormal costs occur are considered abnormal hour periods.
8. The method according to claim 6, characterized in that, The Allure test report framework is used to display the difference values with anomaly indicators.
9. The method according to claim 1, characterized in that, The method further includes: Configure a local area network cost accounting result sharing service, and publish the generated cost accounting results to the intranet environment through a port mapping tool.
10. A cost accounting system for online advertising, characterized in that, include: The first acquisition module is used to acquire the number of new users for each channel within a specified time period; The data calculation module is used to calculate the theoretical user acquisition cost for each channel within the specified time period based on the preset unit price of each channel and the number of new users acquired. The second acquisition module is used to acquire the actual user acquisition cost for each channel within the specified time period. The data generation module is used to obtain the cost accounting results for each channel by comparing the actual user acquisition cost with the theoretical user acquisition cost.