WO2019184571A1 - 一种记账的方法及装置 - Google Patents
一种记账的方法及装置 Download PDFInfo
- Publication number
- WO2019184571A1 WO2019184571A1 PCT/CN2019/072909 CN2019072909W WO2019184571A1 WO 2019184571 A1 WO2019184571 A1 WO 2019184571A1 CN 2019072909 W CN2019072909 W CN 2019072909W WO 2019184571 A1 WO2019184571 A1 WO 2019184571A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- billing
- account
- request
- billing request
- processed
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/12—Accounting
- G06Q40/125—Finance or payroll
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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
- G06Q30/00—Commerce
- G06Q30/04—Billing or invoicing
Definitions
- the present application relates to the field of information technology, and in particular, to a method and an apparatus for accounting.
- Bookkeeping refers to the act of recording economic affairs of enterprises, institutions, individuals or families in the books according to certain recording methods.
- data is transferred from an account, or data is transferred to an account, the account will receive a billing request, and there is a billing process.
- the accounting process mainly consists of two parts, one is to record the accounting vouchers, and the other is to update the residual value of the account.
- the resources of the account are first locked, and the lock is automatically released after the accounting process is completed.
- accounts in the accounting database often generate multiple concurrent operations in an instant, but only one of all corresponding concurrent threads can hold the resource lock of the current account, and other threads must wait.
- the accounting process is performed one by one, so that the account will be frequently locked and unlocked, making the account a hot spot in the accounting database, causing performance bottlenecks and seriously affecting the performance of the accounting database.
- each account is usually accounted for by the accounting system.
- the accounting system needs to first write a lock on the account, so that only the thread holding the lock can The account operates and releases the lock for the account after the billing is completed.
- the transaction business has the characteristics of high concurrency. This makes the standard bookkeeping process write lock operation on the account, which seriously affects the efficiency of business execution. In addition to causing an increase in the operating pressure of the accounting system, it is also easy to cause the transaction business to fail due to waiting for a timeout.
- a buffering accounting method can be configured for the account in advance to avoid a series of problems caused by the standard accounting process. .
- the accounting system when the account is buffered, the accounting system does not need to update the balance of the account in real time, but each thread determines the accounting details of the account according to the accounting request for the account. In the database. The specific period of the period can be set as needed.
- the accounting details are determined by each thread according to the accounting request for the account in the period and stored in the database. Among them, how long is this period of time, can be set as needed. Therefore, the accounting system does not need to write a lock on the account for each period in the cycle, and the thread does not need to perform accounting operations on the account, as shown in Table 1.
- the account is locked by the accounting system, and the balance of the account is determined and adjusted according to the accounting details stored in the database. And the change of the balance of the account corresponding to each billing detail is added.
- the process of adjusting the balance of the account and replenishing the accounting details may be asynchronous.
- the accounting system determines the total accounting result corresponding to each accounting detail based on each accounting detail to adjust the balance of the account according to the total accounting result. For example, assuming that there are separate accounting income of 100 yuan, expenditure of 10 yuan, and expenditure of 20 yuan, the accounting system can determine that the total accounting result is income of 70 yuan.
- the existing billing method of buffer accounting has the risk of account overdraft because the total billing result of each billing detail in the period cannot be determined before the account balance is adjusted. Therefore, it is generally necessary to pre-determine an account that needs to be configured and can configure buffer accounting according to manual experience, so that the existing buffering accounting method is not flexible enough in configuration, and relies on manual experience, which is risky.
- the embodiment of the present specification provides a method and an apparatus for accounting, which are used to solve various accounting methods in the prior art.
- an account for buffering accounting needs to be configured in advance, and the configured parameters are also configured. There is a need to rely on manual experience and there are multiple defects.
- a method of accounting including:
- a billing device comprising:
- a request determining module for each billing request received, determining an account for which the billing request is directed;
- a billing and storage module when there is a billing request for the account to be processed in another billing request belonging to the same transaction as the billing request, according to the billing request and the billing request to be processed Determining whether the balance of the account needs to be deducted, and if so, acquiring the resource lock of the account, performing a billing operation, and if not, when the resource lock of the account cannot be obtained, the billing request is regarded as pending Accounting request for storage;
- the billing and storage module when there is no billing request for the account to be processed in another billing request belonging to the same transaction as the billing request, according to the billing request, determining whether the deduction is required Determining the balance of the account, if yes, acquiring the resource lock of the account, performing a billing operation, and if not, storing the billing request as a billing request to be processed when the resource lock of the account cannot be obtained .
- a server wherein the server comprises: one or more processors and a memory, the memory storing a program, and being configured to perform the following steps by one or more processors:
- the account for which the billing request is directed is first determined. Thereafter, it may be determined whether there is a pending billing request that belongs to the same transaction and is for the same account. If it does not exist, it may be determined whether the billing request may be stored as a pending billing request according to whether the billing request needs to deduct the balance of the account. And if it exists, it is determined whether the billing request can be stored as a pending billing request according to the billing request and the billing request to be processed.
- the billing request to be processed may be stored first when the resource lock of the account cannot be acquired, without waiting in line for the billing operation. .
- FIG. 1 is a process of billing provided by an embodiment of the present specification
- FIG. 2 is a schematic diagram showing a detailed process of providing accounting for an embodiment of the present specification
- FIG. 3 is a schematic diagram of another detailed process of billing provided by an embodiment of the present specification.
- FIG. 4 is a schematic structural diagram of an apparatus for accounting according to an embodiment of the present disclosure.
- FIG. 5 is a schematic structural diagram of a server according to an embodiment of the present disclosure.
- FIG. 1 is a process of billing provided by an embodiment of the present invention, which may specifically include the following steps:
- S100 Determine, for each billing request received, an account for which the billing request is directed.
- the billing request may be accepted by the billing system and the operations of the subsequent steps performed.
- the billing system may include: a server for performing a billing operation, and a database storing billing-related data such as account information and billing details.
- the specific form of the accounting system can be configured as needed.
- the database can be a distributed database, and the server can also be a distributed server, which is not limited in this specification.
- the billing system can receive billing requests in this specification.
- the accounting system since the accounting is a record of economic activities and is generated according to the accounting needs at the time of execution of the business, the accounting system is usually also the accounting request sent by the system that executes the business.
- this specification is not limited as to how the billing request is specifically generated.
- a transaction may need to generate multiple accounting requests during execution, different accounting requests may correspond to the same transaction. For example, if user A transfers 100 yuan to user B, the system performing the business may separately generate two billing requests for deducting 100 yuan from user A's account and adding user B's account for 100 yuan. Then the two billing requests correspond to the same transfer transaction.
- the identifier of the transaction corresponding to the accounting request is carried in the accounting request (for example, the accounting request may carry a serial number, a service identifier, etc. Wait).
- the billing system can receive a number of billing requests and can determine the account for which the billing request is directed for each billing request received.
- the billing system can receive a plurality of billing requests at the same time, and the billing request may be a billing request for an account that is not identical, and may also be executed. Generated when the exact same transaction is generated, so the accounting system can first determine the account for which each accounting request received is separately determined in order to determine the operation of the subsequent steps.
- Each accounting request received by the accounting system at the same time may correspond to an account that is not identical and a transaction that is not identical.
- the billing system can determine, for each billing request, the account for which the billing request is directed for subsequent steps.
- step S100 since the account for which the billing request is directed is determined for each billing request received in step S100, the description is still based on the billing request in step S102.
- the billing operation corresponding to the billing request can be divided into four types of operations, that is, a freeze operation, a defrosting operation, an outflow operation, and an inflow operation, depending on the content of the billing request.
- the accounting operation corresponding to the accounting request needs to be executed synchronously: if the accounting is not performed synchronously, the transaction execution result may result in the deduction amount being greater than the value of the balance in the account, which may cause the transaction to be executed. An error or an exception has occurred.
- the accounting operation is performed asynchronously, and the accounting operation corresponding to the accounting request is not executed after the high concurrency scenario is solved, and the transaction does not continue to be executed, resulting in various problems (for example, the transaction waiting time is long, affecting efficiency, Or the transaction timeout causes the transaction to fail and so on).
- the accounting system can determine whether the accounting is present according to the accounting request determined in step S100.
- the request belongs to the same transaction, and the billing request is for the billing request of the same account to be processed. If yes, step S102 is performed otherwise step S104 is performed.
- step S102 of the present specification a case where there is a billing request that belongs to the same transaction and is the same account as the billing request is described.
- the billing system first, the billing details of the billing request can be determined and stored, and the billing details of the billing request to be processed are determined, wherein the billing details include the type of billing operation and the amount of the billing operation. Thereafter, based on the billing details of the billing request and the billing details of the billing request to be processed, the total amount of the details is determined, and finally it is judged whether the expenditure of the total amount of the details is greater than the income.
- the account balance needs to be deducted, indicating that if the accounting operation is performed asynchronously, the account balance may be incorrect, so the accounting system may obtain the resource lock of the account according to the accounting request and the pending billing request. Perform accounting operations.
- the resource lock of the account cannot be obtained, it can be consistent with the standard accounting process, waiting in line to acquire the lock.
- the accounting operation is not performed asynchronously, the account balance may not be obtained, so the accounting system may not obtain the resource lock of the account.
- the billing request is stored as a billing request to be processed. Of course, if the accounting system can obtain the resource lock of the account, it can be consistent with the standard billing process, and the billing operation is performed according to the billing request and the billing request to be processed.
- billing requests there may be multiple billing requests to be processed determined by the billing system. For example, suppose a certain thing is executed in the process of chronological order, and has generated accounting request 1 to accounting request 3, respectively: account b balance increased by 100 yuan, account b balance increased by 50 yuan, and account b balance expenditure 10 yuan. It can be seen that the total amount of the above three billing requests is: the account b balance is increased by 140 yuan. as shown in Table 3.
- Accounting request Targeted account Corresponding transaction Accounting details Total amount of detail Accounting request 1 Account b Transaction 002 Inflow operation, 100 yuan Increase 100 yuan Accounting request 2 Account b Transaction 002 Inflow operation, 50 yuan Increase 150 yuan Accounting request 3 Account b Transaction 002 Expenditure operation, 10 yuan Increase 140 yuan
- the total amount of detail corresponding to each row of billing request in Table 3 is the total amount of the details determined by the billing request to be processed in the current account b in transaction 002. Therefore, when the billing system receives the billing requests 1 to 3, if the resource lock of the account b cannot be obtained, the three billing requests may be sequentially stored as billing requests to be processed.
- a billing request 4 is generated: the account b balance is increased by 50 yuan, and the accounting system can further determine that the total amount of the expenditure is not greater than the income, so the resource of the account b cannot be obtained.
- the billing request can also be stored as a billing request to be processed.
- the generated accounting request 4 is: the account b balance is deducted by 200 yuan, and the accounting system can determine that the total amount of expenditure is greater than the income, then the accounting system needs to obtain the resource lock of the account b. And will perform accounting operations.
- the accounting system can make the accounting request when the resource lock of the account cannot be obtained.
- S104 When there is no pending billing request for the account in another billing request that belongs to the same transaction as the billing request, according to the billing request, it is determined whether the balance of the account needs to be deducted, if And acquiring a resource lock of the account, performing a billing operation, and if not, storing the billing request as a billing request to be processed when the resource lock of the account cannot be obtained.
- the billing system can determine whether it is necessary to acquire the resource lock of the account according to the type of the accounting operation of the accounting request. Since, among the types of billing operations, except for the inflow operation, the remaining billing operations exist in the case of the amount of the account balance, so the billing system determines that there is no billing request to be processed, and can only The billing operation type of the billing request, determining whether the type of the billing operation is another billing operation other than the inflow operation, and if so, consistent with the description in step S102, the billing system may perform the billing process using the billing account. Operation, if not, the accounting system may store the accounting request as a pending accounting request when the resource lock of the account cannot be obtained.
- the accounting system when the accounting system receives the accounting request, it can determine whether the accounting of the account is not available when the resource lock of the account cannot be obtained according to the accounting details corresponding to the accounting request. operating. Or, when there is a billing request in the same transaction as the billing request and for the same account, whether the asynchronous billing operation can be performed is determined according to the billing request and the total amount of the billing request to be processed. . This eliminates the need to pre-configure whether an account can be asynchronously billed, which reduces the cost of manual configuration and avoids the account risk caused by existing buffer accounting. Moreover, for an account with a majority of inflow operations, the number of times the resource lock of the account is acquired can be reduced, and the operating pressure of the database is alleviated. It solves the problems existing in various billing techniques in the face of high concurrent billing request scenarios.
- the accounting system can make judgments again. Determining whether a billing request for the account that belongs to the transaction is still stored, and if so, acquiring a resource lock of the account, and performing, according to the stored billing requests for the account. The accounting operation, and the end of the transaction is determined after the accounting operation is completed. If not, it can be directly determined that the transaction is over.
- S200 Determine, for each billing request received, an account for which the billing request is directed.
- step S204 According to the accounting request, and the determined billing request to be processed, determine whether it is necessary to deduct the balance of the account, if yes, proceed to step S208, and if not, proceed to step S210;
- S208 Acquire a resource lock of the account, perform a billing operation according to the billing request, and the determined billing request to be processed;
- S212 Acquire a resource lock of the account, and perform a billing operation according to the billing request.
- step S210 may specifically include:
- step S2100 determining whether the resource lock of the account is obtained, if step S2102 is performed, if not, executing step S2104;
- S2104 Store the accounting request as a billing request to be processed. As shown in Figure 3.
- the execution bodies of the steps of the method provided in the embodiments of the present specification may all be the same device, or the method may also be performed by different devices.
- the execution body of step S100 and step S102 may be device 1, and the execution body of step S102 may be device 2; or the execution body of step S100 may be device 1, and the execution body of step S102 and step S104 may be device 2; and many more.
- the embodiment of the present specification further provides an apparatus for billing, as shown in FIG.
- FIG. 4 is a schematic structural diagram of an apparatus for accounting according to an embodiment of the present disclosure, where the apparatus includes:
- the request determining module 300 determines, for each billing request received, an account for which the billing request is directed;
- the billing and storage module 302 when there is a billing request for the account to be processed in another billing request belonging to the same transaction as the billing request, according to the billing request and the billing to be processed Requesting, determining whether it is necessary to deduct the balance of the account, and if so, acquiring a resource lock of the account, performing a billing operation, and if not, when the resource lock of the account cannot be obtained, the billing request is treated as The processed billing request is stored;
- the billing and storage module 302 when there is no billing request for the account to be processed in another billing request belonging to the same transaction as the billing request, according to the billing request, determining whether deduction is required And the balance of the account, if yes, acquiring a resource lock of the account, performing a billing operation; if not, when the resource lock of the account cannot be obtained, the billing request is performed as a billing request to be processed storage.
- the billing and storage module 302 before determining whether the balance of the account needs to be deducted, determining, according to the billing request, the billing details and storing, wherein the billing details include performing billing operations on the account. Amount.
- the billing and storage module 302 determines the billing request and the billing request to be processed according to the stored billing details of the billing request to be processed and the billing details of the billing request The total amount of the details, whether the expenditure of the total amount of the details is greater than the income.
- the operation type of the accounting operation corresponding to the accounting request includes one of freezing, thawing, streaming, and inflow.
- the accounting and storage module 302 determines an operation type of the accounting request, and determines whether the operation type is another operation type other than the inflow operation type.
- the billing and storage module 302 acquires a resource lock of the account, and according to the A billing request and the unprocessed billing request perform a billing operation on the account.
- the billing and storage module 302 acquires the resource lock of the account, and according to The billing request performs a billing operation on the account.
- the billing and storage module 302 when it is determined that the balance of the account is not required to be deducted, and the resource lock of the account is acquired, the billing operation is performed according to the billing request, or according to the billing request and the The billing request to be processed is subjected to a billing operation.
- the device also includes:
- the replenishment module 304 before the end of the transaction, determines whether a billing request for the account is still stored, and if so, acquires a resource lock of the account, and according to the stored
- the pending billing request of the account after performing the billing operation, determines that the transaction ends, and if not, determines that the transaction ends.
- the present specification correspondingly provides a server, as shown in FIG. 10, wherein the server includes: one or more processors and a memory, the memory stores a program, and is configured to The following steps are performed by one or more processors:
- PLD Programmable Logic Device
- FPGA Field Programmable Gate Array
- HDL Hardware Description Language
- the controller can be implemented in any suitable manner, for example, the controller can take the form of, for example, a microprocessor or processor and computer readable storage storing computer readable program code (eg, software or firmware) executable by the (micro)processor.
- computer readable program code eg, software or firmware
- examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM The Microchip PIC18F26K20 and the Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic.
- the controller can be logically programmed by means of logic gates, switches, ASICs, programmable logic controllers, and embedding.
- Such a controller can therefore be considered a hardware component, and the means for implementing various functions included therein can also be considered as a structure within the hardware component.
- a device for implementing various functions can be considered as a software module that can be both a method of implementation and a structure within a hardware component.
- the system, device, module or unit illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product having a certain function.
- a typical implementation device is a computer.
- the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or A combination of any of these devices.
- embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
- computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
- the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
- the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
- These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
- the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
- a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and computer readable storage media.
- processors CPUs
- input/output interfaces network interfaces
- computer readable storage media computer readable storage media
- Computer readable storage media including both permanent and non-persistent, removable and non-removable media may be implemented by any method or technology.
- the information can be computer readable instructions, data structures, modules of programs, or other data.
- Examples of computer readable storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only Memory (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, CD-ROM, digital versatile disc (DVD) or other optical storage
- PRAM phase change memory
- SRAM static random access memory
- DRAM dynamic random access memory
- RAM random access memory
- ROM read only Memory
- EEPROM electrically erasable programmable read only memory
- flash memory or other memory technology
- CD-ROM compact disc
- DVD digital versatile disc
- Computer-readable storage media does not include temporary storage computer readable media, such as modulated data signals and carrier waves.
- the application can be described in the general context of computer-executable instructions executed by a computer, such as a program module.
- program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types.
- the present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network.
- program modules can be located in both local and remote computer storage media including storage devices.
Landscapes
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Development Economics (AREA)
- Engineering & Computer Science (AREA)
- Strategic Management (AREA)
- Marketing (AREA)
- Physics & Mathematics (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Economics (AREA)
- Theoretical Computer Science (AREA)
- Technology Law (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
Abstract
一种记账的方法及装置,该方法包括:针对接收到的每个记账请求,确定该记账请求针对的账户(S100)。之后,可先判断是否存在与该记账请求属于同一事务且针对同一账户的待处理的记账请求。若不存在,则可根据该记账请求是否需要扣除该账户的余额,确定是否可将该记账请求作为待处理记账请求进行存储。而若存在,则需要根据该记账请求以及待处理的记账请求,确定是否可将该记账请求作为待处理记账请求进行存储。
Description
相关申请的交叉引用
本专利申请要求于2018年3月29日提交的、申请号为201810270039.3、发明名称为“一种记账的方法及装置”的中国专利申请的优先权,该申请的全文以引用的方式并入本文中。
本申请涉及信息技术领域,尤其涉及一种记账的方法及装置。
记账是指将企事业单位、个人或者家庭发生的经济业务,按照一定的记录方法在账簿上记录的行为。
在账务数据库的处理中,数据从一个账户转出,或者有数据转入一个账户,账户都会收到记账请求,并都有一个记账处理的过程。
记账处理过程主要包括两部分,一是记录记账凭证,二是更新账户的余值。为了保证账户不被其他请求影响数据的准确性,在进行记账处理时,会先对账户的资源加锁,记账处理完毕后会自动释放锁。随着账务处理业务量的增大,账务数据库中的账户常常会在瞬间产生多个并发操作,但所有对应的并发线程中只有一个线程能够持有当前账户的资源锁,其他线程必须等待该锁被释放后再逐一进行记账处理,这样该账户将会被频繁加锁释锁,使该账户成为账务数据库热点,产生性能瓶颈点,严重影响账务数据库的性能。
目前,随着无纸化办公的普及,通常由记账系统对各账户进行记账。而为了防止多个线程对同一个账户进行并发的记账操作,导致数据错误,在标准记账过程中,记账系统需要先对该账户写锁,使得只有持有该锁的线程可以对该账户进行操作,并在记账完成之后再释放该账户的锁。
而对电子商务平台来说,交易业务存在高并发的特点。这就使得,标准记账过程对账户的写锁操作,严重影响了业务执行的效率。除了导致记账系统运行压力增大以外,还容易导致交易业务由于等待超时而失败。
因此,在现有的电子商务平台的记账系统中,对于有高并发记账需求的账户,可预先为该账户配置缓冲记账的记账方法,以避免标准记账过程导致的一系列问题。
具体的,在对账户进行缓冲记账时,记账系统无需实时更新该账户的余额,而是按周期由各线程根据对该账户的记账请求,确定该账户的各记账明细并存储在数据库中。其中,该周期具体时长,可根据需要设置。
由各线程分别根据周期内对该账户的记账请求,确定记账明细并存储在数据库中。其中,该一段时间具体多长,可根据需要设置。因此记账系统在每个周期内无需因为记账而对该账户写锁,而线程也无需对账户进行记账操作,如表1所示。
表1
在表1中,可见记账系统中的不同的线程,可根据不同的记账请求,确定针对账户a的若干记账明细,并存储在数据库中。
并在每个周期结束时,由记账系统对该账户写锁,并根据数据库中存储的各记账明细的,确定该账户的余额并进行调整。以及将各记账明细对应的该账户的余额变动情况进行补记。其中,对账户的余额调整以及将记账明细进行补记的过程可以是异步进行的。
另外,在该账户的余额并进行调整时,记账系统是根据各记账明细,确定各记账明细对应的总记账结果,以根据总记账结果调整账户的余额。例如,假设分别存在记账明细收入100元,支出10元以及支出20元,则记账系统可确定总记账结果为收入70元。
但是,现有缓冲记账的记账方法,由于在调整账户余额之前,无法确定周期内各记账明细的总记账结果,所以存在账户透支的风险。所以一般需要根据人工经验预先判断需要配置以及可以配置缓冲记账的账户,使得现有缓冲记账的记账方法在配置时不够灵活,且依赖人工经验,存在风险。
可见,现有技术的各种记账方法,在面对高并发的交易业务时,仍存在多个方面的缺陷。因此,本说明书提供一种新的记账方法。
发明内容
本说明书实施例提供一种记账的方法及装置,用于解决现有技术的各种记账方法,在面对高并发的交易业务时,需要提前配置缓冲记账的账户,配置的参数也需要依靠人工经验,存在多个方面缺陷的问题。
本说明书实施例采用下述技术方案:
一种记账的方法,包括:
针对接收到的每个记账请求,确定该记账请求针对的账户;
当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时,根据该记账请求以及所述待处理的记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储;
当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,根据该记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
一种记账的装置,包括:
请求确定模块,针对接收到的每个记账请求,确定该记账请求针对的账户;
记账以及存储模块,当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时,根据该记账请求以及所述待处理的记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储;
所述记账以及存储模块,当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,根据该记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
一种服务器,其中,所述服务器包括:一个或多个处理器及存储器,存储器存储有程序,并且被配置成由一个或多个处理器执行以下步骤:
针对接收到的每个记账请求,确定该记账请求针对的账户;
当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时,根据该记账请求以及所述待处理的记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储;
当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,根据该记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
本说明书实施例采用的上述至少一个技术方案能够达到以下有益效果:
通过本说明书提供的方法及装置,针对接收到的每个记账请求,先确定该记账请求针对的账户。之后,可先判断是否存在与该记账请求属于同一事务且针对同一账户的待处理的记账请求。若不存在,则可根据该记账请求是否需要扣除该账户的余额,确定是否可将该记账请求作为待处理记账请求进行存储。而若存在,则需要根据该记账请求以及待处理的记账请求,确定是否可将该记账请求作为待处理记账请求进行存储。也就是说,如果存在若干待处理的记账请求不需要扣除账户的余额,则可在不能获取到账户的资源锁时,先将待处理的记账请求进行存储,而无需排队等待记账操作。使得当事务并发率较高时,记账操作更加灵活,同时保证了账户不会出现风险。并且,无需人工对账户进行配置,使得记账操作的效率提高风险降低。
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:
图1为本说明书实施例提供的一种记账的过程;
图2为本说明书实施例提供记账的详细过程的示意图;
图3为本说明书实施例提供的另一种记账的详细过程的示意图;
图4为本说明书实施例提供的一种记账的装置的结构示意图;
图5为本说明书实施例提供的一种服务器的结构示意图。
为使本说明书的目的、技术方案和优点更加清楚,下面将结合本说明书具体实施例及相应的附图对本申请技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于说明书中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
以下结合附图,详细说明本申请各实施例提供的技术方案。
图1为说明书实施例提供的一种记账的过程,具体可包括以下步骤:
S100:针对接收到的每个记账请求,确定该记账请求针对的账户。
在本说明书一个或多个实施例中,可由记账系统接受记账请求,并执行后续步骤的操作。其中,该记账系统可以包括:用于执行记账操作的服务器,以及存储有账户信息以及记账明细等与记账相关的数据的数据库。当然,该记账系统具体的形式可根据需要配置,例如,该数据库可以是分布式数据库,该服务器也可以是分布式服务器,本说明书对此不做限定。
为方便描述,后续本说明书以记账系统为执行该记账过程的执行主体进行说明。于是,在本说明书中该记账系统可接收记账请求。其中,由于记账是对经济活动的记录,是根据业务执行时的记账需要而生成的,因此记账系统通常也是接收执行业务的系统发送的记账请求的。当然,对于该记账请求具体是如何生成的本说明书不做限定。
而由于一个事务在执行过程中,可能需要生成多个记账请求,因此不同的记账请求可能对应于同一个事务。例如,用户A向用户B转账100元,则执行业务的系统可分别生成从用户A的账户中扣除100元,以及将用户B的账户添加100元的两个记账请求。则上述两个记账请求时对应于同一个转账事务。而为了表明记账请求对应的事务,通常在生成记账请求时,会将记账请求对应的事务的标识携带在记账请求中(例如,记账请求中可携带有流水号、业务标识等等)。
另外,本说明书提供的记账过程,主要用于解决现有技术在高并发记账请求的场景下存在的问题,因此本说明书也已高并发记账请求的场景为例进行后续的说明。因此该记账系统可以接收到若干记账请求,并且可针对接收到的每个记账请求,确定该记账请求针对的账户。
具体的,由于在高并发场景下,记账系统在同一时间可以接收到复数的记账请求, 而该记账请求可能是针对不完全相同的账户的记账请求,并且也可能是在执行不完全相同的事务时生成的,因此记账系统可先确定接收到的每个记账请求分别针对的账户,以便确定后续步骤的操作。
例如,假设记账系统在某一时刻接收到了如表2所示的记账请求。
记账请求 | 针对的账户 | 对应的事务 | 内容 |
记账请求n | 账户a | 事务001 | 支出10元 |
记账请求n+1 | 账户c | 事务001 | 冻结100元 |
…… | …… | …… | …… |
记账请求m | 账户f | 事务101 | 收入20元 |
表2
该记账系统在同一时间接收到的各记账请求可以对应不完全相同的账户以及不完全相同的事务的。于是,记账系统可针对每个记账请求,确定该记账请求针对的账户,以便后续步骤的操作。
S102:当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户且待处理的记账请求时,根据该记账请求以及所述待处理的记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
在本说明书中,由于步骤S100中针对接收到的每个记账请求,都确定了该记账请求针对的账户,因此在步骤S102中,仍然基于该记账请求进行说明。
另外,在本说明书中,根据记账请求的内容的不同,可将记账请求对应的记账操作划分为4种类型的操作,即,冻结操作、解冻操作、流出操作以及流入操作。
而现有技术中记账请求对应的记账操作需要同步执行的原因是:若不同步进行记账,可能导致事务执行结果出现扣除金额的数值大于账户中余额的数值情况出现,可能导致事务执行出现错误或者异常。
于是,在本说明书中,为了避免这一情况的出现,可以根据记账请求对应的操作类型以及对应的内容,判断是否需要扣除账户的余额,若是,则采用标准的记账方式进行记账操作,若否,则在无法获取账户的资源锁时,将该记账请求作为待处理的记账请求进行存储,并在该记账请求所属的事务结束之前,进行相应的记账操作。也就是异步的 进行记账操作,从解决的高并发场景下记账请求对应的记账操作不执行完毕,事务不会继续执行而导致各类问题(如,事务等待时间较长,影响效率,或者事务超时导致事务执行失败等等问题)。
具体的,由于对应不同事务的记账请求不能一起结算,而针对不同账户的记账请求也不能一起结算,因此记账系统可根据步骤S100中确定的记账请求,判断是否存在与该记账请求属于同一事务,且与该记账请求针对的是同一账户的待处理的记账请求。若是,则执行步骤S102否则执行步骤S104。
在本说明书步骤S102中,针对存在属于同一事务,且与该记账请求针对的是同一账户的待处理的记账请求情况进行说明。记账系统首先,可以确定该记账请求的记账明细并存储,并确定待处理的记账请求的记账明细,其中,记账明细中包括记账操作的类型以及记账操作的金额。之后,根据该记账请求的记账明细,以及待处理的记账请求的记账明细,确定明细总额,最后判断明细总额的支出是否大于收入。
若是,则需要扣除账户的余额,说明若异步进行记账操作,可能导致账户余额出现错误,因此记账系统可根据该记账请求以及待处理的记账请求,获取该账户的资源锁,以进行记账操作。当然,若是无法获取该账户的资源锁,则可与标准记账过程一致,排队等待获取锁。
若否,则说明当前该事务中对于该账户的各记账请求无需扣除账户余额,若异步进行记账操作也不回导致账户余额出现错误,因此记账系统可在不能获取该账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。当然,若是记账系统可获取该账户的资源锁,则可与标准记账过程一致,根据该记账请求以及待处理的记账请求进行记账操作。
需要说明的是,在本说明书中,记账系统确定出的待处理的记账请求可以存在多个。例如,假设某一事物在执行过程中,按照时间先后顺序,先后生成了记账请求1~记账请求3,分别为:账户b余额增加100元,账户b余额增加50元以及账户b余额支出10元。可见上述3条记账请求的明细总额为:账户b余额增加140元。如表3所示。
记账请求 | 针对的账户 | 对应的事务 | 记账明细 | 明细总额 |
记账请求1 | 账户b | 事务002 | 流入操作,100元 | 增加100元 |
记账请求2 | 账户b | 事务002 | 流入操作,50元 | 增加150元 |
记账请求3 | 账户b | 事务002 | 支出操作,10元 | 增加140元 |
表3
表3中每行记账请求对应的明细总额,为当前该账户b在事务002中,待处理的记账请求确定出的明细总额。因此,当记账系统接收到上述记账请求1~3时,若都无法获取账户b的资源锁,可依次将上述3条记账请求分别作为待处理的记账请求进行存储。
进一步假设,该事务在执行过程中,又生成了一个记账请求4为:账户b余额增加50元,则记账系统可进一步确定明细总额的支出不大于收入,因此在无法获取账户b的资源锁时,还可将该记账请求作为待处理的记账请求存储。
假设,在该事务执行过程,生成的记账请求4为:账户b余额扣除200元,则记账系统可确定明细总额的支出大于收入,则此时,记账系统需要获取账户b的资源锁,并将进行记账操作。
可见,在本说明书中,只要对应同一事务,且针对同一账户的若干记账请求的明细总额的支出不大于收入,则记账系统在无法获取该账户的资源锁时,都可以将记账请求作为待存储的记账请求存储。是该事务的执行可以继续进行,而不会应为排队等待资源锁而导致事务执行的效率下降。同时,也可减少排队等待获取资源锁的线程的数量,减少了数据库的运行压力。
S104:当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,根据该记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
在本说明书中,基于前述步骤S102中所述的判断步骤,若记账系统可确定与该记账请求属于同一事务的其他记账请求中,不存在针对该账户的待处理的记账请求时,记账系统可以根据该记账请求的记账操作的类型,判断是否需要获取该账户的资源锁。由于,各记账操作的类型中,除了流入操作以外,其余记账操作都存在从账户余额中支出金额的情况存在,因此记账系统在确定没有待处理的记账请求是,可以仅根据该记账请求的记账操作类型,判断该记账操作的类型是否是流入操作以外的其他记账操作,若是,则与步骤S102中描述一致,记账系统可采用标记账的过程进行记账操作,若否,则记账系统可以在不能获取到该账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
基于图1所示的记账过程,记账系统在接收到记账请求时,可根据该记账请求对应的记账明细,来判断是否在不能获取到账户的资源锁时,异步进行记账操作。或者,当 存在与该记账请求同属一个事务,且针对同一账户的待处理的记账请求时,根据该记账请求以及待处理的记账请求的明细总额,判断是否可以进行异步记账操作。使得无需预先对账户是否可进行异步记账操作进行配置,在减少人工配置带来的成本以外,也避免了现有缓冲记账导致的账户风险。并且,对于流入操作占多数的账户来说,可以减少获取账户的资源锁的次数,减轻了数据库的运行压力。解决了现有各种记账技术在面对高并发的记账请求场景时存在的问题。
另外,在本说明书中,当记账系统将记账请求作为待处理的记账请求进行存储之后,由于该记账请求对应的记账操作未执行,所以在该记账请所属的事务结束之前,记账系统可再次进行判断。判断是否仍存储有属于该事务的,针对该账户的待处理的记账请求,若是,则获取该账户的资源锁,并根据已存储的若干针对所述账户的待处理的记账请求,进行记账操作,并在记账操作执行完毕后确定该事务结束。若否,则可直接确定该事务结束。
基于图1所示的记账流程以及上述对记账流程的描述,本说明书对应提供一种记账的详细流程图,如图2所示。
S200:针对接收到的每个记账请求,确定该记账请求针对的账户。
S202:判断是否存在与该记账请求属于同一事务,且针对同一账户的已存储的待处理的记账请求,若是,执行步骤S204,若否执行步骤S206;
S204:根据该记账请求,以及确定出的待处理的记账请求,判断是否需要扣除所述账户的余额,若是则执行步骤S208,若否,则执行步骤S210;
S206:根据该记账请求,判断是否需要扣除所述账户的余额,若是则执行步骤S212,若否,则执行步骤S210;
S208:获取所述账户的资源锁,根据该记账请求,以及确定出的待处理的记账请求进行记账操作;
S210:在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
S212:获取所述账户的资源锁,根据该记账请求进行记账操作。
进一步地,步骤S210具体还可包括:
S2100:判断是否获取到了所述账户的资源锁,若是执行步骤S2102,若否,则执行 步骤S2104;
S2102:进行记账操作;
S2104:将该记账请求作为待处理的记账请求进行存储。如图3所示。
需要说明的是,本说明书实施例所提供方法的各步骤的执行主体均可以是同一设备,或者,该方法也由不同设备作为执行主体。比如,步骤S100和步骤S102的执行主体可以为设备1,步骤S102的执行主体可以为设备2;或者,步骤S100的执行主体可以为设备1,步骤S102和步骤S104的执行主体可以为设备2;等等。上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。
基于图1所示的记账的方法,本说明书实施例还提供一种记账的装置,如图4所示。
图4为本说明书实施例提供的一种记账的装置的结构示意图,所述装置包括:
请求确定模块300,针对接收到的每个记账请求,确定该记账请求针对的账户;
记账以及存储模块302,当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时,根据该记账请求以及所述待处理的记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储;
所述记账以及存储模块302,当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,根据该记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
所述记账以及存储模块302,判断是否需要扣除所述账户的余额之前,根据该记账请求,确定记账明细并存储,其中所述记账明细中包括对所述账户进行记账操作的金额。
所述记账以及存储模块302,根据存储的所述待处理的记账请求的记账明细,以及该记账请求的记账明细,确定该记账请求以及所述待处理的记账请求的明细总额,判断所述明细总额的支出是否大于收入。
所述记账请求对应的记账操作的操作类型包括:冻结、解冻、流出以及流入中的一种。
所述记账以及存储模块302,确定该记账请求的操作类型,判断所述操作类型是否是流入操作类型以外的其他操作类型。
当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时,所述记账以及存储模块302,获取所述账户的资源锁,并根据该记账请求以及所述未处理的记账请求,对所述账户进行记账操作。
当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,所述记账以及存储模块302,获取所述账户的资源锁,并根据该记账请求对所述账户进行记账操作。
所述记账以及存储模块302,当判断不需要扣除所述账户的余额,且获取到了所述账户的资源锁时,则根据该记账请求进行记账操作,或根据该记账请求以及所述待处理的记账请求进行记账操作。
所述装置还包括:
补账模块304,当所述事务结束之前,判断是否仍存储有针对所述账户的待处理的记账请求,若是,则获取所述账户的资源锁,并在根据已存储的若干针对所述账户的待处理的记账请求,进行记账操作之后,确定所述事务结束,若否,则确定所述事务结束。
基于图1所述的记账的方法,本说明书对应提供一种服务器,如图10所示,其中,所述服务器包括:一个或多个处理器及存储器,存储器存储有程序,并且被配置成由一个或多个处理器执行以下步骤:
针对接收到的每个记账请求,确定该记账请求针对的账户;
当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时,根据该记账请求以及所述待处理的记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储;
当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,根据该记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请 求作为待处理的记账请求进行存储。
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读存储介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以 将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和计算机可读存储介质。
计算机可读存储介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机可读存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读存储介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。
本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。
Claims (19)
- 一种记账的方法,包括:针对接收到的每个记账请求,确定该记账请求针对的账户;当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时,根据该记账请求以及所述待处理的记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储;当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,根据该记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
- 如权利要求1所述的方法,判断是否需要扣除所述账户的余额之前,所述方法还包括:根据该记账请求,确定记账明细并存储,其中所述记账明细中包括对所述账户进行记账操作的金额。
- 如权利要求2所述的方法,根据该记账请求以及所述待处理的记账请求,判断是否需要扣除所述账户的余额,具体包括:根据存储的所述待处理的记账请求的记账明细,以及该记账请求的记账明细,确定该记账请求以及所述待处理的记账请求的明细总额;判断所述明细总额的支出是否大于收入。
- 如权利要求1所述的方法,所述记账请求对应的记账操作的操作类型包括:冻结、解冻、流出以及流入中的一种。
- 如权利要求4所述的方法,根据该记账请求,判断是否需要扣除所述账户的余额,具体包括:确定该记账请求的操作类型;判断所述操作类型是否是流入操作类型以外的其他操作类型。
- 如权利要求1所述的方法,当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时;获取所述账户的资源锁,进行记账操作,具体包括:获取所述账户的资源锁,并根据该记账请求以及所述未处理的记账请求,对所述账户进行记账操作。
- 如权利要求1所述的方法,当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时;获取所述账户的资源锁,进行记账操作,具体包括:获取所述账户的资源锁,并根据该记账请求对所述账户进行记账操作。
- 如权利要求1所述的方法,当判断不需要扣除所述账户的余额,且获取到了所述账户的资源锁时,则根据该记账请求进行记账操作,或根据该记账请求以及所述待处理的记账请求进行记账操作。
- 如权利要求1所述的方法,所述方法还包括:当所述事务结束之前,判断是否仍存储有针对所述账户的待处理的记账请求;若是,则获取所述账户的资源锁,并在根据已存储的若干针对所述账户的待处理的记账请求,进行记账操作之后,确定所述事务结束;若否,则确定所述事务结束。
- 一种记账的装置,包括:请求确定模块,针对接收到的每个记账请求,确定该记账请求针对的账户;记账以及存储模块,当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时,根据该记账请求以及所述待处理的记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储;所述记账以及存储模块,当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,根据该记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
- 如权利要求10所述的装置,所述记账以及存储模块,判断是否需要扣除所述账户的余额之前,根据该记账请求,确定记账明细并存储,其中所述记账明细中包括对所述账户进行记账操作的金额。
- 如权利要求11所述的装置,所述记账以及存储模块,根据存储的所述待处理的记账请求的记账明细,以及该记账请求的记账明细,确定该记账请求以及所述待处理的记账请求的明细总额,判断所述明细总额的支出是否大于收入。
- 如权利要求10所述的装置,所述记账请求对应的记账操作的操作类型包括:冻结、解冻、流出以及流入中的一种。
- 如权利要求13所述的装置,所述记账以及存储模块,确定该记账请求的操作 类型,判断所述操作类型是否是流入操作类型以外的其他操作类型。
- 如权利要求10所述的装置,当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时,所述记账以及存储模块,获取所述账户的资源锁,并根据该记账请求以及所述未处理的记账请求,对所述账户进行记账操作。
- 如权利要求10所述的装置,当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,所述记账以及存储模块,获取所述账户的资源锁,并根据该记账请求对所述账户进行记账操作。
- 如权利要求10所述的装置,所述记账以及存储模块,当判断不需要扣除所述账户的余额,且获取到了所述账户的资源锁时,则根据该记账请求进行记账操作,或根据该记账请求以及所述待处理的记账请求进行记账操作。
- 如权利要求10所述的装置,所述装置还包括:补账模块,当所述事务结束之前,判断是否仍存储有针对所述账户的待处理的记账请求,若是,则获取所述账户的资源锁,并在根据已存储的若干针对所述账户的待处理的记账请求,进行记账操作之后,确定所述事务结束,若否,则确定所述事务结束。
- 一种服务器,其中,所述服务器包括:一个或多个处理器及存储器,存储器存储有程序,并且被配置成由一个或多个处理器执行以下步骤:针对接收到的每个记账请求,确定该记账请求针对的账户;当与该记账请求属于同一事务的其他记账请求中,存在针对所述账户的待处理的记账请求时,根据该记账请求以及所述待处理的记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储;当与该记账请求属于同一事务的其他记账请求中,不存在针对所述账户的待处理的记账请求时,根据该记账请求,判断是否需要扣除所述账户的余额,若是,则获取所述账户的资源锁,进行记账操作,若否,则在不能获取所述账户的资源锁时,将该记账请求作为待处理的记账请求进行存储。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810270039.3A CN108615184B (zh) | 2018-03-29 | 2018-03-29 | 一种记账的方法及装置 |
CN201810270039.3 | 2018-03-29 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019184571A1 true WO2019184571A1 (zh) | 2019-10-03 |
Family
ID=63659058
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2019/072909 WO2019184571A1 (zh) | 2018-03-29 | 2019-01-24 | 一种记账的方法及装置 |
Country Status (3)
Country | Link |
---|---|
CN (1) | CN108615184B (zh) |
TW (1) | TWI684944B (zh) |
WO (1) | WO2019184571A1 (zh) |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108615184B (zh) * | 2018-03-29 | 2020-12-18 | 创新先进技术有限公司 | 一种记账的方法及装置 |
CN110020931B (zh) * | 2019-01-10 | 2024-02-09 | 创新先进技术有限公司 | 一种记账、异常业务的识别方法和装置 |
CN109919623B (zh) * | 2019-02-28 | 2021-08-13 | 泰康保险集团股份有限公司 | 防止账户透支方法、装置、设备及可读存储介质 |
CN110827001A (zh) * | 2019-11-07 | 2020-02-21 | 深圳乐信软件技术有限公司 | 一种会计事件记账方法、系统、设备和存储介质 |
CN111930855A (zh) * | 2020-06-24 | 2020-11-13 | 山东浪潮通软信息科技有限公司 | 一种账本记账方法、装置、设备及介质 |
CN112685189B (zh) * | 2020-12-24 | 2024-03-22 | 北京中交兴路信息科技有限公司 | 一种实现数据处理方法、装置、设备及介质 |
CN115034902A (zh) * | 2022-06-21 | 2022-09-09 | 支付宝(杭州)信息技术有限公司 | 记账处理方法及装置 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106952158A (zh) * | 2017-03-17 | 2017-07-14 | 证通股份有限公司 | 解决热点账户问题的记账方法及设备 |
CN107015869A (zh) * | 2017-01-16 | 2017-08-04 | 平安银行股份有限公司 | 交易入账控制方法及系统 |
CN107153649A (zh) * | 2016-03-02 | 2017-09-12 | 阿里巴巴集团控股有限公司 | 一种数据备份方法及装置 |
CN107274162A (zh) * | 2017-05-31 | 2017-10-20 | 深圳市长亮科技股份有限公司 | 一种高交易并发量的处理方法 |
CN108615184A (zh) * | 2018-03-29 | 2018-10-02 | 阿里巴巴集团控股有限公司 | 一种记账的方法及装置 |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1037147A1 (en) * | 1999-03-15 | 2000-09-20 | BRITISH TELECOMMUNICATIONS public limited company | Resource scheduling |
US20040187108A1 (en) * | 2003-02-21 | 2004-09-23 | Knowles W. Jeffrey | Method of scheduling and event processing in computer operating system |
CN101620703B (zh) * | 2008-07-04 | 2013-10-16 | 阿里巴巴集团控股有限公司 | 一种缓冲记账方法及装置 |
CN101639792B (zh) * | 2008-07-29 | 2016-04-06 | 阿里巴巴集团控股有限公司 | 一种并发数据处理方法、装置及一种电子记账系统 |
CN105869043A (zh) * | 2015-01-19 | 2016-08-17 | 阿里巴巴集团控股有限公司 | 分散热点的数据库账户转入、转出的记账方法及装置 |
US10535063B2 (en) * | 2015-03-13 | 2020-01-14 | First Data Corporation | Systems and methods for securing digital gift cards with a public ledger |
CN106127568A (zh) * | 2016-06-15 | 2016-11-16 | 中国人民银行清算总中心 | 跨行支付系统的清算业务队列解救方法及装置 |
CN107016604A (zh) * | 2017-02-22 | 2017-08-04 | 阿里巴巴集团控股有限公司 | 缓冲记账的方法、装置及设备 |
-
2018
- 2018-03-29 CN CN201810270039.3A patent/CN108615184B/zh active Active
-
2019
- 2019-01-10 TW TW108101005A patent/TWI684944B/zh active
- 2019-01-24 WO PCT/CN2019/072909 patent/WO2019184571A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107153649A (zh) * | 2016-03-02 | 2017-09-12 | 阿里巴巴集团控股有限公司 | 一种数据备份方法及装置 |
CN107015869A (zh) * | 2017-01-16 | 2017-08-04 | 平安银行股份有限公司 | 交易入账控制方法及系统 |
CN106952158A (zh) * | 2017-03-17 | 2017-07-14 | 证通股份有限公司 | 解决热点账户问题的记账方法及设备 |
CN107274162A (zh) * | 2017-05-31 | 2017-10-20 | 深圳市长亮科技股份有限公司 | 一种高交易并发量的处理方法 |
CN108615184A (zh) * | 2018-03-29 | 2018-10-02 | 阿里巴巴集团控股有限公司 | 一种记账的方法及装置 |
Also Published As
Publication number | Publication date |
---|---|
TW201942843A (zh) | 2019-11-01 |
CN108615184A (zh) | 2018-10-02 |
CN108615184B (zh) | 2020-12-18 |
TWI684944B (zh) | 2020-02-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019184571A1 (zh) | 一种记账的方法及装置 | |
WO2018177235A1 (zh) | 一种区块链共识方法及装置 | |
WO2019154162A1 (zh) | 一种风控规则生成方法和装置 | |
US9400677B2 (en) | Adaptive handling of priority inversions using transactions | |
WO2019196551A1 (zh) | 一种配置支付流程、执行支付流程的方法、装置及设备 | |
WO2018214835A1 (zh) | 一种区块链业务受理及业务共识方法及装置 | |
WO2019128526A1 (zh) | 一种训练风控模型和风控的方法、装置及设备 | |
TWI694342B (zh) | 一種資料快取方法、裝置及系統 | |
WO2018113534A1 (zh) | 一种数据库死锁的处理方法、装置和数据库系统 | |
WO2019085601A1 (zh) | 一种任务执行的方法及装置 | |
US20200210228A1 (en) | Scheduling Applications in CPU and GPU Hybrid Environments | |
CN110297837B (zh) | 一种数据更新方法和装置、数据查询方法和装置 | |
WO2021239087A1 (zh) | 一种数据处理方法、装置、设备及介质 | |
US20240202025A1 (en) | Hybrid virtual gpu co-scheduling | |
US11188336B2 (en) | Replay of partially executed instruction blocks in a processor-based system employing a block-atomic execution model | |
TWI712879B (zh) | 容災資料處理方法、裝置、設備及系統 | |
WO2020219185A1 (en) | Tokenization request handling at a throttled rate in a payment network | |
CN108346039B (zh) | 互联网金融结算系统的业务处理方法、装置以及设备 | |
WO2024055779A1 (zh) | 账单处理方法及装置 | |
CN108681959A (zh) | 一种记账方法及服务器 | |
CN110928565A (zh) | 热点账户数据更新方法、装置、服务器及存储介质 | |
CN110046877B (zh) | 对账方法和装置、服务器 | |
CN109598511B (zh) | 一种账户风险识别方法、装置及设备 | |
CN107645541B (zh) | 数据存储方法、装置及服务器 | |
WO2013189011A1 (zh) | 交易处理的方法和装置 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19777074 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 19777074 Country of ref document: EP Kind code of ref document: A1 |