Method and device for generating high-concurrency payment flow serial number of bank distributed payment system

By using a method combining central database and program memory in a distributed payment system, the payment flow serial number is generated, which solves the problems of repetition and disorder of serial numbers under high concurrency, and the requirements of uniqueness, orderliness and traceability are achieved.

CN120106832AInactive Publication Date: 2025-06-06MEIZHOU HAKKA BANK CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510559420.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-30
Publication Date
2025-06-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art is difficult to effectively generate unique, orderly, distinguishable and traceable payment flow serial numbers in distributed payment systems with high concurrency and large transaction volume, resulting in duplicate flow, disorder and difficult to distinguish.

Method used

By establishing a sequence list in the central database, the corresponding sequence value is called in different stages according to the payment service, and the node value is calculated in the program memory, and the machine ID, timestamp and sequence value are spliced ​​to form a flowing sequence number.

Benefits of technology

It realizes the generation of unique, orderly, distinguishable and traceable payment serial numbers under high concurrency, reducing the possibility of repeated serial numbers and improving the stability and efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120106832A_ABST
    Figure CN120106832A_ABST
Patent Text Reader

Abstract

The invention relates to the field of bank financial data processing, and discloses a high-concurrency payment flow serial number generation device and method for a bank distributed payment system, the device comprises a central database and a program memory, the central database stores an ordered list, and the sequence list comprises a service name and a corresponding sequence value; calling the service name and the sequence value in the sequence table through a program memory, adding the number value to the sequence value to form a maximum value executed by the current service, and updating the maximum value to the sequence table for next calling; the program memory calls the service name, the machine ID and the timestamp of the sequence table and the serial number which is generated in the program memory and is smaller than the maximum value, then splicing generation of the payment flow serial number is completed, and by the adoption of the scheme, the requirements for uniqueness, orderliness, distinguishability and traceability of the payment flow are met, and the serial number generation efficiency can also be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of bank financial data processing, and in particular to a method and device for generating high-concurrency payment flow sequence numbers of a bank distributed payment system. Background Art

[0002] In the existing banking fintech payment field, for financial transactions, payment serial numbers are generally required to identify and find a financial transaction. For distributed payment systems with high concurrency and large transaction volumes, duplicate transactions, disorder, and difficulty in identification often occur, resulting in system anomalies and problems in the search for fund transaction records by business personnel. The existing methods for generating serial numbers on the market mainly include the following methods: 1. Timestamp method: Use timestamps accurate to milliseconds as serial numbers. If the timestamp method is used alone, duplication problems will occur when multiple machines access the data at the same time and there is high concurrency.

[0003] Second, the database auto-increment ID, create an auto-increment field in the database, and the field automatically increments every time a new record is inserted. This method is simple and easy, but in a distributed environment, it is necessary to consider cross-database and cross-server. Since the generation of the database auto-increment ID depends on the counter inside a single database, in a distributed system, database instances on different nodes cannot directly share and coordinate the value of the counter, which may cause conflicts.

[0004] 3. UUID method: UUID is a 128-bit value, usually expressed as 32 hexadecimal digits, divided into 5 segments, in the form of {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}. UUID consists of a timestamp, clock sequence, and hardware address, which can almost guarantee uniqueness worldwide, but lacks orderliness and is difficult to distinguish, making it unsuitable for banking transactions.

[0005] Fourth, the atomic incrementer method uses thread-safe atomic variables to generate incremental serial numbers. This is only applicable to a single-machine environment, but in a distributed system, a global coordinator is required to manage the increment operation, which increases the waste of system resources.

[0006] 5. The ID is generated based on the Snowflake algorithm. The Snowflake algorithm is a distributed ID generation algorithm developed by Twitter. The ID it generates is a 64-bit integer, including a timestamp, data center ID, machine ID, and serial number.

[0007] However, the Snowflake algorithm is highly dependent on system timestamps. If the server's system time is dialed back, that is, the system time goes backwards, it may cause duplicate IDs to be generated. For example, when the system time is dialed back from T to T-1, the algorithm may regenerate an ID that has been generated before.

[0008] Sixth, the random number generator generates serial numbers. The serial numbers are generated by the random number generator random. The random number generator is essentially a pseudo-random number generator. The random number sequence it generates is calculated using a specific algorithm and seed. In a distributed system, if multiple nodes use the same algorithm and seed, or are initialized in a short period of time, the same random number sequence may be generated, resulting in duplicate serial numbers.

