CN111177169B - Charging method, electronic device and storage medium - Google Patents

Charging method, electronic device and storage medium Download PDF

Info

Publication number
CN111177169B
CN111177169B CN201911396783.9A CN201911396783A CN111177169B CN 111177169 B CN111177169 B CN 111177169B CN 201911396783 A CN201911396783 A CN 201911396783A CN 111177169 B CN111177169 B CN 111177169B
Authority
CN
China
Prior art keywords
pricing
resource
list
information
charging
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911396783.9A
Other languages
Chinese (zh)
Other versions
CN111177169A (en
Inventor
童启铭
邱鹏庆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Wangsu Co Ltd
Original Assignee
Xiamen Wangsu Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiamen Wangsu Co Ltd filed Critical Xiamen Wangsu Co Ltd
Priority to CN201911396783.9A priority Critical patent/CN111177169B/en
Publication of CN111177169A publication Critical patent/CN111177169A/en
Application granted granted Critical
Publication of CN111177169B publication Critical patent/CN111177169B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0201Market modelling; Market analysis; Collecting market data
    • G06Q30/0206Price or cost determination based on market factors

Abstract

The embodiment of the invention relates to the field of data processing, and discloses a charging method, electronic equipment and a storage medium. In some embodiments of the present application, a charging method is applied to a charging system, and includes the following steps: searching a pricing list of the resources in a memory according to the identification information of the resources; the pricing list of the resources comprises pricing tree structure data of the resources, and the pricing tree structure data of the resources are determined according to pricing information of the resources in the first database; and determining the pricing of the resource according to the pricing list of the resource. In the embodiment, the charging speed is improved.

Description

Charging method, electronic device and storage medium
Technical Field
The embodiment of the invention relates to the field of internet, in particular to a charging method, electronic equipment and a storage medium.
Background
At present, in the charging process of cloud computing, various commodities related to the cloud computing are often priced through a charging system, and the specific consumption amount of a client is calculated, so that the labor cost is reduced, and the charging speed is increased.
However, the inventors found that at least the following problems exist in the prior art: the current charging mode can not meet the requirement of quick charging.
Disclosure of Invention
An object of embodiments of the present invention is to provide a charging method, an electronic device, and a storage medium, so that charging efficiency is improved.
In order to solve the above technical problem, an embodiment of the present invention provides a charging method, which is applied to a charging system, and includes the following steps: searching a pricing list of the resources in a memory according to the identification information of the resources; the pricing list of the resource comprises pricing tree structure data of the resource, and the pricing tree structure data of the resource is determined according to pricing information of the resource in the first database; and determining the pricing of the resource according to the pricing list of the resource.
An embodiment of the present invention also provides an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executable by the at least one processor to enable the at least one processor to perform the charging method as set forth in the above embodiments.
Embodiments of the present invention also provide a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the charging method mentioned in the above embodiments.
Compared with the prior art, the pricing information of the resources is stored in the memory in the form of the pricing tree structure, so that the charging system can inquire the pricing of the resources from the memory preferentially, the pricing information can be inquired without structural processing, the pricing reading speed is greatly improved, the pricing reading time in the charging process is reduced, and the charging efficiency is improved.
In addition, according to the identification information of the resource, searching a pricing list of the resource in the memory specifically includes: judging whether a pricing list of the resources exists in the memory or not according to the identification information of the resources; if the pricing list of the resources does not exist, reading the pricing information of the resources from the first database, and determining the pricing list of the resources according to the reading result; a pricing list of the resource is stored in the memory. In this embodiment, a data base is provided for increasing the pricing speed of the resource to be queried next.
In addition, if the pricing list of the resource is determined according to the reading result, the charging method further comprises the following steps: if the reading result indicates that the pricing information of the resources exists in the first database, generating a pricing list of the resources according to the read pricing information of the resources; and if the reading result indicates that the pricing information of the resource does not exist in the first database, creating a pricing list of the resource with empty content. In this embodiment, it is avoided that repeatedly querying pricing of non-charged resources results in a computational load on the first database.
In addition, the charging system is also provided with a second database, the second database is used for caching a time list of pricing information of the resources and/or an identifier of the pricing information of the resources, and the time list comprises the updating time of the pricing information; the pricing list of the resource stores the updating time of the pricing list of the resource, and the identification of the pricing list of the resource is the same as the identification of the pricing information corresponding to the pricing list of the resource; determining pricing of the resource according to the pricing list of the resource specifically comprises: judging whether a pricing list of resources meets a preset condition or not; the preset condition comprises that the updating time of the pricing list of the resource is equal to or later than the updating time of the pricing information of the resource stored in the second database, and/or the identification of the pricing list of the resource is consistent with the identification of the pricing information of the resource stored in the second database; if yes, inquiring pricing tree structure data of the resources to obtain pricing of the resources; if not, reading pricing information of the resources from the first database; generating new pricing tree structure data in a new pricing list of the resources according to the acquired pricing information of the resources, and storing the new pricing tree structure data in a memory; and inquiring new pricing tree structure data to obtain pricing of resources. In the embodiment, the effectiveness of the pricing list of the resource is judged, so that the overdue pricing list can be updated, and the accuracy of the queried pricing of the resource is improved.
In addition, after determining that the pricing information of the resource in the first database is updated, the information storing method further includes: acquiring the update time of new pricing information of the resource; sending the updating information to a second database through a message queue; the update information includes an update time of the new pricing information and/or an identification of the new pricing information for the resource.
In addition, before reading the pricing information of the resource from the first database, the charging method further comprises: all pricing lists for resources in memory are locked. In this embodiment, the problem of repeated reading and updating of pricing caused by multiple threads can be avoided.
In addition, N pricing lists of resources are stored in the memory, the pricing lists of the resources also comprise effective time and ineffective time of the pricing lists of the resources, and N is a positive integer; the time list of pricing information of the resource further comprises an effective time and an ineffective time of the pricing information of the resource; before judging whether the pricing list of the resources meets the preset conditions, the charging method further comprises the following steps: determining a pricing list of the resources corresponding to the query time according to the query time and the effective time and the ineffective time of the pricing list of each resource; and determining a time list corresponding to the query time according to the query time and the effective time and the ineffective time of the pricing information of each resource.
In addition, any one or any combination of a basic charging model, a step charging model, a discount charging model and a logic charging model is stored in the charging system; before searching the pricing list of the resource in the memory according to the identification information of the resource, the charging method further comprises the following steps: determining a charging model for the resource; determining the value of a parameter in a charging model of a resource; and determining pricing information of the resources according to the charging model of the resources and the determined parameter values, and storing the pricing information of the resources in a first database. In the embodiment, the flexibility and the efficiency of charging are improved.
In addition, the pricing tree structure data of the resource comprises a pricing tree of the resource, a root node of the pricing tree of the resource is identification information of the resource, and the types of nodes except the root node in the pricing tree of the resource comprise any one or any combination of a simple pricing type, a discount pricing type and a logic pricing type; wherein, the nodes belonging to the simple pricing type are leaf nodes; the node belonging to the discount pricing type has child nodes, and the type of the bottommost child node of the node belonging to the discount pricing type is a simple pricing type; the node belonging to the logic pricing type has child nodes, and the type of the lowest child node of the node belonging to the logic pricing type is a simple pricing type; the node belonging to the simple pricing type stores price information of resources, the node belonging to the discount pricing type stores discount information, and the node belonging to the logic pricing type stores condition information of each sub-node of the node.
In addition, the type of the child node of the node belonging to the discounted pricing type includes any one or any combination of the simple pricing type, the discounted pricing type, and the logical pricing type; the types of child nodes belonging to a node of the logical pricing type include any one or any combination of a simple pricing type, a discounted pricing type, and a logical pricing type.
Drawings
One or more embodiments are illustrated by way of example in the accompanying drawings, which correspond to the figures in which like reference numerals refer to similar elements and which are not to scale unless otherwise specified.
Fig. 1 is a flowchart of a charging method according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of a pricing tree according to a first embodiment of the invention;
FIG. 3 is a schematic diagram of a data structure in Redis according to a first embodiment of the present invention;
FIG. 4 is a diagram illustrating a structure of cached data in a memory according to a first embodiment of the present invention;
fig. 5 is a flowchart of a charging method according to a second embodiment of the present invention;
fig. 6 is a schematic structural diagram of a charging apparatus according to a third embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, it will be appreciated by those of ordinary skill in the art that numerous technical details are set forth in order to provide a better understanding of the present application in various embodiments of the present invention. However, the technical solution claimed in the present application can be implemented without these technical details and various changes and modifications based on the following embodiments.
Unless the context clearly requires otherwise, throughout the description and the claims, the words "comprise", "comprising", and the like are to be construed in an inclusive sense as opposed to an exclusive or exhaustive sense; that is, what is meant is "including, but not limited to".
In the description of the present disclosure, it is to be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In addition, in the description of the present disclosure, "a plurality" means two or more unless otherwise specified.
The first embodiment of the invention relates to a charging method, which is applied to a charging system, for example, a charging system for calculating consumption of each commodity in the field of cloud computing. As shown in fig. 1, the charging method includes:
step 101: and searching a pricing list of the resources in the memory according to the identification information of the resources.
Specifically, the pricing list for the resource includes pricing tree data for the resource, the pricing tree data for the resource being determined based on pricing information for the resource in the first database. Wherein the identification information of the resource may be an ID of the resource.
It should be noted that, as can be understood by those skilled in the art, the resource may be various goods, and the embodiment does not limit the type of the resource.
It is worth mentioning that the tree structure obtained by structuring the pricing information in the first database is stored in the memory, and when the pricing information is queried, the structured processing of the pricing information is not needed, so that the reading speed of the pricing is greatly accelerated.
In one embodiment, the process for the charging system to obtain the pricing list of the resource includes: judging whether a pricing list of the resources exists in the memory or not according to the identification information of the resources; if the pricing list of the resources does not exist, reading the pricing information of the resources from the first database, and determining the pricing list of the resources according to the reading result; a pricing list of the resource is stored in the memory.
It is worth mentioning that under the condition that the pricing list of the resources does not exist in the memory, the data of the memory is updated in time according to the pricing information of the resources in the first database, and a data basis is provided for improving the pricing speed of the resources to be inquired next time.
It should be noted that, in practical applications, the charging system may periodically read the pricing information of the resource in the first database, and update the pricing list of the resource in the memory, or may read the pricing information of the resource in the first database and update the pricing list of the resource in the memory when the trigger condition is satisfied. The trigger condition may be that an update instruction is received, or the number of times of error reporting is greater than a preset value, and the embodiment is not limited.
In one embodiment, the pricing tree structure data of the resource comprises a pricing tree of the resource, a root node of the pricing tree of the resource is identification information of the resource, and the types of nodes except the root node in the pricing tree of the resource comprise any one or any combination of a simple pricing type, a discount pricing type and a logic pricing type; wherein, the nodes belonging to the simple pricing type are leaf nodes; the node belonging to the discount pricing type has child nodes, and the type of the bottommost child node of the node belonging to the discount pricing type is a simple pricing type; the node belonging to the logic pricing type has child nodes, and the type of the lowest child node of the node belonging to the logic pricing type is a simple pricing type; the node belonging to the simple pricing type stores price information of resources, the node belonging to the discount pricing type stores discount information, and the node belonging to the logic pricing type stores condition information of each sub-node of the node. Wherein, a leaf node refers to a node in which no child node exists in the pricing tree.
In one embodiment, the types of child nodes of the node belonging to the discounted pricing type include any one or any combination of the simple pricing type, the discounted pricing type, and the logical pricing type; the types of child nodes belonging to a node of the logical pricing type include any one or any combination of a simple pricing type, a discounted pricing type, and a logical pricing type.
Specifically, the first database stores pricing information corresponding to various contracts of resources, and before the charging method according to the present embodiment is not used, pricing trees of the resources need to be generated for each contract. By directly solidifying pricing of resources, the contract can use discount coefficients to quote solidified pricing to form new pricing (such as quote a basic charging model or a step charging model in a discount charging model) or use conditions to quote solidified pricing to form new pricing (such as quote the basic charging model or the step charging model in a logic charging model), so that redundant storage of data in a database is simplified, and flexible application of services is facilitated. The generation of the pricing tree needs to fetch data from a database and generate the pricing tree, and different orders contain discount coefficients or other preferential terms; therefore, different orders generate different bills for the same commodity; in the embodiment, all pricing possibly existing corresponding to the service is combined into a pricing tree by solidifying the pricing tree, and the pricing tree is cached in a memory; when bills are generated for the service by different orders, the bills can be generated quickly only by calling the solidified pricing tree.
For example, the resulting pricing tree structure is shown in FIG. 2 based on all pricing information for a resource. The root node of the pricing tree for the resource is the identification information for the resource. The child nodes of the identification information of the resource include a node 1 belonging to a simple pricing type, a node 2 belonging to a discount pricing type, and a node 3 belonging to a logical pricing type. The node 1 belonging to the simple pricing type defines the price at which the customer consumes the resource, such as unit rate and flat rate required for charging, in the case where the judgment condition of the path in which the node 1 is located is satisfied. The node 2 belonging to the discount pricing type defines a discount for the discount to be enjoyed when the customer consumes the resource, in the case where the judgment condition of the path in which the node 1 is located is satisfied. Since the sub-nodes of the node 2 include the node 21 belonging to the logical pricing type, the node 22 belonging to the simple pricing type, and the node 23 belonging to the discount pricing type, alternatively, the selection conditions corresponding to the respective sub-nodes may also be included in the node 2. The node 21 defines condition information of child nodes (the node 211 belonging to the simple pricing type and the node 212 belonging to the simple pricing type), that is, selection conditions corresponding to the respective child nodes. Like node 1, node 22 directly defines the price of the resource. Like node 2, node 23 directly defines the discount enjoyed by the customer. The children of node 23 may include a node 231 that is of a simple pricing type and a node 232 that is of a logical pricing type. The children of the node 232 include a node 2321 that is of a discount pricing type, a node 2322 that is of a logical pricing type, and a node 2323 that is of a simple pricing type. The children of node 2321 include node 23211, which is of the simple pricing type, and node 23212, which is of the simple pricing type. The children of node 2322 include node 23221 which is of the simple pricing type and node 23222 which is of the simple pricing type. The child nodes of node 3 include a node 31 belonging to the simple pricing type, a node 32 belonging to the discount pricing type, a node 33 belonging to the logical pricing type, and a node 34 belonging to the simple pricing type. The children of node 32 include node 321, which is of the simple pricing type. The child nodes of node 33 include node 331 that is of the simple pricing type and node 332 that is of the simple pricing type. As can be seen from fig. 2, in this embodiment, the pricing information of the resource may include pricing information obtained based on a simple pricing method, such as pricing information obtained through a basic charging model or a tiered charging model, corresponding to a path in a pricing tree: root node → node 1, or pricing information obtained based on a complex pricing method, such as pricing information obtained by a discount charging model, corresponding to a path in a pricing tree: root node → node 2 → node 22, or pricing information obtained through the logical charging model, corresponds to the path in the pricing tree: root node → node 3 → node 31, root node → node 3 → node 32, root node → node 3 → node 33 and root node → node 3 → node 34, it can also be pricing information based on a combined pricing means, such as pricing information obtained by combining a discount charging model and a logical charging model, corresponding to a path in a pricing tree: root node → node 2 → node 21 → node 211 and root node → node 2 → node 21 → node 212; or, the pricing information obtained by combining the discount charging model and the discount charging model corresponds to the path in the pricing tree: root node → node 2 → node 23 → node 231; or, the pricing information obtained by combining the logic charging model and the discount charging model corresponds to the path in the pricing tree: root node → node 3 → node 32 → node 321; or, the pricing information obtained by combining the logic charging model and the logic charging model corresponds to the path in the pricing tree: root node → node 3 → node 33 → node 331 and root node → node 3 → node 33 → node 332. Other combinations are not listed here. As can be seen from FIG. 2, the lowest level child nodes are all nodes that are of the simple pricing type, and the child nodes that are of the discounted pricing type (e.g., node 2) can be nodes of the simple pricing type (e.g., node 22), nodes of the logical pricing type (e.g., node 21), and nodes of the logical pricing type (e.g., node 23). The children of a node that belongs to a logical pricing type (e.g., node 232) may be a node that belongs to a simple pricing type (e.g., node 2323), a node that belongs to a logical pricing type (e.g., node 2322), and a node that belongs to a logical pricing type (e.g., node 2321).
It should be noted that, in practical applications, the types of the node belonging to the discounted pricing type and the sub-node of the node belonging to the logical pricing type are determined according to the pricing information determined based on the contract of the resource, and this embodiment is only for illustration, and in the actually generated pricing tree, the types of the node belonging to the discounted pricing type and the sub-node of the node belonging to the logical pricing type may include the node belonging to the simple pricing type, the node belonging to the logical pricing type and the node belonging to the logical pricing type at the same time, or may include any one or both of them.
In one embodiment, the billing system locks all pricing listings for the resource in memory before reading pricing information for the resource from the first database.
In one example, the billing system may lock all pricing listings for the resource before determining whether the pricing listings for the resource meet the preset conditions.
It is worth mentioning that locking the pricing list can avoid the problem of repeated reading and updating of pricing caused by multithreading.
In one embodiment, in the process that the charging system determines the pricing list of the resource according to the reading result, if the reading result indicates that the pricing information of the resource exists in the first database, the pricing list of the resource is generated according to the read pricing information of the resource; and if the reading result indicates that the pricing information of the resource does not exist in the first database, creating a pricing list of the resource with empty content.
It should be noted that, when the pricing information of a certain resource does not exist in the first database, it indicates that the resource has not customized the charging plan, in this case, an empty pricing list is created for the resource, so that when the pricing information of the resource is queried next time, it can be determined that the resource is not charged at present according to the information that the list is empty, and the calculation load of the first database caused by repeatedly querying the pricing information of the resource which is not charged is avoided.
It should be noted that, as will be understood by those skilled in the art, in practical applications, resources that are not currently charged may be marked in a memory in other manners, and this embodiment is merely an example.
Step 102: and determining the pricing of the resource according to the pricing list of the resource.
Specifically, the charging system queries the pricing list according to the use condition of the resource, and determines the pricing of the resource under the use condition.
For example, the pricing list of resources indicates that if the usage area of the resource is in region a, the pricing is 100-yuan, and if the usage area of the resource is in region B, the pricing is 80-yuan. When the use area corresponding to the charging is the region A, the pricing of the resource is determined to be 100 yuan.
In one embodiment, in order to ensure that the memory stores a pricing list corresponding to the latest pricing information of the resource, the device storing the first database or another device connected to the device storing the first database may push the pricing information to each charging system in the distributed system architecture after determining that the pricing information in the first database is updated.
In one embodiment, the charging system is further provided with a second database for caching a time list of pricing information of the resource and/or an identification of the pricing information of the resource, the time list including an update time of the pricing information. The pricing list of the resource stores the updating time of the pricing list of the resource, and the identification of the pricing list of the resource is the same as the identification of the pricing information corresponding to the pricing list of the resource. The charging system adopts a form of secondary cache to cache pricing tree structure data of resources. The cache space of the first-level cache is a second database and is used for caching the updating time of the pricing information of the resources. The cache space of the second-level cache is a memory used for caching a pricing list of resources. The charging system needs to judge the effectiveness of the pricing list of resources based on the information of the pricing list of resources and the information stored in the second database. Specifically, the charging system judges whether a pricing list of the resources meets a preset condition; the preset condition comprises that the updating time of the pricing list of the resource is equal to or later than the updating time of the pricing information of the resource stored in the second database, and/or the identification of the pricing list of the resource is consistent with the identification of the pricing information of the resource stored in the second database; if yes, inquiring pricing tree structure data of the resources to obtain pricing of the resources; if not, reading pricing information of the resources from the first database; generating new pricing tree structure data in a new pricing list of the resources according to the acquired pricing information of the resources, and storing the new pricing tree structure data in a memory; and inquiring new pricing tree structure data to obtain pricing of resources.
It is worth mentioning that the effectiveness of the pricing list of the resource is judged, so that the overdue pricing list can be updated, and the accuracy of the pricing of the inquired resource is improved.
In one embodiment, N pricing lists of resources are stored in a memory, the pricing lists of the resources further include effective time and ineffective time of the pricing lists of the resources, and N is a positive integer; the time list of pricing information for the resource also includes an effective time and an ineffective time of the pricing information for the resource. Before judging whether the pricing list of the resource meets the preset condition, the charging system needs to determine the actually needed pricing list and time list. Specifically, the charging system determines the pricing list of the resource corresponding to the query time according to the query time and the effective time and the ineffective time of the pricing list of each resource. And the charging system determines a time list corresponding to the query time according to the query time and the effective time and the ineffective time of the pricing information of each resource. The query time may be order validation time or charging time, and the like, and the embodiment is not limited.
For example, pricing information 1 and pricing information 2 of two versions of a certain resource are stored in the first database, the effective time of the pricing information 1 is 9 month 2, the ineffective time is 9 month 9, the effective time of the pricing information 2 is 9 month 10, and the ineffective time is 9 month 20. By the charging method provided by the embodiment, the pricing list 1 and the pricing list 2 corresponding to the pricing information 1 are cached in the memory, the effective time of the pricing list 1 is 9 month 2, the ineffective time is 9 month 9, the effective time of the pricing list 2 is 9 month 10, and the ineffective time is 9 month 20. The second database stores a time list 1 and a time list 2 of pricing information of resources, the effective time corresponding to the time list 1 is 9 month 2, the invalid time is 9 month 9, the effective time of the time list 2 is 9 month 10, and the invalid time is 9 month 20. If the query time is 9 months and 3, the pricing list corresponding to the query time is a pricing list 1, the time list corresponding to the query time is a time list 1, and when judging whether the pricing list of the resources meets the preset conditions, judging based on the time list 1 and the pricing list 1; and if the pricing list 1 meets the preset condition, pricing is carried out based on the pricing list 1 during pricing. If the query time is 9 months and 17 th, the pricing list corresponding to the query time is a pricing list 2, the time list corresponding to the query time is a time list 2, and when judging whether the pricing list of the resources meets the preset conditions, judging based on the time list 2 and the pricing list 2; if the pricing list 2 meets the preset conditions, pricing is carried out based on the pricing list 2 during pricing.
In one embodiment, after determining that the pricing information for the resource in the first database is updated, the information storage method further comprises: acquiring the update time of new pricing information of the resource; sending the update information to a second database through a message queue; the update information includes an update time of the new pricing information and/or an identification of the new pricing information for the resource.
In one embodiment, if the billing system does not find pricing information for a resource in the first database, an empty list of the resource is generated in the second database to avoid overloading the first database due to the billing system repeatedly querying the pricing information in the first database.
In one embodiment, after determining the price of the resource, the amount of consumption by the user is determined based on the price of the resource.
The following description will be given by taking the first database as a system database and the second database as a Remote Dictionary service database (Redis) as an example, to illustrate the manner of pricing information of the secondary cache resource mentioned in this embodiment.
1. First-level caching: a temporal listing of pricing information for the resource is cached using Redis.
When the resource is added and priced or updated, the current operation time is written into the field of the 'update time' of the current operated record. And sending a message through the message queue, and saving or updating all the priced effective time, invalid time and updating time of the resource into the Redis, namely creating a time list of the pricing information of the resource in the Redis, wherein the time list comprises the updating time, the effective time and the invalid time of the pricing information. The key values in Redis take the value "identification information of resources", so that one key value in Redis corresponds to a list of priced update times for a set of different validity periods. The data structure of the Redis cache can be referred to FIG. 3. When the charging system reads the pricing of the resource, the time list of the pricing information of the resource is obtained from Redis through the identification information of the resource. And if the corresponding record is not found in the Redis, reading out all time lists of pricing information corresponding to the identification information of the resource from the system database and caching the time lists into the Redis. If no corresponding pricing information is found in the system database, an empty list with a validity period of 0 is generated by default and cached in Redis.
2. Secondary caching: and caching the structured pricing information in the memory.
The data structure of the memory cache may be stored according to a hash map (hashMap) key-value pair format, where the key value is identification information of the resource, such as a protocol ID or a commodity ID or a combination of the two, the value is a pricing list corresponding to pricing information of different versions, and the data structure diagram may refer to fig. 4. After the charging system reads all pricing information of the resources from the system database, the pricing information of the resources is structured into a pricing tree structure. The charging system judges whether the pricing information of the version exists in the memory according to the identifier of the current pricing list of the resource, such as the primary key value of the pricing list of the resource. If so, a pricing list using the current resource may be selected, covering the same pricing list as the primary key value of the pricing list. If not, the pricing list for the current resource is added to memory. For some agreement pricing is empty, the billing system may generate an empty pricing list to store in memory, and the validity period may be set to infinity.
When the two-level cache structure is adopted, the reading process of pricing is as follows: when the charging system reads the pricing of the resource, firstly, the pricing list of the resource is read from the memory through the identification information of the resource. If the pricing list of the resource is not read in the memory, the pricing is directly read from the system database and structured, and then the pricing list is cached in the memory. If the pricing list of the resource is read in the memory, the pricing list corresponding to the query time can be filtered according to the query time, and the actual pricing of the resource is determined. According to the same principle, the updating time of the pricing information of the resource is read from the Redis through the identification information of the resource, and the updating time of the pricing information corresponding to the query time is determined according to the query time.
When the two-level cache structure is adopted, the judgment process of whether the cache is refreshed or not is as follows: the charging system compares whether the identification of the pricing list of the resources in the memory is consistent with the identification of the pricing information in the Redis, and if not, the pricing in the memory is overdue. If so, the charging system compares the update time of the pricing list of the resource in the memory with the update time cached in Redis, and if the latter is later than the former, the pricing in the memory is also shown to be expired. If the pricing in the memory is judged to be overdue, the pricing list of the resources in the memory needs to be refreshed, otherwise, the charging operation is performed by directly using the read pricing, namely, the charging system updates the new pricing information in the system database into the memory cache, and the specific process can refer to the related description of the second-level cache part in the embodiment. If pricing needs to be read from the system database, locking can be performed on the resource identification information, and then whether the pricing list in the memory needs to be refreshed or not is checked after locking, so that the problem of repeated pricing reading and updating caused by multithreading is solved.
The above description is only for illustration and does not limit the technical solution of the present invention.
Compared with the prior art, in the charging method provided by the embodiment, because the pricing information of the resources is stored in the memory in the form of the pricing tree structure, the charging system can preferentially query the pricing of the resources from the memory, and can query the pricing of the resources without performing structural processing on the pricing information, so that the pricing reading speed is greatly improved, the time consumed by pricing reading in the charging process is reduced, and the charging efficiency is improved.
A second embodiment of the present invention relates to a charging method. This embodiment is an example of the first embodiment, and specifically describes: and (3) a generation process of pricing information of the resource. Specifically, as shown in fig. 5, the generation process of the pricing information of the resource includes the following steps:
step 401: a charging model for the resource is determined.
Specifically, any one or any combination of a basic charging model, a step charging model, a discount charging model and a logic charging model is stored in the charging system, and a user can select one or more charging models according to needs for defining charging modes of resources.
Each charging model and a combination of charging models mentioned in the present embodiment are described below.
In determining pricing, a pricing plan and charging terms need to be determined first. The pricing plan may be a pricing strategy for the resource. Under the pricing plan, a plurality of charging items can be hung down, and the charging system calculates the cost by taking the charging items as units. In this embodiment, each charging item may be a simple charging item in a general sense, or may be a reference charging item that is relatively abstract. Simple charge terms are also called substantial charge terms, i.e. the price is directly defined. The reference charge defines the price indirectly by way of reference to the substantive charge. The simple charging items can use a basic charging model and a step charging model, and correspond to a simple pricing mode. The reference charging item may correspond to a complex pricing scheme using a discount charging model and a logical charging model. If 2 types of charging models and 2 or more charging models are combined, a complicated pricing method is adopted.
1. Simple pricing method
For general charging requirements, it is sufficient to make a simple pricing for the resources. The simple pricing mode is concise and easy to understand and configure. Basic rate information and the like required by charging are clearly defined in the simple pricing mode. When the charging system calculates the fee, the pricing of the resource is obtained by screening according to fixed filtering conditions (such as regions, pricing periods and the like), and the fee can be calculated to obtain the final consumption amount. The charging model in the simple pricing method has the following two types:
1. basic charging model: the basic charging model defines a unit rate and a fixed rate required for resource charging, and can meet the general charging requirement of fixed unit rate charging.
2. Step charging model: the step charging model defines a plurality of step ranges, and defines unit rates and fixed rates corresponding to each step, so that the requirement of step charging can be realized.
2. Complex pricing method
In some fields, such as the cloud computing field, the charging system not only needs to meet general charging requirements, but also needs to make a set of complex pricing modes corresponding to complex charging scenarios. The complex pricing approach enables more flexible pricing by defining ways to reference the charging terms. Models for referring to the charge items include a discount charge model (discount pricing) and a logical charge model (logical pricing).
1. The discount charging model is as follows: the discount charging model refers to a pricing method in which a certain resource is priced by referring to another resource by a certain discount or alternative method. A discount charging model is defined in the pricing of the resource, a specific discount mode (such as integral discount or item-by-item discount), a discount rate and the identification of the referenced resource are defined on the charging model, and the final pricing of the resource is determined through the reference relations. When reading the discount charging model, the substantial pricing charging model of the referenced resource is used as the substantial charging item information of the charging model through the discount rate.
It should be noted that the charging items defined by the discount charging model do not directly define the final unit rate and fixed rate information of the resource, and the final quoted pricing mode of the discount pricing is necessarily simple pricing.
It is worth mentioning that the discount charging model well solves special pricing modes such as discount pricing.
2. Logical charging model: logical pricing is a pricing means that defines several conditional items and several choice items. And selecting the charging mode of the corresponding specific charging item through matching of the conditions. The logic charging model comprises two parts of a condition item and a selection item. The condition item is a logic expression containing the current charging, and when the expression is true, the corresponding option is selected. The option is a next level charge item, which may be a substantial charge item or a reference charge item. The logical charging model is classified into an IF conditional charging model and a SWITCH selection charging model by type. The IF conditional charging model defines condition items, options satisfying the conditions, and else options, and selects an option satisfying the conditions when the conditions are satisfied, or else selects an else option. The SWITCH conditional charging model defines a condition item and a plurality of case options, and when the condition meets one of the case options, the current option is selected. The logical charging model, like the discount charging model, does not define specific unit rate and flat rate information, and the charging item to which the lowermost leaf is referenced must be simply priced.
Third, combined pricing mode
In order to meet diversified demands of the market, only a single pricing mode can be used for solving some simpler charging demands, and for some complex charging demands, the single pricing mode can hardly meet the demands, so that a pricing mode for combining and applying different types of charging models is derived. Some combined pricing approaches are exemplified below.
1. Discount charge model + discount charge model: the combination use of a plurality of discount charging models solves the problem that charging cannot be carried out by using multiple resources, and realizes a discount charging scene.
2. Discount charging model + logical charging model: the combination mode can use different pricing in different scenes (regions, time, packages and the like) on the premise of uniform preferential benefit, so that one resource can meet the charging requirements of different scenes by making one pricing, and the combination mode is very flexible.
3. Logical charging model + discount charging model: the combination mode can use different benefits according to different scenes (areas, time, packages and the like).
4. Logical charging model + logical charging model: the combination solves the charging requirement under various scene combinations.
It should be noted that, the combined pricing method may be a combination of 2 charging models, or a combination of more than 2 different charging models, so as to achieve very flexible charging requirements.
Step 402: and determining the value of the parameter in the charging model of the resource.
Specifically, there are parameter values in each charging model that need to be determined according to the value of the resource. For example, unit rates and flat rates in the basic charging model, ranges of steps and unit rates and flat rates of steps in the stepped charging model, discounting rates and identities of referenced resources in the discounted charging model, conditional orientation and options in the logical charging model. The charging system can display the parameter value needing to be confirmed by the user according to the determined charging model; and determining the value of each parameter according to the input of the user.
Step 403: and determining pricing information of the resources according to the charging model of the resources and the determined parameter values, and storing the pricing information of the resources in a first database.
Specifically, each charging model has its own calculation rule, and the pricing information of the resource can be obtained by substituting the determined parameter value into the calculation rule.
For example, the charging model of resource a is a discounted charging model, the determined discount rate takes a value of 0.8, the identifier of the referenced resource is the identifier of resource B, and the pricing information of the resource indicates pricing of resource a =0.8 × pricing of resource B.
For another example, the charging model of resource a is an IF charging model in the logical charging model, the condition item is that the usage area is area a, the charging item satisfying the condition is the identifier of resource B, the else selection item is a discount charging model, the discount rate is 0.8, and the identifier of the referenced resource is the identifier of resource B, so that the pricing information of the resource indicates that when the usage area of resource a is area a, the pricing of resource a is the same as the pricing of resource B, and when the usage area of resource a is not area a, the pricing of resource a =0.8 and the pricing of resource B.
The above description is only for illustrative purposes and does not limit the technical aspects of the present invention.
Compared with the prior art, in the charging method provided by the embodiment, a plurality of charging models are stored in the charging system, and different charging models can be selected according to different requirements under the condition that the customer requirements are diversified, so that different charging modes can be realized. The basic charging model or the step charging model can solve general charging requirements, the discount charging model or the logic charging model can solve delivered charging requirements, and the combined pricing mode can solve multi-scene interlaced charging requirements. For different charging scenes, different charging models can be selected, and the charging flexibility and the charging efficiency are greatly improved.
The steps of the above methods are divided for clarity, and the implementation may be combined into one step or split some steps, and the steps are divided into multiple steps, so long as the same logical relationship is included, which are all within the protection scope of the present patent; it is within the scope of the patent to add insignificant modifications to the algorithms or processes or to introduce insignificant design changes to the core design without changing the algorithms or processes.
A third embodiment of the present invention relates to a charging apparatus, as shown in fig. 6, including: a lookup module 501 and a determination module 502. The searching module 501 searches a pricing list of the resource in the memory according to the identification information of the resource; the pricing list of the resource comprises pricing tree structure data of the resource, and the pricing tree structure data of the resource is determined according to pricing information of the resource in the first database. The determining module 502 is configured to determine pricing for the resource based on the pricing list of the resource.
It should be understood that this embodiment is a system example corresponding to the first embodiment, and may be implemented in cooperation with the first embodiment. The related technical details mentioned in the first embodiment are still valid in this embodiment, and are not described herein again in order to reduce repetition. Accordingly, the related technical details mentioned in the present embodiment can also be applied to the first embodiment.
It should be noted that, in practical applications, one logical unit may be one physical unit, may be a part of one physical unit, and may also be implemented by a combination of multiple physical units. In addition, in order to highlight the innovative part of the present invention, elements that are not so closely related to solving the technical problems proposed by the present invention are not introduced in the present embodiment, but this does not indicate that other elements are not present in the present embodiment.
A fourth embodiment of the present invention relates to an electronic device, such as a terminal or a server, as shown in fig. 7, including: at least one processor 601; and a memory 602 communicatively coupled to the at least one processor 601; wherein the memory 602 stores instructions executable by the at least one processor 601, the instructions being executable by the at least one processor 601 to enable the at least one processor 601 to perform the charging method as mentioned in the above embodiments.
The electronic device includes: one or more processors 601 and a memory 602, one processor 601 being illustrated in fig. 7. The processor 601 and the memory 602 may be connected by a bus or other means, and fig. 7 illustrates an example of a connection by a bus. The memory 602, which is a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The processor 601 executes various functional applications and data processing of the device by running nonvolatile software programs, instructions and modules stored in the memory 602, that is, the above-described billing method is implemented.
The memory 602 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store a list of options, etc. Further, the memory 602 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, the memory 602 may optionally include memory located remotely from the processor 601, which may be connected to an external device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
One or more modules are stored in the memory 602 and, when executed by the one or more processors 601, perform the charging method of any of the method embodiments described above.
The product can execute the method provided by the embodiment of the application, has corresponding functional modules and beneficial effects of the execution method, and can refer to the method provided by the embodiment of the application without detailed technical details in the embodiment.
A fifth embodiment of the present invention relates to a computer-readable storage medium storing a computer program. The computer program realizes the above-described method embodiments when executed by a processor.
That is, as can be understood by those skilled in the art, all or part of the steps in the method for implementing the embodiments described above may be implemented by a program instructing related hardware, where the program is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, or the like) or a processor (processor) to execute all or part of the steps of the method described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It will be understood by those of ordinary skill in the art that the foregoing embodiments are specific examples of practicing the invention, and that various changes in form and detail may be made therein without departing from the spirit and scope of the invention in practice.

