Transaction posting methods, devices, electronic equipment and media
By configuring information sharding and an accounting thread, authorized transaction information is processed asynchronously and in parallel, solving the problem of real-time accounting for single-information transactions in credit payments and improving processing speed and timeliness.
Patent Information
- Application Number
- CN202210895545.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-27
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-07-27
AI Technical Summary
In existing credit payment solutions, when a credit card transaction involves a single information transaction, the processing of accounting information is delayed, affecting the timeliness of business support and preventing real-time billing.
By configuring information sharding and accounting threads, authorized transaction information is processed asynchronously and in parallel. It is allocated and read according to consumption time and customer identifier to achieve asynchronous and parallel real-time accounting processing.
This ensures the correct processing order of consumption information in a multi-threaded parallel mode when the same customer is conducting continuous high-frequency transactions, thereby improving processing speed and the timeliness of real-time accounting.
Smart Images

Figure CN115131154B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and more specifically, to a transaction recording method, apparatus, electronic device, and medium. Background Technology
[0002] In the credit payment solution, the financial transaction processing method for credit card business scenarios is as follows: two transaction lines, authorization and clearing, are used to process financial transaction information sent by international organizations. Authorization transactions mainly involve transaction inspection and credit limit update processing, while clearing transactions mainly involve transaction processing and balance update. Authorization transactions are implemented online, while clearing transactions are mostly implemented in batches.
[0003] Currently, some credit cards (such as UnionPay cards) have single-information transaction characteristics, while others (Visa cards) involve both single-information and dual-information transactions simultaneously. Single-information transactions refer to financial transactions transmitted through the UnionPay channel. For a single financial transaction, UnionPay only sends one request to the issuing institution, while other international organizations send two requests: authorization and clearing. Currently, for single-information credit cards, when a transaction occurs, the issuing institution stores the account information and then processes it in batches at a specified time. This account update lags behind the transaction occurrence, affecting the timeliness of business support. Summary of the Invention
[0004] The purpose of this application is to provide a transaction recording method, apparatus, electronic device, and medium to solve the problem that transaction information cannot be recorded in real time in existing credit payment systems, which affects the timeliness of business support.
[0005] Firstly, a method for recording transactions is provided, which may include:
[0006] After obtaining the consumption information from the consumption request of the authorized transaction customer, the consumption information is identified as authorized transaction information; the consumption information includes the consumption time and customer identifier;
[0007] Based on the amount of information in the authorized transaction information, the number of information shards and the number of accounting threads are configured to obtain a target number of information shards and a target number of accounting threads; the information shards are used to carry the allocated authorized transaction information, and the accounting threads are used to read the allocated authorized transaction information in the corresponding information shards;
[0008] According to the customer identifier, the authorized transaction information is allocated to the target number of information segments, wherein each allocated information segment includes at least one authorized transaction information corresponding to each customer identifier arranged in chronological order of the consumption time;
[0009] The target number of accounting threads reads the authorized transaction information from the target number of information shards and performs accounting processing on the read authorized transaction information.
[0010] In an optional implementation, before the target number of inbound threads read the authorized transaction information from the target number of information shards, the method further includes:
[0011] According to the shard number corresponding to the target number of information shards, the authorized transaction information in the target number of information shards is recorded in the transaction record table;
[0012] The corresponding thread for receiving payments uses the target number of authorized transaction information fragments to read the information fragments corresponding to the target number of such fragments, including:
[0013] The corresponding number of inbound threads reads the authorized transaction information from the information fragments of the target number in the transaction record table.
[0014] In an optional implementation, before the target number of inbound threads read the authorized transaction information from the target number of information shards, the method further includes:
[0015] Based on the target quantity, the number of message queues in the message middleware is configured to obtain message queues that correspond one-to-one with the allocated information fragments of the target quantity. For each information fragment, the corresponding authorized transaction information is transmitted to the message queue corresponding to the information fragment according to the order of the authorized transaction information in the information fragment.
[0016] The corresponding thread for receiving payments uses the target number of authorized transaction information fragments to read the information fragments corresponding to the target number of such fragments, including:
[0017] The target number of receiving threads are used to read the authorized transaction information from the target number of message queues.
[0018] In an optional implementation, after determining the consumption information as authorized transaction information, the method further includes:
[0019] Authorized transactions are registered according to the chronological order of the consumption time.
[0020] According to the customer identifier, the authorized transaction information is allocated to the target number of information fragments, including:
[0021] Based on the customer identifier, the registered authorized transaction information is allocated to the target number of information segments.
[0022] In an optional implementation, the authorized transaction information is allocated to the target number of information fragments according to the customer identifier, including:
[0023] A preset hash algorithm is used to perform a hash operation on the customer identifier to obtain the hash value corresponding to the customer identifier;
[0024] The hash value corresponding to the customer identifier and the remainder of the target quantity are determined as the shard number corresponding to the customer identifier;
[0025] The authorized transaction information corresponding to the customer identifier is allocated to the information fragment corresponding to the fragment number.
[0026] In an optional implementation, the authorized transaction information is allocated to the target number of information fragments according to the customer identifier, including:
[0027] If the pre-recorded mapping relationship between customer identifiers and the shard numbers corresponding to the target number of information shards contains the target customer identifier, then according to the mapping relationship between the customer identifier and the shard number, the target shard number corresponding to the target customer identifier is found, and the authorized transaction information corresponding to the target customer identifier is allocated to the information shard corresponding to the target shard number.
[0028] If the pre-recorded mapping relationship between customer identifiers and the shard numbers corresponding to the target number of information shards does not include the target customer identifier, then based on the number of customer identifiers corresponding to each shard number in the mapping relationship between customer identifiers and shard numbers, a mapping relationship between the target shard number with the minimum number of identifiers and the target customer identifier is established, and the authorized transaction information corresponding to the target customer identifier is allocated to the information shard corresponding to the target shard number.
[0029] In an optional implementation, the consumption information includes the amount of this consumption;
[0030] Obtain consumption information from the consumption requests of customers authorized for transactions, including:
[0031] Obtain consumption information from the customer's consumption request;
[0032] The consumption information is authorized and verified. If the verification result meets the preset authorization conditions, the consumption information is authorized for transaction in order to obtain the consumption information in the consumption request of the authorized transaction customer. The preset authorization conditions refer to whether the customer's account balance is greater than the consumption amount, whether the card status of the credit card used for payment is normal, and whether the risk control rule verification result is risk-free.
[0033] In an optional implementation, the target number of inbound threads reads the authorized transaction information from the target number of information fragments in the transaction record table, including:
[0034] Search the transaction record table to determine the shard number of the information shard that corresponds one-to-one with the thread number of each receiving thread;
[0035] Based on the matching relationship between the thread number and the shard number, the authorized transaction information in the information shards of the target number of receiving threads is read from the transaction record table.
[0036] In an optional implementation, if the authorized transaction information and the posting information after posting processing share the transaction record table, then the read authorized transaction information is posted, including:
[0037] The authorization status of the authorized transaction information stored in the transaction record table is updated to the receipt status.
[0038] In an optional implementation, a target number of inbound threads are used to read authorized transaction information from the target number of message queues, including:
[0039] Get the thread number of each accounting thread and the queue number of each message queue;
[0040] Based on the matching relationship between the thread number and the queue number, the authorized transaction information in the message queue is read from the target number of message queues corresponding to the target number of receiving threads.
[0041] In an optional implementation, after processing the read authorized transaction information for posting, the method further includes:
[0042] For each message queue, the authorized transaction information after the accounting process is completed is deleted from the message queue.
[0043] Secondly, a transaction posting device is provided, which may include:
[0044] The determining unit is configured to determine the consumption information as authorized transaction information after obtaining the consumption information in the consumption request of the customer authorized to conduct the transaction; the consumption information includes the consumption time and the customer identifier.
[0045] The quantity configuration unit is used to configure the number of information shards and the number of accounting threads based on the amount of information in the authorized transaction information, so as to obtain a target number of information shards and a target number of accounting threads; the information shards are used to carry the allocated authorized transaction information, and the accounting threads are used to read the allocated authorized transaction information in the corresponding information shards;
[0046] The allocation unit is configured to allocate the authorized transaction information to the target number of information segments according to the customer identifier, wherein each information segment after allocation includes at least one authorized transaction information corresponding to each customer identifier arranged in chronological order of the consumption time;
[0047] The reading unit is used to read the authorized transaction information from the information slices corresponding to the target number of inbound threads;
[0048] The posting unit is used to post the authorized transaction information that has been read.
[0049] In an optional implementation, the apparatus further includes a recording unit;
[0050] The recording unit is used to record authorized transaction information in the target number of information shards in the transaction record table according to the shard number corresponding to the shard number of the target number of information shards;
[0051] The reading unit is specifically used to read the authorized transaction information from the information fragments of the target number of accounting threads in the transaction record table.
[0052] In an optional implementation, the quantity configuration unit is further configured to configure the number of message queues of the message middleware according to the target quantity, to obtain message queues that correspond one-to-one with the allocated information fragments of the target quantity, and for each information fragment, transmit the corresponding authorized transaction information to the message queue corresponding to the information fragment according to the order of the authorized transaction information in the information fragment.
[0053] The reading unit is also specifically used to read the authorized transaction information in the message queue corresponding to the target number of inbound threads.
[0054] In an optional implementation, the apparatus further includes a registration unit;
[0055] The registration unit is used to register the authorized transaction information in chronological order of the consumption time.
[0056] The allocation unit is specifically used to allocate the registered authorized transaction information to the target number of information segments according to the customer identifier.
[0057] In an optional implementation, the allocation unit is further specifically used for:
[0058] A preset hash algorithm is used to perform a hash operation on the customer identifier to obtain the hash value corresponding to the customer identifier;
[0059] The hash value corresponding to the customer identifier and the remainder of the target quantity are determined as the shard number corresponding to the customer identifier;
[0060] The authorized transaction information corresponding to the customer identifier is allocated to the information fragment corresponding to the fragment number.
[0061] In an optional implementation, the allocation unit is further specifically used for:
[0062] If the pre-recorded mapping relationship between customer identifiers and the shard numbers corresponding to the target number of information shards contains the target customer identifier, then according to the mapping relationship between the customer identifier and the shard number, the target shard number corresponding to the target customer identifier is found, and the authorized transaction information corresponding to the target customer identifier is allocated to the information shard corresponding to the target shard number.
[0063] If the pre-recorded mapping relationship between customer identifiers and the shard numbers corresponding to the target number of information shards does not include the target customer identifier, then based on the number of customer identifiers corresponding to each shard number in the mapping relationship between customer identifiers and shard numbers, a mapping relationship between the target shard number with the minimum number of identifiers and the target customer identifier is established, and the authorized transaction information corresponding to the target customer identifier is allocated to the information shard corresponding to the target shard number.
[0064] In an optional implementation, the consumption information includes the amount of the current consumption; the device further includes an acquisition unit;
[0065] The acquisition unit is used to acquire consumption information from the customer's consumption request;
[0066] In addition, the consumption information is authorized and verified. If the verification result meets the preset authorization conditions, the consumption information is authorized for transaction in order to obtain the consumption information in the consumption request of the authorized transaction customer. The preset authorization conditions refer to whether the customer's account balance is greater than the consumption amount, whether the card status of the credit card used for payment is normal, and whether the risk control rule verification result is risk-free.
[0067] Thirdly, an electronic device is provided, which includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0068] Memory, used to store computer programs;
[0069] When a processor executes a program stored in memory, it implements any of the steps described in the first aspect above.
[0070] Fourthly, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when executed by a processor, the computer program implements the steps of any of the methods described in the first aspect above.
[0071] The transaction posting method provided in this application, after obtaining the consumption information from the consumption request of the authorized transaction customer, identifies the consumption information as authorized transaction information. The consumption information includes the consumption time and customer identifier. Based on the amount of information in the authorized transaction information, the number of information shards and the number of posting threads are configured to obtain a target number of information shards and a target number of posting threads. Information shards are used to carry the allocated authorized transaction information, and posting threads are used to read the allocated authorized transaction information from the corresponding information shards. According to the customer identifier, the authorized transaction information is allocated to the target number of information shards. Each allocated information shard includes at least one customer identifier, with authorized transaction information arranged in chronological order of consumption time for each customer identifier. The target number of posting threads read the authorized transaction information from the target number of information shards and perform posting processing on the read authorized transaction information. This method performs asynchronous parallel real-time posting processing on the consumption information of authorized transactions, ensuring the correct processing order of consumption information in a multi-threaded parallel mode during continuous high-frequency transactions by the same customer, and also improving processing speed, i.e., improving the timeliness of real-time posting. Attached Figure Description
[0072] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0073] Figure 1 A schematic diagram of a credit card transaction process provided for an embodiment of this application;
[0074] Figure 2 A flowchart illustrating a transaction posting method provided in an embodiment of this application;
[0075] Figure 3 This is a schematic diagram of the structure of a transaction posting device provided in an embodiment of this application;
[0076] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0077] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0078] For ease of understanding, the following is... Figure 1 The transaction process for the shown credit card is described below:
[0079] 1. Cardholders swipe their cards to make purchases at merchants' POS machines.
[0080] 2. The acquiring bank receives the bank card information through the POS machine and sends a payment request to itself, which includes payment information.
[0081] 3. The acquiring bank requires the card organization to obtain payment permission (authorization) from the issuing bank.
[0082] 4. The card organization submits payment information to the issuing bank and requests payment authorization (license).
[0083] 5. The issuing bank authorizes merchants to collect payments from cardholders.
[0084] 6. The issuing bank settles the money with the acquiring bank (or the merchant's bank), and then the acquiring bank deposits the payment into the account.
[0085] Among them, cardholder refers to consumer; merchant refers to person who sells goods; acquiring bank refers to merchant's bank; issuing bank refers to cardholder's bank; card organization refers to network that builds payment and clearing information flow, such as VISA and Mastercard.
[0086] The transaction posting method provided in this application can be applied to the issuing bank's server. After obtaining the consumption information from the consumption request of the authorized transaction customer, the method identifies the consumption information as authorized transaction information. The consumption information includes the consumption time and customer identifier. Based on the amount of information in the authorized transaction information, the method configures the number of information shards and the number of posting threads to obtain a target number of information shards and a target number of posting threads. Information shards are used to carry the allocated authorized transaction information, and posting threads are used to read the allocated authorized transaction information from the corresponding information shards. According to the customer identifier, the authorized transaction information is allocated to the target number of information shards. Each allocated information shard includes at least one customer identifier, with authorized transaction information arranged in chronological order of consumption time for each customer identifier. The target number of posting threads read the authorized transaction information from the target number of information shards and perform posting processing on the read authorized transaction information.
[0087] In other words, this method performs asynchronous and parallel real-time accounting processing on the consumption information of authorized transactions, ensuring the correct processing order of consumption information in a multi-threaded parallel mode when the same customer is conducting continuous high-frequency transactions, and also improving the processing speed.
[0088] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.
[0089] Figure 2 This is a flowchart illustrating a transaction posting method provided in an embodiment of this application. Figure 2 As shown, the method may include:
[0090] Step S210: After obtaining the consumption information from the consumption request of the authorized transaction customer, the consumption information is identified as authorized transaction information.
[0091] Before performing this step, it is necessary to obtain the consumption information from the consumption request of the customer authorized for the transaction, which may specifically include:
[0092] Obtain consumption information from a customer's consumption request; wherein, a customer's consumption request can be a consumption request corresponding to at least one customer.
[0093] Specifically, after applying for a credit card, the backend server receives transaction information for each transaction. This transaction information is in a message format. The data fields in this message represent the details of the transaction, such as the card information (bank card or credit card), transaction time, transaction amount, product purchased, and customer identifier. The card information can be the bank card or credit card number. Since the card information is unique for each customer, the customer identifier can be either the card number or the corresponding customer number.
[0094] The system verifies the authorization of transaction information. If the verification result meets the preset authorization conditions, the system authorizes the transaction for the corresponding transaction information, thereby obtaining the transaction information from the authorized customer's transaction request. The preset authorization conditions refer to verification conditions indicating that the transaction information is normal, such as whether the customer's account balance is greater than the transaction amount, whether the credit card used for payment is in good condition, and whether the risk control rule verification result is no risk.
[0095] In practice, after obtaining the consumption information from the consumption request of the authorized transaction customer, the consumption information is identified as authorized transaction information.
[0096] In some embodiments, after the consumption information is identified as authorized transaction information, the authorized transaction information can be registered for authorized transactions in chronological order of consumption time.
[0097] Step S220: Based on the amount of authorized transaction information, configure the number of information shards and the number of inbound threads to obtain the target number of information shards and the target number of inbound threads.
[0098] Among them, the information shard is used to carry the allocated authorized transaction information, and the accounting thread is used to read the allocated authorized transaction information in the corresponding information shard.
[0099] To ensure that business resources are not wasted, the number of information shards and the number of accounting threads can be configured according to business needs (i.e., the amount of business to be processed) to improve resource utilization. Since the accounting threads are used to read authorized transaction information from the information shards, the number of information shards and the number of accounting threads configured are the same and correspond one-to-one.
[0100] In some embodiments, if the amount of authorized transaction information is between the first amount of information and the second amount of information, a fixed number of information fragments and accounting threads can be configured; the first amount of information is greater than the second amount of information.
[0101] If the amount of information in the authorized transaction information is greater than the first amount of information, the number of information shards and the number of accounting threads can be increased based on the difference between the amount of information in the authorized transaction information and the first amount of information, as well as the maximum amount of authorized transaction information that each information shard can carry, on the basis of the configured fixed number.
[0102] For example, if the difference between the amount of authorized transaction information and the first amount of information is 10, and each information shard can carry a maximum of 20 authorized transaction information, then one more information shard and one accounting thread can be added on the basis of the configured fixed number.
[0103] If the amount of authorized transaction information is less than the amount of second information, the number of information shards and the number of accounting threads can be reduced based on the difference between the amount of second information and the amount of authorized transaction information, as well as the maximum amount of authorized transaction information that each information shard can carry, on the basis of the configured fixed number.
[0104] For example, if the difference between the amount of information in the second information and the amount of information in the authorized transaction information is 20, and each information shard can carry a maximum of 20 pieces of authorized transaction information, then one information shard and one accounting thread can be reduced from the configured fixed number.
[0105] Step S230: Assign the authorized transaction information to the target number of information fragments according to the customer identifier.
[0106] Each allocated information segment includes authorized transaction information corresponding to at least one customer identifier, arranged in chronological order of consumption time.
[0107] To ensure the correct processing order and speed in a multi-threaded mode when the same customer engages in continuous high-frequency transactions, all authorized transaction information corresponding to each customer identifier can be allocated to the same information slice. The authorized transaction information corresponding to each customer identifier can be sorted according to the order of consumption time. In other words, each information slice after allocation includes authorized transaction information corresponding to each customer identifier in at least one customer identifier, arranged in the order of consumption time.
[0108] Furthermore, in order to achieve load balancing of information shards, the authorized transaction information corresponding to the customer identifier needs to be evenly distributed so that the authorized transaction information is included in the target number of information shards, and the authorized transaction information corresponding to the same customer identifier is allocated to the same information shard.
[0109] In practice, the following two allocation methods can be included:
[0110] Method 1: Use a preset hash algorithm to perform a hash operation on the customer identifier to obtain the hash value corresponding to the customer identifier;
[0111] The remainder of the hash value corresponding to the customer identifier and the target number of information shards is determined as the shard number corresponding to the customer identifier; then the authorized transaction information corresponding to the customer identifier is allocated to the information shard corresponding to the shard number.
[0112] For example, if the customer identifier is 2455 and the target number of information shards is 100, since the remainder of 2455 and 100 is 55, the shard number corresponding to the customer identifier 2455 is 55. At this time, the authorized transaction information corresponding to the customer identifier 2455 is allocated to the information shard corresponding to the 55th shard number.
[0113] Method 2: Pre-record the mapping relationship between customer identifiers and the corresponding shard numbers of the target quantity information shards;
[0114] If the mapping relationship between the customer identifier and the shard number includes the target customer identifier, then according to the mapping relationship between the customer identifier and the shard number, find the target shard number corresponding to the target customer identifier, and allocate the authorized transaction information corresponding to the target customer identifier to the information shard corresponding to the target shard number.
[0115] If the mapping relationship between the customer identifier and the shard number does not include the target customer identifier, then based on the number of customer identifiers corresponding to each shard number in the mapping relationship between the customer identifier and the shard number, a mapping relationship between the target shard number with the minimum number of identifiers and the target customer identifier is established, and the authorized transaction information corresponding to the target customer identifier is allocated to the information shard corresponding to the target shard number.
[0116] If there are multiple fragment numbers with the fewest identifiers, a fragment number can be randomly selected as the target fragment number, or the smallest fragment number can be selected as the target fragment number according to the fragment number order.
[0117] For example, the pre-recorded mapping relationship between customer identifiers and three shard numbers includes: the mapping relationship between customer identifier 1 and shard number 1; the mapping relationship between customer identifier 2 and shard number 1; the mapping relationship between customer identifier 3 and shard number 2; and the mapping relationship between customer identifier 4 and shard number 3.
[0118] When the target customer identifier is 2, find the mapping relationship between the customer identifier and the 3 shard numbers. If the target shard number corresponding to the target customer identifier 2 is 1, then the authorized transaction information corresponding to the target customer identifier 2 is allocated to the information shard corresponding to the target shard number 1.
[0119] When the target customer identifier is 5, the mapping relationship between the customer identifier and the three shard numbers does not include the target customer identifier 5. At this time, the number of customer identifiers corresponding to each shard number is obtained. The shard numbers 3 and 2 with the fewest identifiers are selected as candidate shard numbers. A shard number is randomly selected from shard numbers 3 and 2 as the target shard number corresponding to the target customer identifier 5. For example, if the target shard number is 2, a mapping relationship is established between the target shard number 2 and the target customer identifier 5. Then, the authorized transaction information corresponding to the target customer identifier 5 is allocated to the information shard corresponding to the target shard number 2.
[0120] It should be noted that since Method 2 requires real-time mapping and recording of new customer identifiers, it not only consumes resources but also incurs high costs. Therefore, Method 1 is the optimal allocation method in this application.
[0121] Step S240: Use the target number of accounting threads to read the authorized transaction information from the target number of information shards, and process the read authorized transaction information for accounting.
[0122] In practical implementation, when authorization and accounting share a single database, the target number of accounting threads can retrieve the corresponding authorized transaction information from the target number of information shards by looking up a table. When authorization and accounting use separate databases, the authorized transaction information from the information shards can be obtained through the message queue in the message middleware, allowing the accounting threads to read the authorized transaction information by performing read operations on the message queue. Specifically:
[0123] Method 1: The receiving threads for the target quantity can retrieve the authorized transaction information from the information shards corresponding to the target quantity by looking up a table.
[0124] Based on the shard number corresponding to the target quantity of information shards, the authorized transaction information in the target quantity of information shards is recorded in the transaction record table; that is, the transaction record table records the correspondence between the shard number of the target quantity and the corresponding authorized transaction information, as well as the specific information content of the authorized transaction information.
[0125] Subsequently, the authorized transaction information is read from the target number of information fragments in the transaction record table using the corresponding target number of inbound threads.
[0126] Specifically, the transaction record table is searched to determine the shard number of the information shard that corresponds one-to-one with the thread number of each receiving thread. Based on the number matching relationship between the thread number and the shard number, the authorized transaction information in the target number of information shards in the transaction record table is read by the target number of receiving threads. The number matching relationship refers to the relationship of having the same number.
[0127] For example, if there is a correspondence between thread number 1 and shard number 1, then the receiving thread corresponding to thread number 1 will only read the authorized transaction information in the information shard corresponding to shard number 1 from the transaction record table.
[0128] Since the authorized transaction information in the information shard is sorted according to the order of consumption time for each customer identifier, and ensures that the authorized transaction information corresponding to the same customer identifier is allocated to the same information shard, this accounting thread can achieve the correct processing order and processing speed in the multi-threaded mode when the same account makes continuous high-frequency transactions.
[0129] Method 2: Obtain the authorized transaction information from the information fragment through the message queue in the message middleware, and then read the authorized transaction information:
[0130] Based on the target quantity, the number of message queues in the message middleware is configured to obtain message queues that correspond one-to-one with the allocated information shards of the target quantity. For each information shard, the corresponding authorized transaction information is transmitted to the message queue corresponding to the information shard according to the order of the authorized transaction information in the information shard.
[0131] In practice, the number of message queues in the message middleware is configured according to the target number of information shards, and the target number of inbound threads are configured, with one thread corresponding to one message queue. Then, for each information shard, the corresponding authorized transaction information is transmitted to the message queue corresponding to the information shard according to the order of the authorized transaction information in the information shard, to ensure that the order of the authorized transaction information in the corresponding message queue remains unchanged.
[0132] Then, the target number of receiving threads read the authorized transaction information from the target number of message queues. Specific steps may include:
[0133] The system retrieves the thread ID of each inbound transaction thread and the queue ID of each message queue. Based on the matching relationship between the thread ID and the queue ID, it reads the authorized transaction information from the target number of message queues corresponding to the target number of inbound transaction threads. The matching relationship refers to the relationship of having the same number.
[0134] For example, if there is a number matching relationship between thread number 1 and queue number 1, then the receiving thread corresponding to thread number 1 will only read the authorized transaction information in the information shard corresponding to shard number 1 from the message queue corresponding to queue number 1.
[0135] Since the authorized transaction information in the message queue is sorted according to the order of consumption time for each customer identifier, and the authorized transaction information corresponding to the same customer identifier is guaranteed to be allocated in the same message queue, this inbound thread can achieve the correct processing order and processing speed in multi-threaded mode when the same account makes continuous high-frequency transactions.
[0136] Furthermore, to ensure that authorized transaction information is not repeatedly recorded, after the read authorized transaction information is recorded, the recorded authorized transaction information needs to be deleted from each message queue.
[0137] As can be seen, the asynchronous accounting method provided in this application configures the number of information fragments and accounting threads based on the amount of information to be processed, thereby achieving reasonable utilization of business resources. Furthermore, by using table lookup or message middleware to implement an asynchronous and parallel accounting process, the accounting processing speed is improved.
[0138] Corresponding to the above method, embodiments of this application also provide a transaction posting device, such as... Figure 3 As shown, the transaction recording device includes: a determination unit 310, a quantity configuration unit 320, an allocation unit 330, a reading unit 340, and a recording unit 350;
[0139] The determining unit 310 is configured to determine the consumption information as authorized transaction information after obtaining the consumption information in the consumption request of the customer authorized to conduct the transaction; the consumption information includes the consumption time and the customer identifier.
[0140] The quantity configuration unit 320 is used to configure the number of information shards and the number of accounting threads based on the amount of information in the authorized transaction information, so as to obtain a target number of information shards and a target number of accounting threads; the information shards are used to carry the allocated authorized transaction information, and the accounting threads are used to read the allocated authorized transaction information in the corresponding information shards;
[0141] The allocation unit 330 is used to allocate the authorized transaction information to the target number of information segments according to the customer identifier, wherein each information segment after allocation includes at least one authorized transaction information corresponding to each customer identifier arranged in chronological order of the consumption time;
[0142] Reading unit 340 is used to read the authorized transaction information in the information slices of the target number of accounting threads corresponding to the target number of accounting threads;
[0143] The posting unit 350 is used to post the authorized transaction information read.
[0144] In an optional implementation, the apparatus further includes a recording unit 360;
[0145] Recording unit 360 is used to record authorized transaction information in the target number of information shards in the transaction record table according to the shard number corresponding to the shards of the target number of information shards;
[0146] The reading unit 340 is specifically used to read the authorized transaction information from the information fragments of the target number of the transaction record table corresponding to the target number of the accounting threads.
[0147] In an optional implementation, the quantity configuration unit 320 is further configured to configure the number of message queues of the message middleware according to the target quantity, to obtain message queues that correspond one-to-one with the allocated information fragments of the target quantity, and for each information fragment, transmit the corresponding authorized transaction information to the message queue corresponding to the information fragment according to the order of the authorized transaction information in the information fragment.
[0148] The reading unit 340 is also specifically used to read the authorized transaction information in the message queue corresponding to the target number of accounting threads.
[0149] In an optional implementation, the apparatus further includes a registration unit 370;
[0150] Registration unit 370 is used to register authorized transactions according to the order of the consumption time;
[0151] The allocation unit 330 is specifically used to allocate the registered authorized transaction information to the target number of information segments according to the customer identifier.
[0152] In an optional implementation, allocation unit 330 is also specifically used for:
[0153] A preset hash algorithm is used to perform a hash operation on the customer identifier to obtain the hash value corresponding to the customer identifier;
[0154] The hash value corresponding to the customer identifier and the remainder of the target quantity are determined as the shard number corresponding to the customer identifier;
[0155] The authorized transaction information corresponding to the customer identifier is allocated to the information fragment corresponding to the fragment number.
[0156] In an optional implementation, allocation unit 330 is also specifically used for:
[0157] If the pre-recorded mapping relationship between customer identifiers and the shard numbers corresponding to the target number of information shards contains the target customer identifier, then according to the mapping relationship between the customer identifier and the shard number, the target shard number corresponding to the target customer identifier is found, and the authorized transaction information corresponding to the target customer identifier is allocated to the information shard corresponding to the target shard number.
[0158] If the pre-recorded mapping relationship between customer identifiers and the shard numbers corresponding to the target number of information shards does not include the target customer identifier, then based on the number of customer identifiers corresponding to each shard number in the mapping relationship between customer identifiers and shard numbers, a mapping relationship between the target shard number with the minimum number of identifiers and the target customer identifier is established, and the authorized transaction information corresponding to the target customer identifier is allocated to the information shard corresponding to the target shard number.
[0159] In an optional implementation, the consumption information includes the amount of the current consumption; the device further includes an acquisition unit 380;
[0160] The acquisition unit 380 is used to acquire consumption information from the customer's consumption request;
[0161] In addition, the consumption information is authorized and verified. If the verification result meets the preset authorization conditions, the consumption information is authorized for transaction in order to obtain the consumption information in the consumption request of the authorized transaction customer. The preset authorization conditions refer to whether the customer's account balance is greater than the consumption amount, whether the card status of the credit card used for payment is normal, and whether the risk control rule verification result is risk-free.
[0162] The functions of each functional unit of the transaction posting device provided in the above embodiments of this application can be implemented through the above methods and steps. Therefore, the specific working process and beneficial effects of each unit in the transaction posting device provided in the embodiments of this application will not be repeated here.
[0163] This application also provides an electronic device, such as... Figure 4 As shown, it includes a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440.
[0164] Memory 430 is used to store computer programs;
[0165] When the processor 410 executes the program stored in the memory 430, it performs the following steps:
[0166] After obtaining the consumption information from the consumption request of the authorized transaction customer, the consumption information is identified as authorized transaction information; the consumption information includes the consumption time and customer identifier;
[0167] Based on the amount of information in the authorized transaction information, the number of information shards and the number of accounting threads are configured to obtain a target number of information shards and a target number of accounting threads; the information shards are used to carry the allocated authorized transaction information, and the accounting threads are used to read the allocated authorized transaction information in the corresponding information shards;
[0168] According to the customer identifier, the authorized transaction information is allocated to the target number of information segments, wherein each allocated information segment includes at least one authorized transaction information corresponding to each customer identifier arranged in chronological order of the consumption time;
[0169] The target number of accounting threads reads the authorized transaction information from the target number of information shards and performs accounting processing on the read authorized transaction information.
[0170] In an optional implementation, before the target number of inbound threads read the authorized transaction information from the target number of information shards, the method further includes:
[0171] According to the shard number corresponding to the target number of information shards, the authorized transaction information in the target number of information shards is recorded in the transaction record table;
[0172] The corresponding thread for receiving payments uses the target number of authorized transaction information fragments to read the information fragments corresponding to the target number of such fragments, including:
[0173] The corresponding number of inbound threads reads the authorized transaction information from the information fragments of the target number in the transaction record table.
[0174] In an optional implementation, before the target number of inbound threads read the authorized transaction information from the target number of information shards, the method further includes:
[0175] Based on the target quantity, the number of message queues in the message middleware is configured to obtain message queues that correspond one-to-one with the allocated information fragments of the target quantity. For each information fragment, the corresponding authorized transaction information is transmitted to the message queue corresponding to the information fragment according to the order of the authorized transaction information in the information fragment.
[0176] The corresponding thread for receiving payments uses the target number of authorized transaction information fragments to read the information fragments corresponding to the target number of such fragments, including:
[0177] The target number of receiving threads are used to read the authorized transaction information from the target number of message queues.
[0178] In an optional implementation, after determining the consumption information as authorized transaction information, the method further includes:
[0179] Authorized transactions are registered according to the chronological order of the consumption time.
[0180] According to the customer identifier, the authorized transaction information is allocated to the target number of information fragments, including:
[0181] Based on the customer identifier, the registered authorized transaction information is allocated to the target number of information segments.
[0182] In an optional implementation, the authorized transaction information is allocated to the target number of information fragments according to the customer identifier, including:
[0183] A preset hash algorithm is used to perform a hash operation on the customer identifier to obtain the hash value corresponding to the customer identifier;
[0184] The hash value corresponding to the customer identifier and the remainder of the target quantity are determined as the shard number corresponding to the customer identifier;
[0185] The authorized transaction information corresponding to the customer identifier is allocated to the information fragment corresponding to the fragment number.
[0186] In an optional implementation, the authorized transaction information is allocated to the target number of information fragments according to the customer identifier, including:
[0187] If the pre-recorded mapping relationship between customer identifiers and the shard numbers corresponding to the target number of information shards contains the target customer identifier, then according to the mapping relationship between the customer identifier and the shard number, the target shard number corresponding to the target customer identifier is found, and the authorized transaction information corresponding to the target customer identifier is allocated to the information shard corresponding to the target shard number.
[0188] If the pre-recorded mapping relationship between customer identifiers and the shard numbers corresponding to the target number of information shards does not include the target customer identifier, then based on the number of customer identifiers corresponding to each shard number in the mapping relationship between customer identifiers and shard numbers, a mapping relationship between the target shard number with the minimum number of identifiers and the target customer identifier is established, and the authorized transaction information corresponding to the target customer identifier is allocated to the information shard corresponding to the target shard number.
[0189] In an optional implementation, the consumption information includes the amount of this consumption;
[0190] Obtain consumption information from the consumption requests of customers authorized for transactions, including:
[0191] Obtain consumption information from the customer's consumption request;
[0192] The consumption information is authorized and verified. If the verification result meets the preset authorization conditions, the consumption information is authorized for transaction in order to obtain the consumption information in the consumption request of the authorized transaction customer. The preset authorization conditions refer to whether the customer's account balance is greater than the consumption amount, whether the card status of the credit card used for payment is normal, and whether the risk control rule verification result is risk-free.
[0193] In an optional implementation, the target number of inbound threads reads the authorized transaction information from the target number of information fragments in the transaction record table, including:
[0194] Search the transaction record table to determine the shard number of the information shard that corresponds one-to-one with the thread number of each receiving thread;
[0195] Based on the matching relationship between the thread number and the shard number, the authorized transaction information in the information shards of the target number of receiving threads is read from the transaction record table.
[0196] In an optional implementation, if the authorized transaction information and the posting information after posting processing share the transaction record table, then the read authorized transaction information is posted, including:
[0197] The authorization status of the authorized transaction information stored in the transaction record table is updated to the receipt status.
[0198] In an optional implementation, a target number of inbound threads are used to read authorized transaction information from the target number of message queues, including:
[0199] Get the thread number of each accounting thread and the queue number of each message queue;
[0200] Based on the matching relationship between the thread number and the queue number, the authorized transaction information in the message queue is read from the target number of message queues corresponding to the target number of receiving threads.
[0201] In an optional implementation, after processing the read authorized transaction information for posting, the method further includes:
[0202] For each message queue, the authorized transaction information after the accounting process is completed is deleted from the message queue.
[0203] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0204] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0205] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0206] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0207] The implementation methods and beneficial effects of the various components of the electronic device in the above embodiments for solving the problem can be found in [reference needed]. Figure 2 The steps in the illustrated embodiments are used to implement the electronic device. Therefore, the specific working process and beneficial effects of the electronic device provided in this application will not be repeated here.
[0208] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores instructions that, when executed on a computer, cause the computer to perform any of the transaction posting methods described in the above embodiments.
[0209] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the transaction posting methods described in the above embodiments.
[0210] Those skilled in the art will understand that the embodiments in this application can be provided as methods, systems, or computer program products. Therefore, the embodiments in this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, the embodiments in this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0211] This application describes embodiments of methods, apparatus (systems), and computer program products according to embodiments of this application with reference to flowchart illustrations and / or block diagrams. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0212] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0213] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0214] Although preferred embodiments have been described in this application, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of this application.
[0215] Obviously, those skilled in the art can make various modifications and variations to the embodiments of this application without departing from the spirit and scope of the embodiments of this application. Therefore, if these modifications and variations to the embodiments of this application fall within the scope of the claims in this application and their equivalents, then this application also intends to include these modifications and variations.
Claims
1. A transaction posting method, characterized by, The method comprises: After obtaining consumption information in a consumption request of a client authorized transaction, the consumption information is determined as authorized transaction information; the consumption information comprises a consumption time and a client identifier; Based on the information amount of the authorized transaction information, the number of information shards and the number of entry threads are configured to obtain a target number of information shards and a target number of entry threads; the information shard is used to carry the allocated authorized transaction information, and the entry thread is used to read the allocated authorized transaction information in the corresponding information shard; According to the client identifier, the authorized transaction information is allocated to the target number of information shards, wherein each information shard after allocation comprises at least one client identifier corresponding to the authorized transaction information arranged in the order of the consumption time; The target number of entry threads are used to read the authorized transaction information in the target number of information shards, and the read authorized transaction information is subjected to entry processing; Wherein, obtaining a target number of information shards and a target number of entry threads comprises: If the information amount of the authorized transaction information is between a first information amount and a second information amount, a fixed number of information shards and entry threads are configured; the first information amount is greater than the second information amount; if the information amount of the authorized transaction information is greater than the first information amount, the number of information shards and the number of entry threads are increased on the basis of the fixed number based on the difference between the information amount and the first information amount and the maximum carrying information amount of each information shard; if the information amount of the authorized transaction information is less than the second information amount, the number of information shards and the number of entry threads are reduced on the basis of the fixed number based on the difference between the second information amount and the information amount and the maximum carrying information amount of each information shard; Before the target number of entry threads are used to read the authorized transaction information in the target number of information shards, the method further comprises: According to the shard number corresponding to the target number of information shards, the authorized transaction information in the target number of information shards is recorded in a transaction record table; Using the target number of entry threads to read the authorized transaction information in the target number of information shards comprises: Using the target number of entry threads to read the authorized transaction information in the target number of information shards in the transaction record table.
2. The method of claim 1, wherein, Before the target number of entry threads are used to read the authorized transaction information in the target number of information shards, the method further comprises: According to the target number, the number of message queues of a message middleware is configured to obtain a message queue corresponding to each information shard after allocation, and for each information shard, the corresponding authorized transaction information is transmitted to the message queue corresponding to the information shard according to the arrangement order of the authorized transaction information in the information shard; Using the target number of entry threads to read the authorized transaction information in the target number of information shards comprises: Using the target number of entry threads to read the authorized transaction information in the target number of message queues.
3. The method of claim 1, wherein, After determining the consumption information as the authorized transaction information, the method further comprises: According to the chronological order of the consumption time, the authorized transaction information is registered for authorized transaction; According to the customer identifier, the authorized transaction information is distributed into the target number of information shards, comprising: According to the customer identifier, the registered authorized transaction information is distributed into the target number of information shards.
4. The method of claim 1 or 3, wherein, According to the customer identifier, the authorized transaction information is distributed into the target number of information shards, comprising: A preset hash algorithm is used to hash the customer identifier to obtain a hash value corresponding to the customer identifier; The hash value corresponding to the customer identifier and the value obtained by taking the target number as a remainder are determined as a shard number corresponding to the customer identifier; The authorized transaction information corresponding to the customer identifier is distributed into the information shard corresponding to the shard number.
5. The method of claim 1 or 3, wherein, According to the customer identifier, the authorized transaction information is distributed into the target number of information shards, comprising: If the target customer identifier is included in the mapping relationship between the pre-recorded customer identifier and the shard number corresponding to the target number of information shards, then according to the mapping relationship between the customer identifier and the shard number, the target shard number corresponding to the target customer identifier is found, and the authorized transaction information corresponding to the target customer identifier is distributed into the information shard corresponding to the target shard number; If the target customer identifier is not included in the mapping relationship between the pre-recorded customer identifier and the shard number corresponding to the target number of information shards, then based on the identifier quantity of the customer identifier corresponding to each shard number in the mapping relationship between the customer identifier and the shard number, a mapping relationship between the target shard number with the least identifier quantity and the target customer identifier is established, and the authorized transaction information corresponding to the target customer identifier is distributed into the information shard corresponding to the target shard number.
6. The method of claim 1, wherein, The consumption information includes the current consumption amount; The consumption information in the consumption request of the customer authorized for transaction is obtained, comprising: The consumption information in the consumption request of the customer is obtained; The consumption information is authorized and verified, and if the verification result meets the preset authorization condition, the consumption information is authorized for transaction to obtain the consumption information in the consumption request of the customer authorized for transaction; the preset authorization condition refers to whether the account balance of the customer is greater than the current consumption amount, whether the card state of the credit card used for payment is normal, and whether the risk control rule verification result is risk-free.
7. A transaction logging method apparatus characterized by, The device comprises: A determination unit is configured to determine the consumption information as the authorized transaction information after obtaining the consumption information in the consumption request of the customer authorized for transaction; the consumption information includes consumption time and a customer identifier; A quantity configuration unit is configured to configure the number of information shards and the number of account threads based on the information quantity of the authorized transaction information to obtain a target number of information shards and the target number of account threads; the information shard is used to carry the distributed authorized transaction information, and the account thread is used to read the distributed authorized transaction information in the corresponding information shard. The allocation unit is configured to allocate the authorized transaction information into the target number of information slices according to the customer identifiers, wherein each information slice after the allocation includes the authorized transaction information corresponding to each of the customer identifiers arranged in the order of the consumption time; The reading unit is configured to read the authorized transaction information in the target number of information slices by using the target number of entry threads; The entry unit is configured to perform entry processing on the read authorized transaction information; The quantity configuration unit is specifically configured to: if the information quantity of the authorized transaction information is between a first information quantity and a second information quantity, configure a fixed number of information slices and entry threads; the first information quantity is greater than the second information quantity; if the information quantity of the authorized transaction information is greater than the first information quantity, increase the number of information slices and the number of entry threads based on the difference between the information quantity and the first information quantity and the maximum carrying information quantity of each information slice; if the information quantity of the authorized transaction information is less than the second information quantity, reduce the number of information slices and the number of entry threads based on the difference between the second information quantity and the information quantity and the maximum carrying information quantity of each information slice; The device further includes: The recording unit is configured to record the authorized transaction information in the target number of information slices in a transaction record table according to the slice numbers corresponding to the target number of information slices; The reading unit is specifically configured to read the authorized transaction information in the target number of information slices in the transaction record table by using the target number of entry threads.
8. An electronic device, comprising: The electronic device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used to store a computer program; The processor is used to execute the program stored on the memory to realize the method steps in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to realize the method steps in any one of claims 1-6.
Citation Information
Patent Citations
Method and system for controlling transaction amount to enter into account
CN107015869A
Account entry method, device, computer device and storage medium
CN109472577A