TW201942843A - Account keeping method and device - Google Patents

Account keeping method and device Download PDF

Info

Publication number
TW201942843A
TW201942843A TW108101005A TW108101005A TW201942843A TW 201942843 A TW201942843 A TW 201942843A TW 108101005 A TW108101005 A TW 108101005A TW 108101005 A TW108101005 A TW 108101005A TW 201942843 A TW201942843 A TW 201942843A
Authority
TW
Taiwan
Prior art keywords
accounting
request
account
billing
pending
Prior art date
Application number
TW108101005A
Other languages
Chinese (zh)
Other versions
TWI684944B (en
Inventor
王磊
Original Assignee
香港商阿里巴巴集團服務有限公司
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 香港商阿里巴巴集團服務有限公司 filed Critical 香港商阿里巴巴集團服務有限公司
Publication of TW201942843A publication Critical patent/TW201942843A/en
Application granted granted Critical
Publication of TWI684944B publication Critical patent/TWI684944B/en

Links

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/12Accounting
    • G06Q40/125Finance or payroll
    • 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
    • G06Q30/00Commerce
    • G06Q30/04Billing or invoicing

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

The invention discloses an account keeping method and device. For each received account keeping request, an account corresponding to the account keeping request is firstly determined; then whether there is a to-be-handled account keeping request which belongs to the same affair and aims at the same account with the account keeping request or not can be firstly judged; if the to-be-handled account keeping request does not exist, whether the account keeping request can serve as a to-be-handled account keeping request for storage or not can be determined according to whether the account keeping request needs to deduct the balance of the account or not; and if the to-be-handled account keeping request exists, it needs to determine whether the account keeping request can serve as a to-be-handled account keeping request for storage or not according to the account keeping request and the to-be-handled account keeping request.

Description

記帳的方法及裝置Accounting method and device

本發明關於資訊技術領域,尤其關於一種記帳的方法及裝置。The present invention relates to the field of information technology, and in particular, to a method and device for bookkeeping.

記帳是指將企事業單位、個人或者家庭發生的經濟業務,按照一定的記錄方法在帳簿上記錄的行為。
在帳務資料庫的處理中,資料從一個帳戶轉出,或者有資料轉入一個帳戶,帳戶都會收到記帳請求,並都有一個記帳處理的過程。
記帳處理過程主要包括兩部分,一是記錄記帳憑證,二是更新帳戶的餘值。為了保證帳戶不被其他請求影響資料的準確性,在進行記帳處理時,會先對帳戶的資源加鎖,記帳處理完畢後會自動釋放鎖。隨著帳務處理業務量的增大,帳務資料庫中的帳戶常常會在瞬間產生多個併發操作,但所有對應的併發執行緒中只有一個執行緒能夠持有當前帳戶的資源鎖,其他執行緒必須等待該鎖被釋放後 再逐一進行記帳處理,這樣該帳戶將會被頻繁加鎖釋鎖,使該帳戶成為帳務資料庫熱點,產生性能瓶頸點,嚴重影響帳務資料庫的性能。
目前,隨著無紙化辦公的普及,通常由記帳系統對各帳戶進行記帳。而為了防止多個執行緒對同一個帳戶進行併發的記帳操作,導致資料錯誤,在標準記帳過程中,記帳系統需要先對該帳戶寫鎖,使得只有持有該鎖的執行緒可以對該帳戶進行操作,並在記帳完成之後再釋放該帳戶的鎖。
而對電子商務平臺來說,交易業務存在高度並行的特點。這就使得,標準記帳過程對帳戶的寫鎖操作,嚴重影響了業務執行的效率。除了導致記帳系統運行壓力增大以外,還容易導致交易業務由於等待超時而失敗。
因此,在現有的電子商務平臺的記帳系統中,對於有高度並行記帳需求的帳戶,可預先為該帳戶配置緩衝記帳的記帳方法,以避免標準記帳過程導致的一系列問題。
具體的,在對帳戶進行緩衝記帳時,記帳系統無需即時更新該帳戶的餘額,而是按週期由各執行緒根據對該帳戶的記帳請求,確定該帳戶的各記帳明細並儲存在資料庫中。其中,該週期具體時長,可根據需要設置。
由各執行緒分別根據週期內對該帳戶的記帳請求,確定記帳明細並儲存在資料庫中。其中,該一段時間具體多長,可根據需要設置。因此記帳系統在每個週期內無需因為記帳而對該帳戶寫鎖,而執行緒也無需對帳戶進行記帳操作,如表1所示。



表1
在表1中,可見記帳系統中的不同的執行緒,可根據不同的記帳請求,確定針對帳戶a的若干記帳明細,並儲存在資料庫中。
並在每個週期結束時,由記帳系統對該帳戶寫鎖,並根據資料庫中儲存的各記帳明細的,確定該帳戶的餘額並進行調整。以及將各記帳明細對應的該帳戶的餘額變動情況進行補記。其中,對帳戶的餘額調整以及將記帳明細進行補記的過程可以是非同步進行的。
另外,在該帳戶的餘額並進行調整時,記帳系統是根據各記帳明細,確定各記帳明細對應的總記帳結果,以根據總記帳結果調整帳戶的餘額。例如,假設分別存在記帳明細收入100元,支出10元以及支出20元,則記帳系統可確定總記帳結果為收入70元。
但是,現有緩衝記帳的記帳方法,由於在調整帳戶餘額之前,無法確定週期內各記帳明細的總記帳結果,所以存在帳戶透支的風險。所以一般需要根據人工經驗預先判斷需要配置以及可以配置緩衝記帳的帳戶,使得現有緩衝記帳的記帳方法在配置時不夠靈活,且依賴人工經驗,存在風險。
可見,現有技術的各種記帳方法,在面對高度並行的交易業務時,仍存在多個方面的缺陷。因此,本說明書提供一種新的記帳方法。
Bookkeeping refers to the act of recording economic transactions in enterprises, institutions, individuals, or households on account books in accordance with a certain recording method.
In the processing of the accounting database, if data is transferred from an account, or if there is data transferred into an account, the account will receive a billing request, and there will be a process of billing processing.
The accounting process mainly includes two parts, one is to record the accounting voucher, and the other is to update the remaining value of the account. In order to ensure that the account is not affected by the accuracy of the data by other requests, the account resources will be locked when the accounting process is performed, and the lock will be automatically released after the accounting process is completed. With the increase of the amount of account processing business, the accounts in the account database often generate multiple concurrent operations in an instant, but only one of all the corresponding concurrent threads can hold the resource lock of the current account. The thread must wait for the lock to be released before proceeding with the accounting process one by one. In this way, the account will be frequently locked and unlocked, making the account a hotspot in the accounting database, creating a performance bottleneck, and seriously affecting the performance of the accounting database .
At present, with the popularization of paperless office, the accounts are usually recorded by an accounting system. In order to prevent multiple threads from performing concurrent accounting operations on the same account, resulting in data errors, in the standard accounting process, the accounting system needs to first write a lock on the account, so that only the thread holding the lock can write on the account. Take action and release the account's lock after accounting is complete.
For e-commerce platforms, transaction services are highly parallel. This makes the write lock operation on the account in the standard accounting process seriously affect the efficiency of business execution. In addition to increasing the operating pressure of the accounting system, it is also easy to cause transaction business to fail due to waiting timeouts.
Therefore, in an existing e-commerce platform's accounting system, for accounts with a high degree of concurrent accounting requirements, a buffered accounting method can be configured for the account in advance to avoid a series of problems caused by the standard accounting process.
Specifically, when the account is buffered, the accounting system does not need to update the balance of the account in real time. Instead, each thread determines the accounting details of the account and stores it in the database on a periodic basis according to the accounting request for the account. . The specific duration of the period can be set as required.
Each thread determines the accounting details according to the accounting request for the account in the cycle and stores them in the database. The specific period of time can be set as required. Therefore, the accounting system does not need to write a lock on the account for each accounting period, and the thread does not need to perform accounting operations on the account, as shown in Table 1.



Table 1
In Table 1, it can be seen that different threads in the accounting system can determine several accounting details for account a according to different accounting requests, and store them in the database.
At the end of each cycle, the accounting system writes a lock on the account, and determines the balance of the account and adjusts it based on the details of each account stored in the database. And make up the change in the balance of the account corresponding to each accounting detail. Among them, the process of adjusting the balance of the account and supplementing the accounting details may be performed asynchronously.
In addition, when the balance of the account is adjusted, the accounting system determines the total accounting result corresponding to each accounting detail according to each accounting detail, so as to adjust the account balance based on the total accounting result. For example, assuming that there are accounting details of 100 yuan in revenue, 10 yuan in expenditure, and 20 yuan in expenditure, the accounting system can determine that the total accounting result is 70 yuan in revenue.
However, in the existing buffered billing method, because the total billing result of each billing detail in the period cannot be determined before the account balance is adjusted, there is a risk of account overdraft. Therefore, it is generally necessary to judge in advance the accounts that need to be configured and can be configured for buffer accounting based on human experience, so that the existing buffer accounting method is not flexible in configuration, and relies on manual experience, which is risky.
It can be seen that the various accounting methods in the prior art still have defects in many aspects when facing highly parallel transaction services. Therefore, this specification provides a new accounting method.

本說明書實施例提供一種記帳的方法及裝置,用於解決現有技術的各種記帳方法,在面對高度並行的交易業務時,需要提前配置緩衝記帳的帳戶,配置的參數也需要依靠人工經驗,存在多個方面缺陷的問題。
本說明書實施例採用下述技術方案:
一種記帳的方法,包括:
針對接收到的每個記帳請求,確定該記帳請求針對的帳戶;
當與該記帳請求屬於同一事務的其他記帳請求中,存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求以及所述待處理的記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存;
當與該記帳請求屬於同一事務的其他記帳請求中,不存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存。
一種記帳的裝置,包括:
請求確定模組,針對接收到的每個記帳請求,確定該記帳請求針對的帳戶;
記帳以及儲存模組,當與該記帳請求屬於同一事務的其他記帳請求中,存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求以及所述待處理的記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存;
所述記帳以及儲存模組,當與該記帳請求屬於同一事務的其他記帳請求中,不存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存。
一種伺服器,其中,所述伺服器包括:一個或多個處理器及記憶體,記憶體儲存有程式,並且被配置成由一個或多個處理器執行以下步驟:
針對接收到的每個記帳請求,確定該記帳請求針對的帳戶;
當與該記帳請求屬於同一事務的其他記帳請求中,存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求以及所述待處理的記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存;
當與該記帳請求屬於同一事務的其他記帳請求中,不存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存。
本說明書實施例採用的上述至少一個技術方案能夠達到以下有益效果:
藉由本說明書提供的方法及裝置,針對接收到的每個記帳請求,先確定該記帳請求針對的帳戶。之後,可先判斷是否存在與該記帳請求屬於同一事務且針對同一帳戶的待處理的記帳請求。若不存在,則可根據該記帳請求是否需要扣除該帳戶的餘額,確定是否可將該記帳請求作為待處理記帳請求進行儲存。而若存在,則需要根據該記帳請求以及待處理的記帳請求,確定是否可將該記帳請求作為待處理記帳請求進行儲存。也就是說,如果存在若干待處理的記帳請求不需要扣除帳戶的餘額,則可在不能獲取到帳戶的資源鎖時,先將待處理的記帳請求進行儲存,而無需排隊等待記帳操作。使得當事務併發率較高時,記帳操作更加靈活,同時保證了帳戶不會出現風險。並且,無需人工對帳戶進行配置,使得記帳操作的效率提高風險降低。
The embodiments of the present specification provide a method and device for accounting, which are used to solve various accounting methods in the prior art. When facing highly parallel transaction services, it is necessary to configure an account for buffer accounting in advance. The configured parameters also rely on manual experience. Defective issues in many ways.
The embodiments of this specification adopt the following technical solutions:
A method of billing, including:
For each billing request received, determine the account to which the billing request is directed;
When there are pending accounting requests for the account in other accounting requests belonging to the same transaction as the accounting request, determining whether the balance of the account needs to be deducted according to the accounting request and the pending accounting request, If it is, obtain the resource lock of the account and perform the accounting operation; if not, when the resource lock of the account cannot be obtained, store the accounting request as a pending accounting request;
When there is no pending billing request for the account in other billing requests belonging to the same transaction as the billing request, according to the billing request, determine whether the balance of the account needs to be deducted, and if so, obtain the account And perform a bookkeeping operation if the resource lock of the account is not obtained, and when the resource lock of the account cannot be obtained, store the bookkeeping request as a pending bookkeeping request.
An accounting device includes:
The request determination module determines, for each received accounting request, the account to which the accounting request is directed;
The billing and storage module, when other billing requests belonging to the same transaction as the billing request have a pending billing request for the account, determine whether a deduction is required based on the billing request and the pending billing request If the balance of the account is obtained, obtain the resource lock of the account and perform the accounting operation; if not, store the accounting request as a pending accounting request when the resource lock of the account cannot be obtained;
In the accounting and storage module, when there is no pending accounting request for the account in other accounting requests belonging to the same transaction as the accounting request, it is determined whether the balance of the account needs to be deducted based on the accounting request. If yes, acquire the resource lock of the account and perform the accounting operation; if not, when the resource lock of the account cannot be obtained, store the accounting request as a pending accounting request.
A server, wherein the server includes: one or more processors and a memory, the memory stores a program, and is configured to perform the following steps by the one or more processors:
For each billing request received, determine the account to which the billing request is directed;
When there are pending accounting requests for the account in other accounting requests belonging to the same transaction as the accounting request, determining whether the balance of the account needs to be deducted according to the accounting request and the pending accounting request, If it is, obtain the resource lock of the account and perform the accounting operation; if not, when the resource lock of the account cannot be obtained, store the accounting request as a pending accounting request;
When there is no pending billing request for the account in other billing requests belonging to the same transaction as the billing request, according to the billing request, determine whether the balance of the account needs to be deducted, and if so, obtain the account And perform a bookkeeping operation if the resource lock of the account is not obtained, and when the resource lock of the account cannot be obtained, store the bookkeeping request as a pending bookkeeping request.
The at least one technical solution adopted in the embodiments of the present specification can achieve the following beneficial effects:
With the method and device provided in this specification, for each received billing request, first determine the account to which the billing request is directed. After that, it can be judged whether there is a pending accounting request belonging to the same transaction as the accounting request and for the same account. If it does not exist, it can be determined whether the accounting request can be stored as a pending accounting request according to whether the accounting request needs to be deducted from the account balance. If it exists, it needs to determine whether the accounting request can be stored as a pending accounting request according to the accounting request and the pending accounting request. That is, if there are several pending accounting requests that do not need to deduct the balance of the account, when the resource lock of the account cannot be obtained, the pending accounting requests can be stored first without waiting in line for the accounting operation. When the transaction concurrency rate is high, the accounting operation is more flexible, and at the same time, the account will not be at risk. In addition, there is no need to manually configure the account, so that the efficiency of the bookkeeping operation is improved and the risk is reduced.

為使本說明書的目的、技術方案和優點更加清楚,下面將結合本說明書具體實施例及相應的附圖對本發明技術方案進行清楚、完整地描述。顯然,所描述的實施例僅是本發明一部分實施例,而不是全部的實施例。基於說明書中的實施例,本領域普通技術人員在沒有做出進步性勞動前提下所獲得的所有其他實施例,都屬於本發明保護的範圍。
以下結合附圖,詳細說明本發明各實施例提供的技術方案。
圖1為說明書實施例提供的一種記帳的過程,具體可包括以下步驟:
S100:針對接收到的每個記帳請求,確定該記帳請求針對的帳戶。
在本說明書一個或多個實施例中,可由記帳系統接受記帳請求,並執行後續步驟的操作。其中,該記帳系統可以包括:用於執行記帳操作的伺服器,以及儲存有帳戶資訊以及記帳明細等與記帳相關的資料的資料庫。當然,該記帳系統具體的形式可根據需要配置,例如,該資料庫可以是分散式資料庫,該伺服器也可以是分散式伺服器,本說明書對此不做限定。
為方便描述,後續本說明書以記帳系統為執行該記帳過程的執行主體進行說明。於是,在本說明書中該記帳系統可接收記帳請求。其中,由於記帳是對經濟活動的記錄,是根據業務執行時的記帳需要而生成的,因此記帳系統通常也是接收執行業務的系統發送的記帳請求的。當然,對於該記帳請求具體是如何生成的本說明書不做限定。
而由於一個事務在執行過程中,可能需要生成多個記帳請求,因此不同的記帳請求可能對應於同一個事務。例如,用戶A向用戶B轉帳100元,則執行業務的系統可分別生成從用戶A的帳戶中扣除100元,以及將用戶B的帳戶添加100元的兩個記帳請求。則上述兩個記帳請求時對應於同一個轉帳事務。而為了表明記帳請求對應的事務,通常在生成記帳請求時,會將記帳請求對應的事務的標識攜帶在記帳請求中(例如,記帳請求中可攜帶有流水號、業務標識等等)。
另外,本說明書提供的記帳過程,主要用於解決現有技術在高度並行記帳請求的場景下存在的問題,因此本說明書也已高度並行記帳請求的場景為例進行後續的說明。因此該記帳系統可以接收到若干記帳請求,並且可針對接收到的每個記帳請求,確定該記帳請求針對的帳戶。
具體的,由於在高度並行場景下,記帳系統在同一時間可以接收到複數的記帳請求,而該記帳請求可能是針對不完全相同的帳戶的記帳請求,並且也可能是在執行不完全相同的事務時生成的,因此記帳系統可先確定接收到的每個記帳請求分別針對的帳戶,以便確定後續步驟的操作。
例如,假設記帳系統在某一時刻接收到了如表2所示的記帳請求。



表2
該記帳系統在同一時間接收到的各記帳請求可以對應不完全相同的帳戶以及不完全相同的事務的。於是,記帳系統可針對每個記帳請求,確定該記帳請求針對的帳戶,以便後續步驟的操作。
S102:當與該記帳請求屬於同一事務的其他記帳請求中,存在針對所述帳戶且待處理的記帳請求時,根據該記帳請求以及所述待處理的記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存。
在本說明書中,由於步驟S100中針對接收到的每個記帳請求,都確定了該記帳請求針對的帳戶,因此在步驟S102中,仍然基於該記帳請求進行說明。
另外,在本說明書中,根據記帳請求的內容的不同,可將記帳請求對應的記帳操作劃分為4種類型的操作,即,凍結操作、解凍操作、流出操作以及流入操作。
而現有技術中記帳請求對應的記帳操作需要同步執行的原因是:若不同步進行記帳,可能導致事務執行結果出現扣除金額的數值大於帳戶中餘額的數值情況出現,可能導致事務執行出現錯誤或者異常。
於是,在本說明書中,為了避免這一情況的出現,可以根據記帳請求對應的操作類型以及對應的內容,判斷是否需要扣除帳戶的餘額,若是,則採用標準的記帳方式進行記帳操作,若否,則在無法獲取帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存,並在該記帳請求所屬的事務結束之前,進行相應的記帳操作。也就是非同步的進行記帳操作,從解決的高度並行場景下記帳請求對應的記帳操作不執行完畢,事務不會繼續執行而導致各類問題(如,事務等待時間較長,影響效率,或者事務超時導致事務執行失敗等等問題)。
具體的,由於對應不同事務的記帳請求不能一起結算,而針對不同帳戶的記帳請求也不能一起結算,因此記帳系統可根據步驟S100中確定的記帳請求,判斷是否存在與該記帳請求屬於同一事務,且與該記帳請求針對的是同一帳戶的待處理的記帳請求。若是,則執行步驟S102否則執行步驟S104。
在本說明書步驟S102中,針對存在屬於同一事務,且與該記帳請求針對的是同一帳戶的待處理的記帳請求情況進行說明。記帳系統首先,可以確定該記帳請求的記帳明細並儲存,並確定待處理的記帳請求的記帳明細,其中,記帳明細中包括記帳操作的類型以及記帳操作的金額。之後,根據該記帳請求的記帳明細,以及待處理的記帳請求的記帳明細,確定明細總額,最後判斷明細總額的支出是否大於收入。
若是,則需要扣除帳戶的餘額,說明若非同步進行記帳操作,可能導致帳戶餘額出現錯誤,因此記帳系統可根據該記帳請求以及待處理的記帳請求,獲取該帳戶的資源鎖,以進行記帳操作。當然,若是無法獲取該帳戶的資源鎖,則可與標準記帳過程一致,排隊等待獲取鎖。
若否,則說明當前該事務中對於該帳戶的各記帳請求無需扣除帳戶餘額,若非同步進行記帳操作也不回導致帳戶餘額出現錯誤,因此記帳系統可在不能獲取該帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存。當然,若是記帳系統可獲取該帳戶的資源鎖,則可與標準記帳過程一致,根據該記帳請求以及待處理的記帳請求進行記帳操作。
需要說明的是,在本說明書中,記帳系統確定出的待處理的記帳請求可以存在多個。例如,假設某一事物在執行過程中,按照時間先後順序,先後生成了記帳請求1~記帳請求3,分別為:帳戶b餘額增加100元,帳戶b餘額增加50元以及帳戶b餘額支出10元。可見上述3條記帳請求的明細總額為:帳戶b餘額增加140元。如表3所示。



表3
表2中每行記帳請求對應的明細總額,為當前該帳戶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)、輸入/輸出介面、網路介面和記憶體。
記憶體可能包括電腦可讀媒體中的非永久性記憶體,隨機存取記憶體(RAM)和/或非揮發性記憶體等形式,如唯讀記憶體(ROM)或快閃記憶體(flash RAM)。記憶體是電腦可讀媒體的示例。
電腦可讀媒體包括永久性和非永久性、可移動和非可移動媒體可以由任何方法或技術來實現資訊儲存。資訊可以是電腦可讀指令、資料結構、程式的模組或其他資料。電腦的儲存媒體的例子包括,但不限於相變記憶體(PRAM)、靜態隨機存取記憶體(SRAM)、動態隨機存取記憶體(DRAM)、其他類型的隨機存取記憶體(RAM)、唯讀記憶體(ROM)、電可抹除可程式設計唯讀記憶體(EEPROM)、快閃記憶體或其他記憶體技術、唯讀光碟唯讀記憶體(CD-ROM)、數位多功能光碟(DVD)或其他光學儲存、磁盒式磁帶,磁帶磁磁片儲存或其他磁性存放裝置或任何其他非傳輸媒體,可用於儲存可以被計算設備存取的資訊。按照本文中的界定,電腦可讀媒體不包括暫存電腦可讀媒體(transitory media),如調變的資料訊號和載波。
還需要說明的是,術語“包括”、“包含”或者其任何其他變體意在涵蓋非排他性的包含,從而使得包括一系列要素的過程、方法、商品或者設備不僅包括那些要素,而且還包括沒有明確列出的其他要素,或者是還包括為這種過程、方法、商品或者設備所固有的要素。在沒有更多限制的情況下,由語句“包括一個……”限定的要素,並不排除在包括所述要素的過程、方法、商品或者設備中還存在另外的相同要素。
本領域技術人員應明白,本發明的實施例可提供為方法、系統或電腦程式產品。因此,本發明可採用完全硬體實施例、完全軟體實施例或結合軟體和硬體態樣的實施例的形式。而且,本發明可採用在一個或多個其中包含有電腦可用程式碼的電腦可用儲存媒體(包括但不限於磁碟記憶體、CD-ROM、光學記憶體等)上實施的電腦程式產品的形式。
本發明可以在由電腦執行的電腦可執行指令的一般上下文中描述,例如程式模組。一般地,程式模組包括執行特定任務或實現特定抽象資料類型的常式、程式、物件、元件、資料結構等等。也可以在分散式運算環境中實踐本發明,在這些分散式運算環境中,由藉由通訊網路而被連接的遠端處理設備來執行任務。在分散式運算環境中,程式模組可以位於包括存放裝置在內的本地和遠端電腦儲存媒體中。
本說明書中的各個實施例均採用遞進的方式描述,各個實施例之間相同相似的部分互相參見即可,每個實施例重點說明的都是與其他實施例的不同之處。尤其,對於系統實施例而言,由於其基本相似於方法實施例,所以描述的比較簡單,相關之處參見方法實施例的部分說明即可。
以上所述僅為本發明的實施例而已,並不用於限制本發明。對於本領域技術人員來說,本發明可以有各種更改和變化。凡在本發明的精神和原理之內所作的任何修改、等同替換、改進等,均應包含在本發明的申請專利範圍的範圍之內。
In order to make the purpose, technical solution, and advantages of the present specification clearer, the technical solution of the present invention will be clearly and completely described in combination with specific embodiments of the present specification and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all the embodiments. Based on the embodiments in the specification, all other embodiments obtained by a person of ordinary skill in the art without making progressive labor fall within the protection scope of the present invention.
The technical solutions provided by the embodiments of the present invention will be described in detail below with reference to the drawings.
FIG. 1 is a billing process provided by an embodiment of the description, which specifically includes the following steps:
S100: For each received accounting request, determine the account to which the accounting request is directed.
In one or more embodiments of the present specification, the accounting request may be accepted by the accounting system and the operations of the subsequent steps may be performed. The accounting system may include: a server for performing accounting operations, and a database storing account-related information such as account information and accounting details. Of course, the specific form of the accounting system can be configured as required. For example, the database can be a distributed database, and the server can also be a distributed server, which is not limited in this specification.
For the convenience of description, the subsequent description in this specification uses the accounting system as the execution subject to execute the accounting process. Thus, the accounting system can receive an accounting request in this specification. Among them, since the accounting is a record of economic activities and is generated according to the accounting needs during the execution of the business, the accounting system usually also receives the accounting request sent by the system performing the business. Of course, this description of how the billing request is specifically generated is not limited.
And because one 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 executing the business can generate two billing requests that deduct 100 yuan from user A's account and add 100 yuan to user B's account. Then the above two billing requests correspond to the same transfer transaction. In order to indicate the transaction corresponding to the billing request, usually when generating the billing request, the identifier of the transaction corresponding to the billing request is carried in the billing request (for example, the billing request may carry a serial number, a service ID, etc.).
In addition, the accounting process provided in this specification is mainly used to solve the existing problems in the scenario of highly parallel accounting requests in the prior art. Therefore, the scenario of highly parallel accounting requests has been used as an example for subsequent descriptions. Therefore, the billing system can receive several billing requests, and for each billing request received, determine the account to which the billing request is directed.
Specifically, in a highly parallel scenario, the billing system can receive multiple billing requests at the same time, and the billing request may be a billing request for a non-identical account, or it may be performing a non-identical transaction Generated, so the billing system can first determine the account to which each billing request was received, in order to determine the operation of the subsequent steps.
For example, suppose the billing system receives a billing request as shown in Table 2 at a certain time.