[0009] None of the above methods are suitable for generating serial numbers in the case of high concurrency in bank payment flows. Therefore, a method for generating serial numbers for identifying unique transactions and payment flows is required for distributed payment systems to meet the requirements of uniqueness, orderliness, distinguishability and traceability of payment flows. Summary of the invention

[0010] The present invention is intended to provide a method and device for generating a high-concurrency payment flow sequence number for a distributed payment system of a bank, so as to realize the generation of a sequence number for identifying a unique transaction and payment flow required by the distributed payment system.

[0011] To achieve the above object, the present invention adopts the following technical solution: a method for generating a high-concurrency payment flow sequence number in a bank distributed payment system, comprising the following steps: S1: Establish a sequence table in the central database, the sequence table includes multiple business names and sequence values ​​corresponding to the business names; S2: according to different payment services, the sequence value of the corresponding payment service is periodically called from the sequence table, the sequence value is stored in the program memory as the starting value, and a quantity value is set in the program memory, the sum of the quantity value and the starting value is calculated to form a node value, and the node value is also stored in the program memory; at the same time, in the sequence table, the node value is used as the new sequence value of the service name; S3: Get the machine ID of the current application; S4: Get the timestamp of the current system; S5: When a payment task issues a request to add a serial number, in the program memory, the starting value is first used as the serial number required for the serial number. When the task needs a new serial number, the starting value is accumulated one by one to form a new serial number. S6: Concatenate the business name in step S1, the machine ID in step S3, the timestamp in step S4 and the sequence value in step S5 to form a serial number, and send it to the payment task for use.

[0012] The principle and advantage of this solution are: in actual application, since the distributed payment system splits each functional system into different service modules, which has high requirements for data consistency, the serial number in this method is completed by splicing, and each spliced ​​part has an independent meaning, making the serial number easy to identify, so that the same business part in the distributed system can be identified using the same serial number.

[0013] In addition, the serial number spliced ​​by this solution includes the business name, machine ID, timestamp and sequence value, which greatly reduces the possibility of serial number duplication. It can fully meet the current high-concurrency serial number usage.

[0014] Finally, due to the high concurrency of the payment system, there are a large number of transactions in the same period. This solution first names each business type separately, assigns a sequence value to each business type, and stores multiple business types and corresponding sequence values ​​in a central database through a table. In this way, the sequence value of the business in the sequence table can be selected according to the different businesses, so that the sequence value of each business does not interfere with each other.

[0015] In the process of generating a serial value of a running sequence number, this solution designs a separate serial value for each business, and various types of serial values ​​are stored in the central database. Since the database is in the computer resources, it is mainly used as a data storage unit and has weak computing power. During calculation, data is called from the database through the program memory. After the program memory is calculated, the result is stored in the central database. However, although the program memory has strong computing power, it has limited storage data. Because of the high concurrency situation, if each time a serial number is generated, the database data is called, and then the result is stored in the central database, the next serial number is generated, and the cycle is repeated. This not only increases the computer resource consumption in the data interaction process; most importantly, it may cause the business under high concurrency demand to be in a queue.

[0016] The clever design of this method is that only the number of serial numbers generated in one stage is set in the program memory, and the program memory only calls data from the database once in each stage; the sequence values ​​required for one stage are successively generated in the program memory by accumulation. In order to prevent the sequence values ​​from being repeated, the maximum sequence value generated in one stage in the program memory, that is, the node value described in this application, is sent to the central database, and the sequence value is only updated once in one stage in the central database. Updating the sequence value in the central database and generating the sequence value in the program memory are both completed independently, which not only speeds up the generation of the sequence number, but also eliminates the need to frequently call the data in the central database. It saves computer computing resources, and ultimately improves the efficiency of sequence number generation, solving the problem of not being able to generate sequence numbers in time during high concurrency.

[0017] Preferably, in step S1, the service name is a custom string, the sequence value is a positive integer, and the initial value of the sequence value is 1; the service name directly uses a string, which increases the human readability of the serial number, and the service type can be directly known from the meaning of the string. The sequence value uses a positive integer to simplify the calculation difficulty of the program memory.

