Fee calculation method, device, equipment and medium
By using modular encapsulation and distributed caching, the problems of long processing time and resource consumption in the financial business billing process have been solved, enabling flexible combination of billing capabilities and improving system performance.
Patent Information
- Application Number
- CN202510919157.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-04
- Publication Date
- 2025-11-21
AI Technical Summary
In financial business scenarios, the existing billing process is time-consuming, consumes underlying database resources, and is difficult to flexibly handle combined algorithm scenarios, affecting the original algorithm logic, and lacks an effective solution.
The steps in the cost calculation process are encapsulated as components, linked by configuration and a chain of responsibility, enabling dynamic combination of cost calculation capabilities. Distributed caching is used for data processing, and multi-level hash ring partitioning is used to improve data location speed.
It enables flexible combination of the calculation process, reduces the coupling between computing and storage, improves system response speed and processing capacity, reduces data query complexity, and enhances system scalability and stability.
Smart Images

Figure CN120996955A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a fee calculation method, device, equipment and medium. BACKGROUND
[0002] In a financial service scenario, a user needs to generate a repayment plan according to some specified algorithm when applying for a loan, which is called fee calculation. Common algorithms for fee calculation include equal principal and interest, equal principal, one-time repayment of principal and interest, etc. In addition to algorithms, a series of parameters need to be provided for the algorithms, such as the repayment period, the number of days of the amount of money, the difference calculation of the guarantee fee, etc. In actual business, there are often combined algorithm scenarios, such as adjusting the first month-end according to the daily interest rate, and the remaining period according to the equal principal and interest rate. When such a combined scenario occurs, special scene compatibility needs to be added to the original equal principal and interest algorithm, which sometimes affects the original algorithm logic. Moreover, the entire process of fee calculation takes a long time and produces long transactions, occupying underlying database resources.
[0003] At present, there is a lack of an effective solution to the above problems. SUMMARY
[0004] Therefore, it is necessary to provide a fee calculation method, device, equipment and medium to encapsulate different steps into components, dynamically combine the fee calculation capabilities by configuration and responsibility chain, and dynamically realize various fee calculation scenario combinations by reading different configurations for different business scenarios.
[0005] According to a first aspect of the present application, a fee calculation method is provided, including the following steps:
[0006] The component calculation step separately calculates each fee calculation component;
[0007] The combination step combines each fee calculation component according to the calculation scenario requirements to realize fee calculation. In some embodiments, the fee calculation component includes a repayment day calculation component, a repayment component calculation component, and a discount calculation component.
[0008] In some embodiments, the repayment component calculation component can implement calculations including interest calculation and guarantee fee calculation.
[0009] In some embodiments, the combination of each fee calculation component according to the calculation scenario requirements includes dynamically combining the fee calculation components through configuration and responsibility chain, and dynamically realizing the combination of the fee calculation components in various calculation scenarios by reading different configurations for different business scenarios.
[0010] In some embodiments, the fee calculation method adopts a separate design for calculation and storage.
[0011] In some embodiments, in the fee calculation method, reading and writing of data are processed by using a distributed cache; the distributed cache uses a multi-level hash ring to partition a data field; and the multi-level hash ring divides the data field into a plurality of first-level partitions according to a hash value field.
[0012] In some embodiments, in the distributed cache, when a first-level partition has a high concurrent demand, the first-level partition is dynamically split into a plurality of second-level partitions according to a hash value field of the first-level partition.
[0013] According to a second aspect of the present application, a fee calculation device is provided, comprising: a component calculation module, configured to separately calculate each fee calculation component; and a combination module, configured to combine each fee calculation component according to a calculation scenario, so as to realize fee calculation.
[0014] According to a third aspect of the present application, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method of any one of the above embodiments when executing the computer program.
[0015] According to a fourth aspect of the present application, a computer readable storage medium is provided, which stores a computer program, and the computer program is executable on a processor to implement the steps of the method of any one of the above embodiments.
[0016] By implementing the above scheme of the present application, the following beneficial effects can be obtained:
[0017] 1. Different steps in the fee calculation process are encapsulated in components, and the ability of fee calculation is dynamically combined by configuration and responsibility chain series connection, so as to realize combination of various fee calculation scenarios by reading different configurations.
[0018] 2. Calculation and storage are separated, so that time-consuming calculation nodes do not occupy transactions, and the calculation process and the storage process are decoupled.
[0019] 3. Distributed cache is used for reading and writing of data, so as to improve the response speed and processing capacity of the overall fee calculation system, and through the multi-level evenly divided hash ring, the positioning speed of data is improved. Compared with the non-uniform partition of the consistent hash, the time complexity of finding the node of the data item through the hash ring binary search is O(log N), and the fixed partition improves the query efficiency of data, and the time complexity is reduced to O(1). BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 is a flow chart showing some embodiments of the fee calculation method of the present application;
[0021] Figure 2 is a structural schematic diagram showing some embodiments of the fee calculation device of the present application;
[0022] Figure 3 FIG. 1 is a diagram showing an internal structure of a computer device for implementing some embodiments of the present application. DETAILED DESCRIPTION
[0023] The technical solutions in the embodiments of the present application will be clearly and completely described with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way limiting on the application or its applications or uses. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of the present application.
[0024] Figure 1 FIG. 2 is a flowchart showing some embodiments of the fee calculation method of the present application.
[0025] As shown in FIG. 2, the method comprises the following steps: Figure 1
[0026] The component calculation step S102 calculates each fee calculation component separately;
[0027] The combination step S104 combines each fee calculation component according to the calculation scenario requirements to realize fee calculation.
[0028] In some embodiments, the fee calculation component comprises: a repayment date calculation component, a repayment component calculation component, and a discount calculation component. The repayment date calculation can include: fixed billing date, month-end adjusted billing date, one day in advance adjusted billing date, etc. The repayment component calculation can include: principal and interest calculation, premium calculation. The discount calculation can include: interest rate discount, amount deduction, product discount, etc.
[0029] In some embodiments, the combination of each fee calculation component according to the calculation scenario requirements comprises: dynamic combination of fee calculation components through configuration and responsibility chain series, and different business scenarios realize the combination of fee calculation components in various calculation scenarios by reading different configurations. The dynamic combination can be, for example: fixed billing date + equal principal + rolling premium + interest rate discount; month-end adjusted billing date + equal principal and interest + no premium + no discount.
[0030] In some embodiments, in the fee calculation method, the calculation and storage adopt a separate design. The time-consuming calculation node does not occupy a transaction, but only produces a corresponding business domain object. The business domain object is converted into a data domain object in the storage node, and no long transaction is generated. The calculation process and the storage process are decoupled.
[0031] In order to cope with the growing data size, improve the access and processing capacity of data in the system, in some embodiments, the reading and writing of data are processed by using a distributed cache; the distributed cache uses a multi-level hash ring to partition the data domain, and divides the data domain into multiple first-level partitions according to the hash value domain. Compared with the non-uniform partitioning of the traditional consistent hashing, the time complexity of finding the node of the data item by the hash ring binary search is O (log n), and the fixed partitioning improves the query efficiency of the data and reduces the time complexity to O (1). Further, when the storage capacity is insufficient or higher concurrency is required, the partition is split into multiple second-level partitions, such as splitting the hash interval [1204, 2048) into [1024, 1536), [1536-2048).
[0032] In addition, in order to ensure the fault tolerance of the system, data backup processing is usually performed. In the present application, data backup can be performed by using one primary data shard and multiple secondary data shards in the partition. Since the traditional consistent hashing algorithm can only map data items to one node, the processing capacity of concurrency is insufficient. Therefore, further, in order to improve the writing speed, by applying multiple independent hash functions to the same data item, the same writing operation is simultaneously mapped to multiple different cache nodes, and the corresponding replica data is written in parallel in each node; by adding the current timestamp, when reading data, the latest writing data is output as the reading data by comparing the time on the timestamp; for example, the writing data is (V i ,t i ),(V j ,t j ), t is a timestamp, t i is compared with t j , and the data closest to the current time is selected as the reading data output. By parallel writing, the writing request pressure is dispersed, and the overall writing performance of the system under high concurrency conditions is improved; and when part of the nodes fail or have communication abnormalities, other nodes can still successfully receive and save the writing data, ensuring that the writing operation has a higher success rate and system stability; the timestamp is recorded when writing, and the timestamp size of each replica is compared when reading to select, which balances the performance and correctness in the scene without strong consistency guarantee.
[0033] The fee calculation method of the present application can realize dynamic assembly to cope with multiple scene requirements by componentizing the fee calculation capability, without frequent code development, and has high expansibility. Each component is independent of other components and is not coupled with other components, and updating a single component will not affect other components, has high compatibility and low coupling. When reading and writing data, distributed cache processing is used to improve the processing capacity of the system, and a multi-level evenly divided hash ring is used to improve the positioning speed of the data.
[0034] The application further provides a fee calculation device. Figure 2 As shown in the figure, comprising:
[0035] The component calculation module 100 is used for separately calculating each fee calculation component.
[0036] The combination module 200 is used for combining each fee calculation component according to the requirement of the calculation scene, and realizing fee calculation.
[0037] The specific limitation of the fee calculation device can refer to the limitation of the fee calculation method in the above, and will not be repeated here. Each module in the above fee calculation device can be realized by software, hardware and combination thereof in whole or in part. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so as to call and execute the operation corresponding to each module by the processor.
[0038] The application further provides a computer device, which can be a terminal, and the internal structure diagram thereof can be as shown in the figure. Figure 3 The computer device comprises a processor, a memory, a network interface, a display screen and an input device connected through a system bus. The processor of the computer device is used for providing calculation and control capability. The memory of the computer device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used for communicating with the external terminal through network connection. The computer program is executed by the processor to realize the above fee calculation method. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc. Those skilled in the art can understand that the structure shown in the figure is only a block diagram of part of the structure related to the application scheme, and does not constitute a limitation on the computer device to which the application scheme is applied. The specific computer device can comprise more or less components than those shown in the figure, or combine certain components, or have different component arrangement. Figure 3
[0039] The application further provides a computer readable storage medium, which stores a computer program. The computer program is executed by the processor to realize the above fee calculation method.
[0040] Those skilled in the art can understand that all or part of the processes in the above-mentioned method embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiments. Any reference to memory, storage, database or other medium used in the embodiments of the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus), direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0041] So far, the embodiments of the present application have been described in detail. In order to avoid obscuring the concept of the present application, some details known in the art are not described. Those skilled in the art can fully understand how to implement the technical solutions disclosed herein according to the above description.
[0042] Although some specific embodiments of the present application have been described in detail through examples, those skilled in the art should understand that the above examples are only for illustration, not for limiting the scope of the present application. Those skilled in the art should understand that the above embodiments can be modified or some technical features can be replaced equivalently without departing from the scope and spirit of the present application. The scope of the present application is defined by the appended claims.
Claims
1. A fare calculation method characterized by, The method comprises the following steps: The component calculation step is to calculate each fee calculation component separately; The combination step is to combine each fee calculation component according to the calculation scene requirement to realize fee calculation.
2. The fee calculation method according to claim 1, wherein The fee calculation component comprises a repayment date calculation component, a repayment component calculation component, and a discount calculation component.
3. The fee calculation method according to claim 2, wherein The repayment component calculation component can realize calculation including principal and interest calculation and premium calculation.
4. The fee calculation method according to claim 1, wherein The combination of each fee calculation component according to the calculation scene requirement comprises dynamic combination of fee calculation components through configuration and responsibility chain series connection, and different business scenes realize dynamic fee calculation component combination in various calculation scenes by reading different configurations.
5. The fee calculation method according to claim 1, wherein In the fee calculation method, calculation and storage are designed separately.
6. The fee calculation method according to claim 1, wherein In the fee calculation method, the reading and writing of data are processed by using a distributed cache; The distributed cache uses a multi-level hash ring to partition the data domain; The multi-level hash ring divides the data domain into multiple first-level partitions according to the hash value domain.
7. The fee calculation method according to claim 6, wherein In the distributed cache, when a first-level partition has high concurrent demand, the first-level partition is dynamically split into multiple second-level partitions according to the hash value domain of the first-level partition.
8. A fare calculation device characterized by comprising: It comprises: The component calculation module is used to calculate each fee calculation component separately; The combination module is used to combine each fee calculation component according to the calculation scene requirement to realize fee calculation.
9. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to realize the steps of the method in any one of claims 1 to 7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to realize the steps of the method in any one of claims 1 to 7.