Table 2
Each accounting request received by the accounting system at the same time may correspond to non-identical accounts and non-identical transactions. Then, the billing system can determine, for each billing request, the account to which the billing request is targeted for subsequent steps.
S102: When other accounting requests belonging to the same transaction as the accounting request exist and there are pending accounting requests for the account, determine whether it is necessary to deduct the account according to the accounting request and the pending accounting request. The balance, if yes, acquires the resource lock of the account, and performs the accounting operation; if not, when the resource lock of the account cannot be obtained, the accounting request is stored as a pending accounting request.
In this specification, since the account to which the billing request is targeted is determined for each billing request received in step S100, the description is still based on the billing request in step S102.
In addition, in this specification, according to the content of the accounting request, the accounting operation corresponding to the accounting request can be divided into four types of operations, that is, a freezing operation, a thawing operation, an outflow operation, and an inflow operation.
In the prior art, the reason that the accounting operation corresponding to the accounting request needs to be performed synchronously is: if the accounting is not performed synchronously, the value of the deduction amount of the transaction execution result may be greater than the value of the balance in the account, which may cause an error or abnormality in the transaction execution .
Therefore, in this specification, in order to avoid this situation, you can determine whether the balance of the account needs to be deducted according to the type of operation and the corresponding content of the accounting request. If it is, use the standard accounting method to perform the accounting operation. , When the resource lock of the account cannot be obtained, the accounting request is stored as a pending accounting request, and a corresponding accounting operation is performed before the transaction to which the accounting request belongs is ended. That is, the accounting operation is performed asynchronously. From the highly parallel scenario that is solved, the accounting operation corresponding to the accounting request is not completed, and the transaction will not continue to execute, resulting in various problems (such as long transaction waiting time, affecting efficiency, or transactions). Timeouts cause problems such as transaction execution failure).
Specifically, since the accounting requests corresponding to different transactions cannot be settled together, and the accounting requests for different accounts cannot be settled together, the accounting system can determine whether there exists the same transaction as the accounting request according to the accounting request determined in step S100. And this billing request is for a pending billing request for the same account. If yes, execute step S102; otherwise, execute step S104.
In step S102 of the present specification, a case is described in which a pending billing request belongs to the same transaction and the billing request is directed to the same account. The billing system can first determine and store the billing details of the billing request, and determine the billing details of the pending billing request. The billing details include the type of billing operation and the amount of the billing operation. Then, according to the accounting details of the accounting request and the accounting details of the pending accounting request, the total amount of the details is determined, and finally, it is determined whether the expenditure of the total amount of the details is greater than the income.
If so, the balance of the account needs to be deducted, indicating that if the accounting operation is performed asynchronously, the account balance may be wrong, so the accounting system can obtain the resource lock of the account for the accounting operation according to the accounting request and the pending accounting request. Of course, if it is not possible to acquire the resource lock for the account, it can be in line with the standard accounting process and queued to acquire the lock.
If not, it means that there is no need to deduct the account balance for each accounting request for this account in the current transaction. If the asynchronous accounting operation does not return, the account balance will be wrong. Therefore, the accounting system can The accounting request is stored as a pending accounting request. Of course, if the accounting system can obtain the resource lock of the account, it can be consistent with the standard accounting process, and perform accounting operations according to the accounting request and the pending accounting request.
It should be noted that in this specification, there may be multiple accounting requests to be processed determined by the accounting system. For example, suppose that during the execution of a certain thing, in accordance with the chronological order, accounting request 1 ~ accounting request 3 were generated, respectively: account b balance increased by 100 yuan, account b balance increased by 50 yuan, and account b balance expenditure of 10 yuan . It can be seen that the total details of the above three billing requests are: the balance of account b increased by 140 yuan. as shown in Table 3.