[0018] Preferably, the service names in the sequence table can be increased or decreased according to the service requirements, the sequence values ​​corresponding to each service name do not interfere with each other, and the service names are not allowed to have the same character string.

[0019] When a new business is generated during the operation of the payment system, a row can be directly added to the sequence table as the name and sequence value of the new business, which improves the convenience of later software system maintenance.

[0020] Preferably, in step S2, the quantity value is an integer of 100*N, where N≥1; Preferably, in step S3, the machine ID of the current application is obtained through the hostname command.

[0021] Preferably, in step S4, the date tool DateUtil is used to obtain the current system timestamp, accurate to milliseconds, and the date is formatted as a number.

[0022] Preferably, in step S5, if there are multiple tasks of the same business type that all issue requests to add serial number, each task calls the sequence value from the sequence table into its own program memory in turn, and the sequence value called by the next task is the sequence value called by the previous task plus the quantity value to form the sequence value, and each task independently outputs the sequence value required for the task serial number in the program memory.

[0023] Beneficial effect: When multiple businesses of the same type need to call sequence values, there is no need to distinguish the businesses. Each business can first use the predetermined quantity value of each business, and each business can call the sequence value updated by the previous business in turn, and finally only store the node value of the last business in the database. Multiple businesses of the same type can complete the generation of sequence values ​​in their own program memory separately, avoiding frequent calls to the data in the database, which increases the amount of calculation in the database.

[0024] Preferably, in step S5, the serial value part of the running sequence number is a fixed number of digits, and the serial value that is less than the fixed number of digits is supplemented with 0 on the left side of the serial value, and when the number of digits of the serial value exceeds the fixed number of digits, the corresponding serial value in the database is reset to 1. By unifying the serial number format, the accuracy of the serial number output is guaranteed.

[0025] Preferably, in step S5, when the business needs a new serial number, after each sequence value is generated, it is necessary to determine whether the next generated sequence value is equal to the node value. If it is equal to the node value, the business repeats steps S2 and S3, and caches the new starting value and node value in the program memory of the business.

[0026] Beneficial effect: In the program memory of each business, only one stage of sequence value generation can be completed. Therefore, in order to prevent the generation of sequence number errors, after each sequence value is generated, it is necessary to determine whether the next generated sequence value is equal to the node value.

[0027] In order to complete the generation of the entire payment flow sequence number, the present application provides a payment flow sequence number generation device for executing the steps of a high-concurrency payment flow sequence number generation method, including a central database and a program memory, the central database is used to store a sequence table, and the sequence table stores and changes the business name and the sequence value corresponding to the business name; the program memory is used to call the business name and sequence value in the sequence table, call the machine ID currently processing the payment business, and call the timestamp of the current system, and the program memory stores an executable program for splicing the payment flow sequence number. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 This is a flow chart of the steps of the payment sequence number generation method according to Embodiment 1 of the present invention.

[0029] Figure 2 This is a schematic diagram of the structure of a payment sequence number generating device according to Embodiment 2 of the present invention.

[0030] Figure 3 Schematic diagram of a method for updating sequence table and program memory data according to embodiment 1 of the present invention.

[0031] Figure 4 This is a schematic diagram of the sequence table structure of Example 1 of the present invention. DETAILED DESCRIPTION

[0032] The following is further described in detail through specific implementation methods: The reference numerals in the drawings of the specification include: central database 1, sequence table 2, business server 3, program memory 4, calling service 5, and serial number splicing module 6.

[0033] Example 1 As attached Figure 1 and Figure 2 The method for generating high-concurrency payment flow sequence numbers of a bank distributed payment system shown includes the following steps: S1: establishing a sequence table in a central database, the sequence table including multiple business names and sequence values ​​corresponding to the business names.

[0034] S2: According to different payment services, the sequence value of the corresponding payment service is called from the sequence table in stages, the sequence value is stored in the program memory as the starting value, and a quantity value is set in the program memory, and the sum of the quantity value and the starting value is calculated to form a node value, and the node value is also stored in the program memory; at the same time, in the sequence table, the node value is used as the new sequence value of the service name; the quantity value is an integer of 100*N, N≥1.

[0035] S3: Get the machine ID of the current application; get the machine ID of the current application through the hostname command.