Claims (11)

1. A charging method is characterized in that the charging method is applied to a charging system and comprises the following steps:
searching a pricing list of the resources in a memory according to the identification information of the resources; wherein the pricing list of the resource comprises pricing tree structure data of the resource, which is determined according to pricing information of the resource in the first database;
determining pricing of the resource according to the pricing list of the resource;
any one or any combination of a basic charging model, a step charging model, a discount charging model and a logic charging model is stored in the charging system;
before searching the pricing list of the resource in the memory according to the identification information of the resource, the charging method further comprises:
determining a charging model for the resource;
determining a parameter value in a charging model of the resource;
and determining pricing information of the resource according to the charging model of the resource and the determined parameter value, and storing the pricing information of the resource in the first database.
2. The charging method according to claim 1, wherein the searching the pricing list of the resource in the memory according to the identification information of the resource specifically comprises:
judging whether a pricing list of the resources exists in the memory or not according to the identification information of the resources;
if the pricing list of the resource does not exist, reading the pricing information of the resource from the first database, and determining the pricing list of the resource according to the reading result; storing the pricing listing for the resource in the memory.
3. The charging method according to claim 2, wherein if the pricing list of the resource is determined according to the reading result, the charging method further comprises:
if the reading result indicates that the pricing information of the resource exists in the first database, generating a pricing list of the resource according to the read pricing information of the resource;
and if the reading result indicates that the pricing information of the resource does not exist in the first database, creating a pricing list of the resource with empty content.
4. The charging method according to claim 1, wherein the charging system is further provided with a second database, the second database is used for caching a time list of pricing information of the resource and/or an identification of the pricing information of the resource, and the time list comprises an update time of the pricing information; the pricing list of the resource stores the updating time of the pricing list of the resource, and the identification of the pricing list of the resource is the same as that of the pricing information corresponding to the pricing list of the resource;
the determining the pricing of the resource according to the pricing list of the resource specifically includes:
judging whether the pricing list of the resources meets preset conditions or not; the preset condition comprises that the pricing list of the resource is updated at a time equal to or later than the updating time of the pricing information of the resource stored in the second database, and/or the identification of the pricing list of the resource is consistent with the identification of the pricing information of the resource stored in the second database;
if yes, inquiring pricing tree structure data of the resources to obtain pricing of the resources;
if not, reading pricing information of the resource from the first database; generating new pricing tree structure data in a new pricing list of the resource according to the obtained pricing information of the resource, and storing the new pricing tree structure data in the memory; and inquiring the new pricing tree structure data to obtain the pricing of the resources.
5. The charging method according to claim 4, wherein after determining that the pricing information of the resource in the first database is updated, the information storing method further comprises:
acquiring the update time of new pricing information of the resource;
sending update information to the second database through a message queue; the update information includes an update time of the new pricing information and/or an identification of new pricing information for the resource.
6. A charging method according to claim 2 or 4, characterized in that before said reading of pricing information of said resource from said first database, said charging method further comprises:
and locking all pricing lists of the resources in the memory.
7. The charging method according to claim 4, wherein N pricing lists of the resource are stored in the memory, the pricing lists of the resource further include effective time and ineffective time of the pricing lists of the resource, and N is a positive integer; the time list of pricing information for the resource further includes an effective time and an ineffective time of the pricing information for the resource;
before the determining whether the pricing list of the resource meets the preset condition, the charging method further includes:
determining a pricing list of the resources corresponding to the query time according to the query time and the effective time and the ineffective time of the pricing list of each resource;
and determining a time list corresponding to the query time according to the query time and the effective time and the ineffective time of the pricing information of each resource.
8. A charging method according to any one of claims 1 to 5, wherein the pricing tree of the resource is included in the pricing tree structure data of the resource, a root node of the pricing tree of the resource is identification information of the resource, and types of nodes in the pricing tree of the resource other than the root node include any one or any combination of a simple pricing type, a discount pricing type and a logic pricing type;
wherein the nodes belonging to the simple pricing type are leaf nodes; the node belonging to the discount pricing type has a child node, and the type of the lowest child node of the node belonging to the discount pricing type is the simple pricing type; a node belonging to the logic pricing type has a child node, and the type of the lowest child node of the node belonging to the logic pricing type is the simple pricing type;
the node belonging to the simple pricing type stores price information of the resource, the node belonging to the discount pricing type stores discount information, and the node belonging to the logic pricing type stores condition information of each sub-node of the node.
9. The charging method according to claim 8, wherein the type of the child node belonging to the node of the discounted pricing type comprises any one or any combination of the simple pricing type, the discounted pricing type, and the logical pricing type; the type of the child node belonging to the node of the logical pricing type includes any one or any combination of the simple pricing type, the discounted pricing type and the logical pricing type.
10. An electronic device, comprising: at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the charging method of any one of claims 1 to 9.
11. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the charging method of any one of claims 1 to 9.
CN201911396783.9A 2019-12-30 2019-12-30 Charging method, electronic device and storage medium Active CN111177169B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911396783.9A CN111177169B (en) 2019-12-30 2019-12-30 Charging method, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911396783.9A CN111177169B (en) 2019-12-30 2019-12-30 Charging method, electronic device and storage medium