table 3
The total amount of detail corresponding to each line of the billing request in Table 2 is the total amount of detail determined by the pending billing request of the current account b in transaction 002. Therefore, when the accounting system receives the above-mentioned accounting requests 1 to 3, if none of the resource locks of account b can be obtained, the above three accounting requests may be stored in turn as pending accounting requests.
It is further assumed that during the execution of this transaction, a billing request 4 is generated: The balance of account b is increased by 50 yuan, and the billing system can further determine that the total detailed expenditure is not greater than the income, so when the resource lock of account b cannot be obtained , You can also store the billing request as a pending billing request.
Assume that during the execution of this transaction, the accounting request 4 generated is: account b deducts 200 yuan from the balance, then the accounting system can determine that the total detailed expenditure is greater than the income. At this time, the accounting system needs to acquire the resource lock of account b, and Perform accounting operations.
It can be seen that in this specification, as long as the corresponding total transaction and the detailed total expenditure of several accounting requests for the same account are not greater than the income, the accounting system can treat the accounting request as a pending storage when it cannot obtain the resource lock of the account. Billing request for storage. It is the execution of this transaction that can continue without the need to queue up for resource locks and cause transaction execution to be less efficient. At the same time, the number of threads waiting in line to acquire resource locks can be reduced, reducing the operating pressure of the database.
S104: When there is no pending billing request for the account in other billing requests that belong to the same transaction as the billing request, determine whether it is necessary to deduct the balance of the account according to the billing request, and if so, obtain the The account resource lock is performed on the account, and an accounting operation is performed. If not, when the resource lock of the account cannot be obtained, the account request is stored as a pending account request.
In this specification, based on the determination steps described in the foregoing step S102, if the accounting system can determine that there are no other accounting requests for the same transaction as the accounting request, the accounting system can According to the type of the accounting operation of the accounting request, determine whether a resource lock of the account needs to be acquired. Because of the types of accounting operations, except for the inflow operation, the remaining accounting operations may have an expenditure amount from the account balance. Therefore, when the accounting system determines that there is no pending accounting request, it can only perform accounting based on the accounting request. Operation type, to determine whether the type of the accounting operation is an accounting operation other than the inflow operation. If so, it is consistent with the description in step S102. The accounting system can use the process of marking the account for accounting operations. If not, the accounting system can When the resource lock of the account is obtained, the accounting request is stored as a pending accounting request.
Based on the accounting process shown in FIG. 1, when the accounting system receives the accounting request, it can determine whether to perform the accounting operation asynchronously when the resource lock of the account cannot be obtained according to the accounting details corresponding to the accounting request. Alternatively, when there is a pending accounting request that belongs to the same transaction as the accounting request and is for the same account, it is determined whether an asynchronous accounting operation can be performed according to the total amount of details of the accounting request and the pending accounting request. This makes it unnecessary to configure in advance whether the account can be operated for asynchronous accounting, and in addition to reducing the cost caused by manual configuration, it also avoids the account risk caused by the existing buffered accounting. In addition, for accounts with a majority of incoming operations, the number of resource locks for the account can be reduced, and the operating pressure of the database is reduced. It solves the problems that exist in various existing accounting technologies when facing highly parallel accounting request scenarios.
In addition, in this specification, after the billing system stores the billing request as a pending billing request, since the billing operation corresponding to the billing request is not performed, the billing system may perform again before the transaction to which the billing request belongs ends. Judge. Determine whether there are still pending accounting requests belonging to the transaction, and if so, obtain a resource lock for the account, and perform accounting operations based on the stored pending accounting requests for the account , And determine the end of the transaction after the accounting operation is completed. If not, you can directly determine the end of the transaction.
Based on the accounting process shown in FIG. 1 and the above description of the accounting process, this specification correspondingly provides a detailed flowchart of accounting, as shown in FIG. 2.
S200: For each received accounting request, determine the account to which the accounting request is directed.
S202: Determine whether there is a pending accounting request that belongs to the same transaction as the accounting request and is stored for the same account. If yes, go to step S204, and if not, go to step S206;
S204: Determine whether it is necessary to deduct the balance of the account according to the billing request and the determined pending billing request, and if yes, perform step S208, and if not, perform step S210;
S206: Determine whether it is necessary to deduct the balance of the account according to the billing request, and if yes, perform step S212; if not, perform step S210;
S208: Obtain a resource lock of the account, and perform an accounting operation according to the accounting request and the determined pending accounting request;
S210: When the resource lock of the account cannot be acquired, the accounting request is stored as a pending accounting request.
S212: Acquire a resource lock of the account, and perform an accounting operation according to the accounting request.
Further, step S210 may further include:
S2100: determine whether the resource lock of the account is obtained, and if it is performed, perform step S2102; if not, perform step S2104;
S2102: Perform accounting operations;
S2104: Store the accounting request as a pending accounting request. As shown in Figure 3.
It should be noted that the execution subject of each step of the method provided in the embodiment of the present specification may be the same device, or the method may also use different devices as the execution subject. For example, the execution subject of steps S100 and S102 may be device 1, and the execution subject of step S102 may be device 2; or, the execution subject of step S100 may be device 1, and the execution subject of steps S102 and S104 may be device 2; and many more. The specific embodiments of the present specification have been described above. Other embodiments are within the scope of the appended patent applications. In some cases, the actions or steps described in the scope of the patent application may be performed in a different order than in the embodiments and still achieve the desired result. In addition, the processes depicted in the figures do not necessarily require a particular order or sequential order shown to achieve the desired result. In some embodiments, multiplexing and parallel processing are also possible or may be advantageous.
Based on the accounting method shown in FIG. 1, an embodiment of the present specification further provides a device for accounting, as shown in FIG. 4.
FIG. 4 is a schematic structural diagram of an accounting device provided by an embodiment of the present specification. The device includes:
The request determination module 300 determines, for each received accounting request, the account to which the accounting request is directed;
The accounting and storage module 302 determines whether there is a pending accounting request for the account in other accounting requests that belong to the same transaction as the accounting request, and determines whether it is needed based on the accounting request and the pending accounting request. Deduct the balance of the account, if yes, obtain the resource lock of the account, and perform the accounting operation; if not, store the accounting request as a pending accounting request when the resource lock of the account cannot be obtained;
In the accounting and storage module 302, when there is no pending accounting request for the account in other accounting requests belonging to the same transaction as the accounting request, it is determined whether the account needs to be deducted based on the accounting request. The balance, if yes, acquires the resource lock of the account, and performs the accounting operation; if not, when the resource lock of the account cannot be obtained, the accounting request is stored as a pending accounting request.
Before determining whether the balance of the account needs to be deducted, the accounting and storage module 302 determines and stores accounting details according to the accounting request, wherein the accounting details include an amount for performing an accounting operation on the account.
The accounting and storage module 302 determines the total amount of details of the accounting request and the pending accounting request based on the stored accounting details of the pending accounting request and the accounting details of the accounting request, and judges the accounting Specify whether the total expenditure is greater than income.
The operation type of the accounting operation corresponding to the accounting request includes one of freezing, thawing, flowing out, and flowing in.
The accounting and storage module 302 determines the operation type of the accounting request, and determines whether the operation type is an operation type other than the inflow operation type.
When there are pending accounting requests for the account in other accounting requests belonging to the same transaction as the accounting request, the accounting and storage module 302 obtains a resource lock of the account, and according to the accounting request and The unprocessed billing request performs a billing operation on the account.
When there is no pending accounting request for the account in other accounting requests belonging to the same transaction as the accounting request, the accounting and storage module 302 obtains a resource lock of the account, and according to the accounting request A billing operation is performed on the account.
When the accounting and storage module 302 determines that it is not necessary to deduct the balance of the account and obtains the resource lock of the account, it performs an accounting operation according to the accounting request, or according to the accounting request and the pending processing. Accounting request for accounting operations.
The device further includes:
The replenishment module 304 determines whether a pending accounting request for the account is still stored before the transaction ends, and if so, obtains a resource lock for the account, and determines the amount of the account lock according to the number of stored accounts. The pending accounting request of the account determines that the transaction ends after performing the accounting operation, and if not, determines that the transaction ends.
Based on the accounting method described in FIG. 1, this 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 perform the following steps by one or more processors:
For each billing request received, determine the account to which the billing request is directed;
When there are pending accounting requests for the account in other accounting requests belonging to the same transaction as the accounting request, determining whether the balance of the account needs to be deducted according to the accounting request and the pending accounting request, If it is, obtain the resource lock of the account and perform the accounting operation; if not, when the resource lock of the account cannot be obtained, store the accounting request as a pending accounting request;
When there is no pending billing request for the account in other billing requests belonging to the same transaction as the billing request, according to the billing request, determine whether the balance of the account needs to be deducted, and if so, obtain the account And perform a bookkeeping operation if the resource lock of the account is not obtained, and when the resource lock of the account cannot be obtained, store the bookkeeping request as a pending bookkeeping request.
In the 1990s, for a technical improvement, it can be clearly distinguished whether it is an improvement in hardware (for example, the improvement of circuit structures such as diodes, transistors, switches, etc.) or an improvement in software (for method and process Improve). However, with the development of technology, the improvement of many methods and processes can be regarded as a direct improvement of the hardware circuit structure. Designers almost always get the corresponding hardware circuit structure by designing the improved method flow program into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be realized by a hardware entity module. For example, a programmable logic device (Programmable Logic Device, PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user's programming of the device. Designers can program a digital system to "integrate" it on a PLD without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, today, instead of making integrated circuit chips manually, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development. The original source code before compilation must also be written in a specific programming language. This is called the Hardware Description Language (HDL), and HDL is not only one, but there are many types, such as 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), etc. Currently, the most commonly used are Very-High-Speed Integrated Circuit Hardware Description Language (VHDL) and Verilog. Those skilled in the art should also be clear that as long as the method flow is logically programmed and integrated into the integrated circuit using the above-mentioned several hardware description languages, the hardware circuit implementing the logic method flow can be easily obtained.
The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable storage of computer-readable code (such as software or firmware) executable by the (micro) processor. Media, logic gates, switches, application specific integrated circuits (ASICs), programmable logic controllers and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D , Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that, in addition to implementing the controller in pure computer-readable code, it is entirely possible to make the controller logic, gate, switch, special application integrated circuit, and programmable design by logic programming of method steps Logic controller and embedded microcontroller to achieve the same function. Therefore, the controller can be considered as a hardware component, and the device included in the controller for implementing various functions can also be considered as a structure in the hardware component. Or even, a device for implementing various functions can be regarded as a structure that can be both a software module implementing the method and a hardware component.
The system, device, module, or unit described in the foregoing embodiments may be specifically implemented by a computer chip or entity, or by a product having a certain function. A typical implementation is a computer. Specifically, the computer may be, for example, a personal computer, a laptop, 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 any combination of these devices.
For the convenience of description, when describing the above device, the functions are divided into various units and described separately. Of course, when implementing the present invention, the functions of each unit may be implemented in the same or multiple software and / or hardware.
Those skilled in the art should understand that the embodiments of the present invention may be provided as a method, a system, or a computer program product. Therefore, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk memory, CD-ROM, optical memory, etc.) containing computer-usable code therein. .
The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and a combination of the flow and / or block in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to generate a machine that can be executed by the processor of the computer or other programmable data processing device. The instructions generate means for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagram.
These computer program instructions may also be stored in computer readable memory that can guide a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory generate a manufactured article including a command device , The instruction device implements the functions specified in a flowchart or a plurality of processes and / or a block or a block of the block diagram.
These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operating steps can be performed on the computer or other programmable equipment to generate computer-implemented processing, and thus on the computer or other programmable equipment The instructions executed on the steps provide steps for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagram.
In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
Memory may include non-persistent memory, random access memory (RAM), and / or non-volatile memory in computer-readable media, such as read-only memory (ROM) or flash memory (flash) RAM). Memory is an example of a computer-readable medium.
Computer-readable media includes permanent and non-permanent, removable and non-removable media. Information can be stored by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), and other types of random access memory (RAM) Read-only memory (ROM), electrically erasable and programmable read-only memory (EEPROM), flash memory or other memory technologies, read-only disc read-only memory (CD-ROM), digital multifunction Optical discs (DVDs) or other optical storage, magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transmitting media may be used to store information that can be accessed by computing devices. According to the definition in this article, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
It should also be noted that the terms "including,""including," or any other variation thereof are intended to encompass non-exclusive inclusion, so that a process, method, product, or device that includes a range of elements includes not only those elements, but also Other elements not explicitly listed, or those that are inherent to such a process, method, product, or device. Without more restrictions, the elements defined by the sentence "including a ..." do not exclude the existence of other identical elements in the process, method, product or equipment including the elements.
Those skilled in the art should understand that the embodiments of the present invention may be provided as a method, a system or a computer program product. Therefore, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk memory, CD-ROM, optical memory, etc.) containing computer-usable code therein. .
The invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The invention can also be practiced in decentralized computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For the relevant part, refer to the description of the method embodiment.
The above description is only an embodiment of the present invention and is not intended to limit the present invention. It will be apparent to those skilled in the art that various modifications and variations can be made in the present invention. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the scope of the patent application of the present invention.