[0036] S4: Get the current system timestamp; use the date tool DateUtil to get the current system timestamp, accurate to milliseconds and format the date as a number.

[0037] S5: When a payment task issues a request to add a serial number, the starting value is first used as the serial value required for the serial number in the program memory. When the task needs a new serial number, the new serial value is accumulated one by one based on the starting value.

[0038] The sequence value part in the serial number is a fixed number of digits. This embodiment uses six digits. If the sequence value is less than six digits, 0 is added to the left of the sequence value. When the number of digits of the sequence value exceeds six digits, the corresponding sequence value in the database is reset to 1.

[0039] S6: Concatenate the business name in step S1, the machine ID in step S3, the timestamp in step S4 and the sequence value in step S5 to form a serial number, and send it to the payment task for use.

[0040] like Figure 4As shown, in step S1, the service name is a custom string, the sequence value is a positive integer, and the initial value of the sequence value is 1; the service name can be added or reduced in the sequence table according to business needs, the sequence values ​​corresponding to each service name do not interfere with each other, and the service names are not allowed to have the same string.

[0041] like Figure 3 As shown: Select the quantity value of 500 each time. If there are multiple tasks of the same business type in step S5 that all send out requests to add a running sequence number, each task will call the sequence value from the sequence table to its own program memory in turn. The sequence value of the first task called for the first time is "1", and the node value stored in the task program memory is "501". A maximum of 500 sequence values ​​can be generated in the program memory. At this time, the sequence value in the sequence table is updated to "501". When the sequence value called by the next task is the sequence value formed by the sequence value called by the previous task plus the quantity value, each task independently outputs the sequence value required for the task running sequence number in the program memory.

[0042] When multiple businesses of the same type need to call sequence values, there is no need to distinguish the businesses. Each business can first use the predetermined quantity value for each business, and each business can call the sequence value updated by the previous business in turn, and finally only store the node value of the last business in the database. Multiple businesses of the same type can complete the generation of sequence values ​​in their own program memory separately, avoiding frequent calls to the data in the database, which increases the amount of calculation in the database.

[0043] In step S5, when the business needs a new serial number, after each sequence value is generated, it is necessary to determine whether the next generated sequence value is equal to the node value. If it is equal to the node value, the business repeats steps S2 and S3, and caches the new starting value and node value in the program memory of the business.

[0044] Example 2 like Figure 2 As shown, a payment flow sequence number generating device is used to execute the steps of a high-concurrency payment flow sequence number generating method, including a central database 1, a program memory 4 and a sequence number splicing module 6, the central database 1 stores an ordered list 2, the sequence list 2 stores and changes the business name and the sequence value corresponding to the business name; the program memory 4 retrieves the business name and sequence value in the sequence list 2 by calling a service 5; the calling service 5 also calls the machine ID of the current processing business server 3, and the timestamp of calling the current business server 3, the program memory 4 calculates the continuously available sequence value, and the sequence number splicing module 6 stores the executable program for splicing the payment flow sequence number.

[0045] In the process of generating a serial value of a running sequence number, this solution designs a separate serial value for each business, and various types of serial values ​​are stored in the central database. Since the database is in the computer resources, it is mainly used as a data storage unit and has weak computing power. During calculation, data is called from the database through the program memory. After the program memory is calculated, the result is stored in the central database. However, although the program memory has strong computing power, it has limited storage data. Because of the high concurrency situation, if each time a serial number is generated, the database data is called, and then the result is stored in the central database, the next serial number is generated, and the cycle is repeated. This not only increases the computer resource consumption in the data interaction process; most importantly, it may cause the business under high concurrency demand to be in a queue.

[0046] In this embodiment, only the number of sequence numbers generated in one stage is set in the program memory, and the program memory in each stage only calls data from the database once; the sequence values ​​required for this stage are successively generated in the program memory by accumulation.

[0047] In order to prevent the sequence value from being repeated, the maximum sequence value generated in the program memory at this stage, that is, the node value described in this application, is sent to the central database. In one stage, the sequence value is updated only once in the central database, saving computer computing resources. The sequence table updates the sequence value and the program memory generates the sequence value. Both are completed independently, which can not only speed up the generation of the sequence number, but also does not need to frequently call the data in the central database. Computer computing resources are saved, and the efficiency of sequence number generation is finally improved, solving the problem that high concurrency cannot generate sequence numbers in time.

