Method and device for deducting resource bundle, electronic equipment and medium
By using existing sorting results or sorting resource packages on demand during resource package settlement, the problem of bill deduction delay in large data magnitude and high concurrency scenarios is solved, and the efficiency and accuracy of resource data deduction are improved. sex.
Patent Information
- Application Number
- CN202411731506.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-11-28
AI Technical Summary
In the large-scale and high-concurrency network communication and data processing scenarios, during the settlement process of resource packages, resource packages need to be searched, filtered and sorted for each bill, resulting in too long time consumption and exceeding the bill deduction. delay limits, resulting in bill backlog and crash.
By acquiring multiple resource packets and determining whether there is a sorting result based on the second resource data for the first resource data, if it exists, the sorting result will be directly obtained; otherwise, the resource packets are sorted based on the first resource data to obtain the target sorting result , and then deduct the resource amount of the resource package according to the sorting result.
The number of sorting times when deducting each bill is reduced, the efficiency of resource data deduction is improved, the possibility of resource package deduction is reduced, and the normal deduction of the bill is ensured.
Smart Images

Figure CN119477356A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to the fields of network communication and data processing. Background Art
[0002] Resource packages, also known as resource packages, are a common commercial promotion and marketing product that is widely used in various fields. For example, in the field of communications, resource packages include: traffic packages for watching videos, traffic packages used in one or more specified applications (APPlication, APP), morning / evening peak traffic packages, traffic packages used in specified areas, and holiday traffic packages. In the field of cloud storage, resource packages include: off-peak / busy time packages, billing item packages, combination packages for using cloud product series, and fixed usage deduction packages, etc. These resource packages can be traffic packages or storage space packages. In the field of online learning, resource packages include: general course video packages, boutique course video packages, course video limited-time acquisition packages, full-platform course video packages, and designated field course video packages. Summary of the invention
[0003] The present disclosure provides a method, device, electronic device and medium for deducting a resource package.
[0004] According to a first aspect of an embodiment of the present disclosure, a method for deducting a resource package is provided, comprising:
[0005] Get multiple resource packs;
[0006] For the first resource data, determining whether there is a sorting result of the plurality of resource packages based on the second resource data, wherein a first attribute value of the second resource data is the same as a first attribute value of the first resource data, and the first attribute value is an attribute value of a first preset attribute;
[0007] If yes, then obtain the sorting result as the target sorting result;
[0008] If not, sorting the multiple resource packages based on the first resource data to obtain a target sorting result;
[0009] According to the target sorting result, based on the resource usage included in the first resource data, the resource amount included in the resource package is deducted in sequence.
[0010] A second aspect of the embodiments of the present disclosure provides a device for deducting resource packages, including:
[0011] Acquisition module, used to obtain multiple resource packages;
[0012] a determination module, configured to determine, for the first resource data, whether there is a sorting result of the plurality of resource packages based on the second resource data, wherein the first attribute value of the second resource data is the same as the first attribute value of the first resource data, and the first attribute value is an attribute value of a first preset attribute;
[0013] The acquisition module is further configured to acquire the sorting result as the target sorting result if the determination result of the determination module is yes;
[0014] a sorting module, configured to sort the plurality of resource packages based on the first resource data to obtain a target sorting result if the determination result of the determination module is no;
[0015] A deduction module is used to deduct the amount of resources included in the resource package in turn based on the resource usage included in the first resource data according to the target sorting result obtained by the acquisition module or obtained by the sorting module.
[0016] According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any method according to the first aspect.
[0020] According to a fourth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute a method according to any one of the first aspects.
[0021] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the method according to any one of the first aspects is implemented.
[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0024] Figure 1is a flow chart of a method for deducting resource packages provided by an embodiment of the present disclosure;
[0025] Figure 2 is a flow chart of a method for obtaining multiple resource packages provided by an embodiment of the present disclosure;
[0026] Figure 3 is a flow chart of a method for sorting multiple resource packages provided by an embodiment of the present disclosure;
[0027] Figure 4 is a flow chart of a method for sorting every two resource packages provided by an embodiment of the present disclosure;
[0028] Figure 5 is a flow chart of another method for deducting resource packages provided by an embodiment of the present disclosure;
[0029] Figure 6 is an exemplary schematic diagram of a rule tree provided by an embodiment of the present disclosure;
[0030] Figure 7 It is a structural schematic diagram of a deduction device for a resource package provided by an embodiment of the present disclosure;
[0031] Figure 8 The block diagram is a block diagram of an electronic device for implementing the method for deducting resource packages according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0032] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0033] At present, when settling the resources used by users based on resource packages, for each bill x, we usually first find the account y to which bill x belongs, and then obtain all accounts associated with account y. Among them, the bill, also known as the resource bill, is a record generated after an account uses resources.
[0034] For example, a group has multiple accounts, and each account can form a tree structure. In this case, all accounts in the tree structure where account y belongs to bill x can be obtained. Since resource packages can be shared among accounts with related relationships, it is necessary to obtain resource packages of all accounts. For example, a superior account can use the resource packages of a subordinate account, and resource packages can be shared between peers. Assume that the number of accounts obtained is M, and the number of resource packages that the mth account has the right to use is , m=1,2,…,M, then the number of resource packages obtained for bill x is:
[0035]
[0036] And found Not every resource package can be used to deduct bill x. For example, the account to which the resource package found belongs is the parent of account y, or the resource package found has a restricted usage area of Beijing, while the resource usage area of bill x is Shanghai. Therefore, it is necessary to filter the found resource packages to filter out the resource package set that can be used to deduct bill x:
[0037]
[0038] in, A collection of resource packages. Indicates matching, Indicates bill.
[0039] Afterwards, the filtered resource package set is sorted, so that the resource packages are used in sequence according to the sorting order, and the resource usage included in the bill x is deducted.
[0040] However, resource package settlement is a typical business scenario with large data volumes and high concurrency, that is, each account has a large number of resource packages, and each settlement involves a large number of bills. The number of bills involved in each settlement can reach millions, and the number of bills involved can reach hundreds of millions. Each bill needs to be searched, filtered, and sorted through resource packages, which takes too long. For example, one minute is too long, which seriously exceeds the bill deduction delay, resulting in the inability to deduct bills, causing bills to accumulate, and ultimately leading to bill deduction anomalies and crashes, making it impossible for users to use resources normally.
[0041] In order to reduce the time consumed in deducting each bill, the embodiment of the present disclosure provides a method for deducting resource packages, which is applied to electronic devices, such as servers, desktop computers, or laptop computers, which have data processing capabilities. Figure 1 As shown, the method for deducting resource packages provided in the embodiment of the present disclosure includes the following steps:
[0042] S101. Acquire multiple resource packages.
[0043] The multiple resource packages may be obtained by searching and filtering according to the above method, or the multiple resource packages may be obtained by referring to the implementation method of S101 below.
[0044] S102: for the first resource data, determine whether there is a sorting result of multiple resource packages based on the second resource data. If yes, execute S103; if no, execute S104.
[0045] The first resource data and the second resource data are both data generated for a resource usage behavior or for a resource usage behavior within a unit of time. Each resource data may include information such as the resource type used, resource usage, resource usage time, and the account that uses the resource. Therefore, resource data can also be called resource usage records. In actual application scenarios such as communications or cloud products, resource data can be bills.
[0046] The first attribute value of the second resource data is the same as the first attribute value of the first resource data, and the first attribute value is the attribute value of the first preset attribute. Taking the first preset attribute as the account to which it belongs as an example, the second resource data is resource data to which the account to which the first resource data belongs is the same.
[0047] S103, obtaining the sorting result as the target sorting result, and then executing S105.
[0048] Since the attribute value of the first preset attribute of the second resource data is the same as the attribute value of the first preset attribute of the first resource data, the sorting result of sorting multiple resource packages based on the second resource data is the same as the sorting result of sorting multiple resource packages based on the first resource data. Therefore, the sorting result of multiple resource packages based on the second resource data can be directly obtained, reducing the impact of repeated sorting on the resource data deduction time and improving the resource data deduction efficiency.
[0049] S104. Sort the multiple resource packages based on the first resource data to obtain a target sorting result.
[0050] Multiple resource packages can be sorted according to a preset sorting method. Taking the resource data as a bill and the first preset attribute as an account as an example, the preset sorting method can be: sorting in the order of the accounts to which the resource packages belong, namely account 2, account 3, and account 1, wherein account 1 is the parent account of the account to which the first bill belongs, account 2 is the account to which the first bill belongs, and account 3 is the same-level account of the account to which the first bill belongs.
[0051] For the specific sorting method, please refer to the description of S104 below.
[0052] S105 . According to the target sorting result, based on the resource usage amount included in the first resource data, the resource amount included in the resource package is deducted in sequence.
[0053] In the disclosed embodiment, for the first resource data, before sorting the multiple resource packages, it is first determined whether there is a sorting result of the multiple resource packages based on the second resource data. If there is, the resource amount included in each resource package is deducted in sequence based on the resource usage amount included in the first resource data directly according to the sorting result. That is, it is not necessary to sort the multiple resource packages once for each resource data, thus reducing the number of sorting times, improving the efficiency of resource data deduction, and improving data processing efficiency.
[0054] The following is a detailed description of the method for deducting resource packages provided in the embodiment of the present disclosure:
[0055] In some embodiments of the present disclosure, the first preset attribute includes at least one of the following: an account, a product, a resource usage area, a statistical item, a statistical method, and a commodity within the product.
[0056] The second preset attribute includes at least one of the following: the account to which it belongs, the product to which it belongs, the resource usage area, the statistical item, the statistical method, the resource providing device, the commodity in the product to which it belongs, and the resource usage time.
[0057] The resource data belongs to an account that uses the resource, and the resource package belongs to an account that purchases the resource package. The attribute value of the belonging account can be an account name or an account identifier (ID).
[0058] The product to which the resource data belongs indicates that the resource consumption comes from the product used. For example, the attribute value of the product is: text recognition, speech recognition, image recognition, cloud storage or cloud computing functions provided by the cloud platform.
[0059] The resource usage region indicates the region where the terminal using the resource is located. For example, the attribute value of the resource usage region is Beijing or the whole country.
[0060] A statistical item indicates a statistical item of a used resource. For example, the attribute value of a statistical item is: the usage duration, usage amount, or usage time of a resource, or a statistical item combination including multiple statistical items. In actual application scenarios such as communications or cloud products, a statistical item may be a billing item.
[0061] The statistical method indicates the statistical method for the used resources. For example, the attribute value of the statistical method is: prepaid, postpaid, or a combination of prepaid and postpaid statistical methods. In actual application scenarios such as communications or cloud products, the statistical method can be a billing method.
[0062] A resource provider, also called an instance, refers to a device that provides resources. For example, the attribute value of a resource provider is an instance ID.
[0063] The commodity in the product, also known as the Stock Keeping Unit (sku), indicates that resource consumption comes from the commodity in the product being used. For example, cloud storage commodities can be public clouds or private clouds. The attribute value of resources for commodities is the commodity name or skuID.
[0064] The resource usage time of resource data indicates the time when the resource is used, and the resource usage time of a resource package is the time interval in which the resource package can be used, that is, the effective time interval of the resource package. For example, the attribute value of the resource usage time of resource data is 2024.1.1 01:01:01, and the attribute value of the resource usage time of the resource package is 2024.1.1~2024.1.31. The resource usage time can be Greenwich Mean Time and / or 24-hour time based on a preset time zone. For example, the 24-hour time based on a preset time zone is Beijing time.
[0065] In addition, the first preset attribute and the second preset attribute may also include other attributes, such as statistical strategies, which are not specifically limited in the embodiments of the present disclosure. For example, the attribute value of the statistical strategy is a monthly settlement or a monthly peak value. Among them, the monthly settlement means summarizing the amount of resources used by the account within a month, and deducting according to the summarized amount of resources. The monthly peak value means sampling the user's resource usage within a month at equal intervals, sorting the sampled values, and selecting the sampled values with specified serial numbers for deduction. In actual application scenarios such as communications or cloud products, the statistical strategy can be a billing strategy.
[0066] For the convenience of description, the account is referred to as account, the product is referred to as product, the resource usage area is referred to as area, the resource providing device is referred to as instance, the resource-specific product is referred to as sku, and the 24-hour time based on the preset time zone is referred to as 24-hour time.
[0067] The disclosed embodiment may use a plurality of attributes as the second preset attributes, so that when matching resource data and resource packages, resource packages that can be used to offset resource data can be obtained more accurately, thereby reducing the possibility of resource package deduction errors and improving the accuracy of resource data offset.
[0068] In the embodiment of the present disclosure, an attribute with a plurality of matching attribute values is used as the first preset attribute, so that resource packages including different attribute values can be sorted based on the first preset attribute. And the first preset attribute includes a plurality of attributes, that is, the resource packages can be sorted from multiple aspects, so that the obtained sorting result is more accurate.
[0069] In some embodiments of the present disclosure, see Figure 2 The method of obtaining multiple resource packages in S101 includes the following steps:
[0070] S201, obtaining multiple candidate resource packages and multiple resource data to be processed, wherein the multiple resource data to be processed include first resource data and second resource data.
[0071] In the embodiment of the present disclosure, multiple resource data to be processed generated within a certain time period can be obtained at intervals of the time period, and each resource data to be processed can be used as the first resource data in sequence. Alternatively, each resource data to be processed can be used as the first resource data in sequence whenever a preset number of resource data to be processed is obtained. Alternatively, multiple resource data to be processed can be obtained in other ways, which are not specifically limited in the embodiment of the present disclosure.
[0072] Each candidate resource package may be a resource package that has been purchased by each account.
[0073] S202: Determine the target attribute value that the second attribute value of each resource data to be processed matches, wherein the second attribute value is the attribute value of the second preset attribute.
[0074] That is, the electronic device can determine, for each piece of resource data to be processed, a target attribute value that matches the attribute value of the second preset attribute of the resource data to be processed.
[0075] Each second preset attribute has a preset matching rule, and the matching rule can be set according to an actual application scenario.
[0076] For example, accounts that match an account include: the account, subordinate accounts of the account, and superior accounts and peer accounts authorized by the account.
[0077] The products that match each product are: the product, the product group to which the product belongs, and the global product group that includes all products.
[0078] The zones that match each zone are: that zone, and the global zone which includes all zones.
[0079] The statistic that matches each statistic is that statistic.
[0080] The statistical methods that match each statistical method include: the statistical method, including a statistical method combination of the statistical method.
[0081] The resource providing device that matches each resource providing device is the resource providing device.
[0082] The SKUs that match each SKU include: the SKU and the product group that includes the SKU.
[0083] The resource usage time that matches each resource usage time is the resource usage time that includes the resource usage time. The value space of the resource usage time of each resource package is preset. For example, the value space of the resource usage time of each resource package includes: 0:00 to 24:00 every day, 6:00 to 10:00 every day, 17:00 to 20:00 every day, the first day to the last day of each month, the first day to the last day of each year, etc. Therefore, for the resource usage time of resource data, the resource usage time that includes the resource usage time of the resource data can be screened from the value space.
[0084] S203: Filter candidate resource packages having any target attribute value to obtain multiple resource packages.
[0085] Through the above method, the embodiment of the present disclosure can determine the target attribute value that matches the attribute value of the second preset attribute of each resource data to be processed, and screen the candidate resource packages with any target attribute value, thereby screening out the resource packages that can offset any resource data to be processed. Compared with the method of obtaining resource packages of all accounts related to the account to which the resource data belongs, the embodiment of the present disclosure obtains fewer resource packages, thereby reducing the time consumed in obtaining resource packages and improving the efficiency of obtaining resource packages.
[0086] In the disclosed embodiment, there is a situation where the same target attribute value is determined for different resource data for the same preset attribute. Therefore, before the electronic device screens the candidate resource package with any target attribute value in the above S203, it can also perform: deduplicate the target attribute values belonging to the same second preset attribute to obtain multiple target attribute value sets.
[0087] That is, the electronic device can deduplicate the target attribute value of each second preset attribute respectively to obtain a set of target attribute values of the second preset attribute. Taking the resource data as a bill as an example, the account to which bill A belongs is account a, the account to which bill B belongs is account b, and the account to which bill C belongs is account c. Account a is the parent account of account b, and bill b is the parent account of bill c. Therefore, the target attribute value determined for bill A includes account a, account b, and account c, the target attribute value determined for bill B includes account b and account c, and the target attribute value determined for bill C includes account c. De-duplicate the target attribute values of bills A, B, and C, and obtain a set of target attribute values including: account a, account b, and account c.
[0088] On this basis, the method of screening candidate resource packages having any target attribute value in S203 can be implemented as follows: screening candidate resource packages whose second attribute values belong to a target attribute value set. That is, the electronic device can screen candidate resource packages whose attribute values of each second preset attribute belong to the target attribute value set of the second preset attribute.
[0089] Through the above method, the embodiment of the present disclosure can avoid obtaining resource packages whose attribute value of any second preset attribute does not match the resource data to be processed, thereby reducing the number of resource packages obtained and reducing the occupation of electronic device memory space by the obtained resource packages.
[0090] In some embodiments of the present disclosure, the above method of screening candidate resource packages whose second attribute values belong to a target attribute value set includes the following steps:
[0091] Step 1: Generate a database query statement based on each target attribute value set, wherein the database query statement is used to find a candidate resource package in which each second attribute value belongs to a target attribute value set, that is, to find a candidate resource package in which the attribute value of each second preset attribute belongs to the target attribute value set of the second preset attribute.
[0092] The electronic device may fill the target attribute value set of each second preset attribute into a preset query statement template, thereby obtaining a database query statement.
[0093] For example, the database query statement is:
[0094] “Select from resources where account in ('account 1', 'account 2', 'account 3', 'account n')
[0095] Select from resources where 'product1', 'product2', 'productx', 'productgroup1', 'globalproductgroup'
[0096] And 'zone 1', 'zone 2', 'zone 3', , , 'global zone' ... And 'start time 1, end time 1', 'start time 2, end time 2', , 'start time n, end time n'".
[0097] The time period between start time 1 and end time 1, the time period between start time 2 and end time 2, and the time period between start time n and end time n are each a resource usage time.
[0098] Step 2: execute a database query statement in the database to obtain multiple candidate resource packages. The database stores multiple candidate resource packages.
[0099] Through the above method, the disclosed embodiment can automatically construct a database query statement, thereby searching the database for candidate resource packages whose attribute values of each second preset attribute belong to the target attribute value set of the second preset attribute, reducing the number of resource packages searched from the database and improving the efficiency of resource package search. Moreover, the disclosed embodiment only needs to search the database once for each resource data to be processed, and does not need to search the database once for each resource data, thus reducing the number of times the resource package is searched from the database, improving the efficiency of resource package search, and reducing the occupation of the electronic device memory by the found resource package.
[0100] In the conventional method, for each bill, it is necessary to search the database for all resource packages of all accounts related to the account to which the bill belongs. The number of resource packages searched each time is The number of resource packages is huge, reaching tens of millions, but most of them are invalid resource packages that cannot be used to deduct the bill. These resource packages greatly occupy the memory of electronic devices, that is, there is a space explosion problem. Moreover, the number of bills involved in each bill settlement can reach hundreds of millions, so the number of resource packages queried for each bill settlement can reach tens of millions. .
[0101] In the disclosed embodiment, however, there is no need to search for all resource packages of all accounts related to the account to which the bill belongs, and there is no need to perform a resource package search for each bill. This significantly reduces the number of resource packages to be searched, solves the space explosion problem, and greatly improves memory usage efficiency.
[0102] In the disclosed embodiment, each resource data to be processed also has a statistical period attribute, and the attribute value of the statistical period attribute is used to indicate whether the resource usage time of the resource data to be processed is in the statistical period, wherein the statistical period indicates a period during which resource packages are not deducted. For example, in actual application scenarios such as communications or cloud products, the statistical period is the account period of the account to which the resource data to be processed belongs. For example, if the attribute value of the statistical period attribute is 1, it indicates that the resource usage time of the resource data to be processed is in the statistical period; if the attribute value of the statistical period attribute is 0, it indicates that the resource usage time of the resource data to be processed is not in the statistical period.
[0103] When the resource usage time of the resource data to be processed is in the statistical period, it means that the resource data to be processed does not need to be processed at present. When the resource usage time of the resource data to be processed is not in the statistical period, it means that the resource data to be processed needs to be processed at present.
[0104] Therefore, before determining the target attribute value that matches the second attribute value of each resource data to be processed in the above S202, the electronic device may further perform: determining whether the resource usage time of the resource data to be processed is in the statistical period. It may be determined whether the attribute value of the statistical period attribute of the resource data to be processed indicates that the resource usage time is in the statistical period, for example, determining whether the attribute value of the statistical period attribute is 1.
[0105] Afterwards, the resource data to be processed whose resource usage time is not in the statistical period is filtered out.
[0106] Through the above method, the embodiment of the present disclosure can ignore the resource data in the statistical period when processing the resource data this time, reduce the impact of the resource data that does not need to be processed temporarily on the processing process of other resource data, and improve the query efficiency of the resource package.
[0107] In the embodiment of the present disclosure, if it is determined that the resource usage time of the resource data to be processed is in the statistical period, the resource data to be processed can also be deleted from multiple resource data to be processed, thereby avoiding the use of resource packages to offset the resource data in the statistical period and improving the accuracy of resource data processing.
[0108] In some embodiments of the present disclosure, see Figure 3 The above S104, based on the first resource data, sorts the multiple resource packages, including the following steps:
[0109] S301. Based on the first attribute value of the first resource data, determine whether the first resource data satisfies a preset special sorting rule between attributes. If yes, execute S302; if no, execute S303.
[0110] Among them, special sorting rules between attributes can be set according to actual needs.
[0111] S302, obtaining the special priority between attributes corresponding to the special sorting rule between attributes, and obtaining the priority between attributes to be executed. Then, S304 is executed.
[0112] The inter-attribute special priority in S302 and the inter-attribute general priority in S303 both represent the sorting priority of each first preset attribute, and the inter-attribute special priority and the inter-attribute general priority are different.
[0113] There may be one or more special sorting rules between attributes, and the special priority between attributes corresponding to each special sorting rule between attributes may be set according to actual needs.
[0114] For example, the correspondence between the special sorting rules between attributes and the special priorities between attributes is shown in Table 1.
[0115] Table 1
[0116] Special sorting rules between attributes Special precedence between attributes The account to which the resource data belongs is the root account of the tree structure, and the product to which the resource data belongs is product A Account>Product>Region>Statistical Item>Statistical Method>sku The account to which the resource data belongs is the root account of the tree structure, and the product to which the resource data belongs is not product A Account > Region > Product > Statistics > Statistics method > sku ... ... The account to which the resource data belongs is the root account of the tree structure, the product to which the resource data belongs is not product A, and the resource usage area is Beijing Account > Region > Statistics > Product > Statistics method > sku
[0117] S303: Obtain a preset common priority between attributes to obtain a priority between attributes to be executed.
[0118] Among them, the general priority between attributes can be set according to actual needs.
[0119] For example, the general priority between attributes is: account>product>region>statistical item>statistical method>sku.
[0120] S304: Sort the resource packages according to the priorities of the attributes to be executed.
[0121] Through the above method, the embodiment of the present disclosure selects the corresponding sorting priority between attributes based on the attribute value of the first preset attribute of the first resource data, so as to sort each resource package in a manner that meets business needs, making the sorting method of resource packages more flexible and more in line with the actual needs in actual application scenarios.
[0122] In some embodiments of the present disclosure, the above S304 sorts the resource packages according to the sorting priority between the attributes to be executed, including the following steps:
[0123] During the sorting process, two resource packages are compared each time to determine the order of the two resource packages. Depending on the sorting method used, the two resource packages to be compared are different each time. For example, when quick sort is used, the two resource packages to be compared each time are a resource package and a benchmark resource package, or a resource package and a resource package before / after the benchmark resource package. When bubble sort is used, the two resource packages to be compared each time are two adjacent resource packages. When merge sort is used, the resource packages are divided into multiple groups. When sorting within a group, the two resource packages to be compared each time are two resource packages within the group. After the sorting within the group is completed, the sorting results of each group are merged. At this time, the two resource packages to be compared each time are two resource packages in different groups.
[0124] The disclosed embodiment compares each two resource packages in the same manner. Figure 4 , perform the following steps for each two resource packages to be compared in each resource package:
[0125] S401 . According to the priority of the attributes to be executed, for a first preset attribute, determine whether the attribute values of the first preset attribute of the two resource packages are the same.
[0126] If they are the same, it means that the sequence of the two resource packages cannot be determined based on the first preset attribute, so S402 is executed.
[0127] If they are different, it means that the sequence of the two resource packages can be determined based on the first preset attribute, so S403 is executed.
[0128] S402 . According to the priority of the attributes to be executed, for the next first preset attribute, return to S401 to determine whether the attribute values of the first preset attributes of the two resource packages are the same.
[0129] For example, assuming that the priority between the attributes to be executed is: account>product>region>statistical item>statistical method>sku, the first preset attribute selected in step 1 is the account. When the two resource packages belong to the same account, the next first preset attribute selected is the product, and the process returns to step 1 to continue to determine whether the attribute values of the products of the two resource packages are the same.
[0130] S403: Determine whether the attribute value of the first preset attribute of the first resource data satisfies a preset special sorting rule within the attribute corresponding to the first preset attribute.
[0131] Among them, a first preset attribute may not have a corresponding special sorting rule within the attribute, or a first preset attribute may correspond to one or more special sorting rules within the attribute, and each special sorting rule within the attribute can be set according to actual needs.
[0132] For example, special sorting rule 1 in the attribute corresponding to the account is: the account to which the resource data belongs is the root account of the tree structure where the account is located. Special sorting rule 2 in the attribute corresponding to the account is: the account to which the resource data belongs is the account in the preset subtree of the tree structure where the account is located.
[0133] For another example, the special sorting rule in the attribute corresponding to the product is: the product to which the resource data belongs is product X2.
[0134] If satisfied, execute S404; if not satisfied, execute S405.
[0135] S404, obtaining the special priority within the attribute corresponding to the special sorting rule within the attribute as the priority within the attribute to be executed, and then executing S406.
[0136] Among them, the special priority level in each attribute corresponding to the special sorting rule in each attribute can be set according to actual needs.
[0137] Taking the resource data as a bill as an example, the special priority in the attribute corresponding to the special sorting rule 1 in the account attribute is: account 4> account 2> account 3> account 1, which means that the accounts to which the resource package belongs are sorted in the order of account 4, account 2, account 3, and account 1, where account 1 is the superior account authorized by the account to which the bill belongs, account 2 is the account to which the bill belongs, account 3 is the peer account authorized by the account to which the bill belongs, and account 4 is the subordinate account of the account to which the bill belongs. The special priority in the attribute corresponding to the special sorting rule 2 in the account attribute is: the accounts to which the resource package belongs are sorted in the order of account 1, account 4, account 3, and account 2.
[0138] For another example, the special priority within the attributes corresponding to the special sorting rule within the product attributes is: global product group > product group to which the resource data belongs > product to which the resource data belongs, indicating that the product to which the resource package belongs is the global product group, the product group to which the resource data belongs is the product, and then the product to which the resource data belongs is sorted in the order of.
[0139] S405: Obtain the general priority within the attribute corresponding to the first preset attribute as the priority within the attribute to be executed, wherein the special priority within the attribute and the general priority within the attribute both represent the sorting priority of each attribute value of the first preset attribute.
[0140] The general priority level within the attribute corresponding to each first preset attribute can be set according to actual needs.
[0141] For example, the general priority in the attributes corresponding to the accounts is: Account 2 > Account 4 > Account 3 > Account 1, which means that the accounts to which the resource packages belong are sorted in the order of Account 2, Account 4, Account 3, and Account 1.
[0142] The general priority in the attributes corresponding to the product is: the product to which the resource data belongs > the product group to which the resource data belongs > the global product group, which means that the product to which the resource package belongs is sorted in the order of the product to which the resource data belongs, the product group to which the resource data belongs, and the global product group.
[0143] The general priority in the attributes corresponding to the region is: resource data region > global region, which means that the resource package region is sorted in the order of resource data region and global region.
[0144] The general priority in the attributes corresponding to the statistical items is: statistical items of resource data > statistical item combinations including statistical items of resource data, which means that the statistical items of the resource package are sorted in the order of statistical items of resource data and statistical item combinations including statistical items of resource data.
[0145] The general priority in the attributes corresponding to the statistical methods is: statistical method of resource data > statistical method combination including the statistical method of resource data, which means that the statistical method of the resource package is sorted in the order of the statistical method of resource data and the statistical method combination including the statistical method of resource data.
[0146] The general priority in the attribute corresponding to sku is: sku of resource data > product combination including sku of resource data, which means that the product combination is sorted in the order of sku of resource package as sku of resource data and sku of resource data.
[0147] S406: Sort the two resource packages according to the priority of the attributes to be executed and based on the attribute values of the first preset attributes of the two resource packages.
[0148] Through the above method, the disclosed embodiment can determine the priority between attributes corresponding to the resource data in a manner consistent with the attribute value of the resource data, and sort the resource packages according to the priority within the attribute for each first preset attribute, so that different resource data can be sorted in different ways. This makes the sorting process more flexible, thereby better meeting the needs of actual scenarios.
[0149] In some embodiments of the present disclosure, since the multiple resource packages acquired in S101 include resource packages that can be used to deduct different resource data to be processed, and a single resource package generally does not support deducting each resource data to be processed. Therefore, before the above S105 deducts the resource amount included in the resource package in turn based on the resource usage included in the first resource data in the order of the target sorting results, the electronic device can also perform: based on the second attribute value of the resource package and the second attribute value of the first resource data, verify whether the resource package matches the first resource data. Among them, the second attribute value is the attribute value of the second preset attribute.
[0150] That is, the electronic device can verify, for each resource package, whether the resource package matches the first resource data based on the attribute value of the second preset attribute of the resource package and the attribute value of the second preset attribute of the first resource data, and then filter out the resource packages that match the first resource data.
[0151] On this basis, the above S105 can be implemented as follows: according to the target sorting result, based on the resource usage included in the first resource data, the resource amount included in the resource package is deducted in sequence.
[0152] Since there may be resource packages among the multiple resource packages obtained by S101 that cannot be used to offset the first resource data, the embodiment of the present disclosure verifies each resource package before deducting the resource packages, and screens out resource packages that match the first resource data, that is, resource packages that can be used to offset the first resource data, thereby improving the accuracy of resource package deduction.
[0153] In some embodiments of the present disclosure, the above-mentioned method of verifying whether the resource package matches the first resource data based on the attribute value of the second preset attribute of the resource package and the second attribute value of the first resource data can be implemented as follows: respectively determine the matching attribute values that match each second attribute value of the first resource data, and then verify whether each second attribute value of the resource package belongs to the matching attribute value.
[0154] That is, the electronic device can determine the matching attribute value that matches the attribute value of each second preset attribute of the first resource data, and then verify whether the attribute value of each second preset attribute of the resource package is the matching attribute value corresponding to the second preset attribute.
[0155] The method for determining the matching attribute value is the same as the method for determining the target attribute value, and the above description may be referred to, and will not be repeated here.
[0156] After determining the matching attribute values, the matching attribute values of each second preset attribute can be deduplicated to obtain a matching attribute value set of the second preset attribute, and then it can be verified whether the attribute values of each second preset attribute of the resource package belong to the matching attribute value set corresponding to the second preset attribute.
[0157] If the verification results are all yes, it is determined that the resource package matches the first resource data.
[0158] If any of the verification results is negative, it is determined that the resource package does not match the first resource data.
[0159] Through the above method, the embodiment of the present disclosure can respectively verify the attribute values of the resource package and each second preset attribute of the first resource data, thereby obtaining a resource package that matches the attribute values of each second preset attribute of the first resource data, thereby improving the accuracy of each resource package obtained for offsetting the first resource data.
[0160] In some embodiments of the present disclosure, the electronic device deducts the resource amount included in the filtered resource packages in sequence based on the resource usage included in the first resource data according to the target sorting result, which can be implemented as follows: according to the target sorting result, for the first filtered resource package, it is determined whether the resource amount included in the resource package is greater than or equal to the remaining resource usage. The initial value of the remaining resource usage is the resource usage included in the first resource data.
[0161] If so, the resource usage is deducted from the resource amount included in the resource package.
[0162] If not, the amount of resources included in the resource package is deducted to zero, the amount of resources included in the resource package is deducted from the remaining resource usage, and according to the target sorting result, for the next resource package filtered out, return to the step of determining whether the amount of resources included in the resource package is greater than or equal to the remaining resource usage.
[0163] Taking resource data as a bill as an example, assume that the filtered resource packages are: resource package 1, resource package 2, resource package 3, and the resource volume included in each resource package is 50, and the resource usage included in the first bill is 70, so the initial value of the remaining resource usage is 70. According to the above sorting results, select resource package 1. Since the resource volume 50 included in resource package 1 is less than the remaining resource usage 70, the resource volume included in resource package 1 is deducted to zero, and the remaining resource usage is determined to be 70-50=20. After that, select resource package 2. Since the resource volume 50 included in resource package 2 is greater than the remaining resource usage 20, the remaining resource usage 20 is deducted from the resource volume 50 included in resource package 2, so that the resource volume included in resource package 2 is updated to 30, and the deduction of the first bill is completed.
[0164] Through the above method, the disclosed embodiment can deduct the resources included in the resource package in sequence according to the sorting order of each resource package and based on the resource usage included in the first resource data, so as to meet the deduction order requirements for different types of resource packages in actual application scenarios and improve the user experience. For example, assuming that the resource package of a single area is cheaper than the resource package of the global area, the resource package of the single area is arranged before the resource package of the global area, so that when processing resource data, the resources included in the resource package of the single area are deducted first, thereby improving the utilization rate of the resource package with a lower price.
[0165] In the disclosed embodiment, each sorting result corresponds to a resource package sorting queue, and the resource package sorting queue is stored using object storage mode technology, such as object application technology of programming language (Java). Therefore, the same resource packages in different queues point to the same resource package in the memory of the electronic device, thereby avoiding repeated deductions, that is, avoiding the situation where the amount of resources deducted from the resource package exceeds the amount of resources included in the resource package.
[0166] See also Figure 5 The overall process of the resource package deduction method provided by the embodiment of the present disclosure is described below:
[0167] S501: Acquire multiple candidate resource packages and multiple resource data to be processed.
[0168] S502: For each piece of resource data to be processed, determine a target attribute value that matches the second attribute value of the resource data to be processed.
[0169] S503: De-duplicate the target attribute value of each second preset attribute respectively to obtain a target attribute value set of the second preset attribute.
[0170] S504: Filter candidate resource packages whose attribute values of each second preset attribute belong to the target attribute value set of the second preset attribute to obtain multiple resource packages.
[0171] S505: Take each resource data to be processed as the first resource data in turn, and for each first order, determine whether there is a sorting result of multiple resource packages based on the second resource data. If yes, execute S506; if not, execute S507.
[0172] S506: Obtain the sorting result of the plurality of resource packages based on the second resource data as the target sorting result. Then, execute S511.
[0173] S507: Based on the first attribute value of the first resource data, determine whether the first resource data satisfies a preset special sorting rule between attributes. If yes, execute S508; if no, execute S509.
[0174] S508, obtaining the inter-attribute special priority corresponding to the inter-attribute special sorting rule, and obtaining the inter-attribute priority to be executed. Then, S510 is executed.
[0175] S509: Obtain a preset common priority between attributes to obtain a priority between attributes to be executed.
[0176] S510 , sorting each resource package according to the sorting priority among the attributes to be executed, and obtaining a target sorting result.
[0177] S511 . For each resource package, based on the second attribute value of the resource package and the second attribute value of the first resource data, verify whether the resource package matches the first resource data.
[0178] S512: Filter out resource packages matching the first resource data.
[0179] S513: According to the target sorting result, based on the resource usage amount included in the first resource data, the resource amount included in the filtered resource package is deducted in sequence.
[0180] Figure 5 The specific display methods of each step in the above description can be referred to, and will not be repeated here.
[0181] See also Figure 6The following is an example to illustrate the method for deducting resource packages provided by the embodiment of the present disclosure:
[0182] Assume that a branch of the rule tree is constructed based on the special sorting rules between attributes, each branch includes at least one node, and each node represents a sub-rule included in the special sorting rules between attributes. Take the resource data as an example, in which the special sorting rules between attributes include:
[0183] The account to which the bill belongs is the root account of the tree structure, and the product to which the bill belongs is product A.
[0184] The account to which the bill belongs is the root account of the tree structure, and the product to which the bill belongs is not product A.
[0185] The account to which the bill belongs is the root account of the tree structure, the product to which the bill belongs is product A, and the resource usage region of the bill is Beijing.
[0186] The account to which the bill belongs is the root account of the tree structure, the product to which the bill belongs is product A, and the resource usage region of the bill is not Beijing.
[0187] The account to which the bill belongs is not the root account of the tree structure, and the product to which the bill belongs is product A.
[0188] The account to which the bill belongs is not the root account of the tree structure, and the product to which the bill belongs is not product A.
[0189] The account to which the bill belongs is not the root account of the tree structure, the product to which the bill belongs is not product A, and the resource usage region of the bill is Beijing.
[0190] The account to which the bill belongs is not the root account of the tree structure, the product to which the bill belongs is not product A, and the resource usage region of the bill is not Beijing.
[0191] like Figure 6 As shown, node 1 indicates that the account to which the bill belongs is the root account of the tree structure.
[0192] Node 2 indicates that the account to which the bill belongs is not the root account of the tree structure.
[0193] Node 3 indicates that the account to which the bill belongs is the root account of the tree structure, and the product to which the bill belongs is product A.
[0194] Node 4 indicates that the account to which the bill belongs is the root account of the tree structure, and the product to which the bill belongs is not product A.
[0195] Node 5 indicates that the account to which the bill belongs is not the root account of the tree structure, and the product to which the bill belongs is product A.
[0196] Node 6 indicates that the account to which the bill belongs is not the root account of the tree structure, and the product to which the bill belongs is not product A.
[0197] Node 7 indicates that the account to which the bill belongs is the root account of the tree structure, the product to which the bill belongs is product A, and the resource usage area of the bill is Beijing.
[0198] Node 8 indicates that the account to which the bill belongs is the root account of the tree structure, the product to which the bill belongs is product A, and the resource usage area of the bill is not Beijing.
[0199] Node 9 indicates that the account to which the bill belongs is not the root account of the tree structure, the product to which the bill belongs is not product A, and the resource usage area of the bill is Beijing.
[0200] Node 10 indicates that the account to which the bill belongs is not the root account of the tree structure, the product to which the bill belongs is not product A, and the resource usage area of the bill is not Beijing.
[0201] Afterwards, multiple resource packages are obtained, and for each bill to be processed, if there is no leaf node representing a value combination of the second preset attribute of the bill to be processed in the rule tree, a branch is added to the rule tree, the branch includes at least one node, and the leaf node of the branch represents a value combination of the second preset attribute of the bill to be processed, for example Figure 6 The leaf node of the newly added branch is node 11. And sorting the multiple resource packages based on the pending bill, adding the sorting result to the leaf node, and taking the sorting result as the target sorting result.
[0202] If there is a leaf node in the rule tree that represents the value combination of the second preset attribute of the bill to be processed, the sorting result is obtained from the leaf node as the target sorting result.
[0203] Then, according to the target sorting result, based on the resource usage included in the first bill, the resource amounts included in the resource package are deducted in sequence.
[0204] In the conventional method, for bills of billions, multiple resource packages are searched for each bill and the found resource packages are sorted. The overall time complexity O is:
[0205]
[0206] in, Indicates the time consumed to search for resource packages based on each bill. Indicates the time it takes to sort resource bundles based on each bill in a quick sort manner. Indicates the number of resource packages found. , then the time to sort resource packages based on each bill is .generally , then the total time consumed for sorting resource packages based on each bill is .
[0207] The embodiment of the present disclosure does not need to search for a resource package for each bill, which reduces the number of searches, and filters resource packages based on the attribute values of the bill, which significantly reduces the acquisition of resource packages that cannot be used to offset bills, that is, reduces the number of resource packages searched. Therefore, the embodiment of the present disclosure reduces the time complexity of searching for resource packages.
[0208] On the other hand, since the embodiment of the present disclosure reduces the number of resource packages found, the number of resource packages targeted during sorting is reduced. Moreover, the embodiment of the present disclosure does not need to sort the resource packages once for each bill, that is, the number of sorting times is reduced. Therefore, the embodiment of the present disclosure reduces the time complexity of sorting the resource packages.
[0209] In the technical solution disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of the attribute information of the bills and resource packages involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0210] It should be noted that the bill information in the embodiment of the present disclosure cannot reflect the personal information of a specific user. The bill and resource package in the embodiment of the present disclosure may come from a public data set.
[0211] Based on the same inventive concept, corresponding to the above method embodiment, the embodiment of the present disclosure also provides a deduction device for a resource package, such as Figure 7 As shown, the device includes: an acquisition module 701, a determination module 702, a sorting module 703 and a deduction module 704;
[0212] The acquisition module 701 is used to acquire multiple resource packages;
[0213] A determination module 702 is used to determine, for the first resource data, whether there is a sorting result of multiple resource packages based on the second resource data, the first attribute value of the second resource data is the same as the first attribute value of the first resource data, and the first attribute value is an attribute value of a first preset attribute;
[0214] The acquisition module 701 is further used to acquire the sorting result as the target sorting result if the determination result of the determination module 702 is yes;
[0215] The sorting module 703 is used to sort the multiple resource packages based on the first resource data to obtain a target sorting result if the determination result of the determination module 702 is no;
[0216] The deduction module 704 is used to deduct the resource amount included in the resource package in turn based on the resource usage amount included in the first resource data according to the target sorting result obtained by the acquisition module 701 or obtained by the sorting module 703.
[0217] In some embodiments of the present disclosure, the sorting module 703 is specifically used to:
[0218] Based on the first attribute value of the first resource data, determining whether the first resource data satisfies a preset special sorting rule between attributes;
[0219] If so, obtain the special priority between attributes corresponding to the special sorting rule between attributes to obtain the priority between attributes to be executed;
[0220] If not, then obtain the preset inter-attribute general priority to obtain the inter-attribute priority to be executed, wherein the inter-attribute special priority and the inter-attribute general priority both represent the sorting priority of each first preset attribute;
[0221] Sort the resource packages according to the priority of the attributes to be executed.
[0222] In some embodiments of the present disclosure, the sorting module 703 is specifically used to:
[0223] For each two resource packs to be compared in each resource pack, perform the following steps:
[0224] According to the priority between the attributes to be executed, for the first first preset attribute, determining whether the attribute values of the first preset attributes of the two resource packages are the same;
[0225] If they are the same, then according to the priority between the attributes to be executed, for the next first preset attribute, return to the step of determining whether the attribute values of the first preset attributes of the two resource packages are the same;
[0226] If they are different, determining whether the attribute value of the first preset attribute of the first resource data satisfies the preset special sorting rule within the attribute corresponding to the first preset attribute;
[0227] If it is satisfied, obtain the special priority in the attribute corresponding to the special sorting rule in the attribute as the priority in the attribute to be executed;
[0228] If not, obtain the general priority within the attribute corresponding to the first preset attribute as the priority within the attribute to be executed, wherein the special priority within the attribute and the general priority within the attribute both represent the sorting priority of each attribute value of the first preset attribute;
[0229] The two resource packages are sorted according to the priority within the attributes to be executed and based on the attribute values of the first preset attributes of the two resource packages.
[0230] In some embodiments of the present disclosure, the device further comprises:
[0231] A verification module, used for verifying whether the resource package matches the first resource data based on the second attribute value of the resource package and the second attribute value of the first resource data before deducting the resource amount included in the resource package in turn based on the resource usage amount included in the first resource data according to the target sorting result, and the second attribute value is the attribute value of the second preset attribute;
[0232] A screening module, used to screen out resource packages matching the first resource data;
[0233] The deduction module 704 is specifically used for:
[0234] According to the target sorting results, based on the resource usage, the resource amounts included in the filtered resource packages are deducted in turn.
[0235] In some embodiments of the present disclosure, the verification module is specifically used to:
[0236] respectively determining matching attribute values that match each second attribute value of the first resource data;
[0237] Verify whether all second attribute values of the resource package are matching attribute values;
[0238] If the verification results are all yes, it is determined that the resource package matches the first resource data;
[0239] If any of the verification results is negative, it is determined that the resource package does not match the first resource data.
[0240] In some embodiments of the present disclosure, the deduction module 704 is specifically used to:
[0241] According to the target sorting result, for the first resource package selected, determine whether the amount of resources included in the resource package is greater than or equal to the remaining resource usage, and the initial value of the remaining resource usage is the resource usage;
[0242] If yes, the remaining resource usage is deducted from the resource amount included in the resource package;
[0243] If not, the amount of resources included in the resource package is deducted to zero, the amount of resources included in the resource package is deducted from the remaining resource usage, and according to the target sorting result, for the next resource package filtered out, return to the step of determining whether the amount of resources included in the resource package is greater than or equal to the remaining resource usage.
[0244] In some embodiments of the present disclosure, the acquisition module 701 is specifically used to:
[0245] Acquire multiple candidate resource packages and multiple resource data to be processed, where the multiple resource data to be processed include first resource data and second resource data;
[0246] Determine the target attribute value that matches the second attribute value of each resource data to be processed, respectively, the second attribute value being the attribute value of the second preset attribute;
[0247] Candidate resource bundles having any target attribute value are screened to obtain multiple resource bundles.
[0248] In some embodiments of the present disclosure, the device further comprises:
[0249] A deduplication module, used for deduplicating target attribute values belonging to the same second preset attribute before screening candidate resource packages having any target attribute value, to obtain multiple target attribute value sets;
[0250] The acquisition module 701 is specifically used for:
[0251] The candidate resource packages whose second attribute values belong to a target attribute value set are screened.
[0252] In some embodiments of the present disclosure, the acquisition module 701 is specifically used to:
[0253] Based on each target attribute value set, a database query statement is generated, where the database query statement is used to find a candidate resource package whose second attribute values belong to a target attribute value set respectively;
[0254] A database query statement is executed in the database to obtain multiple candidate resource packages. The database stores multiple candidate resource packages.
[0255] In some embodiments of the present disclosure, the determination module 702 is further configured to:
[0256] Before respectively determining the target attribute value that matches the second attribute value of each resource data to be processed, determining whether the resource usage time of the resource data to be processed is within a statistical period, where the statistical period indicates a period in which resource packages are not deducted;
[0257] Filter out the pending resource data whose resource usage time is not within the statistical period.
[0258] In some embodiments of the present disclosure, the first preset attribute includes at least one of the following: an account, a product, a resource usage area, a statistical item, a statistical method, and a commodity within the product.
[0259] In some embodiments of the present disclosure, the second preset attribute includes at least one of the following: the account, the product, the resource usage area, the statistical item, the statistical method, the resource providing device, the goods in the product and the resource usage time.
[0260] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0261] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0262] like Figure 8 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 to a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0263] Multiple components in the electronic device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0264] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as a method for deducting resource packages. For example, in some embodiments, the method for deducting resource packages may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the method for deducting resource packages described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to execute the deduction method for the resource package in any other appropriate manner (eg, by means of firmware).
[0265] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0266] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0267] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0268] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0269] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0270] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0271] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0272] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for deducting a resource package, comprising: Get multiple resource packs; For the first resource data, determining whether there is a sorting result of the plurality of resource packages based on the second resource data, wherein a first attribute value of the second resource data is the same as a first attribute value of the first resource data, and the first attribute value is an attribute value of a first preset attribute; If yes, then obtain the sorting result as the target sorting result; If not, sorting the multiple resource packages based on the first resource data to obtain a target sorting result; According to the target sorting result, based on the resource usage included in the first resource data, the resource amount included in the resource package is deducted in sequence.
2. The method according to claim 1, wherein: The step of sorting the plurality of resource packages based on the first resource data includes: Based on the first attribute value of the first resource data, determining whether the first resource data satisfies a preset special sorting rule between attributes; If so, obtain the inter-attribute special priority corresponding to the inter-attribute special sorting rule to obtain the inter-attribute priority to be executed; If not, then obtaining a preset inter-attribute general priority to obtain an inter-attribute priority to be executed, wherein the inter-attribute special priority and the inter-attribute general priority both represent the sorting priority of each first preset attribute; The resource packages are sorted according to the priorities among the attributes to be executed.
3. The method according to claim 2, wherein: The sorting of the resource packages according to the priority of the attributes to be executed includes: For each two resource packs to be compared in each resource pack, perform the following steps: According to the priority between the attributes to be executed, for a first first preset attribute, determining whether the attribute values of the first preset attribute of the two resource packages are the same; If they are the same, then according to the priority between the attributes to be executed, for the next first preset attribute, returning to the step of determining whether the attribute values of the first preset attributes of the two resource packages are the same; If they are different, determining whether the attribute value of the first preset attribute of the first resource data satisfies the preset special sorting rule within the attribute corresponding to the first preset attribute; If satisfied, obtain the special priority level in the attribute corresponding to the special sorting rule in the attribute as the priority level in the attribute to be executed; If not, obtaining the general priority within the attribute corresponding to the first preset attribute as the priority within the attribute to be executed, wherein the special priority within the attribute and the general priority within the attribute both represent the sorting priority of each attribute value of the first preset attribute; The two resource packages are sorted according to the priority within the to-be-executed attribute and based on the attribute values of the first preset attribute of the two resource packages.
4. The method according to any one of claims 1 to 3, before deducting the resource amount included in the resource package in sequence based on the resource usage amount included in the first resource data according to the target sorting result, further comprising: Verify whether the resource package matches the first resource data based on a second attribute value of the resource package and a second attribute value of the first resource data, wherein the second attribute value is an attribute value of a second preset attribute; Filtering out resource packages matching the first resource data; The step of sequentially deducting the resource amounts included in the resource package based on the resource usage amounts included in the first resource data according to the target sorting result includes: According to the target sorting result and based on the resource usage, the resource amounts included in the filtered resource packages are deducted in sequence.
5. The method according to claim 4, wherein: The verifying whether the resource package matches the first resource data based on the second attribute value of the resource package and the second attribute value of the first resource data includes: respectively determining matching attribute values that match each second attribute value of the first resource data; Verifying whether each second attribute value of the resource package belongs to the matching attribute value; If the verification results are all yes, it is determined that the resource package matches the first resource data; If any verification result is negative, it is determined that the resource package does not match the first resource data.
6. The method according to claim 4 or 5, wherein: The step of deducting the resource amounts included in the filtered resource packages in sequence according to the target sorting result and based on the resource usage includes: According to the target sorting result, for the first resource package screened out, determine whether the amount of resources included in the resource package is greater than or equal to the remaining resource usage, where the initial value of the remaining resource usage is the resource usage; If yes, deducting the remaining resource usage from the resource amount included in the resource package; If not, the amount of resources included in the resource package is deducted to zero, the amount of resources included in the resource package is deducted from the remaining resource usage, and according to the target sorting result, for the next resource package screened out, return to the step of determining whether the amount of resources included in the resource package is greater than or equal to the remaining resource usage.
7. The method according to any one of claims 1 to 6, wherein: The obtaining of multiple resource packages includes: Acquire multiple candidate resource packages and multiple resource data to be processed, wherein the multiple resource data to be processed include the first resource data and the second resource data; Determine a target attribute value that matches a second attribute value of each to-be-processed resource data, wherein the second attribute value is an attribute value of a second preset attribute; The candidate resource bundles having any target attribute value are screened to obtain the multiple resource bundles.
8. The method according to claim 7, before screening the candidate resource packages having any target attribute value, further comprises: Deduplication is performed on target attribute values belonging to the same second preset attribute to obtain multiple target attribute value sets; The screening of candidate resource packages having any target attribute value includes: The candidate resource packages whose second attribute values belong to a target attribute value set are screened.
9. The method according to claim 8, wherein: The screening of candidate resource packages whose second attribute values respectively belong to a target attribute value set includes: Based on each target attribute value set, generating a database query statement, wherein the database query statement is used to find a candidate resource package whose second attribute values belong to a target attribute value set respectively; The database query statement is executed in the database to obtain multiple candidate resource packages that are queried, and the database stores the multiple candidate resource packages.
10. The method according to any one of claims 7 to 9, before respectively determining the target attribute value that matches the second attribute value of each to-be-processed resource data, further comprising: Determine whether the resource usage time of the resource data to be processed is within a statistical period, where the statistical period indicates a period during which resource packages are not deducted; Filter out the pending resource data whose resource usage time is not within the statistical period.
11. The method according to any one of claims 1 to 10, wherein: The first preset attribute includes at least one of the following: an account, a product, a resource usage area, a statistical item, a statistical method, and a commodity within the product.
12. According to the method described in any one of claims 4-10, the second preset attribute includes at least one of the following: the account to which it belongs, the product to which it belongs, the resource usage area, the statistical item, the statistical method, the resource providing device, the goods in the product to which it belongs, and the resource usage time.
13. A device for deducting resource packages, comprising: Acquisition module, used to obtain multiple resource packages; a determination module, configured to determine, for the first resource data, whether there is a sorting result of the plurality of resource packages based on the second resource data, wherein the first attribute value of the second resource data is the same as the first attribute value of the first resource data, and the first attribute value is an attribute value of a first preset attribute; The acquisition module is further configured to acquire the sorting result as a target sorting result if the determination result of the determination module is yes; a sorting module, configured to sort the plurality of resource packages based on the first resource data to obtain a target sorting result if the determination result of the determination module is no; A deduction module is used to deduct the amount of resources included in the resource package in turn based on the resource usage included in the first resource data according to the target sorting result obtained by the acquisition module or obtained by the sorting module.
14. The device according to claim 13, wherein: The sorting module is specifically used for: Based on the first attribute value of the first resource data, determining whether the first resource data satisfies a preset special sorting rule between attributes; If so, obtain the inter-attribute special priority corresponding to the inter-attribute special sorting rule to obtain the inter-attribute priority to be executed; If not, then obtaining a preset inter-attribute general priority to obtain an inter-attribute priority to be executed, wherein the inter-attribute special priority and the inter-attribute general priority both represent the sorting priority of each first preset attribute; The resource packages are sorted according to the priorities among the attributes to be executed.
15. The device according to claim 14, wherein: The sorting module is specifically used for: For each two resource packs to be compared in each resource pack, perform the following steps: According to the priority between the attributes to be executed, for a first first preset attribute, determining whether the attribute values of the first preset attribute of the two resource packages are the same; If they are the same, then according to the priority between the attributes to be executed, for the next first preset attribute, returning to the step of determining whether the attribute values of the first preset attributes of the two resource packages are the same; If they are different, determining whether the attribute value of the first preset attribute of the first resource data satisfies the preset special sorting rule within the attribute corresponding to the first preset attribute; If satisfied, obtain the special priority level in the attribute corresponding to the special sorting rule in the attribute as the priority level in the attribute to be executed; If not, obtaining the general priority within the attribute corresponding to the first preset attribute as the priority within the attribute to be executed, wherein the special priority within the attribute and the general priority within the attribute both represent the sorting priority of each attribute value of the first preset attribute; The two resource packages are sorted according to the priority within the to-be-executed attribute and based on the attribute values of the first preset attribute of the two resource packages.
16. The device according to any one of claims 13 to 15, further comprising: a verification module, configured to verify whether the resource package matches the first resource data based on a second attribute value of the resource package and a second attribute value of the first resource data before deducting the resource amount included in the resource package in sequence based on the resource usage amount included in the first resource data according to the result of sorting according to the target, wherein the second attribute value is an attribute value of a second preset attribute; A screening module, used to screen out resource packages matching the first resource data; The deduction module is specifically used for: According to the target sorting result and based on the resource usage, the resource amounts included in the filtered resource packages are deducted in sequence.
17. The device according to claim 16, wherein: The verification module is specifically used for: respectively determining matching attribute values that match each second attribute value of the first resource data; Verifying whether each second attribute value of the resource package belongs to the matching attribute value; If the verification results are all yes, it is determined that the resource package matches the first resource data; If any verification result is negative, it is determined that the resource package does not match the first resource data.
18. The device according to claim 16 or 17, wherein: The deduction module is specifically used for: According to the target sorting result, for the first resource package screened out, determine whether the amount of resources included in the resource package is greater than or equal to the remaining resource usage, where the initial value of the remaining resource usage is the resource usage; If yes, deducting the remaining resource usage from the resource amount included in the resource package; If not, the amount of resources included in the resource package is deducted to zero, the amount of resources included in the resource package is deducted from the remaining resource usage, and according to the target sorting result, for the next resource package screened out, return to the step of determining whether the amount of resources included in the resource package is greater than or equal to the remaining resource usage.
19. The device according to any one of claims 13 to 18, wherein: The acquisition module is specifically used for: Acquire multiple candidate resource packages and multiple resource data to be processed, wherein the multiple resource data to be processed include the first resource data and the second resource data; Determine a target attribute value that matches a second attribute value of each to-be-processed resource data, wherein the second attribute value is an attribute value of a second preset attribute; The candidate resource bundles having any target attribute value are screened to obtain the multiple resource bundles.
20. The apparatus according to claim 19, further comprising: a deduplication module, configured to, before screening the candidate resource packages having any target attribute value, deduplication each target attribute value belonging to the same second preset attribute to obtain a plurality of target attribute value sets; The acquisition module is specifically used for: The candidate resource packages whose second attribute values belong to a target attribute value set are screened.
21. The device according to claim 20, wherein: The acquisition module is specifically used for: Based on each target attribute value set, generating a database query statement, wherein the database query statement is used to find a candidate resource package whose second attribute values belong to a target attribute value set respectively; The database query statement is executed in the database to obtain multiple candidate resource packages that are queried, and the database stores the multiple candidate resource packages.
22. The apparatus according to any one of claims 19 to 21, wherein the determining module is further configured to: Before respectively determining the target attribute value that matches the second attribute value of each resource data to be processed, determining whether the resource usage time of the resource data to be processed is within a statistical period, wherein the statistical period indicates a period in which resource packages are not deducted; Filter out the pending resource data whose resource usage time is not within the statistical period.
23. The device according to any one of claims 13 to 22, wherein: The first preset attribute includes at least one of the following: an account, a product, a resource usage area, a statistical item, a statistical method, and a commodity within the product.
24. According to the device according to any one of claims 16-22, the second preset attribute includes at least one of the following: the account to which it belongs, the product to which it belongs, the resource usage area, the statistical item, the statistical method, the resource providing device, the goods in the product to which it belongs, and the resource usage time.
25. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 12.
26. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-12.
27. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Commodity recommendation method and device, electronic equipment and storage medium
CN110458650A
Multi-energy settlement method suitable for microgrid
CN110555688A
Multi-account cloud service consumption packet sharing method and device and related equipment
CN111162921A
Virtual resource regulation and control method and device, computer equipment and storage medium
CN112100204A
Statistical method and device for network resource consumption and server
CN113037512A