S100-S104‧‧‧步驟S100-S104‧‧‧step

S200-S212‧‧‧步驟 S200-S212‧‧‧step

S2100-S2104‧‧‧步驟 S2100-S2104‧‧‧step

300‧‧‧請求確定模組 300‧‧‧ Request confirmation module

302‧‧‧記帳以及儲存模組 302‧‧‧Accounting and storage module

304‧‧‧補帳模組 304‧‧‧ Make-up module

此處所說明的附圖用來提供對本發明的進一步理解,構成本發明的一部分,本發明的示意性實施例及其說明用於解釋本發明,並不構成對本發明的不當限定。在附圖中:The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The schematic embodiments of the present invention and the descriptions thereof are used to explain the present invention, and do not constitute an improper limitation on the present invention. In the drawings:

圖1為本說明書實施例提供的一種記帳的過程; FIG. 1 is a billing process provided by an embodiment of the present specification;

圖2為本說明書實施例提供記帳的詳細過程的示意圖; 2 is a schematic diagram of a detailed process of providing accounting in an embodiment of the present specification;

圖3為本說明書實施例提供的另一種記帳的詳細過程的示意圖; FIG. 3 is a schematic diagram of another detailed accounting process provided by an embodiment of the present specification; FIG.

圖4為本說明書實施例提供的一種記帳的裝置的結構示意圖; 4 is a schematic structural diagram of an accounting device provided by an embodiment of the present specification;

