CN114998019A - Transaction processing method and device, electronic equipment and readable storage medium - Google Patents

Transaction processing method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN114998019A
CN114998019A CN202210838427.3A CN202210838427A CN114998019A CN 114998019 A CN114998019 A CN 114998019A CN 202210838427 A CN202210838427 A CN 202210838427A CN 114998019 A CN114998019 A CN 114998019A
Authority
CN
China
Prior art keywords
transaction
account
processing
concurrent
balance
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210838427.3A
Other languages
Chinese (zh)
Inventor
张晓光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongdian Jinxin Software Co Ltd
Original Assignee
Zhongdian Jinxin Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhongdian Jinxin Software Co Ltd filed Critical Zhongdian Jinxin Software Co Ltd
Priority to CN202210838427.3A priority Critical patent/CN114998019A/en
Publication of CN114998019A publication Critical patent/CN114998019A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/02Banking, e.g. interest calculation or account maintenance

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Engineering & Computer Science (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

The application provides a transaction processing method, a transaction processing device, electronic equipment and a readable storage medium, wherein a concurrent transaction request of an account to be transacted is obtained, information such as transaction amount related to the concurrent transaction request is recorded by combining a service type related to the transaction of the account to be transacted, and a transaction record of the account to be checked is obtained; when the processing mode of concurrent transaction is balance comparison processing, comparing the absolute value of the total transaction amount of the transaction request in the to-be-processed state in the to-be-checked account transaction record with the account balance of the to-be-transacted account; and when the account balance is greater than or equal to the absolute value of the total transaction amount, the transaction requests are allowed to be processed in parallel, so that in the transaction process of the account to be transacted, the concurrent transaction requests of the account to be transacted are allowed to be processed only under the condition that the account to be transacted does not have the overdraft problem, and the problem of overdraft of the account to be transacted and unnecessary fund loss are avoided.

Description

Transaction processing method and device, electronic equipment and readable storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a transaction processing method and apparatus, an electronic device, and a readable storage medium.
Background
In a transaction system of a bank, a single account concurrency phenomenon often exists, and the account which is frequently used in a preset time period can be called a hot account; however, due to the characteristic of exclusive lock of the database, the problem of lock waiting occurs in the transaction process of the same account, that is, when the database processes the current transaction request, other transaction requests cannot be processed at the same time, and only when the current transaction request is completed, the next transaction request can be processed; therefore, if the transaction request cannot be processed in the process of processing the current transaction request, the lock waiting time is further prolonged, and the problem of locking the table of the database is caused.
In a conventional processing mode, in order to avoid long waiting time of a lock, a mode of 'locking not' is usually selected, that is, the balance is not updated in the process of processing a single transaction request, but the balance is updated after each concurrent transaction of a hotspot account is finished, so that the problem of account overdraft occurs.
Disclosure of Invention
In view of the above, an object of the present application is to provide a transaction processing method, a transaction processing apparatus, an electronic device, and a readable storage medium, which can determine in advance whether a concurrent transaction request will cause overdraft of an account to be transacted, so as to avoid a lock waiting problem when a database side processes each transaction request one by one, and at the same time, ensure that the account to be transacted will not have the overdraft problem after the transaction is passed.
The embodiment of the application provides a transaction processing method, which comprises the following steps:
acquiring a concurrent transaction request of an account to be transacted; the concurrent transaction requests are all transaction requests received within a long time spent on processing a single transaction request;
recording the concurrent transaction request according to the service type related to the account to be transacted to obtain a transaction record of the account to be checked; wherein the recording comprises: setting the concurrent transaction request to be in a pending state and recording the transaction amount;
determining a processing mode of the concurrent transaction request according to the transaction type and the service type of the concurrent transaction request;
when the processing mode is balance comparison processing, determining the positive and negative of the total transaction amount of the transaction request in the to-be-checked account transaction record in the to-be-processed state;
comparing the absolute value of the total transaction amount with the account balance of the account to be transacted under the condition that the total transaction amount is negative;
and under the condition that the account balance is greater than or equal to the absolute value of the total transaction amount, processing the transaction requests in parallel.
In a possible implementation manner, the determining, according to the transaction type and the service type of the concurrent transaction request, a processing manner of the concurrent transaction request includes:
when the service type is accounting service and the transaction type of the concurrent transaction request comprises balance deduction transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing; wherein the transaction types comprise balance deduction and balance increase;
when the service type is accounting service and the transaction types of the concurrent transaction requests are balance increase transactions, determining that the processing mode of the concurrent transaction requests is direct processing;
when the service type is backspacing service and the concurrent transaction request comprises balance increasing transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing;
and when the service type is backspacing service and the transaction types of the concurrent transaction requests are balance deduction transactions, determining that the processing mode of the concurrent transaction requests is direct processing.
In a possible implementation manner, the recording the concurrent transaction request according to the service type related to the account to be transacted to obtain a transaction record of the account to be verified includes:
generating transaction record information of the concurrent transaction requests based on the account information of the account to be transacted and the transaction information related to each transaction request in the concurrent transaction requests;
and updating the transaction record of the primary account by using the transaction record information according to the service type, and setting the processing state of the transaction record information as a to-be-processed state to obtain the transaction record of the account to be checked.
In a possible implementation manner, the updating an initial account transaction record by using the transaction record information according to the service type, and setting a processing state of the transaction record information to a to-be-processed state to obtain a to-be-checked account transaction record includes:
when the service type is the accounting service, recording the transaction record information into the primary account transaction record, and adjusting the processing state of the transaction record information into a to-be-processed state to obtain an account transaction record to be checked;
and when the service type is backspacing service, deleting the original transaction record corresponding to the concurrent transaction request in the initial account transaction record, recording the transaction record information, and adjusting the processing state of the transaction record information to be a to-be-processed state to obtain an account transaction record to be checked.
In one possible implementation, the transaction processing method further includes:
denying processing of each of the transaction requests if the account balance is less than an absolute value of the total transaction amount.
In one possible implementation, the transaction processing method further includes:
and when the processing mode is direct processing, processing the transaction requests in parallel.
An embodiment of the present application further provides a transaction processing apparatus, where the transaction processing apparatus includes:
the request acquisition module is used for acquiring a concurrent transaction request of the account to be transacted; wherein the concurrent transaction requests are transaction requests received within a long time consumed by processing a single transaction request;
the recording module is used for recording the concurrent transaction request according to the service type related to the account to be transacted to obtain the transaction record of the account to be checked; wherein the recording comprises: setting the concurrent transaction request to be in a pending state and recording the transaction amount;
a processing mode determining module, configured to determine a processing mode of the concurrent transaction request according to the transaction type of the concurrent transaction request and the service type;
the transaction amount determining module is used for determining the positive and negative of the total transaction amount of the transaction request in the to-be-checked account transaction record in the to-be-processed state when the processing mode is balance comparison processing;
the balance comparison module is used for comparing the absolute value of the total transaction amount with the account balance of the account to be transacted under the condition that the total transaction amount is negative;
and the transaction processing module is used for processing the transaction requests in parallel under the condition that the account balance is greater than or equal to the absolute value of the total transaction amount.
In a possible implementation manner, when the processing manner determining module is configured to determine the processing manner of the concurrent transaction request according to the transaction type and the service type of the concurrent transaction request, the processing manner determining module is configured to:
when the service type is an accounting service and the transaction type of the concurrent transaction request comprises a balance deduction transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing; wherein the transaction types comprise balance deduction transaction and balance increase transaction;
when the service type is accounting service and the transaction types of the concurrent transaction requests are balance increase transactions, determining that the processing mode of the concurrent transaction requests is direct processing;
when the service type is backspacing service and the concurrent transaction request comprises balance increasing transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing;
and when the service type is backspacing service and the transaction types of the concurrent transaction requests are balance deduction transactions, determining that the processing mode of the concurrent transaction requests is direct processing.
In a possible implementation manner, when the recording module is configured to record the concurrent transaction request according to a service type related to the account to be transacted, and obtain a transaction record of the account to be verified, the recording module is configured to:
generating transaction record information of the concurrent transaction requests based on the account information of the account to be transacted and the transaction information related to each transaction request in the concurrent transaction requests;
and updating the transaction record of the primary account by using the transaction record information according to the service type, and setting the processing state of the transaction record information as a to-be-processed state to obtain the transaction record of the account to be checked.
In a possible implementation manner, when the recording module is configured to update a transaction record of an initial account by using the transaction record information according to the service type, and set a processing state of the transaction record information to a to-be-processed state, and obtain a transaction record of an account to be checked, the recording module is configured to:
when the service type is accounting service, recording the transaction record information into the initial account transaction record, and adjusting the processing state of the transaction record information to be a to-be-processed state to obtain an account transaction record to be checked;
and when the service type is backspacing service, deleting the original transaction record corresponding to the concurrent transaction request in the initial account transaction record, recording the transaction record information, and adjusting the processing state of the transaction record information to be a to-be-processed state to obtain the to-be-checked account transaction record.
In one possible embodiment, the transaction processing device includes a rejection processing module to:
denying processing of each of the transaction requests if the account balance is less than an absolute value of the total transaction amount.
In a possible implementation, the transaction processing device comprises a direct processing module configured to:
and when the processing mode is direct processing, processing the transaction requests in parallel.
An embodiment of the present application further provides an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the electronic device is operating, the machine-readable instructions when executed by the processor performing the steps of the transaction processing method as described above.
Embodiments of the present application further provide a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the transaction processing method as described above.
The transaction processing method, the transaction processing device, the electronic equipment and the readable storage medium, provided by the embodiment of the application, are used for acquiring a concurrent transaction request of an account to be transacted; wherein the concurrent transaction requests are transaction requests received within a long time consumed by processing a single transaction request; recording the concurrent transaction request according to the service type related to the account to be transacted to obtain a transaction record of the account to be checked; wherein the recording comprises: setting the concurrent transaction request to be in a pending state and recording transaction amount; determining a processing mode of the concurrent transaction request according to the transaction type and the service type of the concurrent transaction request; when the processing mode is balance comparison processing, determining the positive and negative of the total transaction amount of the transaction request in the to-be-checked account transaction record in the to-be-processed state; comparing the absolute value of the total transaction amount with the account balance of the account to be transacted under the condition that the total transaction amount is negative; processing each of the transaction requests in parallel if the account balance is greater than or equal to an absolute value of the total transaction amount. Therefore, whether the concurrent transaction requests can cause overdraft of the account to be transacted can be judged in advance, the problem of lock waiting existing when the database end processes the transaction requests one by one is avoided, and meanwhile, the problem of overdraft of the account to be transacted after the transaction is finished can be avoided.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 is a flowchart of a transaction processing method according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of a transaction processing device according to an embodiment of the present disclosure;
fig. 3 is a second schematic structural diagram of a transaction processing apparatus according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. Every other embodiment that can be obtained by a person skilled in the art without making creative efforts based on the embodiments of the present application falls within the protection scope of the present application.
Research shows that a single account concurrency phenomenon often exists in a transaction system of a bank, and the account which is frequently used in a preset time period can be called a hot account; however, due to the characteristic of exclusive lock of the database, the problem of lock waiting occurs in the transaction process of the same account, that is, when the database processes the current transaction request, other transaction requests cannot be processed at the same time, and only when the current transaction request is completed, the next transaction request can be processed; therefore, if the situation that the transaction cannot be processed occurs in the process of processing the current transaction request, the waiting time of the lock is further prolonged, and the problem of locking the table of the database is caused; in a conventional processing mode, in order to avoid long waiting time of a lock, a mode of 'locking not' is usually selected, that is, the balance is not updated in the process of processing a single transaction, but the balance is updated after each concurrent transaction of a hotspot account is finished, so that the problem of overdraft of the account occurs.
Based on this, the embodiment of the application provides a transaction processing method, which can prejudge whether the concurrent transaction request can cause the overdraft problem to occur to the account to be transacted, so as to avoid the overdraft problem occurring after the account to be transacted performs the transaction.
Referring to fig. 1, fig. 1 is a flowchart illustrating a transaction processing method according to an embodiment of the present disclosure. As shown in fig. 1, a transaction processing method provided in an embodiment of the present application includes:
s101, acquiring a concurrent transaction request of the account to be transacted.
And S102, recording the concurrent transaction request according to the service type related to the account to be transacted to obtain the transaction record of the account to be checked.
S103, determining a processing mode of the concurrent transaction request according to the transaction type and the service type of the concurrent transaction request.
And S104, when the processing mode is balance comparison processing, determining the positive and negative of the total transaction amount of the transaction request in the to-be-checked account transaction record in the to-be-processed state.
And S105, comparing the absolute value of the total transaction amount with the account balance of the account to be transacted under the condition that the total transaction amount is negative.
And S106, under the condition that the account balance is larger than or equal to the absolute value of the total transaction amount, processing the transaction requests in parallel.
The transaction processing method provided by the embodiment of the application obtains the concurrent transaction request of the account to be transacted, and records the transaction amount and other information related to the concurrent transaction request by combining the service type related to the transaction of the account to be transacted, so as to obtain the transaction record of the account to be checked; when the processing mode of concurrent transaction is balance comparison processing, comparing the absolute value of the total transaction amount of the transaction request in the to-be-processed state in the to-be-checked account transaction record with the account balance of the to-be-transacted account; and in the case that the account balance is greater than or equal to the absolute value of the total transaction amount, the transaction requests are allowed to be processed in parallel, so that in the transaction process of the account to be transacted, the concurrent transaction requests of the account to be transacted are allowed to be processed only under the condition that the account to be transacted does not have the overdraft problem, and the problem of overdraft of the account to be transacted and unnecessary fund loss are avoided.
Here, different accounts have different account types; specifically, the account types may be roughly divided into two types, one is a common account, and the other is a hot-spot account; for a common account, the number of data to be traded related in the trading process is small or the amount of money is small, and the problem of account overdraft does not exist; for the hot account, the number of concurrent transaction requests involved in the transaction process is large or the amount of money is large, and the overdraft problem is easy to occur.
In step S101, when a transaction needs to be performed on an account to be transacted, a concurrent transaction request of the account to be transacted is obtained; wherein the concurrent transaction requests are transaction requests received within a long time period taken to process a single transaction request.
The transaction requests included in the concurrent transaction request include transaction requests of different transaction types, and the transaction types may include balance deduction transaction and balance increase transaction, that is, the concurrent transaction request may include a transaction request of balance deduction transaction and a transaction request of balance increase transaction.
Here, whether the account to be traded is a hotspot account may be determined in advance according to the number of the single transaction requests included in the concurrent transaction requests of the account to be traded, so that in a subsequent process, a prejudgment can be performed on the hotspot account.
In one embodiment, the account type of the account to be traded is determined by: if the number of the transaction requests in the concurrent transaction requests is larger than a preset number threshold, determining that the account type of the account to be transacted is a hot account; otherwise, determining the account type of the account to be traded as a common account.
In the step, the number of concurrent transaction requests in the current concurrent transaction request and/or historical concurrent transaction requests within a preset time period is counted; if the quantity of the concurrent transaction requests in the preset time period is larger than a preset quantity threshold value, determining that the account to be transacted has overdraft risk, and determining that the account type of the account to be transacted is a hot account; on the contrary, if the number of the concurrent transaction requests in the preset time period is less than or equal to the preset number threshold, the account to be transacted is determined not to have overdraft risk, the account type of the account to be transacted is determined to be a common account, and the subsequent transaction can be normally carried out.
And/or determining the account type of the account to be traded as a hot account if the transaction amount related to the concurrent transaction request is greater than a preset transaction threshold value; otherwise, determining the account type of the account to be traded as a common account.
In the step, determining the total transaction amount related to the concurrent transaction request of the account to be transacted (by accumulating the transaction amount of each transaction request), if the total transaction amount related to the concurrent transaction request is greater than a preset transaction threshold value, determining that the account to be transacted has overdraft risk, and determining that the account type of the account to be transacted is a hot account; on the contrary, if the total transaction amount involved in the concurrent transaction request is less than or equal to the preset transaction threshold, the account to be transacted is determined not to have overdraft risk, the account type of the account to be transacted is determined to be a common account, and the subsequent transaction can be normally carried out.
For an account to be transacted, if the account to be transacted initiates a concurrent traffic request comprising a plurality of transaction requests, in the existing processing process, each transaction request needs to be submitted to a database transaction separately, and the database processes each transaction request one by one; here, for the database, due to the characteristic that the database has an exclusive lock, that is, for one database, when processing any transaction request related to the account, the same account will adopt a "locking" manner, so that in the process of processing the current transaction request, no other transaction request will be processed, thereby ensuring that no transaction error exists; if the number of the transaction requests existing in a certain account in a preset time period is too large, the database is caused to have a 'lock waiting' problem by the processing mode, namely a plurality of transaction requests wait for the database to be processed; as the number of lock waits increases, the database may have a "lock table problem"; therefore, in order to avoid the 'table locking problem', the 'table locking problem' existing in the processing of transaction requests one by one is avoided by collecting the transaction requests in the account transaction table set for the account to be transacted.
In step S102, transaction record information (e.g., information such as processing status of the concurrent transaction request, transaction amount, etc.) related to the concurrent transaction request may be further recorded in a preset initial account transaction record according to the service type related to the transaction of the account to be transacted, so as to obtain an account transaction table to be checked, that is, in the account transaction table to be checked, the processing status of the concurrent transaction request is set to be in a pending status; meanwhile, the transaction amount of each transaction request in the concurrent transaction requests is recorded, or the total transaction amount of each transaction request in the concurrent transaction requests is recorded.
Here, since the concurrent transaction requests are each transaction request received within a long time taken to process a single transaction request, the concurrent transaction requests are set to a pending state, that is, the processing state of each transaction request is set to a pending state.
In one embodiment, step S102 includes: generating transaction record information of the concurrent transaction requests based on the account information of the account to be transacted and the transaction information related to each transaction request in the concurrent transaction requests; and updating the transaction record of the primary account by using the transaction record information according to the service type, and setting the processing state of the transaction record information as a to-be-processed state to obtain the transaction record of the account to be checked.
In this step, transaction record information of the concurrent transaction request may be generated based on account information of the account to be transacted (e.g., information of an account number, user information of a user to whom the account belongs, and account transaction time), and transaction information related to each transaction request in the concurrent transaction request (e.g., information of a transaction amount, a transaction time, and information of both parties to the transaction, which requires a transaction in the transaction request).
Here, for the concurrent transaction requests of different service types, the way of updating the transaction record of the primary account is also different, for example, when the service type is the accounting service, only the transaction record information of the concurrent transaction request needs to be recorded in the transaction record of the primary account; when the service type is the rollback service, the transaction record information of the concurrent transaction request is recorded in the primary account transaction record, and meanwhile, the original transaction record recorded in the primary account transaction record needs to be deleted.
Therefore, when the transaction record information of the concurrent transaction request is recorded to the transaction record of the primary account, the transaction record information of the concurrent transaction request is further utilized to update the transaction record of the primary account by combining the service type related to the account to be transacted; and meanwhile, adjusting the processing state of the transaction record information newly added into the transaction record of the primary account into a to-be-processed state to obtain the transaction record of the account to be checked.
In one embodiment, the updating the initial account transaction record by using the transaction record information according to the service type and setting the processing state of the transaction record information to be a pending state to obtain a pending account transaction record, including: and when the service type is accounting service, recording the transaction record information into the initial account transaction record, and adjusting the processing state of the transaction record information into a to-be-processed state to obtain an account transaction record to be checked.
In the step, when the service type related to the account to be transacted is the accounting service, the transaction record information of the concurrent transaction request is recorded into the transaction record of the primary account, the processing state of the transaction record information newly added into the transaction record of the primary account is adjusted after the transaction record information is recorded, and the processing state of the newly added transaction record information is set to be a to-be-processed state, so that the transaction record of the account to be checked is obtained.
In another embodiment, when the service type is a fallback service, deleting an original transaction record corresponding to the concurrent transaction request in the initial account transaction record, recording the transaction record information, and adjusting the processing state of the transaction record information to be a to-be-processed state to obtain a to-be-checked account transaction record.
In the step, when the service type related to the account to be traded is backspacing service, firstly, an original transaction record generated in an accounting service stage by a concurrent transaction request is deleted from a transaction record of an initial account; and then, recording the transaction record information of the concurrent transaction request into the transaction record of the primary account, adjusting the processing state of the transaction record information newly added into the transaction record of the primary account after recording, and setting the processing state of the newly added transaction record information into a to-be-processed state, so as to obtain the updated to-be-checked transaction record of the account.
Here, it is not to say that there is always an overdraft risk in the concurrent transaction request of the account to be transacted, for example, when each transaction request in the concurrent transaction request initiated by the account to be transacted is "deposit", that is, the account balance in the account to be transacted increases with the transaction, even if there is a concurrent transaction request for the user to be transacted, the overdraft problem does not occur in the account; when the transaction of the account to be transacted with the concurrent transaction request is withdrawal/refund, that is, the balance of the account in the account to be transacted is less along with the transaction, if the concurrent transaction request exists for the user to be transacted, the overdraft problem occurs in the account.
Therefore, in order to avoid performing subsequent checking on unnecessary transaction requests, in step S103, the present application can further determine a processing manner for processing the concurrent transaction request according to the transaction type and the service type of the concurrent transaction request.
Here, the effect of increasing or decreasing the account balance of the account to be transacted is different for the concurrent transaction request of each transaction type under different service types; for example, in the rollback service, if the transaction type corresponding to the concurrent transaction request is balance deduction, it indicates that the total transaction amount of the concurrent transaction request is deducted from the account balance of the account to be transacted in the original transaction process, and the rollback service of this time indicates that the total transaction amount originally deducted needs to be added back to the account balance of the account to be transacted, so that the account balance in the account to be transacted is added at this time, and therefore, the account balance of the account to be transacted does not need to be checked.
In one embodiment, step S103 includes: and when the service type is accounting service and the transaction type of the concurrent transaction request comprises balance deduction transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing.
In this step, when the service type of the account to be transacted is the accounting service and the transaction type related to each transaction request in the concurrent transaction request includes a balance deduction transaction, it indicates that the transaction amount of the transaction request of which the transaction type is the balance deduction transaction in the concurrent transaction request needs to be deducted from the account balance of the account to be transacted at this time; in order to avoid the overdraft problem of the account to be transacted, the total transaction amount is compared with the account balance in the account to be transacted, so that the account to be transacted is determined not to be overdraft after the total transaction amount of each transaction request is deducted; therefore, in this case, when the service type is the billing service and the balance deduction transaction is included in the transaction type, the processing mode of determining the concurrent transaction request is the balance comparison processing.
Wherein the transaction types comprise balance deduction transaction and balance increase transaction.
In another embodiment, step S103 includes: and when the service type is accounting service and the transaction types of the concurrent transaction requests are balance increase transactions, determining that the processing mode of the concurrent transaction requests is direct processing.
In the step, when the service type is the accounting service and the transaction types of the concurrent transaction requests are balance increasing transactions, the balance of the account to be transacted is increased; therefore, the account to be traded does not have the overdraft problem; therefore, in this case, when the service type is the accounting service and the transaction types of the concurrent transaction requests are both balance increase transactions, it is determined that the processing manner of the concurrent transaction request is direct processing.
In another embodiment, step S103 includes: and when the service type is backspacing service and the concurrent transaction request comprises balance increasing transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing.
In this step, when the service type is a fallback service and the concurrent transaction request includes a balance increase transaction, it indicates that there is a transaction request with the transaction type of balance increase in the concurrent transaction request, that is, the original transaction increases the account balance of the account to be transacted, and the fallback service refers to that the amount of money originally added to the account balance needs to be deducted, that is, the transaction amount of the transaction request with the transaction type of balance increase transaction in the concurrent transaction request needs to be deducted from the account balance of the account to be transacted; in order to avoid the overdraft problem of the account to be transacted, the total transaction amount of each transaction request is compared with the account balance of the account to be transacted, so that the overdraft condition can not exist after the total transaction amount of each transaction request in the concurrent transaction requests is deducted from the account to be transacted; therefore, in this case, when the service type is the fallback service and the concurrent transaction request includes the balance increase transaction, it is determined that the processing manner of the concurrent transaction request is the balance comparison processing.
In another embodiment, step S103 includes: and when the service type is backspacing service and the transaction types of the concurrent transaction requests are balance deduction transactions, determining that the processing mode of the concurrent transaction requests is direct processing.
In this step, when the service type is a fallback service and the transaction types of the concurrent transaction requests are both balance deduction transactions, it is indicated that the transaction type of each transaction request in the concurrent transaction requests is balance deduction, that is, the original transaction reduces the account balance of the account to be transacted, and the fallback service refers to that the amount of money which is originally deducted needs to be added back to the account balance, that is, the account balance of the account to be transacted needs to be added; therefore, the account to be traded does not have the overdraft problem; therefore, in this case, when the service type is the fallback service and the transaction types of the concurrent transaction requests are both balance deduction transactions, it is determined that the processing mode of the concurrent transaction request is the direct processing.
In step S104, after determining that the processing mode of the concurrent transaction request is balance comparison processing, it is determined whether the total transaction amount of the transaction request in the pending status in the transaction record of the account to be checked is positive or negative, so as to determine whether the overdraft problem occurs after the account to be transacted executes each transaction request in the concurrent transaction request.
In step S105, when the total transaction amount of each transaction request of the concurrent transaction requests is negative, it indicates that the total transaction amount needs to be deducted from the account balance of the account to be transacted, that is, the account balance of the account to be transacted needs to be reduced, at this time, the absolute value of the total transaction amount needs to be compared with the account balance of the account to be transacted, so that it is determined that the overdraft problem does not occur after the total transaction amount is deducted from the account to be transacted.
Under the condition that the total transaction amount of each transaction request of the concurrent transaction requests is a positive number, the total transaction amount needs to be increased from the account balance of the account to be transacted, namely the account balance of the account to be transacted needs to be increased, and at the moment, the transaction requests can be directly processed in parallel.
In step S106, when the account balance is greater than or equal to the absolute value of the total transaction amount, it indicates that even if the total transaction amount is deducted from the account balance of the account to be transacted, the overdraft problem does not occur in the account to be transacted, and at this time, the transaction requests may be processed in parallel.
In one embodiment, the transaction processing method further comprises: denying processing of each of the transaction requests if the account balance is less than an absolute value of the total transaction amount.
In this step, when the account balance is smaller than the absolute value of the total transaction amount, it is indicated that if the total transaction amount is deducted from the account balance of the account to be transacted, the account to be transacted will have an overdraft problem, and at this time, it is necessary to refuse to process each transaction request.
In one embodiment, the transaction processing method further comprises: and when the processing mode is direct processing, processing the transaction requests in parallel.
In this step, if it is determined that the processing mode of the concurrent transaction request is direct processing according to the transaction type and the service type of the concurrent transaction request, it is not necessary to compare the total transaction amount related to the transaction request whose processing state is the pending state in the to-be-checked account transaction table with the account balance of the to-be-transacted account, and each transaction request can be directly processed in parallel.
According to the transaction processing method provided by the embodiment of the application, a concurrent transaction request of an account to be transacted is obtained; wherein the concurrent transaction requests are transaction requests received within a long time consumed by processing a single transaction request; recording the concurrent transaction request according to the service type related to the account to be transacted to obtain a transaction record of the account to be checked; wherein the recording comprises: setting the concurrent transaction request to be in a pending state and recording the transaction amount; determining a processing mode of the concurrent transaction request according to the transaction type and the service type of the concurrent transaction request; when the processing mode is balance comparison processing, determining the positive and negative of the total transaction amount of the transaction request in the to-be-checked account transaction record in the to-be-processed state; comparing the absolute value of the total transaction amount with the account balance of the account to be transacted under the condition that the total transaction amount is negative; and under the condition that the account balance is greater than or equal to the absolute value of the total transaction amount, processing the transaction requests in parallel. Therefore, whether the concurrent transaction requests can cause overdraft of the account to be transacted can be judged in advance, the problem of lock waiting existing when the database end processes the transaction requests one by one is avoided, and meanwhile, the problem of overdraft of the account to be transacted after the transaction is finished can be avoided.
Referring to fig. 2 and fig. 3, fig. 2 is a first schematic structural diagram of a transaction processing device according to an embodiment of the present application, and fig. 3 is a second schematic structural diagram of a transaction processing device according to an embodiment of the present application. As shown in fig. 2, the transaction processing device 200 includes:
a request obtaining module 210, configured to obtain a concurrent transaction request of an account to be transacted; the concurrent transaction requests are all transaction requests received within a long time spent on processing a single transaction request;
the recording module 220 is configured to record the concurrent transaction request according to the service type related to the account to be transacted, so as to obtain a transaction record of the account to be checked; wherein the recording comprises: setting the concurrent transaction request to be in a pending state and recording the transaction amount;
a processing mode determining module 230, configured to determine a processing mode of the concurrent transaction request according to the transaction type of the concurrent transaction request and the service type;
a transaction amount determining module 240, configured to determine whether a total transaction amount of the transaction request in the to-be-checked account transaction record in the to-be-checked state is positive or negative when the processing manner is balance comparison processing;
a balance comparison module 250, configured to compare an absolute value of the total transaction amount with an account balance of the account to be transacted when the total transaction amount is a negative number;
a transaction processing module 260, configured to process each transaction request in parallel if the account balance is greater than or equal to an absolute value of the total transaction amount.
Further, when the processing mode determining module 230 is configured to determine the processing mode of the concurrent transaction request according to the transaction type and the service type of the concurrent transaction request, the processing mode determining module 230 is configured to:
when the service type is accounting service and the transaction type of the concurrent transaction request comprises balance deduction transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing; wherein the transaction types comprise balance deduction transaction and balance increase transaction;
when the service type is accounting service and the transaction types of the concurrent transaction requests are balance increase transactions, determining that the processing mode of the concurrent transaction requests is direct processing;
when the service type is backspacing service and the concurrent transaction request comprises balance increasing transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing;
and when the service type is backspacing service and the transaction types of the concurrent transaction requests are balance deduction transactions, determining that the processing mode of the concurrent transaction requests is direct processing.
Further, when the recording module 220 is configured to record the concurrent transaction request according to the service type related to the account to be transacted, and obtain a transaction record of the account to be checked, the recording module 220 is configured to:
generating transaction record information of the concurrent transaction requests based on the account information of the account to be transacted and the transaction information related to each transaction request in the concurrent transaction requests;
and updating the transaction record of the primary account by using the transaction record information according to the service type, and setting the processing state of the transaction record information as a to-be-processed state to obtain the transaction record of the account to be checked.
Further, when the recording module 220 is configured to update the transaction record of the primary account by using the transaction record information according to the service type, and set the processing state of the transaction record information to a to-be-processed state, and obtain the transaction record of the account to be checked, the recording module 220 is configured to:
when the service type is accounting service, recording the transaction record information into the initial account transaction record, and adjusting the processing state of the transaction record information to be a to-be-processed state to obtain an account transaction record to be checked;
and when the service type is backspacing service, deleting the original transaction record corresponding to the concurrent transaction request in the initial account transaction record, recording the transaction record information, and adjusting the processing state of the transaction record information to be a to-be-processed state to obtain the to-be-checked account transaction record.
Further, the transaction processing device 200 includes a rejection processing module 270, and the rejection processing module 270 is configured to:
denying processing of each of the transaction requests if the account balance is less than an absolute value of the total transaction amount.
Further, the transaction processing device 200 includes a direct processing module 280, and the direct processing module 280 is configured to:
and when the processing mode is direct processing, processing the transaction requests in parallel.
The transaction processing device provided by the embodiment of the application acquires a concurrent transaction request of an account to be transacted; wherein the concurrent transaction requests are transaction requests received within a long time consumed by processing a single transaction request; recording the concurrent transaction request according to the service type related to the account to be transacted to obtain a transaction record of the account to be checked; wherein the recording comprises: setting the concurrent transaction request to be in a pending state and recording the transaction amount; determining a processing mode of the concurrent transaction request according to the transaction type and the service type of the concurrent transaction request; when the processing mode is balance comparison processing, determining the positive and negative of the total transaction amount of the transaction request in the to-be-checked account transaction record in the to-be-processed state; comparing the absolute value of the total transaction amount with the account balance of the account to be transacted under the condition that the total transaction amount is negative; processing each of the transaction requests in parallel if the account balance is greater than or equal to an absolute value of the total transaction amount. Therefore, whether the concurrent transaction requests can cause overdraft of the account to be transacted can be judged in advance, the problem of lock waiting existing when the database end processes the transaction requests one by one is avoided, and meanwhile, the problem of overdraft of the account to be transacted after the transaction is finished can be avoided.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. As shown in fig. 4, the electronic device 400 includes a processor 410, a memory 420, and a bus 430.
The memory 420 stores machine-readable instructions executable by the processor 410, when the electronic device 400 runs, the processor 410 communicates with the memory 420 through the bus 430, and when the machine-readable instructions are executed by the processor 410, the steps of the transaction processing method in the method embodiment shown in fig. 1 may be executed.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the transaction processing method in the method embodiment shown in fig. 1 may be executed.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described apparatus embodiments are merely illustrative, and for example, the division of the units into only one type of logical function may be implemented in other ways, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in software functional units and sold or used as a stand-alone product, may be stored in a non-transitory computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present application, and are used to illustrate the technical solutions of the present application, but not to limit the technical solutions, and the scope of the present application is not limited to the above-mentioned embodiments, although the present application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope disclosed in the present application; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present application and are intended to be covered by the appended claims. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A transaction processing method, characterized in that the transaction processing method comprises:
acquiring a concurrent transaction request of an account to be transacted; wherein the concurrent transaction requests are transaction requests received within a long time consumed by processing a single transaction request;
recording the concurrent transaction request according to the service type related to the account to be transacted to obtain a transaction record of the account to be checked; wherein the recording comprises: setting the concurrent transaction request to be in a pending state and recording the transaction amount;
determining a processing mode of the concurrent transaction request according to the transaction type and the service type of the concurrent transaction request;
when the processing mode is balance comparison processing, determining the positive and negative of the total transaction amount of the transaction request in the to-be-checked account transaction record in the to-be-processed state;
comparing the absolute value of the total transaction amount with the account balance of the account to be transacted under the condition that the total transaction amount is negative;
and under the condition that the account balance is greater than or equal to the absolute value of the total transaction amount, processing the transaction requests in parallel.
2. The transaction processing method according to claim 1, wherein the determining a processing manner of the concurrent transaction request according to the transaction type and the service type of the concurrent transaction request includes:
when the service type is accounting service and the transaction type of the concurrent transaction request comprises balance deduction transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing; wherein the transaction types comprise balance deduction transaction and balance increase transaction;
when the service type is an accounting service and the transaction types of the concurrent transaction requests are balance increase transactions, determining that the processing mode of the concurrent transaction requests is direct processing;
when the service type is backspacing service and the concurrent transaction request comprises balance increasing transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing;
and when the service type is backspacing service and the transaction types of the concurrent transaction requests are balance deduction transactions, determining that the processing mode of the concurrent transaction requests is direct processing.
3. The transaction processing method according to claim 1, wherein the recording the concurrent transaction request according to the service type related to the account to be transacted to obtain a transaction record of the account to be verified comprises:
generating transaction record information of the concurrent transaction requests based on the account information of the account to be transacted and the transaction information related to each transaction request in the concurrent transaction requests;
and updating the transaction record of the primary account by using the transaction record information according to the service type, and setting the processing state of the transaction record information as a to-be-processed state to obtain the transaction record of the account to be checked.
4. The transaction processing method according to claim 3, wherein the updating of the initial account transaction record by using the transaction record information according to the service type and the setting of the processing state of the transaction record information to a pending state to obtain a pending account transaction record comprises:
when the service type is accounting service, recording the transaction record information into the initial account transaction record, and adjusting the processing state of the transaction record information to be a to-be-processed state to obtain an account transaction record to be checked;
and when the service type is backspacing service, deleting the original transaction record corresponding to the concurrent transaction request in the initial account transaction record, recording the transaction record information, and adjusting the processing state of the transaction record information to be a to-be-processed state to obtain an account transaction record to be checked.
5. The transaction processing method of claim 1, further comprising:
denying processing of each of the transaction requests if the account balance is less than an absolute value of the total transaction amount.
6. The transaction processing method of claim 1, further comprising:
and when the processing mode is direct processing, processing the transaction requests in parallel.
7. A transaction processing device, the transaction processing device comprising:
the request acquisition module is used for acquiring a concurrent transaction request of the account to be transacted; the concurrent transaction requests are all transaction requests received within a long time spent on processing a single transaction request;
the recording module is used for recording the concurrent transaction request according to the service type related to the account to be transacted to obtain the transaction record of the account to be checked; wherein the recording comprises: setting the concurrent transaction request to be in a pending state and recording the transaction amount;
a processing mode determining module, configured to determine a processing mode of the concurrent transaction request according to the transaction type of the concurrent transaction request and the service type;
the transaction amount determining module is used for determining the positive and negative of the total transaction amount of the transaction request in the to-be-checked account transaction record in the to-be-processed state when the processing mode is balance comparison processing;
the balance comparison module is used for comparing the absolute value of the total transaction amount with the account balance of the account to be transacted under the condition that the total transaction amount is negative;
and the transaction processing module is used for processing the transaction requests in parallel under the condition that the account balance is greater than or equal to the absolute value of the total transaction amount.
8. The transaction processing apparatus of claim 7, wherein when the processing manner determining module is configured to determine the processing manner of the concurrent transaction request according to the transaction type of the concurrent transaction request and the service type, the processing manner determining module is configured to:
when the service type is accounting service and the transaction type of the concurrent transaction request comprises balance deduction transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing; wherein the transaction types comprise balance deduction transaction and balance increase transaction;
when the service type is accounting service and the transaction types of the concurrent transaction requests are balance increase transactions, determining that the processing mode of the concurrent transaction requests is direct processing;
when the service type is backspacing service and the concurrent transaction request comprises balance increasing transaction, determining that the processing mode of the concurrent transaction request is balance comparison processing;
and when the service type is backspacing service and the transaction types of the concurrent transaction requests are balance deduction transactions, determining that the processing mode of the concurrent transaction requests is direct processing.
9. An electronic device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the electronic device is operated, the machine-readable instructions being executable by the processor to perform the steps of the transaction processing method according to any one of claims 1 to 6.
10. A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, performs the steps of the transaction processing method according to any one of claims 1 to 6.
CN202210838427.3A 2022-07-18 2022-07-18 Transaction processing method and device, electronic equipment and readable storage medium Pending CN114998019A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210838427.3A CN114998019A (en) 2022-07-18 2022-07-18 Transaction processing method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210838427.3A CN114998019A (en) 2022-07-18 2022-07-18 Transaction processing method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114998019A true CN114998019A (en) 2022-09-02

Family

ID=83022091

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210838427.3A Pending CN114998019A (en) 2022-07-18 2022-07-18 Transaction processing method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114998019A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120095913A1 (en) * 2010-10-17 2012-04-19 Bank Of America Corporation Overdraft Payment Balance Exception Processing
CN105931109A (en) * 2015-09-18 2016-09-07 ***股份有限公司 Method and device for account balance update
CN107563889A (en) * 2017-08-29 2018-01-09 中国银行股份有限公司 Account balance information processing method and processing device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120095913A1 (en) * 2010-10-17 2012-04-19 Bank Of America Corporation Overdraft Payment Balance Exception Processing
CN105931109A (en) * 2015-09-18 2016-09-07 ***股份有限公司 Method and device for account balance update
CN107563889A (en) * 2017-08-29 2018-01-09 中国银行股份有限公司 Account balance information processing method and processing device

Similar Documents

Publication Publication Date Title
US20180308089A1 (en) Settlement system, server device, terminal device, method and program
CN112101955B (en) Concurrent payment method, system and device
CN108492109B (en) Electronic device, dynamic code request processing method and storage medium
US20160300203A1 (en) Settlement system, server device, terminal device, recording medium, method and program
CN110275892B (en) Block chain-oriented data management method, device, equipment and storage medium
CN110889687A (en) Method and device for processing account balance under distributed architecture
CN113112344B (en) Service processing method, device, storage medium and computer program product
CN109614263B (en) Disaster tolerance data processing method, device and system
CN110084692A (en) A kind of bookkeeping methods and device
CN112988812A (en) Inventory data processing method, device, equipment and storage medium
CN114998019A (en) Transaction processing method and device, electronic equipment and readable storage medium
CN115719274A (en) Control method, device, equipment and storage medium for distributed transaction
US10146644B2 (en) Integrity of transactional memory of card computing devices in case of card tear events
CN112035458B (en) Data isolation method, device and equipment
WO2013189011A1 (en) Method and apparatus for transaction processing
CN111429125B (en) Account management method and device, storage medium and electronic equipment
CN110457272B (en) Bill batch processing method and device
CN112669151A (en) Method and equipment for processing multi-system cooperative service
CN111861746A (en) Method and device for processing transaction data
CN111768293A (en) Transaction information processing method, device, equipment and storage medium
CN111476671A (en) Block chain rollback insurance method, equipment and storage medium
CN110766540A (en) Bill verification and cancellation method and device and electronic equipment
JP7221927B2 (en) Information processing device, method and program
JP7000549B1 (en) Information processing equipment, methods and programs
CN117170849A (en) Data processing method, device and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination