Card number generation method and device, computer device and storage medium
The card number generation method using hierarchical storage and distributed locking mechanisms solves the problems of slow card number generation and deadlocks in traditional databases under high concurrency, achieving efficient and unique card number generation.
Patent Information
- Application Number
- CN202210748234.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-29
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-06-29
AI Technical Summary
Traditional databases are slow at generating card numbers under high concurrency and are prone to data table deadlocks, making them unable to effectively handle large-volume, high-concurrency bank card number generation needs.
A hierarchical strategy of card number generation server, underlying server and upper-layer server is adopted. The target serial number is obtained from local storage through a distributed lock mechanism and generated by combining it with business identification information, thereby reducing the frequency of centralized reading and writing of serial numbers.
It improves the card number generation capability under high concurrency conditions, reduces the risk of mutex lock generation, and improves the efficiency and uniqueness of card number generation.
Smart Images

Figure CN115048429B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of big data, and in particular to a card number generation method and device, computer equipment, a storage medium, and a computer program product. BACKGROUND
[0002] In the banking industry, a card number is a very important business element, and is widely used in various business scenarios such as bank card handling and credit card handling.
[0003] In the traditional technology, the generation of a card number relies on the read-write technology of a database. However, the database has limited performance in processing data concurrency. In the case of a large number of concurrent requests, the processing speed of the database will be sharply reduced and the data table will be easily locked, so that the database cannot well handle the generation of a card number in a large-capacity and high-concurrency banking scenario. SUMMARY
[0004] Therefore, it is necessary to provide a card number generation method and device, computer equipment, a computer readable storage medium, and a computer program product that can improve the card number generation capability in a large-capacity and high-concurrency scenario.
[0005] In a first aspect, the present application provides a card number generation method. The method comprises:
[0006] receiving a card number acquisition request carrying business identification information;
[0007] in the case where a target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, acquiring the target serial number corresponding to the card number acquisition request from a bottom-layer server associated with the card number generation server according to the business identification information; the target serial number is obtained by the bottom-layer server from a top-layer server associated with the bottom-layer server;
[0008] generating target card number information corresponding to the card number acquisition request according to the target serial number and the business identification information.
[0009] In one embodiment, in the case where a target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, acquiring the target serial number corresponding to the card number acquisition request from a bottom-layer server associated with the card number generation server according to the business identification information comprises:
[0010] in the case where a target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, sending a serial number segment request carrying a step of a first serial number segment to a bottom-layer server associated with the card number generation server;
[0011] According to the business identification information, query a second business information table in an underlying server associated with the card number generation server to obtain a second current serial number, a second historical serial number and a second step length in the second business information table;
[0012] In a case where it is detected that a sum of the second current serial number and a step length of the first serial number segment is less than or equal to a sum of the second historical serial number and the second step length, perform a locking process on the underlying server based on a distributed lock, and receive a first serial number segment returned by the underlying server based on the second current serial number and the step length of the first serial number segment;
[0013] According to the step length of the first serial number segment, update the second current serial number in the second business information table, and perform an unlocking process on the underlying server;
[0014] According to the first serial number segment, update the first current serial number in the local storage, and take the first current serial number as a target serial number corresponding to the card number acquisition request.
[0015] In one of the embodiments, before the case where it is detected that the sum of the second current serial number and the step length of the first serial number segment is less than or equal to the sum of the second historical serial number and the second step length, further comprising:
[0016] In a case where it is detected that the sum of the second current serial number and the step length of the first serial number segment is greater than the sum of the second historical serial number and the second step length, request a second serial number segment from an upper server associated with the underlying server through the underlying server;
[0017] According to the second serial number segment, update the second historical serial number and the second step length in the second business information table;
[0018] According to the second historical serial number, update the second current serial number.
[0019] In one of the embodiments, before the case where the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, further comprising:
[0020] According to the business identification information, query a first business information table in the local storage to obtain a first current serial number, a first historical serial number and a first step length in the first business information table;
[0021] In a case where it is detected that the first current serial number is greater than or equal to the sum of the first historical serial number and the first step length, confirm that the target serial number corresponding to the card number acquisition request does not exist in the local storage.
[0022] In a case where the first current sequence number is detected to be less than the sum of the first historical sequence number and the first step length, it is confirmed that the target sequence number corresponding to the card number acquisition request exists in the local storage.
[0023] In one of the embodiments, after receiving the card number acquisition request carrying the service identification information, the method further comprises:
[0024] In a case where the target sequence number corresponding to the card number acquisition request exists in the local storage, the local storage is locked based on a distributed lock, and a first current sequence number in a first service information table in the local storage is taken as the target sequence number corresponding to the card number acquisition request;
[0025] The first current sequence number in the first service information table is updated according to the target sequence number, and the local storage is unlocked.
[0026] In one of the embodiments, after the target card number information corresponding to the card number acquisition request is generated according to the target sequence number and the service identification information, the method further comprises:
[0027] The target card number information is checked for duplication according to historical target card number information, to obtain a check result of the target card number information;
[0028] In a case where the check result of the target card number information is card number duplication, the step of obtaining the target sequence number corresponding to the card number acquisition request from the underlying server associated with the card number generation server according to the service identification information is jumped to in a case where the target sequence number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, until the check result of the target card number information is card number non-duplication.
[0029] In a second aspect, the application further provides a card number generation device. The device comprises:
[0030] A request acquisition module is configured to receive a card number acquisition request carrying service identification information;
[0031] A sequence number acquisition module is configured to obtain a target sequence number corresponding to the card number acquisition request from an underlying server associated with the card number generation server according to the service identification information in a case where the target sequence number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server; the target sequence number is obtained by the underlying server from an upper server associated with the underlying server;
[0032] The card number generation module is configured to generate target card number information corresponding to the card number acquisition request according to the target serial number and the service identification information.
[0033] In a third aspect, the present application provides a computer device. The computer device comprises a memory and a processor. The memory stores a computer program. The processor implements the following steps when executing the computer program:
[0034] receiving a card number acquisition request carrying service identification information;
[0035] in a case where the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, obtaining the target serial number corresponding to the card number acquisition request from a bottom-layer server associated with the card number generation server according to the service identification information; the target serial number is obtained from an upper-layer server associated with the bottom-layer server by the bottom-layer server;
[0036] generating target card number information corresponding to the card number acquisition request according to the target serial number and the service identification information.
[0037] In a fourth aspect, the present application provides a computer readable storage medium. The computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the following steps:
[0038] receiving a card number acquisition request carrying service identification information;
[0039] in a case where the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, obtaining the target serial number corresponding to the card number acquisition request from a bottom-layer server associated with the card number generation server according to the service identification information; the target serial number is obtained from an upper-layer server associated with the bottom-layer server by the bottom-layer server;
[0040] generating target card number information corresponding to the card number acquisition request according to the target serial number and the service identification information.
[0041] In a fifth aspect, the present application provides a computer program product. The computer program product comprises a computer program. The computer program is executed by a processor to implement the following steps:
[0042] receiving a card number acquisition request carrying service identification information;
[0043] in a case where the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, the target serial number corresponding to the card number acquisition request is acquired from a bottom layer server associated with the card number generation server according to the service identification information; the target serial number is requested from an upper layer server associated with the bottom layer server by the bottom layer server;
[0044] target card number information corresponding to the card number acquisition request is generated according to the target serial number and the service identification information.
[0045] The card number generation method, device, computer device, storage medium and computer program product receive a card number acquisition request carrying service identification information; in a case where a target serial number corresponding to the card number acquisition request does not exist in the local storage of a card number generation server, the target serial number corresponding to the card number acquisition request is acquired from a bottom layer server associated with the card number generation server according to the service identification information; the target serial number is requested from an upper layer server associated with the bottom layer server by the bottom layer server; and target card number information corresponding to the card number acquisition request is generated according to the target serial number and the service identification information. By using the method, the target serial number is acquired through the hierarchical strategy of the card number generation server, the bottom layer server and the upper layer server, the frequency of reading and writing of the target serial number can be effectively reduced, and the card number is generated in combination with the service identification information and the target serial number, thereby improving the card number generation capability in a high concurrency situation. BRIEF DESCRIPTION OF DRAWINGS
[0046] Figure 1 An application environment diagram of the card number generation method in an embodiment;
[0047] Figure 2 A flowchart of the card number generation method in an embodiment;
[0048] Figure 3 A structural diagram of the card number generation server in an embodiment;
[0049] Figure 4 A flowchart of a step in a case where the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server in an embodiment;
[0050] Figure 5 A structural diagram of the bottom layer server or the upper layer server in an embodiment;
[0051] Figure 6 A flowchart of the card number generation method in another embodiment;
[0052] Figure 7 A structural block diagram of the card number generation device in an embodiment;
[0053] Figure 8 Figure 1 is a schematic diagram of the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0054] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application.
[0055] It should be noted that the card number generation method and device provided by the present application can be used in the field of big data to improve the card number generation capability in the case of large capacity and high concurrency, and can also be used in the application of card number generation in any field other than the field of big data, for example, the field of finance. The application field of the card number generation method and device of the present application is not limited.
[0056] In one embodiment, as shown in Figure 1 , a card number generation method is provided, and the present embodiment is exemplified by the application of the method in a server, wherein the server includes a card number generation server 101, a bottom layer server 102 and at least one upper layer server 103. A higher layer server can also be provided above the upper layer server 103, and similarly, multiple servers can also be provided unlimitedly above the higher layer server. It should be noted that the server architecture is pre-configured between the card number generation server and the bottom layer server. For example, as shown in Figure 1 , when the server architecture is configured, the card number generation server 1 to the card number generation server n is connected to the bottom layer server 1, and then when the card number generation server obtains the target serial number corresponding to the card number acquisition request from the associated bottom layer server, the card number generation server 1 to the card number generation server n will request the target serial number from the bottom layer server 1. Similarly, the connection relationship of the server architecture is also pre-configured between the bottom layer server and the upper layer server, and the connection relationship of the server architecture is also pre-configured between the upper layer server and other upper layer servers.
[0057] It can be understood that the method can be applied to the card number generation server, and can also be applied to a system including the card number generation server, the bottom layer server and at least one upper layer server, and is realized through the interaction of the card number generation server, the bottom layer server and the at least one upper layer server. As shown in Figure 2 , the method includes the following steps in the present embodiment:
[0058] Step S201, receiving a card number acquisition request carrying service identification information.
[0059] The business identification information refers to the identification information associated with the card number service; this includes, but is not limited to, identification codes, area codes, and verification codes. Identification codes include, but are not limited to, the Bank Identification Number (BIN) of the bank that needs to obtain the card number.
[0060] Specifically, when a bank needs a new card number, it generates and sends a card number retrieval request carrying business identification information to the card number generation server through a terminal or server. The card number generation server then receives the card number retrieval request carrying the business identification information.
[0061] In step S202, if the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, the target serial number corresponding to the card number acquisition request is obtained from the underlying server associated with the card number generation server according to the business identification information; the target serial number is obtained by the underlying server from the upper-level server associated with the underlying server.
[0062] Local storage can be the local cache of the card number generation server.
[0063] Specifically, Figure 3 A schematic diagram of the internal structure of the server for generating card numbers, as shown below. Figure 3 As shown, the card number generation server mainly consists of multiple processes 301 and local storage 302. The card number generation server calls the processes to query the local storage to see if a target serial number corresponding to the card number acquisition request exists. If the process finds that the target serial number corresponding to the card number acquisition request does not exist in the local storage, the card number generation server retrieves the target serial number corresponding to the card number acquisition request from the associated underlying server and stores it in the local storage, so that the processes can retrieve the target serial number corresponding to the card number acquisition request from the local storage. The underlying server can also request the target serial number from the upper-level server associated with it. The process is used to process the generation of card numbers.
[0064] Step S203: Generate the target card number information corresponding to the card number acquisition request based on the target serial number and service identification information.
[0065] Specifically, the process involves retrieving the identification code and region code from the business identification information; calculating the checksum corresponding to the card number retrieval request based on the checksum algorithm; and processing the target serial number, identification code, region code, and checksum according to a preset card number generation instruction to obtain the target card number information corresponding to the card number retrieval request. For example, the target serial number, identification code, region code, and checksum can be permuted and combined to obtain the target card number information corresponding to the card number retrieval request.
[0066] In the card number generation method, a card number acquisition request carrying service identification information is received; in the case that a target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, the target serial number corresponding to the card number acquisition request is acquired from a bottom layer server associated with the card number generation server according to the service identification information; the target serial number is requested from an upper layer server associated with the bottom layer server by the bottom layer server; and target card number information corresponding to the card number acquisition request is generated according to the target serial number and the service identification information. By using the method, the target serial number is acquired through the hierarchical strategy of the local server, the bottom layer server and the upper layer server, the frequency of reading and writing of the serial number set can be effectively reduced, and the card number is generated in combination with the service identification information and the target serial number, thereby improving the card number generation capability in the case of high concurrency.
[0067] In one embodiment, as shown in FIG. 2, Figure 4 In the case that a target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, the target serial number corresponding to the card number acquisition request is acquired from a bottom layer server associated with the card number generation server according to the service identification information, and the specific contents include the following contents:
[0068] Step S401: In the case that a target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, a serial number segment request carrying a step of a first serial number segment is sent to a bottom layer server associated with the card number generation server.
[0069] Step S402: According to the service identification information, a second service information table in the bottom layer server associated with the card number generation server is queried to obtain a second current serial number, a second historical serial number and a second step in the second service information table.
[0070] In the bottom layer server, a plurality of second service information tables are stored, a plurality of serial numbers are stored in the second service information table, and the second current serial number, the second historical serial number and the second step in the second service information table are marked. There is an association relationship between the second service information table and the identification code and the area code information, so that the associated card number generation server can acquire the second serial number segment corresponding to the area code information and the identification code from the bottom layer server. It should be noted that the second service information table, the first service information table or other service information table in the embodiment refers to a data file storing a plurality of serial numbers corresponding to the identification code and the area code information, and the form of the data file includes but is not limited to.xlsx,.xls,.csv,.xml and.json.
[0071] The second historical serial number refers to the first serial number in the second serial number range that the underlying server last obtained from the upper-layer server. For example, if the second serial number range that the underlying server last obtained from the upper-layer server was 200 to 209, then the second historical serial number would be 200.
[0072] The second current serial number refers to the first usable serial number stored in the second business information table of the underlying server. For example, if the second business information table stores serial numbers 200 to 209, and serial numbers 200 to 205 have all been used or obtained by the card number generation server, then the second current serial number is 206.
[0073] The second step size refers to the step size of the second sequence number segment that the lower-level server obtained from the upper-level server in the last time. For example, if the sequence number segment obtained by the lower-level server from the upper-level server in the last time is 200 to 209, then the second step size is 10.
[0074] The first serial number segment refers to the serial number segment that the card number generation server requests from the underlying server associated with it.
[0075] The step size of the first sequence number segment is an integer greater than 1, and the step size of the first sequence number segment is used to control how many sequence numbers are obtained from the underlying server.
[0076] Specifically, Figure 5 This is a schematic diagram of the internal structure of a lower-level server, an upper-level server, or a server even higher up, such as... Figure 5 As shown, the servers other than the card number generation server mainly consist of a serial number storage unit 501 and a processing process 502. The serial number storage unit is used to store the business information table. If the target serial number corresponding to the card number acquisition request does not exist in the local storage, the card number generation server sends a serial number segment request carrying the step size of the first serial number segment to its associated underlying server. This serial number segment request also carries business identification information. The underlying server process receives the serial number segment request, uses the business identification information or the identification code and area code information within the business identification information as an index, and calls the process to query the second business information table corresponding to the index. From this second business information table, it obtains the second current serial number, the second historical serial number, and the second step size.
[0077] Step S403: If the sum of the step size of the second current sequence number and the first sequence number segment is less than or equal to the sum of the second historical sequence number and the second step size, lock the underlying server based on the distributed lock, and receive the first sequence number segment returned by the underlying server based on the step size of the second current sequence number and the first sequence number segment.
[0078] Specifically, it is judged whether the sum of the second current serial number and the step of the first serial number segment is less than the sum of the second historical serial number and the second step; in the case that the sum of the second current serial number and the step of the first serial number segment is less than or equal to the sum of the second historical serial number and the second step, the distributed lock processing or the row-level lock processing is added to the second current serial number to the serial number corresponding to the sum of the second current serial number and the step of the first serial number segment in the second service information table, and then the first serial number segment is generated according to the second current serial number to the step of the first serial number segment, and the first serial number segment is sent to the card number generation server. The distributed lock or the row-level lock can ensure the correctness of the serial numbers related to the first serial number segment in the case of high concurrency, and will not affect the use of other serial numbers in the second service information table.
[0079] For example, in the underlying server, assuming that the second current serial number is 105, the second historical serial number is 100, and the second step is 50 in the second service information table corresponding to the business identification information or the identification code and the area code information in the business identification information, the last obtained serial number in the second service information table is 100 to 149, the serial numbers from 100 to 104 have been used, and the current available serial number is 105. If the step of the first serial number segment sent by the card number generation server to the underlying server is 10, then 105+10 is less than 100+50, it is considered that the first serial number segment required by the card number generation server is within the available serial number segment range of the underlying server, and the serial numbers from 105 to 114 are taken as the first serial number segment and sent to the card number generation server, and the card number generation server receives the first serial number segment from 105 to 114.
[0080] In step S404, the second current serial number in the second service information table is updated according to the step of the first serial number segment, and the underlying server is unlocked.
[0081] After the card number generation server receives the first serial number segment, the card number generation server or the underlying server updates the second current serial number in the second service information table according to the step length of the transmitted first serial number segment. After confirming that the updating of the second current serial number is completed, the second current serial number to the serial number corresponding to the sum of the second current serial number and the step length of the first serial number segment is unlocked. It should be noted that each time the card number generation server obtains the first serial number segment from the second service information table of the underlying server, the second current serial number in the underlying server needs to be updated so as to obtain the latest second current serial number from the underlying server next time. For example, assuming that the second current serial number in the second service information table of the underlying server is 105, and the first serial number segment obtained by the card number generation server from the underlying server is 105 to 114, the step length of the first serial number segment is 114-105+1=10, the second current serial number in the underlying server is updated from 105 to 115, and then the first serial number segment obtained by the next card number generation server from the underlying server starts from 115.
[0082] In step S405, the first current serial number in the local storage is updated according to the first serial number segment, and the first current serial number is taken as the target serial number corresponding to the card number acquisition request.
[0083] Since the card number generation needs to be completed by the card number generation server, the card number generation server still needs to obtain the target serial number from the local storage to generate the card number. Therefore, the card number generation server updates the first current serial number, the first historical serial number and the first step length in the first service information table in the local storage according to the first serial number in the received first serial number segment and the step length of the first serial number segment, and then takes the updated first current serial number as the target serial number corresponding to the card number acquisition request. For example, assuming that the first current serial number in the first service information table in the local storage is 90, the first historical serial number is 80 and the first step length is 10, the last obtained serial number in the first service information table is 80 to 89, and the serial numbers from 80 to 89 have been used and there is no available serial number at present; then the first serial number segment obtained by the card number generation server from the underlying server associated therewith is 105 to 114, which indicates that the serial numbers from 90 to 104 in the associated underlying server have been used by other card number generation servers; the card number generation server updates the first historical serial number from 80 to 105, the first step length from 10 to 10 (unchanged), and the first current serial number from 90 to 105.
[0084] In the embodiment, the sequence number is stored in the card number generation server and the underlying server in stages, which can avoid frequent read and write of data on a single server, and reduce the risk of mutual exclusion. The card number generation server queries a second business information table corresponding to the business identification information or the identification code and the area code information in the business identification information from the associated underlying server. In a case where a sum of a second current sequence number in the second business information table and a step length of a first sequence number segment is less than or equal to a sum of a second historical sequence number and a second step length, the sequence number related to the first sequence number segment in the second business information table is subjected to distributed lock processing, so as to prevent other card number generation servers from simultaneously obtaining the same first sequence number segment from the second business information table, and to avoid repeated use of the first sequence number segment. The sequence number in the second business information table is subjected to unlocking processing after the second current sequence number is updated, so as to enable a next card number generation server to obtain the updated second current sequence number. The target sequence number is ensured to be unique in the server, and the acquisition efficiency of the target sequence number is improved, and thus the generation efficiency of the card number is improved.
[0085] In one embodiment, before the case where the sum of the second current sequence number and the step length of the first sequence number segment is less than or equal to the sum of the second historical sequence number and the second step length is detected, the method further includes: in a case where the sum of the second current sequence number and the step length of the first sequence number segment is greater than the sum of the second historical sequence number and the second step length, requesting and obtaining, by the underlying server, a second sequence number segment from an upper server associated with the underlying server; updating the second historical sequence number and the second step length in the second business information table according to the second sequence number segment; and updating the second current sequence number according to the second historical sequence number.
[0086] The upper server stores a plurality of third business information tables, and each third business information table stores a plurality of sequence numbers. The third business information table and the identification code and the area code information have an association relationship, so that the underlying server obtains a second sequence number segment corresponding to the area code information and the identification code from an associated upper server, or the upper server obtains a sequence number segment corresponding to the area code information and the identification code from an associated upper server.
[0087] The third historical sequence number refers to a first sequence number in a third sequence number segment that is last obtained by the upper server from a higher upper server. For example, the sequence number segment that is last obtained by the upper server from the higher upper server is 300 to 309, and the second historical sequence number is 300.
[0088] The third current serial number refers to the first serial number that can be used currently in the serial numbers stored in the third service information table of the upper server. For example, the third service information table stores serial numbers 300 to 309, and serial numbers 300 to 305 have been used or obtained by the lower server, and the third current serial number is 306.
[0089] The third step length refers to the step length of the third serial number segment obtained by the upper server from the upper server last time. For example, the serial number segment obtained by the upper server from the upper server last time is 300 to 309, and the second step length is 10.
[0090] The second serial number segment refers to a serial number segment applied by the lower server to the upper server associated with the lower server, and the third serial number segment refers to a serial number segment applied by the upper server to the upper server associated with the lower server. Similarly, the fourth serial number segment, the fifth serial number segment, and the like can be obtained.
[0091] The step length of the second serial number segment is an integer greater than 1, and the step length of the second serial number segment is used to control how many serial numbers are obtained from the upper server.
[0092] Specifically, in the case where the sum of the second current serial number and the step length of the first serial number segment is greater than the sum of the second historical serial number and the second step length, the lower server sends a second serial number segment request to the upper server associated with the lower server; the second serial number segment request carries an identification code, an area code information and a step length of the second serial number segment; the associated upper server receives the second serial number segment request, takes the identification code and the area code information in the second serial number segment request as an index, and queries a third service information table corresponding to the index to obtain the third current serial number, the third historical serial number and the third step length. In the case where the sum of the third current serial number and the step length of the second serial number segment is less than or equal to the sum of the third historical serial number and the third step length, the third current serial number to the serial number corresponding to the sum of the third current serial number and the step length of the second serial number segment in the third service information table is added with a distributed lock or a row-level lock, and then the second serial number segment corresponding to the second serial number segment request is obtained according to the third current serial number and the step length of the second serial number segment and sent to the lower server.
[0093] After the bottom layer server confirms the reception of the second sequence number segment, the third current sequence number in the third service information table is updated according to the step of the transmitted second sequence number segment, so that the next bottom layer server obtains the latest third current sequence number from the upper layer server. After confirming the completion of the update of the third current sequence number, the third current sequence number in the third service information table to the sequence number corresponding to the sum of the third current sequence number and the step of the second sequence number segment is unlocked. The bottom layer server updates the second historical sequence number and the second step in the second service information table according to the first sequence number in the received second sequence number segment and the step of the second sequence number segment, and then takes the updated second historical sequence number as the second current sequence number. It is judged whether the sum of the second current sequence number and the step of the first sequence number segment is less than the sum of the second historical sequence number and the second step. If yes, steps S403 to S405 are executed, otherwise, the technical solution of the embodiment is executed again.
[0094] It should be noted that in the case where the sum of the third current sequence number and the step of the second sequence number segment is greater than the sum of the third historical sequence number and the third step, the third sequence number segment is first requested from a higher layer server associated with the upper layer server through the upper layer server and stored in the third service information table, then the second sequence number segment is requested from the third service information table of the upper layer server associated with the bottom layer server through the bottom layer server and stored in the second service information table, the first sequence number segment is requested from the bottom layer server associated with the card number generation server through the card number generation server and stored in the locally stored first service information table, and finally the card number generation server generates a card number using the first current sequence number stored locally.
[0095] In the embodiment, in the case where the sum of the second current sequence number and the step of the first sequence number segment is greater than the sum of the second historical sequence number and the second step, the second sequence number segment is requested from the upper layer server associated with the bottom layer server through the bottom layer server; the second historical sequence number and the second step in the second service information table are updated according to the second sequence number segment; and the second current sequence number is updated according to the second historical sequence number, which realizes the hierarchical storage of sequence numbers among the card number generation server, the bottom layer server and the upper layer server, avoids frequent reading and writing of data on a single server, reduces the risk of mutual exclusion, improves the card number generation efficiency, and flexibly increases or reduces the number of servers and the number of layers of cascaded servers according to the demand of sequence numbers, so as to ensure that the card number generation server obtains a unique target sequence number under an infinite concurrent condition.
[0096] In one embodiment, before the case where the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, further comprising: querying the first business information table in the local storage according to the business identification information to obtain the first current serial number, the first historical serial number and the first step length in the first business information table; in the case of detecting that the first current serial number is greater than or equal to the sum of the first historical serial number and the first step length, confirming that the local storage does not exist The target serial number corresponding to the card number acquisition request; in the case of detecting that the first current serial number is less than the sum of the first historical serial number and the first step length, confirming that the local storage exists The target serial number corresponding to the card number acquisition request.
[0097] Among them, the local storage stores a plurality of first business information tables, and the first business information table stores a plurality of serial numbers and marks the first current serial number, the first historical serial number and the first step length in the first business information table. There is an association relationship between the first business information table and the identification code and the area code information, so that the corresponding area or the corresponding bank uses the serial number in the matched first business information table.
[0098] Among them, the first current serial number refers to the first serial number that can be currently used in the serial numbers stored in the first business information table of the local storage.
[0099] Among them, the first historical serial number refers to the first serial number in the first serial number segment that is last acquired from the underlying server in the local storage. For example, the first historical serial number is 100 if the first serial number segment that is last acquired from the underlying server in the local storage is 100 to 109.
[0100] Among them, the first step length refers to the step length of the first serial number segment that is last acquired from the underlying server in the local storage. For example, the first step length is 10 if the first serial number segment that is last acquired from the underlying server in the local storage is 100 to 109.
[0101] It should be noted that the target serial number corresponding to the card number acquisition request does not exist, which means that there is no serial number that can be used in the local storage; for example, assuming that the first historical serial number is 100 and the second step length is 50, it means that the serial numbers in the first business information table are 100 to 149, and the first current serial number is 150, that is, 150 equals 100+50, which means that there is no serial number that can be used in the local storage.
[0102] In this embodiment, by comparing the first current serial number with the sum of the first historical serial number and the first step length, it can be confirmed whether the local storage exists The target serial number corresponding to the card number acquisition request, so that the card number generation server acquires the target serial number to execute the card number generation step.
[0103] In one embodiment, after receiving the card number acquisition request carrying the service identification information, further comprising: in the case that the target serial number corresponding to the card number acquisition request exists in the local storage, locking the local storage based on the distributed lock, and taking the first current serial number in the first service information table in the local storage as the target serial number corresponding to the card number acquisition request; updating the first current serial number in the first service information table according to the target serial number, and unlocking the local storage.
[0104] Specifically, in the case that the target serial number corresponding to the card number acquisition request exists in the local storage, the first current serial number in the first service information table in the local storage is locked based on the distributed lock or the row-level lock, and the first current serial number in the first service information table is taken as the target serial number corresponding to the card number acquisition request; since the number of target serial numbers is 1, the first current serial number in the first service information table is incremented by 1 to obtain the updated first current serial number, and the updated first current serial number in the first service information table is unlocked.
[0105] The card number generation server is the lowest layer in the multi-level cascade server, and the card number generation server can only obtain one serial number from the local storage at a time, while the card number generation server and each server above the card number generation server request a serial number segment from the last server associated therewith. For example, the card number generation server obtains a first serial number segment from the bottom server, and for another example, the bottom server obtains a second serial number segment from the upper server.
[0106] In this embodiment, the card number generation server can only obtain one target serial number from the local storage at a time, which can avoid the card number generation server from consuming too many serial numbers due to a single card number acquisition request, so that the card number generation server needs to frequently request the first serial number segment from the bottom server, or even wait for the bottom server to request the second serial number segment from the upper server. In the case of high concurrency, the waiting time of the concurrent request can be effectively reduced, thereby improving the generation efficiency of the card number.
[0107] In one embodiment, after generating the target card number information corresponding to the card number acquisition request according to the target serial number and the service identification information, further comprising: performing duplicate checking on the target card number information according to historical target card number information to obtain a duplicate checking result of the target card number information; in the case that the duplicate checking result of the target card number information is card number duplication, jumping to the step of acquiring the updated serial number corresponding to the card number acquisition request from the bottom server associated with the card number generation server according to the service identification information in the case that the target serial number corresponding to the card number acquisition request does not exist in the local storage, until the duplicate checking result of the target card number information is card number non-duplication.
[0108] The historical target card number information refers to all target card numbers generated by the card number generation server.
[0109] It should be noted that the card number generation server usually generates target card number information according to certain rules, so that the probability of target card number information duplication is low. However, there are also target card number information that has been generated in advance, such as self-selected card numbers, lucky card numbers, etc. Therefore, it is necessary to perform duplication checking on the target card number information.
[0110] Specifically, the card number generation server queries whether there is historical target card number information that is the same as the currently generated target card number information in the historical target card number information, and obtains the duplication checking result of the currently generated target card number information. In the case that the duplication checking result of the target card number information is that the card numbers are not duplicated, the target card number information is returned. In the case that the duplication checking result of the target card number information is that the card numbers are duplicated, jump to step S202 described above until the duplication checking result of the currently generated target card number information is that the card numbers are not duplicated.
[0111] In this embodiment, after generating the target card number information corresponding to the card number acquisition request, the target card number information is checked according to the historical target card number information, which can ensure the uniqueness of the target card number information in the global cascading server.
[0112] In one embodiment, as shown in Figure 6 Another card number generation method is provided, which is applied to a card number generation server as an example for illustration, including the following steps:
[0113] Step S601, receiving a card number acquisition request carrying business identification information.
[0114] Step S602, querying a first business information table in the local storage according to the business identification information to obtain a first current serial number, a first historical serial number and a first step length in the first business information table.
[0115] Step S603, in the case that the first current serial number is less than the sum of the first historical serial number and the first step length, confirming that there is a target serial number corresponding to the card number acquisition request in the local storage.
[0116] Step S604, in the case that there is a target serial number corresponding to the card number acquisition request in the local storage, locking the local storage based on a distributed lock, and taking the first current serial number in the first business information table in the local storage as the target serial number corresponding to the card number acquisition request; updating the first current serial number in the first business information table according to the target serial number, and unlocking the local storage.
[0117] Step S605, in the case of detecting that the first current serial number is greater than or equal to the sum of the first historical serial number and the first step length, it is confirmed that the target serial number corresponding to the card number acquisition request does not exist in the local storage.
[0118] Step S606, in the case that the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, a serial number segment request carrying the step length of the first serial number segment is sent to the underlying server associated with the card number generation server; according to the business identification information, the second business information table in the underlying server associated with the card number generation server is queried to obtain the second current serial number, the second historical serial number and the second step length in the second business information table.
[0119] Step S607, in the case of detecting that the sum of the second current serial number and the step length of the first serial number segment is greater than the sum of the second historical serial number and the second step length, the second serial number segment is requested from the upper server associated with the underlying server through the underlying server; according to the second serial number segment, the second historical serial number and the second step length in the second business information table are updated; and the second current serial number is updated according to the second historical serial number.
[0120] Step S608, in the case of detecting that the sum of the second current serial number and the step length of the first serial number segment is less than or equal to the sum of the second historical serial number and the second step length, the underlying server is locked based on the distributed lock, and the first serial number segment returned by the underlying server based on the second current serial number and the step length of the first serial number segment is received.
[0121] Step S609, according to the step length of the first serial number segment, the second current serial number in the second business information table is updated, and the underlying server is unlocked.
[0122] Step S610, according to the first serial number segment, the first current serial number in the local storage is updated, and the first current serial number is taken as the target serial number corresponding to the card number acquisition request.
[0123] Step S611, according to the target serial number and the business identification information, the target card number information corresponding to the card number acquisition request is generated.
[0124] The above card number generation method has the following beneficial effects:
[0125] (1) Through the hierarchical strategy of the local server, the underlying server and the upper server, the target serial number is obtained, which can effectively reduce the frequency of reading and writing of the serial number, and according to the serial number requirement transformation, the number and the number of cascade servers of each level can be flexibly increased or reduced, and in theory, the unique target serial number can be obtained under the condition of infinite concurrency, and the card number is generated combined with the business identification information and the target serial number, which improves the card number generation ability under high concurrency.
[0126] (2) By adding a distributed lock to the serial number or serial number segment to be obtained, the repeated use of the same serial number or serial number segment by other servers is prevented; after updating the current serial number, the unlocking process is performed to facilitate the server to obtain the updated current serial number, which can improve the efficiency of obtaining the target serial number while ensuring the uniqueness of the target serial number, and greatly improves the efficiency of generating the card number.
[0127] (3) The local storage of the card number generation server adopts a single target serial number acquisition mode, which can avoid the card number generation server consuming a large number of serial numbers due to a single card number acquisition request, so that the card number generation server needs to frequently request the first serial number segment from the underlying server, and even wait for the underlying server to request the second serial number segment from the upper server. In high concurrency, the waiting time of the concurrent request can be effectively reduced. The card number generation server, the underlying server and the upper server all use a single serial number segment acquisition mode, which reduces the serial number request frequency between servers and improves the efficiency of generating the card number.
[0128] It should be understood that, although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.
[0129] Based on the same inventive concept, the embodiments of the present application also provide a card number generation device for implementing the card number generation method described above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more card number generation device embodiments provided below can refer to the limitations of the card number generation method described above, which will not be repeated here.
[0130] In one embodiment, as shown in FIG. 7, a card number generation apparatus 700 is provided, comprising: a request acquisition module 701, a serial number acquisition module 702, and a card number generation module 703, wherein: Figure 7
[0131] The request acquisition module 701 is configured to receive a card number acquisition request carrying service identification information.
[0132] The serial number acquisition module 702 is configured to, in a case where a target serial number corresponding to the card number acquisition request does not exist in a local storage of the card number generation server, acquire the target serial number corresponding to the card number acquisition request from a bottom layer server associated with the card number generation server according to the service identification information; the target serial number is requested from an upper layer server associated with the bottom layer server by the bottom layer server.
[0133] The card number generation module 703 is configured to generate target card number information corresponding to the card number acquisition request according to the target serial number and the service identification information.
[0134] In one embodiment, the serial number acquisition module 702 is further configured to, in a case where a target serial number corresponding to the card number acquisition request does not exist in a local storage of the card number generation server, send a serial number segment request carrying a step of a first serial number segment to a bottom layer server associated with the card number generation server; query a second service information table in the bottom layer server associated with the card number generation server according to the service identification information to obtain a second current serial number, a second historical serial number, and a second step in the second service information table; in a case where a sum of the second current serial number and the step of the first serial number segment is less than or equal to a sum of the second historical serial number and the second step, perform locking processing on the bottom layer server based on a distributed lock, and receive a first serial number segment returned by the bottom layer server based on the second current serial number and the step of the first serial number segment; update the second current serial number in the second service information table according to the step of the first serial number segment, and perform unlocking processing on the bottom layer server; and update the first current serial number in the local storage according to the first serial number segment, and take the first current serial number as the target serial number corresponding to the card number acquisition request.
[0135] In one embodiment, the card number generation apparatus 700 further comprises a second serial number segment acquisition module configured to, in a case where a sum of the second current serial number and the step of the first serial number segment is greater than a sum of the second historical serial number and the second step, request a second serial number segment from an upper layer server associated with the bottom layer server by the bottom layer server; update the second historical serial number and the second step in the second service information table according to the second serial number segment; and update the second current serial number according to the second historical serial number.
[0136] In an embodiment, the card number generation apparatus 700 further comprises a sequence number judgment module configured to query a first service information table in the local storage according to the service identifier information, to obtain a first current sequence number, a first historical sequence number and a first step length in the first service information table; in a case where it is detected that the first current sequence number is greater than or equal to a sum of the first historical sequence number and the first step length, it is confirmed that the target sequence number corresponding to the card number acquisition request does not exist in the local storage; in a case where it is detected that the first current sequence number is less than the sum of the first historical sequence number and the first step length, it is confirmed that the target sequence number corresponding to the card number acquisition request exists in the local storage.
[0137] In an embodiment, the card number generation apparatus 700 further comprises a local sequence number acquisition module configured to, in a case where the target sequence number corresponding to the card number acquisition request exists in the local storage, perform a locking process on the local storage based on a distributed lock, and take the first current sequence number in the first service information table in the local storage as the target sequence number corresponding to the card number acquisition request; update the first current sequence number in the first service information table according to the target sequence number, and perform an unlocking process on the local storage.
[0138] In an embodiment, the card number generation apparatus 700 further comprises a card number duplication checking module configured to perform a duplication checking process on the target card number information according to the historical target card number information, to obtain a duplication checking result of the target card number information; in a case where the duplication checking result of the target card number information is card number duplication, jump to a case where the target sequence number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, and according to the service identifier information, acquire the target sequence number corresponding to the card number acquisition request from a bottom server associated with the card number generation server, until the duplication checking result of the target card number information is card number non-duplication.
[0139] The above various modules in the card number generation apparatus can be realized by software, hardware and combinations thereof in whole or in part. The above various modules can be embedded in or independent of a processor in a computer device in a hardware form, or can be stored in a memory in the computer device in a software form, so as to be called and executed by a processor to perform operations corresponding to the above various modules.
[0140] In an embodiment, a computer device is provided, which can be a server, and an internal structure diagram of the computer device can be as shown in Figure 8As shown in the figure. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as the second current serial number, the second service information table, the second historical serial number and the second step length. The network interface of the computer device is used to communicate with the terminal outside through the network connection. The computer program is executed by the processor to realize a card number generation method.
[0141] Those skilled in the art can understand that, Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0142] In one embodiment, a computer device is also provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to realize the steps in each of the above method embodiments.
[0143] In one embodiment, a computer readable storage medium is provided, which stores a computer program, and the computer program is executed by a processor to realize the steps in each of the above method embodiments.
[0144] In one embodiment, a computer program product is provided, including a computer program, and the computer program is executed by a processor to realize the steps in each of the above method embodiments.
[0145] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.
[0146] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.
[0147] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.
[0148] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A method for generating a card number, characterized in that, Applied to a card number generation server, the method includes: Receive a card number retrieval request carrying service identification information; If the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, a serial number segment request carrying the step size of the first serial number segment is sent to the underlying server associated with the card number generation server. Based on the business identification information, the second business information table in the underlying server associated with the card number generation server is queried to obtain the second current serial number, the second historical serial number, and the second step size in the second business information table; the second historical serial number refers to the first serial number in the second serial number segment that the underlying server last obtained from the upper-level server; the second step size refers to the step size of the second serial number segment that the underlying server last obtained from the upper-level server. If the sum of the step size of the second current sequence number and the first sequence number segment is greater than the sum of the second historical sequence number and the second step size, the second sequence number segment is requested from the upper-level server associated with the lower-level server through the lower-level server; the upper-level server stores multiple third business information tables, and the third business information tables store multiple sequence numbers; Update the second historical sequence number and the second step size in the second business information table according to the second sequence number segment; Update the second current serial number according to the second historical serial number; If the sum of the step size of the second current sequence number and the first sequence number segment is less than or equal to the sum of the second historical sequence number and the second step size, the system performs a locking process on the sequence numbers from the second current sequence number to the sequence number corresponding to the sum of the step size of the second current sequence number and the first sequence number segment in the second business information table of the underlying server based on a distributed lock, and receives the first sequence number segment returned by the underlying server based on the step size of the second current sequence number and the first sequence number segment. Based on the step size of the first sequence number segment, update the second current sequence number in the second business information table, and unlock the underlying server. Based on the first serial number segment, update the first current serial number in the local storage, and use the first current serial number as the target serial number corresponding to the card number acquisition request; Based on the target serial number and the service identification information, generate the target card number information corresponding to the card number acquisition request.
2. The method according to claim 1, characterized in that, Before the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, the process further includes: Based on the service identification information, query the first service information table in the local storage to obtain the first current sequence number, the first historical sequence number, and the first step length in the first service information table; If the first current serial number is detected to be greater than or equal to the sum of the first historical serial number and the first step length, it is confirmed that there is no target serial number in the local storage corresponding to the card number acquisition request; If the first current serial number is detected to be less than the sum of the first historical serial number and the first step length, it is confirmed that the target serial number corresponding to the card number acquisition request exists in the local storage.
3. The method according to claim 1, characterized in that, After receiving the card number retrieval request carrying service identification information, the process also includes: If a target serial number corresponding to the card number acquisition request exists in the local storage, the local storage is locked based on a distributed lock, and the first current serial number in the first business information table in the local storage is used as the target serial number corresponding to the card number acquisition request. Update the first current serial number in the first business information table according to the target serial number, and unlock the local storage.
4. The method according to claim 1, characterized in that, After generating the target card number information corresponding to the card number retrieval request based on the target serial number and the service identification information, the method further includes: Based on the historical target card number information, the target card number information is deduplicated to obtain the deduplication result of the target card number information; If the deduplication result of the target card number information is that the card number is duplicated, the process jumps to the step of obtaining the target serial number corresponding to the card number acquisition request from the underlying server associated with the card number generation server based on the business identification information if the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server, until the deduplication result of the target card number information is that the card number is not duplicated.
5. A card number generation apparatus for implementing the card number generation method as described in any one of claims 1-4, characterized in that, The device includes: The request acquisition module is used to receive card number acquisition requests carrying business identification information; The serial number acquisition module is used to acquire the target serial number corresponding to the card number acquisition request from the underlying server associated with the card number generation server based on the service identification information when the target serial number corresponding to the card number acquisition request does not exist in the local storage of the card number generation server; the target serial number is obtained by requesting the target serial number from the upper-layer server associated with the underlying server through the underlying server; The card number generation module is used to generate the target card number information corresponding to the card number acquisition request based on the target serial number and the service identification information.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Physical card information intelligent recommendation method and device
CN112905899A
Serial number generation method and device, computer equipment and storage medium
CN112948399A
Method and system for randomly generating credit card number
CN113485676A