圖5為本說明書實施例提供的一種伺服器的結構示意圖。 FIG. 5 is a schematic structural diagram of a server provided by an embodiment of the present specification.

Claims (19)

一種記帳的方法,包括: 針對接收到的每個記帳請求,確定該記帳請求針對的帳戶; 當與該記帳請求屬於同一事務的其他記帳請求中,存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求以及所述待處理的記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存; 當與該記帳請求屬於同一事務的其他記帳請求中,不存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存。A method of billing, including: For each billing request received, determine the account to which the billing request is directed; When there are pending accounting requests for the account in other accounting requests belonging to the same transaction as the accounting request, determining whether the balance of the account needs to be deducted according to the accounting request and the pending accounting request, If it is, obtain the resource lock of the account and perform the accounting operation; if not, when the resource lock of the account cannot be obtained, store the accounting request as a pending accounting request; When there is no pending billing request for the account in other billing requests belonging to the same transaction as the billing request, according to the billing request, determine whether the balance of the account needs to be deducted, and if so, obtain the account And perform a bookkeeping operation if the resource lock of the account is not obtained, and when the resource lock of the account cannot be obtained, store the bookkeeping request as a pending bookkeeping request. 如申請專利範圍第1項所述的方法,判斷是否需要扣除所述帳戶的餘額之前,所述方法還包括: 根據該記帳請求,確定記帳明細並儲存,其中所述記帳明細中包括對所述帳戶進行記帳操作的金額。Before applying the method described in item 1 of the patent scope, before determining whether the balance of the account needs to be deducted, the method further includes: According to the billing request, a billing detail is determined and stored, where the billing detail includes an amount for performing a billing operation on the account. 如申請專利範圍第2項所述的方法,根據該記帳請求以及所述待處理的記帳請求,判斷是否需要扣除所述帳戶的餘額,具體包括: 根據儲存的所述待處理的記帳請求的記帳明細,以及該記帳請求的記帳明細,確定該記帳請求以及所述待處理的記帳請求的明細總額; 判斷所述明細總額的支出是否大於收入。According to the method described in item 2 of the scope of patent application, determining whether the balance of the account needs to be deducted according to the billing request and the pending billing request, specifically including: Determining the total amount of details of the accounting request and the pending accounting request according to the stored accounting details of the pending accounting request and the accounting details of the accounting request; Determine whether the total expenditure of the details is greater than income. 如申請專利範圍第1項所述的方法,所述記帳請求對應的記帳操作的操作類型包括:凍結、解凍、流出以及流入中的一種。According to the method described in item 1 of the scope of patent application, the operation type of the accounting operation corresponding to the accounting request includes one of freezing, thawing, flowing out, and flowing in. 如申請專利範圍第4項所述的方法,根據該記帳請求,判斷是否需要扣除所述帳戶的餘額,具體包括: 確定該記帳請求的操作類型; 判斷所述操作類型是否是流入操作類型以外的其他操作類型。According to the method described in item 4 of the scope of patent application, whether to deduct the balance of the account according to the billing request specifically includes: Determine the type of operation for this billing request; It is determined whether the operation type is an operation type other than the inflow operation type. 如申請專利範圍第1項所述的方法,當與該記帳請求屬於同一事務的其他記帳請求中,存在針對所述帳戶的待處理的記帳請求時; 獲取所述帳戶的資源鎖,進行記帳操作,具體包括: 獲取所述帳戶的資源鎖,並根據該記帳請求以及所述未處理的記帳請求,對所述帳戶進行記帳操作。As in the method described in the first patent application scope, when there is a pending billing request for the account in other billing requests that belong to the same transaction as the billing request; Obtaining a resource lock of the account and performing an accounting operation specifically include: Acquiring a resource lock of the account, and performing a billing operation on the account according to the billing request and the unprocessed billing request. 如申請專利範圍第1項所述的方法,當與該記帳請求屬於同一事務的其他記帳請求中,不存在針對所述帳戶的待處理的記帳請求時; 獲取所述帳戶的資源鎖,進行記帳操作,具體包括: 獲取所述帳戶的資源鎖,並根據該記帳請求對所述帳戶進行記帳操作。As in the method described in item 1 of the scope of patent application, when there is no pending billing request for the account in other billing requests that belong to the same transaction as the billing request; Obtaining a resource lock of the account and performing an accounting operation specifically include: Acquiring a resource lock of the account, and performing an accounting operation on the account according to the accounting request. 如申請專利範圍第1項所述的方法,當判斷不需要扣除所述帳戶的餘額,且獲取到了所述帳戶的資源鎖時,則根據該記帳請求進行記帳操作,或根據該記帳請求以及所述待處理的記帳請求進行記帳操作。According to the method described in item 1 of the scope of patent application, when it is judged that the balance of the account does not need to be deducted, and the resource lock of the account is obtained, the accounting operation is performed according to the accounting request, or according to the accounting request and the Describe the pending accounting request for accounting operations. 如申請專利範圍第1項所述的方法,所述方法還包括: 當所述事務結束之前,判斷是否仍儲存有針對所述帳戶的待處理的記帳請求; 若是,則獲取所述帳戶的資源鎖,並在根據已儲存的若干針對所述帳戶的待處理的記帳請求,進行記帳操作之後,確定所述事務結束; 若否,則確定所述事務結束。The method according to item 1 of the patent application scope, further comprising: Before the transaction ends, determining whether a pending billing request for the account is still stored; If yes, then acquire the resource lock of the account, and determine the end of the transaction after performing an accounting operation based on a number of pending accounting requests for the account that have been stored; If not, it is determined that the transaction ends. 一種記帳的裝置,包括: 請求確定模組,針對接收到的每個記帳請求,確定該記帳請求針對的帳戶; 記帳以及儲存模組,當與該記帳請求屬於同一事務的其他記帳請求中,存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求以及所述待處理的記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存; 所述記帳以及儲存模組,當與該記帳請求屬於同一事務的其他記帳請求中,不存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存。An accounting device includes: The request determination module determines, for each received accounting request, the account to which the accounting request is directed; The billing and storage module, when other billing requests belonging to the same transaction as the billing request have a pending billing request for the account, determine whether a deduction is required based on the billing request and the pending billing request If the balance of the account is obtained, obtain the resource lock of the account and perform the accounting operation; if not, store the accounting request as a pending accounting request when the resource lock of the account cannot be obtained; In the accounting and storage module, when there is no pending accounting request for the account in other accounting requests belonging to the same transaction as the accounting request, it is determined whether the balance of the account needs to be deducted based on the accounting request. If yes, acquire the resource lock of the account and perform the accounting operation; if not, when the resource lock of the account cannot be obtained, store the accounting request as a pending accounting request. 如申請專利範圍第10項所述的裝置,所述記帳以及儲存模組,判斷是否需要扣除所述帳戶的餘額之前,根據該記帳請求,確定記帳明細並儲存,其中所述記帳明細中包括對所述帳戶進行記帳操作的金額。According to the device described in claim 10 of the patent application, the accounting and storage module determines whether the balance of the account needs to be deducted before determining and storing the accounting details according to the accounting request, wherein the accounting details include The amount of the account for the accounting operation. 如申請專利範圍第11項所述的裝置,所述記帳以及儲存模組,根據儲存的所述待處理的記帳請求的記帳明細,以及該記帳請求的記帳明細,確定該記帳請求以及所述待處理的記帳請求的明細總額,判斷所述明細總額的支出是否大於收入。According to the device according to item 11 of the scope of the patent application, the accounting and storage module determines the accounting request and the accounting information according to the stored accounting details of the pending accounting request and the accounting details of the accounting request. The total amount of details of the processed accounting request determines whether the expenditure of the total amount of details is greater than income. 如申請專利範圍第10項所述的裝置,所述記帳請求對應的記帳操作的操作類型包括:凍結、解凍、流出以及流入中的一種。According to the device described in claim 10, the operation type of the accounting operation corresponding to the accounting request includes one of freezing, thawing, flowing out, and flowing in. 如申請專利範圍第13項所述的裝置,所述記帳以及儲存模組,確定該記帳請求的操作類型,判斷所述操作類型是否是流入操作類型以外的其他操作類型。According to the device described in claim 13, the accounting and storage module determine the operation type of the accounting request, and determine whether the operation type is an operation type other than the inflow operation type. 如申請專利範圍第10項所述的裝置,當與該記帳請求屬於同一事務的其他記帳請求中,存在針對所述帳戶的待處理的記帳請求時,所述記帳以及儲存模組,獲取所述帳戶的資源鎖,並根據該記帳請求以及所述未處理的記帳請求,對所述帳戶進行記帳操作。According to the device described in claim 10, when there are pending accounting requests for the account in other accounting requests belonging to the same transaction as the accounting request, the accounting and storage module obtains the accounting request. The account is locked for resources, and an accounting operation is performed on the account according to the accounting request and the unprocessed accounting request. 如申請專利範圍第10項所述的裝置,當與該記帳請求屬於同一事務的其他記帳請求中,不存在針對所述帳戶的待處理的記帳請求時,所述記帳以及儲存模組,獲取所述帳戶的資源鎖,並根據該記帳請求對所述帳戶進行記帳操作。According to the device described in claim 10 of the patent application scope, when there is no pending billing request for the account in other billing requests belonging to the same transaction as the billing request, the billing and storage module obtains all The account is resource locked, and an accounting operation is performed on the account according to the accounting request. 如申請專利範圍第10項所述的裝置,所述記帳以及儲存模組,當判斷不需要扣除所述帳戶的餘額,且獲取到了所述帳戶的資源鎖時,則根據該記帳請求進行記帳操作,或根據該記帳請求以及所述待處理的記帳請求進行記帳操作。According to the device described in claim 10, the accounting and storage module, when it is judged that the balance of the account does not need to be deducted, and the resource lock of the account is obtained, the accounting operation is performed according to the accounting request , Or perform an accounting operation according to the accounting request and the pending accounting request. 如申請專利範圍第10項所述的裝置,所述裝置還包括: 補帳模組,當所述事務結束之前,判斷是否仍儲存有針對所述帳戶的待處理的記帳請求,若是,則獲取所述帳戶的資源鎖,並在根據已儲存的若干針對所述帳戶的待處理的記帳請求,進行記帳操作之後,確定所述事務結束,若否,則確定所述事務結束。The device according to item 10 of the patent application scope, further comprising: The replenishment module, before the transaction ends, determines whether a pending accounting request for the account is still stored, and if so, obtains a resource lock for the account, and based on the number of stored accounts for the account For the pending accounting request, after the accounting operation is performed, it is determined that the transaction is ended, and if not, it is determined that the transaction is ended. 一種伺服器,其中,所述伺服器包括:一個或多個處理器及記憶體,記憶體儲存有程式,並且被配置成由一個或多個處理器執行以下步驟: 針對接收到的每個記帳請求,確定該記帳請求針對的帳戶; 當與該記帳請求屬於同一事務的其他記帳請求中,存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求以及所述待處理的記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存; 當與該記帳請求屬於同一事務的其他記帳請求中,不存在針對所述帳戶的待處理的記帳請求時,根據該記帳請求,判斷是否需要扣除所述帳戶的餘額,若是,則獲取所述帳戶的資源鎖,進行記帳操作,若否,則在不能獲取所述帳戶的資源鎖時,將該記帳請求作為待處理的記帳請求進行儲存。A server, wherein the server includes: one or more processors and a memory, the memory stores a program, and is configured to perform the following steps by the one or more processors: For each billing request received, determine the account to which the billing request is directed; When there are pending accounting requests for the account in other accounting requests belonging to the same transaction as the accounting request, determining whether the balance of the account needs to be deducted according to the accounting request and the pending accounting request, If it is, obtain the resource lock of the account and perform the accounting operation; if not, when the resource lock of the account cannot be obtained, store the accounting request as a pending accounting request; When there is no pending billing request for the account in other billing requests belonging to the same transaction as the billing request, according to the billing request, determine whether the balance of the account needs to be deducted, and if so, obtain the account And perform a bookkeeping operation if the resource lock of the account is not obtained, and when the resource lock of the account cannot be obtained, store the bookkeeping request as a pending bookkeeping request.
TW108101005A 2018-03-29 2019-01-10 Accounting method and device TWI684944B (en)

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
CN201810270039.3A CN108615184B (en) 2018-03-29 2018-03-29 Accounting method and device
??201810270039.3 2018-03-29
CN201810270039.3 2018-03-29

Publications (2)

Publication Number Publication Date
TW201942843A true TW201942843A (en) 2019-11-01
TWI684944B TWI684944B (en) 2020-02-11

Family

ID=63659058

Family Applications (1)

Application Number Title Priority Date Filing Date
TW108101005A TWI684944B (en) 2018-03-29 2019-01-10 Accounting method and device

Country Status (3)

Country Link
CN (1) CN108615184B (en)
TW (1) TWI684944B (en)
WO (1) WO2019184571A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108615184B (en) * 2018-03-29 2020-12-18 创新先进技术有限公司 Accounting method and device
CN110020931B (en) * 2019-01-10 2024-02-09 创新先进技术有限公司 Accounting and abnormal business identification method and device
CN109919623B (en) * 2019-02-28 2021-08-13 泰康保险集团股份有限公司 Method, device and equipment for preventing account overdraft and readable storage medium
CN110827001A (en) * 2019-11-07 2020-02-21 深圳乐信软件技术有限公司 Accounting event bookkeeping method, system, equipment and storage medium
CN111930855A (en) * 2020-06-24 2020-11-13 山东浪潮通软信息科技有限公司 Account book accounting method, device, equipment and medium
CN112685189B (en) * 2020-12-24 2024-03-22 北京中交兴路信息科技有限公司 Method, device, equipment and medium for realizing data processing
CN115034902A (en) * 2022-06-21 2022-09-09 支付宝(杭州)信息技术有限公司 Accounting processing method and device

Family Cites Families (13)

* Cited by examiner, † Cited by third party
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 (en) * 2008-07-04 2013-10-16 阿里巴巴集团控股有限公司 Buffer bookkeeping method and device
CN101639792B (en) * 2008-07-29 2016-04-06 阿里巴巴集团控股有限公司 A kind of concurrent data disposal route, device and a kind of electronic accounting system
CN105869043A (en) * 2015-01-19 2016-08-17 阿里巴巴集团控股有限公司 Disperse hot spot database account transfer-in and transfer-out accounting method and device
US10535063B2 (en) * 2015-03-13 2020-01-14 First Data Corporation Systems and methods for securing digital gift cards with a public ledger
CN107153649B (en) * 2016-03-02 2020-06-30 阿里巴巴集团控股有限公司 Data backup method and device
CN106127568A (en) * 2016-06-15 2016-11-16 中国人民银行清算总中心 The clearing operation queue rescue method of inter-bank payment system and device
CN107015869B (en) * 2017-01-16 2018-08-31 平安银行股份有限公司 Transaction keeps accounts control method and system
CN107016604A (en) * 2017-02-22 2017-08-04 阿里巴巴集团控股有限公司 Buffer method, device and the equipment of book keeping operation
CN106952158A (en) * 2017-03-17 2017-07-14 证通股份有限公司 Solve the problems, such as the bookkeeping methods and equipment of focus account
CN107274162A (en) * 2017-05-31 2017-10-20 深圳市长亮科技股份有限公司 A kind of processing method of high transaction concurrency
CN108615184B (en) * 2018-03-29 2020-12-18 创新先进技术有限公司 Accounting method and device