[0048] The above is only an embodiment of the present invention, and the common knowledge such as the known specific technical solutions and / or characteristics in the solution is not described in detail here. It should be pointed out that for those skilled in the art, without departing from the technical solution of the present invention, several modifications and improvements can be made, which should also be regarded as the protection scope of the present invention, and these will not affect the effect of the implementation of the present invention and the practicality of the patent. The scope of protection required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.

Claims

1. A method for generating high-concurrency payment sequence numbers in a bank distributed payment system, characterized in that: The following steps are included: S1: Establish a sequence table in the central database, the sequence table including the names of multiple services and the sequence values ​​corresponding to the names of the multiple services; S2: According to the payment service development type, the sequence value corresponding to the service is periodically called from the sequence table, the sequence value is used as the starting value and stored in the program memory, and a quantity value is set in the program memory, the sum of the quantity value and the starting value is calculated to form a node value, and the node value is also stored in the program memory; at the same time, in the sequence table, the node value is used as the sequence value corresponding to the service name; S3: Get the machine ID of the current application; S4: Get the timestamp of the current system; S5: When a payment task issues a request to add a serial number, in the program memory, the starting value is first output as the serial number required for the serial number. When the task needs a new serial number, the starting value is accumulated one by one to form a new serial number for output; S6: Concatenate the service name in step S1, the machine ID in step S3, the timestamp in step S4 and the sequence value in step S5 to form a serial number, and send it to the corresponding service for use.

2. The method for generating a high-concurrency payment sequence number according to claim 1, characterized in that: In step S1, the service name is a user-defined character string, the sequence value is a positive integer, and the initial value of the sequence value is 1.

3. The method for generating a high-concurrency payment sequence number according to claim 1, characterized in that: The service names in the sequence table can be increased or decreased according to the service requirements. The sequence values ​​corresponding to each service name do not interfere with each other, and the service names are not allowed to have the same character string.

4. The method for generating a high-concurrency payment sequence number according to claim 1, characterized in that: In step S2, the quantity value is an integer of 100*N, where N≥1.

5. The high-concurrency payment sequence number generation method according to claim 1, characterized in that: In step S3, the machine ID of the current application is obtained through the hostname command.

6. The high-concurrency payment serial number generation method according to claim 1, characterized in that: In step S4, the date tool DateUtil is used to obtain the current system timestamp, accurate to milliseconds, and format the date into a number.

7. The high-concurrency payment sequence number generation method according to claim 1, characterized in that: In step S5, if there are multiple tasks of the same business type that all issue requests to add serial numbers, each task calls the sequence value from the sequence table to its own program memory in turn, and the sequence value called by the next task is the sequence value called by the previous task plus the sequence value formed by the quantity value, and each task outputs the sequence value independently.

8. The method for generating high-concurrency payment serial numbers according to claim 7, characterized in that: In step S5, the sequence value part of the serial number is a fixed number of digits. If it is less than the fixed number of digits, 0 is added to the left of the sequence value. When the number of digits of the sequence value exceeds the fixed number of digits, the corresponding sequence value in the database is reset to 1.

9. The method for generating high-concurrency payment serial numbers according to claim 8, characterized in that: In step S5, when the business needs a new serial number, each time the sequence value is output, it is determined whether the next generated sequence value is equal to the node value. If it is equal to the node value, the business repeats steps S2 and S3, and caches the new starting value and node value in the program memory of the business.

10. A payment sequence number generation device, used to perform the steps of the high-concurrency payment sequence number generation method described in any one of items 1 to 9, characterized in that: It includes a central database and a program memory. The central database stores an ordered list. The sequence list stores and changes the business name and the sequence value corresponding to the business name. The program memory is used to call the business name and sequence value in the sequence list, call the machine ID currently processing the payment business, and call the timestamp of the current system. The program memory stores an executable program for splicing the payment flow sequence number.

Citation Information

Patent Citations

  • Method and equipment for generating data sequence identifier

    CN112860661A

  • Service serial number generation method, number sender component, equipment and storage medium

    CN113722323A

  • Serial number acquisition method and device, server and storage medium

    CN114282968A

  • Streaming serial number generation method and device, computer equipment and readable storage medium

    CN116483892A

  • Highly available, monotonic increasing sequence number generation

    US20020112139A1