Publications (2)

Publication Number Publication Date
CN111177169A CN111177169A (en) 2020-05-19
CN111177169B true CN111177169B (en) 2022-11-04

Family

ID=70650510

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911396783.9A Active CN111177169B (en) 2019-12-30 2019-12-30 Charging method, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN111177169B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112036937B (en) * 2020-08-19 2023-11-28 深圳市分期乐网络科技有限公司 Commodity pricing method, device, computer equipment and storage medium
CN112000317A (en) * 2020-08-26 2020-11-27 济南浪潮数据技术有限公司 Resource charging method and device, electronic equipment and storage medium
CN112054912B (en) * 2020-08-31 2023-06-13 北京易捷思达科技发展有限公司 Resource charging system and method of OpenStack open source cloud platform
CN113724009A (en) * 2021-09-01 2021-11-30 拉扎斯网络科技(上海)有限公司 Transportation capacity pricing method and device, electronic equipment and machine-readable storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1407492A (en) * 2001-09-10 2003-04-02 好利集团有限公司 Point to point price negotiating method and system
US20120254000A1 (en) * 2011-03-31 2012-10-04 NetCracker Technology Corporation Systems and methods for improved billing and ordering
CN102546190B (en) * 2011-11-28 2014-04-09 上海理想信息产业(集团)有限公司 Search method of universal fee packets of cloud computing resources
US20130179363A1 (en) * 2012-01-09 2013-07-11 Oracle International Corporation Functional model for rating events
CN107153973A (en) * 2017-05-12 2017-09-12 微鲸科技有限公司 Information resources pricing method and device
CN110009400A (en) * 2019-03-18 2019-07-12 康美药业股份有限公司 Merchandise valuation method, terminal and computer readable storage medium

