Card bin identification method, system and device of bank card and storage medium
By generating a fake card bin collection and querying the Redis cache, combined with hard database analysis, the bank card number identification problems are solved, and fast and accurate card number identification is achieved.
Patent Information
- Application Number
- CN202410952782.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-11-26
AI Technical Summary
The existing bank card number identification method causes database performance to be degraded in high concurrency scenarios, slow response speed, high error rate, and users are prone to forget or select the wrong issuing bank, causing dirty data.
By generating a fake card bin collection, intercepting a collection of numbers of different lengths from the bank card number, assembling the cache query primary key, querying Redis cache data, and performing hard analysis of the database if there is no result, and the card bin information is stored in the Redis cache to improve subsequent queries efficiency.
It improves the rate and accuracy of bank card number identification, reduces the number of queries to the database, and improves the response speed and recognition accuracy.
Smart Images

Figure CN119025559A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of financial technology, and in particular to a bank card bin recognition method, system, device and storage medium. Background Art
[0002] At present, various commercial banks have issued a large number of bank card products according to the characteristics of their bank card business. Within the financial system, a series of bank card verifications and fund business docking are required according to the type of bank card and the issuing institution. In previous business, users are required to select the branch where their bank card was opened in the user interface. However, in actual operations, users often forget the issuing bank or select the wrong issuing bank, resulting in a large amount of dirty data and causing system errors.
[0003] Based on this, a method of determining the issuing bank through card number recognition is derived, for example, by matching the card Bin information of a bank card, to identify which bank and which card the bank card belongs to. Usually, according to the card number information, the matching number segment is searched in the database or cache through exhaustive method to achieve the function of identifying the card Bin, but this method is completed through hard matching of the database at each time of recognition, which easily causes large database system overhead and low recognition efficiency, and seriously drags down the database performance in high-concurrency scenarios, resulting in slow response speed and high error rate of bank card number recognition.
[0004] Therefore, there is an urgent need for a bank card bin recognition method to solve the above technical problems. Summary of the invention
[0005] In order to solve the above technical problems, the present application provides a bank card bin recognition method, system, device and storage medium, which can improve the recognition rate and recognition accuracy of bank card numbers.
[0006] The technical solution provided in this application is described below:
[0007] The first aspect of the present application provides a method for identifying a bank card bin, comprising:
[0008] Obtaining bank card information, wherein the bank card information includes at least the bank card number;
[0009] Generate a pseudo card bin set according to the card face information, wherein the pseudo card bin set represents a set of different numbers intercepted from the card number according to different length ranges;
[0010] Assemble a cache query primary key based on the card face information and the pseudo card bin set;
[0011] Query cached data based on the cache query primary key and obtain query results;
[0012] The card bin information of the bank card is obtained according to the query result and fed back to the client.
[0013] Optionally, when the query result is empty, obtaining the card bin information of the bank card according to the query result includes:
[0014] The card bin information is obtained by hard parsing the card surface information in a database.
[0015] Optionally, after obtaining the card bin information by hard parsing the card surface information in a database, the card bin identification method further includes:
[0016] The card bin information is stored in the Redis cache.
[0017] Optionally, obtaining the card bin information by hard parsing the card surface information in a database includes:
[0018] Determine a target card bin in a card bin table according to the card surface information, wherein the card bin table is located in the database;
[0019] Obtain the card bin information corresponding to the target card bin.
[0020] Optionally, when the query result is not empty, acquiring the card bin information of the bank card according to the query result includes:
[0021] The card bin information is obtained in the Redis cache according to the card face information.
[0022] Optionally, obtaining the card bin information of the bank card according to the query result and feeding back to the client includes:
[0023] Obtain the format requirement of the client, and assemble the card bin information into card bin information response data according to the format requirement;
[0024] Feedback the card bin information response data to the client.
[0025] Optionally, the length range is 6-9 digits, and generating a pseudo card bin set according to the card surface information includes:
[0026] The card number in the card face information is truncated from the first digit according to the length range to form a 6-digit number, a 7-digit number, an 8-digit number and a 9-digit number respectively.
[0027] The second aspect of the present application provides a bank card bin recognition system, comprising:
[0028] A first acquisition unit is used to acquire card information of a bank card, wherein the card information at least includes a card number of the bank card;
[0029] A generating unit, configured to generate a pseudo card bin set according to the card face information, wherein the pseudo card bin set represents a set of different numbers intercepted from the card number according to different length ranges;
[0030] An assembling unit, used for assembling a cache query primary key according to the card face information and the pseudo card bin set;
[0031] A query unit, used to query cached data based on the cache query primary key and obtain query results;
[0032] The second acquisition unit is used to acquire the card bin information of the bank card according to the query result and feed it back to the client.
[0033] Optionally, when the query result is empty, the second acquiring unit includes:
[0034] The acquisition module is used to obtain the card bin information by hard parsing the card surface information in a database.
[0035] Optionally, the bank card bin recognition system further includes:
[0036] The storage unit is used to store the card bin information into the Redis cache.
[0037] Optionally, the obtaining module includes:
[0038] A determination submodule, configured to determine a target card bin in a card bin table according to the card surface information, wherein the card bin table is located in the database;
[0039] The acquisition submodule is used to acquire the card bin information corresponding to the target card bin.
[0040] Optionally, when the query result is not empty, the second acquiring unit includes:
[0041] The cache module is used to obtain the card bin information in the Redis cache according to the card surface information.
[0042] Optionally, the second acquiring unit includes:
[0043] An assembling module, used for obtaining the format requirement of the client, and assembling the card bin information into card bin information response data according to the format requirement;
[0044] A feedback module is used to feed back the card bin information response data to the client.
[0045] Optionally, the length ranges from 6 to 9 digits, and the generating unit includes:
[0046] The generating module is used to cut the card number in the card face information from the first digit according to the length range to form a 6-digit number, a 7-digit number, an 8-digit number and a 9-digit number respectively.
[0047] The third aspect of the present application provides a bank card bin recognition device, comprising:
[0048] Processor, memory, input-output unit, and bus;
[0049] The processor is connected to the memory, the input and output unit, and the bus;
[0050] The memory stores a program, and the processor calls the program to execute the first aspect and any optional card bin identification method in the first aspect.
[0051] A fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the program executes the first aspect and any optional card bin identification method in the first aspect.
[0052] It can be seen from the above technical solutions that this application has the following advantages:
[0053] First, a pseudo-card bin set is generated based on the card face information of the bank card. The pseudo-card bin set represents a set of different numbers intercepted from the card number according to different length ranges. Then, a cache query primary key is assembled based on the pseudo-card bin set and the card face information. The cached data is queried based on the cache query primary key to obtain the query result. Finally, the card bin information of the bank card is obtained based on the query result and fed back to the client. In this application, the pseudo-card BIN set of the card number is parsed according to different length ranges, and accurate query and retrieval are performed according to the pseudo-card bin set range, thereby improving retrieval efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solution in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0055] Figure 1A flowchart of an embodiment of a method for identifying a bank card bin is provided in the present application;
[0056] Figure 2 A flowchart of another embodiment of a method for identifying a bank card bin in the present application;
[0057] Figure 3 A schematic diagram of an embodiment of a bank card bin recognition system of the present application;
[0058] Figure 4 A schematic diagram of another embodiment of a bank card bin recognition system of the present application;
[0059] Figure 5 This is a schematic diagram of an embodiment of a card bin recognition device for a bank card of the present application. DETAILED DESCRIPTION
[0060] It should be noted that the bank card bin identification method provided in this application can be applied to a terminal, a system, or a server. For the convenience of explanation, this application uses the system as an example for illustration.
[0061] See also Figure 1 The present application first provides an embodiment of a method for identifying a bank card bin, the embodiment comprising:
[0062] 101. The system obtains bank card information, where the card information at least includes the bank card number.
[0063] In this embodiment, the system first needs to obtain the bank card surface information from user input, scanning device, or other interfaces (such as API calls). The scanning device can be a card reader or a mobile terminal equipped with a camera. The card reader directly reads the bank card number. The mobile terminal obtains the card surface information by taking a picture of the bank card and identifying it. The card surface information usually includes the bank card number, the color of the bank card (obtained by taking a picture), and the type of bank card (such as debit card, credit card, etc.). Possible information includes the cardholder's name and expiration date.
[0064] For example, the front of a bank card is photographed with a mobile phone, and the card number of the bank card is extracted from the obtained image by optical character recognition. The extracted card number is such as 621700abcxxxxxxxxxx. The following description uses this card number as an example.
[0065] 102. The system generates a pseudo card bin set according to the card surface information. The pseudo card bin set represents a set of different numbers extracted from the card number according to different length ranges.
[0066] The purpose of generating a pseudo card bin set is to be able to match the target card bins (card BIN codes) of various lengths that may exist in subsequent queries. The target card bin is the first few digits of the bank card number, which is used to identify the issuing bank and card type. Because the processing of the target card bin length may be different in different systems or scenarios, for example, some systems may only use the first 6 digits of the target card bin, while others may use the first 8 digits, so it is necessary to extract prefixes of different lengths from the card number as pseudo card bins.
[0067] For example, for the above card number "621700abcxxxxxxxxxx", a pseudo card bin set can be generated, which includes numbers of different lengths such as "621700", "621700a", "621700ab", etc.
[0068] In this step, the card number in the card information is truncated from the first digit according to the length range to form a 6-digit number, a 7-digit number, an 8-digit number and a 9-digit number, and the obtained numbers constitute a pseudo card bin set.
[0069] 103. The system assembles the cache query primary key based on the card information and the pseudo-card bin collection.
[0070] Combine the card face information with each pseudo-bin code in the pseudo-card bin set to generate a primary key KEY for querying the cache database. In this application, the cache database used can be a Redis cache. The purpose of this is to cover all possible query paths as much as possible and improve the query hit rate.
[0071] Define a cache primary key prefix, such as [BASE:DATA:CARDBIN:]. Concatenate the cache primary key prefix [BASE:DATA:CARDBIN:] and the length of the bank card number string into the primary key KEY. For example, for the above card number "621700abcxxxxxxxxxx", the card number length is 19, so the primary key KEY is BASE:DATA:CARDBIN:19.
[0072] During the query process, the system executes the HMGET instruction to query the Redis cache. The HMGET instruction realizes the retrieval of the primary key KEY within the key value range of the pseudo-card bin set. The primary key KEY refers to the unique identifier of the cache object. HMGET refers to the command to query the cache data using the identifier. The HMGET instruction includes: primary key KEY and pseudo-card bin set.
[0073] 104. The system queries the cached data based on the cache query primary key and obtains the query result.
[0074] The system uses the primary key KEY generated in step 103 to perform a query in the cache database, for example, calling the primary key KEY to query in the Redis cache. If there is matching cache data in the Redis cache, it means that the information about the bank card already exists in the Redis cache, and the query result is directly returned at this time, and the returned query result can be the queried data; if it does not exist, it means that the information about the bank card does not exist in the Redis cache, and the query result returns "empty" or "null" at this time.
[0075] 105. The system obtains the card bin information of the bank card according to the query result and feeds it back to the client.
[0076] The system will feed back the queried card bin information (such as the name of the issuing bank, card type, etc.) to the client in an appropriate manner (such as JSON, XML or directly displayed on the user interface). This step is the end point of the user interaction, ensuring that the user can obtain the required bank card information.
[0077] In this embodiment, there are two types of query results. If the query result is that the data is found, the queried data is directly returned to the system, and the system obtains the card bin information of the bank card based on the data; if the query result is that no data is found, the system obtains the card bin information of the bank card through hard parsing.
[0078] For example, for the above card number "621700abcxxxxxxxxxx", after the system completes the above steps, it will display to the user through the mobile application interface: "Your bank card is issued by China Construction Bank xx Branch".
[0079] Alternatively, the specific implementation in this step is: the system first obtains the format requirements of the client, and assembles the card bin information into card bin information response data according to the format requirements; then the system feeds back the card bin information response data to the client.
[0080] In this specific implementation, the system needs to first understand the specific format requirements of the data that the client expects to receive. The format requirements here refer to the arrangement form when displayed, such as the arrangement of card number, bank card type, and bank card issuing bank name.
[0081] Once the format requirements of the client are obtained, the system needs to assemble the card bin information (such as the name of the issuing bank, card type, etc.) obtained in step 105 into response data according to these requirements and then feed it back to the client.
[0082] In the present application, firstly, a pseudo-card bin set is generated based on the card face information of the bank card, the pseudo-card bin set represents a set of different numbers intercepted from the card number according to different length ranges, then a cache query primary key is assembled according to the pseudo-card bin set and the card face information, and then the cached data is queried according to the cache query primary key, at this time the query result is obtained, and finally the card bin information of the bank card is obtained according to the query result and fed back to the client, thereby parsing the bank card number into a pseudo-card bin set according to a preset length range, narrowing the retrieval range of the card bin, and thus achieving accurate retrieval; secondly, a good retrieval strategy for the cache query primary key and the pseudo-card bin set is designed, so as to quickly and accurately realize the recognition function of the bank card number; in addition, querying directly from the Redis cache can reduce the number of direct accesses to the database and improve the response speed and recognition accuracy of the recognition.
[0083] See also Figure 2 The present application also provides another embodiment of a bank card bin identification method, which includes:
[0084] 201. The system obtains bank card information, where the card information at least includes the bank card number.
[0085] 202. The system generates a pseudo card bin set according to the card surface information. The pseudo card bin set represents a set of different numbers extracted from the card number according to different length ranges.
[0086] 203. The system assembles a cache query primary key based on the card face information and the pseudo card bin set.
[0087] 204. The system queries the cached data based on the cache query primary key and obtains the query result.
[0088] Steps 201-204 in this embodiment are Figure 1 Steps 101-104 in the embodiment are similar and will not be described again here.
[0089] 205. The system determines whether the query result is empty.
[0090] After obtaining the query result, the system determines whether the query result is empty. If it is empty, it means that there is no corresponding data cached in the Redis cache. At this time, steps 206-207 are executed. If it is not empty, it means that the data has been queried, the data is directly returned, and step 208 is executed.
[0091] 206. The system obtains the card bin information by hard parsing the card surface information in the database.
[0092] Specifically, the target card bin is determined in the card bin table according to the card surface information, the card bin table is located in the database, and then the card bin information corresponding to the target card bin is obtained in the database;
[0093] In this embodiment, the length of the card number is first calculated to be 19 through the card surface information, and then the length of the card number is truncated. The length of the truncated string is consistent with the length in the card bin table of the database. Then, the truncated string is traversed and queried on the card bin table in the database. When the target card bin is found in the card bin table, the card bin information corresponding to the target card bin is called from the database.
[0094] 207. The system stores the card bin information in the Redis cache.
[0095] When the system obtains the card bin information from the database by hard parsing, it stores the card bin information in the Redis cache, so that the next query can directly access the Redis cache without accessing the database, thereby improving recognition efficiency. During the caching process, the system executes the instruction: HSET KEY CARBIN CARDBIN_INFO, where KEY is [BASE:DATA:CARDBIN:] concatenated with the length of the bank card number string, CARBIN is the card bin field in the card bin information, and CARDBIN is the card bin information, thus completing the caching of the card bin information.
[0096] 208. The system obtains the card bin information in the Redis cache according to the card surface information.
[0097] When the query result is not empty, it means that the card bin information already exists in the Redis cache. At this time, the system directly calls the corresponding card bin information in the Redis cache.
[0098] In this embodiment, through the key design of the query strategy, the pseudo card bin set of the card number is parsed according to the length range of the card bin, and the HMGET method is used to perform accurate redis retrieval according to the pseudo card bin range, thereby improving the retrieval efficiency and accuracy. The results of the database hard parsing are cached in redis, and only one hard parsing is required to complete the caching of the card bin information, which greatly improves the efficiency of bank card number recognition.
[0099] See also Figure 3 The present application provides an embodiment of a bank card bin recognition system, including:
[0100] The first acquisition unit 301 is used to acquire the card face information of the bank card, where the card face information at least includes the card number of the bank card;
[0101] A generating unit 302 is used to generate a pseudo card bin set according to the card surface information, where the pseudo card bin set represents a set of different numbers intercepted from the card number according to different length ranges;
[0102] Assembling unit 303, used to assemble cache query primary key according to card face information and pseudo card bin set;
[0103] A query unit 304 is used to query cached data based on the cache query primary key and obtain query results;
[0104] The second acquisition unit 305 is used to acquire the card bin information of the bank card according to the query result and feed it back to the client.
[0105] In this embodiment, the system first obtains the card face information of the bank card through the first acquisition unit 301, and the card face information at least includes the card number of the bank card. Secondly, the generation unit 302 generates a pseudo card bin set according to the card face information, and the pseudo card bin set represents a set of different numbers intercepted from the card number according to different length ranges. Then, the assembly unit 303 assembles the cache query primary key according to the card face information and the pseudo card bin set. Then, the query unit 304 queries the cached data based on the cache query primary key and obtains the query result. Finally, the second acquisition unit 305 obtains the card bin information of the bank card according to the query result and feeds it back to the client. In this way, first, the bank card number is parsed into a pseudo card bin set according to a preset length range, and the search range of the card BIN is narrowed, thereby achieving accurate search; secondly, a well-designed cache query primary key and pseudo card bin set search strategy are used to quickly and accurately realize the recognition function of the bank card number; in addition, querying directly from the Redis cache can reduce the number of direct accesses to the database and improve the response speed and recognition accuracy of the recognition.
[0106] See also Figure 4 The present application also provides another embodiment of a bank card bin recognition system, including:
[0107] The first acquisition unit 401 is used to acquire the card face information of the bank card, where the card face information at least includes the card number of the bank card;
[0108] A generating unit 402 is used to generate a pseudo card bin set according to the card surface information, where the pseudo card bin set represents a set of different numbers intercepted from the card number according to different length ranges;
[0109] The generating unit 402 includes:
[0110] A generating module 4021 is used to cut off the card number in the card face information from the first digit according to the length range to form a 6-digit number, a 7-digit number, an 8-digit number and a 9-digit number respectively;
[0111] Assembling unit 403, used to assemble cache query primary key according to card face information and pseudo card bin set;
[0112] A query unit 404 is used to query cached data based on the cache query primary key and obtain query results;
[0113] The second acquisition unit 405 is used to acquire the card bin information of the bank card according to the query result and feed it back to the client.
[0114] The second acquisition unit 405 includes:
[0115] An acquisition module 4051 is used to obtain card bin information by hard parsing the card surface information in a database;
[0116] The acquisition module 4051 includes:
[0117] A determination submodule 40511 is used to determine a target card bin in a card bin table according to the card surface information, where the card bin table is located in a database;
[0118] The acquisition submodule 40512 is used to acquire the card bin information corresponding to the target card bin;
[0119] The cache module 4052 is used to obtain the card bin information in the Redis cache according to the card face information;
[0120] The assembly module 4053 is used to obtain the format requirements of the client and assemble the card bin information into card bin information response data according to the format requirements;
[0121] Feedback module 4054, used to feed back the card bin information response data to the client;
[0122] The storage unit 406 is used to store the card bin information into the Redis cache.
[0123] See also Figure 5 The present application also provides a bank card bin recognition device, including:
[0124] Processor 501, memory 502, input and output unit 503, bus 504;
[0125] The processor 501 is connected to the memory 502, the input and output unit 503 and the bus 504;
[0126] The memory 502 stores a program, and the processor 501 calls the program to execute the above Figure 1 and Figure 2 Embodiment of the invention.
[0127] The present application also relates to a computer-readable storage medium, on which a program is stored, wherein when the program is run on a computer, the computer executes the above Figure 1 and Figure 2 Embodiment of the invention.
[0128] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0129] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0130] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0131] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0132] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. A bank card bin recognition method, characterized in that: include: Obtaining bank card information, wherein the bank card information includes at least the bank card number; Generate a pseudo card bin set according to the card face information, wherein the pseudo card bin set represents a set of different numbers intercepted from the card number according to different length ranges; Assemble a cache query primary key based on the card face information and the pseudo card bin set; Query cached data based on the cache query primary key and obtain query results; The card bin information of the bank card is obtained according to the query result and fed back to the client.
2. The card bin identification method according to claim 1, characterized in that: When the query result is empty, obtaining the card bin information of the bank card according to the query result includes: The card bin information is obtained by hard parsing the card surface information in a database.
3. The card bin identification method according to claim 2, characterized in that: After obtaining the card bin information by hard parsing the card surface information in a database, the card bin identification method further includes: The card bin information is stored in the Redis cache.
4. The card bin identification method according to claim 2, characterized in that: The obtaining of the card bin information by hard parsing the card surface information in a database includes: Determine a target card bin in a card bin table according to the card surface information, wherein the card bin table is located in the database; Obtain the card bin information corresponding to the target card bin.
5. The card bin identification method according to claim 1, characterized in that: When the query result is not empty, obtaining the card bin information of the bank card according to the query result includes: The card bin information is obtained in the Redis cache according to the card face information.
6. The card bin identification method according to any one of claims 1 to 5, characterized in that: The obtaining the card bin information of the bank card according to the query result and feeding it back to the client comprises: Obtain the format requirement of the client, and assemble the card bin information into card bin information response data according to the format requirement; Feedback the card bin information response data to the client.
7. The card bin identification method according to any one of claims 1 to 5, characterized in that: The length range is 6-9 digits, and generating a pseudo card bin set according to the card surface information includes: The card number in the card face information is truncated from the first digit according to the length range to form a 6-digit number, a 7-digit number, an 8-digit number and a 9-digit number respectively.
8. A bank card bin recognition system, characterized in that: include: A first acquisition unit is used to acquire card information of a bank card, wherein the card information at least includes a card number of the bank card; A generating unit, configured to generate a pseudo card bin set according to the card face information, wherein the pseudo card bin set represents a set of different numbers intercepted from the card number according to different length ranges; An assembling unit, used for assembling a cache query primary key according to the card face information and the pseudo card bin set; A query unit, used to query cached data based on the cache query primary key and obtain query results; The second acquisition unit is used to acquire the card bin information of the bank card according to the query result and feed it back to the client.
9. A bank card bin recognition device, characterized in that: include: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the card bin identification method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a program stored thereon, wherein the program, when executed on a computer, performs the card bin identification method according to any one of claims 1 to 7.