Also Published As

Publication number Publication date
CN108615184B (en) 2020-12-18
TWI684944B (en) 2020-02-11
WO2019184571A1 (en) 2019-10-03
CN108615184A (en) 2018-10-02

Similar Documents

Publication Publication Date Title
TWI684944B (en) Accounting method and device
TWI752118B (en) A blockchain consensus method and device
TWI679547B (en) Block chain business acceptance and business consensus method and device
CA3048740C (en) Blockchain-based data processing method and device
JP7048738B2 (en) Virtual card opening method and system, payment system, and card issuing system
CN109040152B (en) Service request and providing method and device based on service arrangement and electronic equipment
TWI694342B (en) Data cache method, device and system
TWI767106B (en) Method, device and device for configuring payment process and executing payment process
CN110008018B (en) Batch task processing method, device and equipment
CN109002362A (en) A kind of method of servicing, device, system and electronic equipment
TW201909596A (en) Data processing method and device based on blockchain
TW201939386A (en) Consensus verification method, apparatus and equipment
CN108566420A (en) Data processing method, equipment and computer readable storage medium for block chain
CN107016016B (en) Data processing method and device
CN107016029B (en) Method, device and system for processing service data
TWI679581B (en) Method and device for task execution
WO2021143397A1 (en) Resource reuse method, apparatus and device based on gpu virtualization
CN110297837B (en) Data updating method and device and data query method and device
WO2020019892A1 (en) Bookkeeping method and device, and integrated transaction and finance system
CN109033124A (en) A kind of method and device of Data Migration
WO2021239087A1 (en) Data processing method, apparatus and device, and medium
CN116305298B (en) Method and device for managing computing power resources, storage medium and electronic equipment
TWI723535B (en) Data calculation method and engine
CN108346039B (en) Service processing method, device and equipment of Internet financial settlement system
TW202016737A (en) Disaster recovery data processing method, device and system