Fee calculation method and device, computer equipment and storage medium
By decoupling the accounting business with the order business in the order management system, and using the visual rule configuration interface to generate the rule engine file for cost calculation, the problem of complex and low efficiency of the calculation logic in the system is solved, and simplified logic and improvement are achieved The effect of efficiency.
Patent Information
- Application Number
- CN202411365285.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-01-10
AI Technical Summary
The calculation business and the order business in the order management system are tightly coupled, resulting in complex calculation logic, long processing time and low efficiency.
By decoupling the calculation business system and the order business system, a visual rule configuration interface is used to generate the rule files executable by the rule engine, perform cost calculations, simplify the calculation logic and improve efficiency.
The calculation of the calculation item cost under the decoupling of the order business system is realized, which simplifies the system logic, reduces the calculation processing time, improves efficiency, and reduces the system complexity and maintenance difficulty.
Smart Images

Figure CN119295159A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of order management, and in particular to a charging method, apparatus, computer equipment and storage medium. Background Art
[0002] The main business processes of the order management system include the processes from customer ordering to order acceptance, preparation, agreement signing, delivery, lease start and service termination. The order management system integrates two parts: order data information processing and billing business of ordered goods. Since the billing business in the system is integrated into multiple links of the order business flow, the system logic is complex, the billing processing time is long, and the billing efficiency is low. Summary of the invention
[0003] The embodiments of the present application provide a charging method, apparatus, computer equipment and storage medium, which can realize the cost calculation of charging items in a charging business system decoupled from an order business system, thereby simplifying the system's charging logic, reducing charging processing time, and improving charging efficiency. The technical solution is as follows.
[0004] On the one hand, a charging method is provided, the method being executed by a charging service system, the charging service system being decoupled from an order service system, the method comprising: Receiving a charging request for a target charging item sent by an order business system; the charging request includes order information of the target charging item; Reading a target charging rule corresponding to the target charging item from a system memory based on the charging request; the target charging rule is obtained by configuring a rule based on a visual rule configuration interface; Parsing the target charging rule to obtain a rule file executable by a rule engine; The rule engine performs fee calculation based on the rule file and the order information of the target fee-charging item to obtain a fee-charging result of the target fee-charging item.
[0005] On the other hand, a charging device is provided, the device is applied to a charging service system, the charging service system is decoupled from an order service system, and the device includes: A request receiving module, used to receive a charging request of a target charging item sent by an order business system; the charging request includes order information of the target charging item; A rule reading module, configured to read a target charging rule corresponding to the target charging item from a system memory based on the charging request; the target charging rule is obtained by configuring the rule based on a visual rule configuration interface; A rule parsing module, used to parse the target charging rule to obtain a rule file executable by a rule engine; The fee calculation module is used to perform fee calculation based on the rule file and the order information of the target charging item through the rule engine to obtain the charging result of the target charging item.
[0006] In a possible implementation, the target charging rule includes condition configuration and operation rule configuration, and the rule parsing module includes: A first parsing submodule, configured to parse the billing elements used in the condition configuration in the target billing rule to obtain a first billing element list; A second parsing submodule is used to parse the charging factors used in the calculation rule configuration in the target charging rule to obtain a factor list; A third parsing submodule is used to traverse the factor list, parse the factor calculation rule of each charging factor, and obtain a second charging element list; A rule conversion submodule is used to perform rule conversion based on a rule engine based on the billing element list and the factor list to obtain a rule file executable by the rule engine; the billing element list includes the first billing element list and the second billing element list; the rule file contains a condition part of the rule based on the rule engine and an action part of the rule based on the rule engine.
[0007] In a possible implementation, the rule conversion submodule includes: A first conversion unit, configured to traverse the billing element list, perform rule conversion based on a rule engine based on a condition configuration and an operation rule configuration of each billing element in the billing element list, and generate a billing element rule file; A second conversion unit is used to use the output of the full amount of charging factor rules in the charging factor rule file as a factor rule variable, re-traverse the factor list, perform rule conversion based on the rule engine based on the factor calculation rule of each charging factor in the factor list, and generate a factor rule file; The third conversion unit is used to use the full charging factor in the factor rule file and the output of the full charging element rule as variables of the charging rule, traverse the charging item list, perform rule conversion based on the rule engine based on the cost calculation rule of each charging item in the charging item list, and generate a charging rule file.
[0008] In a possible implementation, the fee calculation module is used to: Executing the billing factor rule file through the rule engine to obtain a billing factor value associated with the target billing item; Executing the factor rule file through the rule engine, calculating the factor value according to the charging element value, and obtaining the factor value associated with the target charging item; The fee rule file is executed by the rule engine, and the fee value is calculated according to the factor value to obtain the fee calculation result of the target fee calculation item.
[0009] In a possible implementation manner, the device further includes: The result display module is used to display the calculation result and calculation process of the target charging item in a visual display manner.
[0010] In a possible implementation manner, the device further includes: An interface display module, used to display the visualization rule configuration interface; the visualization configuration interface includes interactive elements; the interactive elements include interactive elements corresponding to condition configuration and interactive elements corresponding to operation rule configuration; An information generation module, configured to generate configuration information based on the configuration operation received from the user through the visual rule configuration interface; A rule generation module is used to generate corresponding charging rules based on the configuration information.
[0011] In a possible implementation, the cost calculation module is used to: If the billing item corresponding to the generated new billing rule has an original billing rule and the original billing rule is in an applied state, during the loading process of the new billing rule, the billing request of the corresponding billing item is processed based on the original billing rule; After the new charging rule is loaded, the charging request of the corresponding charging item is processed based on the new charging rule.
[0012] On the other hand, a computer device is provided, which includes a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement any of the above-mentioned charging methods.
[0013] On the other hand, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and the computer program is loaded and executed by a processor to implement any of the above-mentioned charging methods.
[0014] On the other hand, a computer program product is provided, the computer program product comprising at least one computer program, the computer program being loaded and executed by a processor to implement any charging method provided in the various optional implementations described above.
[0015] The technical solution provided by this application may have the following beneficial effects: The charging method provided in the embodiment of the present application, when the charging business system is decoupled from the order business system, the charging business system receives the charging request of the target charging item sent by the order business system, and reads the target charging rule corresponding to the target charging item from the system memory based on the charging request, and obtains the rule file executable by the rule engine by parsing the target charging rule, and then calculates the fee based on the rule sorting and the order information of the target charging item by the rule engine to obtain the charging result of the target charging item; wherein, the target charging rule is obtained by the user through rule configuration based on the visual rule configuration interface; through the above method, the fee calculation of the charging item can be realized in the charging business system decoupled from the order business system, thereby simplifying the system's charging logic, reducing the charging processing time, and improving the charging efficiency; In addition, by decoupling the billing business system from the order business system, the complexity of the order management system can be reduced, and the maintainability and risk resistance of the system can be improved.
[0016] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] Figure 1 A schematic diagram of an order management system provided by an exemplary embodiment of the present application is shown; Figure 2 A flowchart of a charging method provided in an embodiment of the present application is shown; Figure 3 A flowchart of a charging method provided by an exemplary embodiment of the present application is shown; Figure 4 A schematic diagram showing a charging rule configuration provided by an exemplary embodiment of the present application is shown; Figure 5 An interactive schematic diagram of charging rule loading provided by an exemplary embodiment of the present application is shown; Figure 6 A block diagram of a charging device provided by an exemplary embodiment of the present application is shown; Figure 7 A structural block diagram of a computer device provided by an exemplary embodiment of the present application is shown. DETAILED DESCRIPTION
[0019] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0020] Figure 1 A schematic diagram of an order management system provided by an exemplary embodiment of the present application is shown. Figure 1 As shown, the order management system includes a charging business system 110 and an order business system 120. The charging business system 110 is decoupled from the order business system 120. The order processing part belongs to the order business system 120, and the calculation part of the order's tariff items (i.e., charging items) belongs to the charging business system 110. The charging business system is responsible for receiving the charging request sent by the order business system. The charging rules of the charging items are visually configured asynchronously by the user, and the configured charging rules are loaded into the system memory of the charging business system in real time. The charging business system parses the rules and converts them into rule files executable by the rule engine. The fee calculation is realized by executing the rule files, and the final charging results and charging process are displayed.
[0021] Through the above-mentioned decoupled architecture, the billing business system can run as an independent service and interact with other systems through defined interfaces, which can reduce the dependencies between systems and facilitate independent updates and maintenance.
[0022] Based on Figure 1 The order management system shown in the embodiment of the present application provides a charging method, which can simplify the charging logic of the system, reduce the charging processing time, and improve the charging efficiency; Figure 2 The flowchart of the charging method provided in the embodiment of the present application is shown. The method can be executed by a charging business system, and the charging business system is decoupled from the order business system; Figure 2 As shown, the method may include the following steps: Step 210: receiving a charging request for a target charging item sent by the order service system; the charging request includes order information for the target charging item.
[0023] Illustratively, the order information included in the billing request may include an order ID, a user ID, service item information (such as service item ID, service type, quantity, service duration, etc.) and other relevant information (such as discount information), etc.
[0024] Step 220, based on the charging request, read the target charging rule corresponding to the target charging item from the system memory; the target charging rule is obtained by configuring the rule based on the visual rule configuration interface.
[0025] In an embodiment of the present application, the system memory of the billing business system stores the billing rules corresponding to each billing item obtained by the user through rule configuration based on a visual rule configuration interface; wherein the process of the user configuring the rules and publishing the rules in the visual rule configuration interface can be executed asynchronously with the process of the billing business system processing the billing request to perform fee calculation.
[0026] After receiving the billing request for the target billing item, the billing service system may perform a rule query in the system memory based on the order information of the target billing item contained in the billing request. For example, the system may perform a rule query in the system memory through the service item identifier to obtain the target billing rule corresponding to the target billing item.
[0027] Step 230, parse the target charging rule to obtain a rule file executable by the rule engine.
[0028] The rule engine, also known as the Business Rule Management System (BRMS), is a component used to execute business rules in the billing business system. It can separate business decisions / business rules from application code, and use predefined language modules to write business decisions / business rules, so that business decisions / business rules can be managed and maintained independently of the application. In the embodiment of the present application, the rule engine is used to convert the format of the billing rules obtained based on the user configuration into a format executable by the rule engine, that is, to obtain a rule file executable by the rule engine. After the rule engine is introduced, the business rules can be completely independent of the application and stored in the rule base / knowledge base. The business rules are loaded into the rule engine for application system calls to facilitate the management of business rules, such as querying, adding, updating, and other operations on business rules.
[0029] In the embodiments of the present application, the charging rule configuration usually includes the configuration of rules for fees, charging factors and charging elements. The configuration of the above items is composed of a condition part and an operation rule part, which is similar to the composition of the rule file. By converting the above configuration into the corresponding rule file, the subsequent execution of the charging rules can be guaranteed. Among them, the charging element refers to the basic data item used for fee calculation, which is usually the data specified or directly obtainable, such as the order quantity, the unit price of the product, the user level, etc.; the charging factor refers to the dynamic variable or condition that affects the fee calculation, which usually needs to be calculated according to certain rules or conditions, such as the discount rate calculated according to the user level or other activities, or the rate dynamically adjusted according to certain conditions, etc.; there can be different types of charging elements and charging factors based on different scenarios, and this application does not limit this.
[0030] Step 240: The rule engine performs fee calculation based on the rule file and the order information of the target fee calculation item to obtain the fee calculation result of the target fee calculation item.
[0031] The billing business system loads the generated rule file into the rule engine, and puts the order information of the target billing item into the working memory of the rule engine, so that the rule engine obtains or calls the order data based on the order information of the target billing item, triggers the rule engine, and executes the rules in the rule file, thereby calculating the billing result of the target billing item.
[0032] In one possible implementation, the billing business system may cache the data required for billing processing in the system memory, and implement a billing process based on the system memory through a rule engine in combination with the billing rules corresponding to each billing item stored in the system memory, thereby reducing data access during the billing process and improving billing efficiency.
[0033] In summary, the charging method provided by the embodiment of the present application is that, when the charging business system is decoupled from the order business system, the charging business system receives the charging request of the target charging item sent by the order business system, and reads the target charging rule corresponding to the target charging item from the system memory based on the charging request, and obtains the rule file executable by the rule engine by parsing the target charging rule, and then calculates the fee based on the rule sorting and the order information of the target charging item by the rule engine to obtain the charging result of the target charging item; wherein, the target charging rule is obtained by the user through rule configuration based on the visual rule configuration interface; through the above method, the fee calculation of the charging item can be realized in the charging business system decoupled from the order business system, thereby simplifying the system's charging logic, reducing the charging processing time, and improving the charging efficiency; In addition, by decoupling the billing business system from the order business system, the complexity of the order management system can be reduced, and the maintainability and risk resistance of the system can be improved.
[0034] In the embodiment of the present application, the process of the user configuring the rules through the visual rule configuration interface and the process of the billing service system processing the billing request can be executed asynchronously. Based on this, Figure 3 A flowchart of a charging method provided by an exemplary embodiment of the present application is shown. The method can be executed by a charging business system, and the charging business system is decoupled from the order business system; Figure 3 As shown, the method may include the following steps: Step 310, displaying a visualization rule configuration interface, wherein the visualization rule configuration interface includes interactive elements; the interactive elements include interactive elements corresponding to condition configurations and interactive elements corresponding to operation rule configurations.
[0035] In an embodiment of the present application, the billing service system may provide a visual rule configuration interface through a billing rule configuration component, so that users can intuitively define and edit billing rules for various billing items.
[0036] In a possible implementation, the charging rule configuration includes two parts: one is the pricing rule configuration, and the other is the system data acquisition configuration. Figure 4 A schematic diagram of a charging rule configuration provided by an exemplary embodiment of the present application is shown. Figure 4 As shown, the charging rule configuration includes two parts: pricing rule configuration 410 and system data acquisition configuration 420. The pricing rule configuration process can be operated and configured by business personnel, and the system data acquisition configuration process can be operated and configured by system development or maintenance personnel.
[0037] The pricing rule configuration section is used to configure the charging rules for the charging items. The process consists of two parts: condition configuration and operation rule configuration. Users build the structure and specific content of the rules by dragging, selecting, and filling in the visual rule configuration interface.
[0038] The visual rule configuration interface may provide interactive elements corresponding to the condition configuration and interactive elements corresponding to the operation rule configuration; in a possible implementation, the interactive elements corresponding to the condition configuration are derived from the billing elements provided to the outside by the system data acquisition configuration part; depending on the content of the condition configuration, the operation rule configuration may also be different.
[0039] For the charging items, the corresponding charging rules may include the fee calculation rules corresponding to the charging items, the factor calculation rules corresponding to each charging factor, and the charging element rules for each charging element, and each rule includes the corresponding condition configuration and the operation rule configuration; wherein, when configuring the operation rules corresponding to the fee calculation rules of the charging items, if the interactive elements corresponding to the operation rule configuration contain the required operation formula, the user can select different formulas to configure the operation rules of the charging items; if the interactive elements corresponding to the operation rule configuration do not contain the required operation formula, the user can configure the operation formula first, and then configure the operation rules of the charging items. For the configuration of the calculation formula, users can form the required formula expression by selecting different combinations of charging factors and relational operators. In this process, if the interactive elements corresponding to the calculation rule configuration do not contain the required charging factors, users can first configure the corresponding charging factors and their factor calculation rules. The factor calculation rule configuration of the charging factor is also composed of two parts: the condition configuration part and the calculation rule configuration part. Among them, the condition configuration method of the charging factor is consistent with the condition configuration method in the charging rule. The calculation rule configuration part of the charging factor supports users to enter a fixed value or select a certain charging element.
[0040] The pricing rule configuration part defines the raw data required for billing. System developers can provide common basic data acquisition rules, such as obtaining configuration data through a certain SQL or API, and finally encapsulating it as billing elements for users to use when configuring pricing rules.
[0041] Step 320: Generate configuration information based on the received configuration operation performed by the user through the visual rule configuration interface.
[0042] The user configures the rules for the operations of each interactive element in the visual rule configuration interface. The billing rule configuration component obtains and stores the configuration information generated in the process so that other components of the billing business system can obtain accurate rules to perform billing operations.
[0043] Step 330: Generate corresponding charging rules based on the configuration information.
[0044] The charging configuration reading component in the charging business system can extract the configuration information obtained and stored by the charging rule configuration component, and after receiving the user's configuration completion operation, determine that the current charging rule configuration is completed, and generate corresponding charging rules based on the extracted configuration information.
[0045] Furthermore, the billing configuration reading component may also notify the billing service component to load the rules online; in a possible implementation, when the billing item corresponding to the generated new billing rule has an original billing rule and the original billing rule is in the application state, during the loading process of the new billing rule, the billing request of the corresponding billing item is processed based on the original billing rule; After the new billing rules are loaded, the billing requests for the corresponding billing items are processed based on the new billing rules.
[0046] Figure 5 FIG. 1 shows an interactive schematic diagram of charging rule loading provided by an exemplary embodiment of the present application. Figure 5 As shown, upon receiving a billing request, the billing service component 510 starts and loads the original billing rules of the billing item to perform fee calculation corresponding to the billing item; if during this period, the user reconfigures the billing rules of the billing item through the visual rule configuration interface, the billing configuration reading component 520 sends a loading request to the billing service component upon receiving an instruction from the user to complete and publish a new billing rule corresponding to the billing item, and the loading request includes the new billing rule; accordingly, the billing service component monitors the loading request in real time, and after receiving the loading request, loads the new billing rule online without interrupting the currently being processed billing process, and after the new billing rule is loaded, the received billing request is subsequently processed based on the new billing rule.
[0047] Step 340: Receive a billing request for the target billing item sent by the order service system; the billing request includes order information for the target billing item.
[0048] In the embodiment of the present application, the process of performing fee calculation in response to a fee calculation request may be executed by a fee calculation service component in the fee calculation business system.
[0049] After receiving the billing request for the target billing item, the billing service component in the billing business system starts and establishes a connection with the database or configuration storage source to ensure that the required data can be obtained; checks the cache status to confirm whether there is available cache configuration information; if the cache status is empty or needs to be updated, sends a request to the database to read the full amount of billing-related configuration data in the database, and loads it into the billing service memory in a data organization form that conforms to the call characteristics; further, the billing service component can also check the integrity and validity of the read data to ensure the accuracy of subsequent fee calculations.
[0050] Step 350: Read the target charging rule corresponding to the target charging item from the system memory based on the charging request; the target charging rule is obtained by configuring the rule based on the visual rule configuration interface.
[0051] The charging business system reads the target charging rules corresponding to the target charging items from the system memory through the charging service component.
[0052] In an embodiment of the present application, the charging rules include charging elements, charging factors and their factor calculation rules, charging items and their fee calculation rules; wherein the charging elements have condition configurations and operation rule configurations corresponding to the charging elements, the factor calculation rules of the charging factors include condition configurations and operation rule configurations corresponding to the charging factors, and the fee calculation rules of the charging items include condition configurations and operation rule configurations corresponding to the charging items.
[0053] Step 360: parse the target charging rule to obtain a rule file executable by the rule engine.
[0054] By analyzing the charging rules, general rules based on the rule engine can be generated. The process can be implemented as follows: Parsing the billing elements used in the condition configuration in the target billing rule to obtain a first billing element list; Parse the charging factors used in the calculation rule configuration in the target charging rule to obtain a factor list; Traverse the factor list, parse the factor calculation rule of each charging factor, and obtain the second charging element list; Based on the billing element list and the factor list, rule conversion based on the rule engine is performed to obtain a rule file executable by the rule engine; the billing element list includes a first billing element list and a second billing element list; the rule file includes a condition part of the rule based on the rule engine and an action part of the rule based on the rule engine.
[0055] That is to say, in this process, the billing service component reads the target billing rule from the memory, parses the billing elements used in the conditional configuration, and generates a first billing element list; parses the billing factors used in the operation rule configuration to generate a factor list; traverses the factor list, reads the factor calculation rules of each billing factor from the memory, parses the billing elements used in the conditional configuration and the operation rules, generates a second billing element list, and merges the first billing element list with the second billing element list to generate a billing element list; then, performs rule conversion based on the rule engine based on the billing element list and the factor list to obtain a rule file executable by the rule engine.
[0056] In a possible implementation, the process of performing rule conversion based on the rule engine based on the billing element list and the factor list to obtain a rule file executable by the rule engine can be implemented as follows: S361, traverse the billing element list, perform rule conversion based on the rule engine based on the condition configuration and operation rule configuration of each billing element in the billing element list, and generate a billing element rule file.
[0057] Traverse the billing element list, parse the condition configuration and operation rule configuration corresponding to each billing element, extract the variables, operators, comparison values, and actions or results to be executed in the condition configuration and operation rule configuration, convert the condition configuration part into the condition part of the rule based on the rule engine, and convert the operation rule configuration part into the action part of the rule based on the rule engine, so as to generate the billing element rule file.
[0058] S362, using the output of the full amount of charging factor rules in the charging factor rule file as the factor rule variable, re-traverse the factor list, perform rule conversion based on the rule engine based on the factor calculation rule of each charging factor in the factor list, and generate a factor rule file.
[0059] Take the output of all billing factor rules in the generated billing factor rule file as the factor rule variable, re-traverse the factor calculation rules of each billing factor in the factor list, convert the condition configuration part into the condition part of the rule based on the rule engine, and convert the calculation rule part into the action part of the rule based on the rule engine, so as to generate the factor rule file.
[0060] S363, using the full amount of charging factors in the factor rule file and the output of the full amount of charging element rules as variables of the charging rules, traverse the list of charging items, perform rule conversion based on the rule engine based on the cost calculation rules of each charging item in the list of charging items, and generate a charging rule file.
[0061] The output of the full charging factor in the factor rule file and the full charging element rule in the charging element rule file are used as variables of the charging rule. The cost calculation rules of each charging item in the charging item list are traversed, and the condition configuration part is converted into the condition part of the rule based on the rule engine, and the calculation rule part is converted into the action part of the rule based on the rule engine, so as to generate the charging rule file.
[0062] After completing the rule parsing of the target charging rule, the rule file corresponding to the target charging rule can be obtained, which contains the charging element rule file, the factor rule file and the charging rule file; the rule file can be uploaded to the rule engine, and after the rule engine is started, the rule file can be executed to perform the cost calculation corresponding to the target charging item.
[0063] Step 370: The rule engine performs fee calculation based on the rule file and the order information of the target fee-charging item to obtain the fee-charging result of the target fee-charging item.
[0064] Illustratively, the embodiment of the present application provides an example and steps for defining a general rule engine, and the process can be implemented as follows: 1) Define the input object of the rule engine.
[0065] Schematically, an element object may be defined, which mainly includes the following elements: rule name ruleName, rule condition conditionStr, rule condition parameter conditionParam, operation rule calMethodStr, and operation rule parameter methodParam.
[0066] 2) Define a common rule file based on the defined input objects and the elements they contain.
[0067] Illustratively, a rule name of a rule file may be defined, the condition part of the rule file is to determine whether the condition exists according to the condition element of the input object, and the action part is to execute the operation rule element of the input object.
[0068] 3) Rule enforcement.
[0069] Integrate the rule file into the Drools rule engine and execute it. This step can be implemented as follows: 3-1) Initialize the rule engine, including: Initialize KieServices by creating an instance of KieServices as the entry point of the Drools rule engine; 3-2) Initialize the rule engine: Get KieContainer, get KieContainer through KieServices, and get all the rules and resources contained in the rule engine.
[0070] 3-3) Initialize the rule engine: Initialize KieSession and create a KieSession from KieContainer as a session for executing rules.
[0071] 3-4) Load data objects: Create test data, such as creating an instance of the Element object, and set the properties of the test data, including the rule name, condition string, operation rule string and related parameters.
[0072] 3-5) Load data object: Insert the data object into the session and use the kieSession.insert() method to insert a list of Element objects containing rule data into the KieSession.
[0073] 3-6) Execute rules: Activate the rule engine and call kieSession.fireAllRules() to execute all activated rules. The rule engine will traverse all objects in the session and try to match the defined rules.
[0074] 3-7) Execute rules: rule matching and execution. For each Element object, the rule engine evaluates conditionStr to determine whether the condition is met; if so, the calculation specified by calMethodStr is executed.
[0075] In a possible implementation, the cost calculation process may be implemented as follows: Execute the billing factor rule file through the rule engine to obtain the billing factor value associated with the target billing item; The factor rule file is executed through the rule engine, and the factor value is calculated according to the billing element value to obtain the factor value associated with the target billing item; The cost rule file is executed through the rule engine, and the cost numerical calculation is performed according to the factor value to obtain the cost calculation result of the target cost calculation item.
[0076] Among them, when executing the fee rule file, the billing service component can judge whether the conditions of the rule are met based on the variables, operators, and comparison values in the conditional expression, and perform actual fee value calculations based on the algorithms and logic established by the rules to obtain the billing results of the target billing items.
[0077] In a possible implementation, after obtaining the billing result of the target billing item, the billing service system can display the billing result and calculation process of the target billing item in a visual display manner. That is, the billing service system can visually display the calculation formula, application parameters and final billing value of each fee; schematically, the visual display method can be a graphical display and / or a textual display, which is not limited in this application.
[0078] In summary, the charging method provided by the embodiment of the present application is that, when the charging business system is decoupled from the order business system, the charging business system receives the charging request of the target charging item sent by the order business system, and reads the target charging rule corresponding to the target charging item from the system memory based on the charging request, and obtains the rule file executable by the rule engine by parsing the target charging rule, and then calculates the fee based on the rule sorting and the order information of the target charging item by the rule engine to obtain the charging result of the target charging item; wherein, the target charging rule is obtained by the user through rule configuration based on the visual rule configuration interface; through the above method, the fee calculation of the charging item can be realized in the charging business system decoupled from the order business system, thereby simplifying the system's charging logic, reducing the charging processing time, and improving the charging efficiency; By decoupling the billing business system from the order business system, the complexity of the order management system can be reduced, and the maintainability and risk resistance of the system can be improved; Configuring charging rules through the visual rule configuration interface can improve the flexibility of charging configuration, meet personalized and diversified charging needs, and make the charging business system flexibly applicable to different business scenarios. At the same time, it also lowers the threshold for formulating charging rules and improves the efficiency of rule management. By transferring data storage and processing to the system memory, the reliance on external systems and data exchange during the calculation process is reduced, the system's response speed and processing performance are improved, and the calculation efficiency is improved; By displaying the billing process and billing results in a visual way, users can intuitively perceive the billing process data and billing rules, which can improve the user experience.
[0079] Figure 6 A block diagram of a charging device provided by an exemplary embodiment of the present application is shown, and the device is applied to a charging service system and is used to perform the following steps: Figure 2 or Figure 3 All or part of the steps of the embodiment shown, the billing business system is decoupled from the order business system, and the device includes: The request receiving module 610 is used to receive a charging request of a target charging item sent by the order service system; the charging request includes order information of the target charging item; A rule reading module 620 is used to read a target charging rule corresponding to the target charging item from a system memory based on the charging request; the target charging rule is obtained by configuring the rule based on a visual rule configuration interface; A rule parsing module 630 is used to parse the target charging rule to obtain a rule file executable by a rule engine; The fee calculation module 640 is used to perform fee calculation based on the rule file and the order information of the target charging item through the rule engine to obtain the charging result of the target charging item.
[0080] In a possible implementation, the target charging rule includes condition configuration and operation rule configuration, and the rule parsing module 630 includes: A first parsing submodule, configured to parse the billing elements used in the condition configuration in the target billing rule to obtain a first billing element list; A second parsing submodule is used to parse the charging factors used in the calculation rule configuration in the target charging rule to obtain a factor list; A third parsing submodule is used to traverse the factor list, parse the factor calculation rule of each charging factor, and obtain a second charging element list; A rule conversion submodule is used to perform rule conversion based on a rule engine based on the billing element list and the factor list to obtain a rule file executable by the rule engine; the billing element list includes the first billing element list and the second billing element list; the rule file contains a condition part of the rule based on the rule engine and an action part of the rule based on the rule engine.
[0081] In a possible implementation, the rule conversion submodule includes: A first conversion unit, configured to traverse the billing element list, perform rule conversion based on a rule engine based on a condition configuration and an operation rule configuration of each billing element in the billing element list, and generate a billing element rule file; A second conversion unit is used to use the output of the full amount of charging factor rules in the charging factor rule file as a factor rule variable, re-traverse the factor list, perform rule conversion based on the rule engine based on the factor calculation rule of each charging factor in the factor list, and generate a factor rule file; The third conversion unit is used to use the full charging factor in the factor rule file and the output of the full charging element rule as variables of the charging rule, traverse the charging item list, perform rule conversion based on the rule engine based on the cost calculation rule of each charging item in the charging item list, and generate a charging rule file.
[0082] In a possible implementation, the fee calculation module 640 is used to: Executing the billing factor rule file through the rule engine to obtain a billing factor value associated with the target billing item; Executing the factor rule file through the rule engine, calculating the factor value according to the charging element value, and obtaining the factor value associated with the target charging item; The fee rule file is executed by the rule engine, and the fee value is calculated according to the factor value to obtain the fee calculation result of the target fee calculation item.
[0083] In a possible implementation manner, the device further includes: The result display module is used to display the calculation result and calculation process of the target charging item in a visual display manner.
[0084] In a possible implementation manner, the device further includes: An interface display module, used to display the visualization rule configuration interface; the visualization configuration interface includes interactive elements; the interactive elements include interactive elements corresponding to condition configuration and interactive elements corresponding to operation rule configuration; An information generation module, configured to generate configuration information based on the configuration operation received from the user through the visual rule configuration interface; A rule generation module is used to generate corresponding charging rules based on the configuration information.
[0085] In one possible implementation, the cost calculation module 640 is used to: If the billing item corresponding to the generated new billing rule has an original billing rule and the original billing rule is in an applied state, during the loading process of the new billing rule, the billing request of the corresponding billing item is processed based on the original billing rule; After the new charging rule is loaded, the charging request of the corresponding charging item is processed based on the new charging rule.
[0086] In summary, the billing device provided by the embodiment of the present application, when the billing business system is decoupled from the order business system, the billing business system receives the billing request of the target billing item sent by the order business system, and reads the target billing rule corresponding to the target billing item from the system memory based on the billing request, and obtains the rule file executable by the rule engine by parsing the target billing rule, and then calculates the cost based on the rule sorting and the order information of the target billing item by the rule engine, and obtains the billing result of the target billing item; wherein, the target billing rule is obtained by the user through rule configuration based on the visual rule configuration interface; through the above-mentioned device, the cost calculation of the billing item can be realized in the billing business system decoupled from the order business system, thereby simplifying the billing logic of the system, reducing the billing processing time, and improving the billing efficiency; In addition, by decoupling the billing business system from the order business system, the complexity of the order management system can be reduced, and the maintainability and risk resistance of the system can be improved.
[0087] Figure 7 The structural block diagram of a computer device 700 shown in an exemplary embodiment of the present application is shown. The computer device can be implemented as a charging business system and / or an order business system in the above-mentioned scheme of the present application. The computer device 700 includes a central processing unit (CPU) 701, a system memory 704 including a random access memory (RAM) 702 and a read-only memory (ROM) 703, and a system bus 705 connecting the system memory 704 and the central processing unit 701. The computer device 700 also includes a large-capacity storage device 706 for storing an operating system 709, an application program 710 and other program modules 711.
[0088] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, Erasable Programmable Read Only Memory (EPROM), Electronically-Erasable Programmable Read-Only Memory (EEPROM) flash memory or other solid-state storage technology, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, cassettes, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that the computer storage medium is not limited to the above. The above-mentioned system memory 704 and mass storage device 706 can be collectively referred to as memory.
[0089] According to various embodiments of the present disclosure, the computer device 700 can also be connected to a remote computer on the network through a network such as the Internet. That is, the computer device 700 can be connected to the network 708 through the network interface unit 707 connected to the system bus 705, or the network interface unit 707 can be used to connect to other types of networks or remote computer systems (not shown).
[0090] The memory also includes at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is stored in the memory. The central processing unit 701 implements all or part of the steps in the charging method shown in the above-mentioned embodiments by executing the at least one instruction, at least one program, code set or instruction set.
[0091] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one computer program is stored, and the computer program is loaded and executed by a processor to implement all or part of the steps in the above-mentioned charging method. For example, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0092] In an exemplary embodiment, a computer program product is also provided, the computer program product comprising at least one computer program, the computer program being loaded and executed by a processor Figure 2 or Figure 3 All or part of the steps of the charging method shown in any embodiment.
[0093] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the claims.
[0094] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A charging method, characterized in that: The method is executed by a charging service system, and the charging service system is decoupled from the order service system; the method includes: Receiving a charging request for a target charging item sent by an order business system; the charging request includes order information of the target charging item; Reading a target charging rule corresponding to the target charging item from a system memory based on the charging request; the target charging rule is obtained by configuring a rule based on a visual rule configuration interface; Parsing the target charging rule to obtain a rule file executable by a rule engine; The rule engine performs fee calculation based on the rule file and the order information of the target fee-charging item to obtain a fee-charging result of the target fee-charging item.
2. The method according to claim 1, characterized in that The target charging rule includes condition configuration and operation rule configuration. The target charging rule is parsed to obtain a rule file executable by a rule engine, including: Parsing the billing elements used in the condition configuration in the target billing rule to obtain a first billing element list; Parsing the charging factors used in the calculation rule configuration in the target charging rule to obtain a factor list; Traversing the factor list, parsing the factor calculation rule of each charging factor, and obtaining a second charging element list; Based on the billing element list and the factor list, rule conversion based on the rule engine is performed to obtain a rule file executable by the rule engine; the billing element list includes the first billing element list and the second billing element list; the rule file contains a condition part of the rule based on the rule engine and an action part of the rule based on the rule engine.
3. The method according to claim 2, characterized in that The rule conversion based on the billing element list and the factor list is performed based on the rule engine to obtain a rule file executable by the rule engine, including: Traversing the billing element list, performing rule conversion based on a rule engine based on the condition configuration and operation rule configuration of each billing element in the billing element list, and generating a billing element rule file; Using the output of the full amount of charging factor rules in the charging factor rule file as the factor rule variable, re-traversing the factor list, performing rule conversion based on the rule engine based on the factor calculation rule of each charging factor in the factor list, and generating a factor rule file; The full charging factor in the factor rule file and the output of the full charging element rule are used as variables of the charging rule, the charging item list is traversed, and the rule conversion based on the rule engine is performed based on the cost calculation rule of each charging item in the charging item list to generate a charging rule file.
4. The method according to claim 3, characterized in that The calculating the cost by the rule engine based on the rule file and the order information of the target charging item to obtain the charging result of the target charging item includes: Executing the billing factor rule file through the rule engine to obtain a billing factor value associated with the target billing item; Executing the factor rule file through the rule engine, calculating the factor value according to the charging element value, and obtaining the factor value associated with the target charging item; The fee rule file is executed by the rule engine, and the fee value is calculated according to the factor value to obtain the fee calculation result of the target fee calculation item.
5. The method according to claim 1, characterized in that: The method further comprises: The calculation results and calculation process of the target charging item are displayed in a visual manner.
6. The method according to claim 1, characterized in that The method further comprises: Displaying the visualization rule configuration interface; the visualization configuration interface includes interactive elements; the interactive elements include interactive elements corresponding to condition configurations and interactive elements corresponding to operation rule configurations; Generate configuration information based on the received configuration operation performed by the user through the visual rule configuration interface; Generate corresponding charging rules based on the configuration information.
7. The method according to claim 6, characterized in that The method further comprises: If the billing item corresponding to the generated new billing rule has an original billing rule and the original billing rule is in an applied state, during the loading process of the new billing rule, the billing request of the corresponding billing item is processed based on the original billing rule; After the new charging rule is loaded, the charging request of the corresponding charging item is processed based on the new charging rule.
8. A charging device, characterized in that: The device is applied to a charging service system, and the charging service system is decoupled from an order service system; the device comprises: A request receiving module, used to receive a charging request of a target charging item sent by an order business system; the charging request includes order information of the target charging item; A rule reading module, configured to read a target charging rule corresponding to the target charging item from a system memory based on the charging request; the target charging rule is obtained by configuring the rule based on a visual rule configuration interface; A rule parsing module, used to parse the target charging rule to obtain a rule file executable by a rule engine; The fee calculation module is used to perform fee calculation based on the rule file and the order information of the target charging item through the rule engine to obtain the charging result of the target charging item.
9. A computer device, characterized in that: The computer device includes a processor and a memory, the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the charging method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the computer program is loaded and executed by a processor to implement the charging method according to any one of claims 1 to 7.