Also Published As

Publication number Publication date
CN111177169A (en) 2020-05-19

Similar Documents

Publication Publication Date Title
CN111177169B (en) Charging method, electronic device and storage medium
CN106981004B (en) Apparatus, method and system for autonomous selection of goods suppliers
EP3798870B1 (en) Search and retrieval data processing system for computing near real-time data aggregations
CN101216855B (en) Message kind business accumulated data caching method and system
CN108415964A (en) Tables of data querying method, device, terminal device and storage medium
CN107968805B (en) Event notification method and server
CN103106585A (en) Real-time duplication eliminating method and device of product information
CN111585798B (en) Network resource parameter configuration method, device and computer readable storage medium
CN117035687A (en) Power grid business fixed asset process configuration method, system and computer storage medium
CN112965710A (en) Processing method, device and system of computation graph
JP6081491B2 (en) A functional model for assessing events
CN114416891B (en) Method, system, apparatus and medium for data processing in a knowledge graph
US20230214355A1 (en) Storage of order books with persistent data structures
CN112269915B (en) Service processing method, device, equipment and storage medium
CN109710610B (en) Data processing method and device and computing equipment
CN114138877A (en) Method, device and equipment for realizing theme data service based on micro-service architecture
CN115017185A (en) Data processing method, device and storage medium
CN114756731A (en) Advertisement channel data processing method and device, storage medium and electronic equipment
Chen et al. 5G Charging Mechanism Based on Dynamic Step Size
CN112785302B (en) Message statistics method and device, electronic equipment and readable storage medium
CN114186267A (en) Virtual asset data processing method and device and computer readable storage medium
CN115858576A (en) Power system monitoring data query method and device, power system and storage medium
CN116662396A (en) Method, device, equipment and storage medium for processing identification information
CN115375350A (en) Information screening method, information screening device, server layer and storage medium
CN113610241A (en) Distributed training method, device, equipment and storage medium for deep learning model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant