TWI684944B - Accounting method and device - Google Patents

Accounting method and device Download PDF

Info

Publication number
TWI684944B
TWI684944B TW108101005A TW108101005A TWI684944B TW I684944 B TWI684944 B TW I684944B TW 108101005 A TW108101005 A TW 108101005A TW 108101005 A TW108101005 A TW 108101005A TW I684944 B TWI684944 B TW I684944B
Authority
TW
Taiwan
Prior art keywords
billing
request
account
accounting
pending
Prior art date
Application number
TW108101005A
Other languages
Chinese (zh)
Other versions
TW201942843A (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

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/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

Abstract

本發明公開了一種記帳的方法及裝置,針對接收到的每個記帳請求,先確定該記帳請求針對的帳戶。之後,可先判斷是否存在與該記帳請求屬於同一事務且針對同一帳戶的待處理的記帳請求。若不存在,則可根據該記帳請求是否需要扣除該帳戶的餘額,確定是否可將該記帳請求作為待處理記帳請求進行儲存。而若存在,則需要根據該記帳請求以及待處理的記帳請求,確定是否可將該記帳請求作為待處理記帳請求進行儲存。The invention discloses a billing method and device. For each billing request received, the account to which the billing request is directed is determined first. After that, you can first determine whether there is a pending accounting request that belongs to the same transaction as the accounting request and is 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 deduct the balance of the account. If it exists, it is necessary to determine whether the accounting request can be stored as a pending accounting request according to the accounting request and the accounting request to be processed.

Description

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

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

記帳是指將企事業單位、個人或者家庭發生的經濟業務,按照一定的記錄方法在帳簿上記錄的行為。 在帳務資料庫的處理中,資料從一個帳戶轉出,或者有資料轉入一個帳戶,帳戶都會收到記帳請求,並都有一個記帳處理的過程。 記帳處理過程主要包括兩部分,一是記錄記帳憑證,二是更新帳戶的餘值。為了保證帳戶不被其他請求影響資料的準確性,在進行記帳處理時,會先對帳戶的資源加鎖,記帳處理完畢後會自動釋放鎖。隨著帳務處理業務量的增大,帳務資料庫中的帳戶常常會在瞬間產生多個併發操作,但所有對應的併發執行緒中只有一個執行緒能夠持有當前帳戶的資源鎖,其他執行緒必須等待該鎖被釋放後 再逐一進行記帳處理,這樣該帳戶將會被頻繁加鎖釋鎖,使該帳戶成為帳務資料庫熱點,產生性能瓶頸點,嚴重影響帳務資料庫的性能。 目前,隨著無紙化辦公的普及,通常由記帳系統對各帳戶進行記帳。而為了防止多個執行緒對同一個帳戶進行併發的記帳操作,導致資料錯誤,在標準記帳過程中,記帳系統需要先對該帳戶寫鎖,使得只有持有該鎖的執行緒可以對該帳戶進行操作,並在記帳完成之後再釋放該帳戶的鎖。 而對電子商務平臺來說,交易業務存在高度並行的特點。這就使得,標準記帳過程對帳戶的寫鎖操作,嚴重影響了業務執行的效率。除了導致記帳系統運行壓力增大以外,還容易導致交易業務由於等待超時而失敗。 因此,在現有的電子商務平臺的記帳系統中,對於有高度並行記帳需求的帳戶,可預先為該帳戶配置緩衝記帳的記帳方法,以避免標準記帳過程導致的一系列問題。 具體的,在對帳戶進行緩衝記帳時,記帳系統無需即時更新該帳戶的餘額,而是按週期由各執行緒根據對該帳戶的記帳請求,確定該帳戶的各記帳明細並儲存在資料庫中。其中,該週期具體時長,可根據需要設置。 由各執行緒分別根據週期內對該帳戶的記帳請求,確定記帳明細並儲存在資料庫中。其中,該一段時間具體多長,可根據需要設置。因此記帳系統在每個週期內無需因為記帳而對該帳戶寫鎖,而執行緒也無需對帳戶進行記帳操作,如表1所示。 帳戶標識 執行緒 記帳請求 記帳明細 帳戶a 執行緒1 記帳請求1 收入100 執行緒5 記帳請求2 支出10 ……       執行緒n 記帳請求m 凍結20 表1 在表1中,可見記帳系統中的不同的執行緒,可根據不同的記帳請求,確定針對帳戶a的若干記帳明細,並儲存在資料庫中。 並在每個週期結束時,由記帳系統對該帳戶寫鎖,並根據資料庫中儲存的各記帳明細的,確定該帳戶的餘額並進行調整。以及將各記帳明細對應的該帳戶的餘額變動情況進行補記。其中,對帳戶的餘額調整以及將記帳明細進行補記的過程可以是非同步進行的。 另外,在該帳戶的餘額並進行調整時,記帳系統是根據各記帳明細,確定各記帳明細對應的總記帳結果,以根據總記帳結果調整帳戶的餘額。例如,假設分別存在記帳明細收入100元,支出10元以及支出20元,則記帳系統可確定總記帳結果為收入70元。 但是,現有緩衝記帳的記帳方法,由於在調整帳戶餘額之前,無法確定週期內各記帳明細的總記帳結果,所以存在帳戶透支的風險。所以一般需要根據人工經驗預先判斷需要配置以及可以配置緩衝記帳的帳戶,使得現有緩衝記帳的記帳方法在配置時不夠靈活,且依賴人工經驗,存在風險。 可見,現有技術的各種記帳方法,在面對高度並行的交易業務時,仍存在多個方面的缺陷。因此,本說明書提供一種新的記帳方法。 Bookkeeping refers to the act of recording economic transactions that have occurred in enterprises, institutions, individuals or households in the account book according to a certain recording method. In the processing of the accounting database, if the data is transferred from an account, or if the data is transferred to an account, the account will receive the accounting request, and there will be an accounting process. The accounting processing process mainly includes two parts, one is to record accounting vouchers, and the other is to update the remaining value of the account. In order to ensure that the account is not affected by other requests, the accuracy of the data will be locked during the accounting process, and the lock will be released automatically after the accounting process is completed. As the volume of account processing business increases, the accounts in the account 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. The thread must wait for the lock to be released and then proceed with the accounting process one by one, so that the account will be frequently locked and released, making the account a hotspot in the accounting database, causing performance bottlenecks and seriously affecting the performance of the accounting database . At present, with the popularization of paperless office, each account is usually accounted by the 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 write a lock on the account first, so that only the thread holding the lock can access the account Perform the operation and release the account lock after the accounting is completed. For e-commerce platforms, the transaction business is highly parallel. This makes the write lock operation of the account by the standard accounting process seriously affect the efficiency of business execution. In addition to increasing the operating pressure of the billing system, it is also easy to cause transaction services to fail due to waiting timeout. Therefore, in the accounting system of the existing e-commerce platform, for accounts with high parallel accounting requirements, the accounting method of buffer accounting can be configured for the account in advance to avoid a series of problems caused by the standard accounting process. Specifically, when buffering an account, 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 and stores it in the database according to the cycle. . The specific duration of this period can be set as required. Each thread determines the accounting details and stores them in the database according to the accounting request for the account in the cycle. Among them, how long the period of time is, can be set according to needs. Therefore, the accounting system does not need to write a lock on the account for accounting in each cycle, and the thread does not need to perform accounting operations on the account, as shown in Table 1. Account ID Thread Billing request Billing details Account a Thread 1 Accounting request 1 Income 100 Thread 5 Accounting request 2 Expenditure 10 ... Thread n Accounting request m Freeze 20 Table 1 In Table 1, we can see the different threads in the accounting system. According to different accounting requests, several accounting details for account a can be determined and stored in the database. And 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 according to the accounting details stored in the database. And make up the balance changes of the account corresponding to each billing detail. Among them, the process of adjusting the balance of the account and replenishing the accounting details may be performed asynchronously. In addition, when adjusting the balance of the account, the accounting system determines the total accounting result corresponding to each accounting detail based on each accounting detail, so as to adjust the account balance according to the total accounting result. For example, assuming that there is an accounting detail income of 100 yuan, an expenditure of 10 yuan, and an expenditure of 20 yuan, the accounting system may determine that the total accounting result is revenue of 70 yuan. However, in the existing accounting method of buffering accounting, before adjusting the account balance, the total accounting result of each accounting detail in the period cannot be determined, so there is a risk of account overdraft. Therefore, it is generally necessary to pre-determine the accounts that need to be configured and can be configured with buffer accounting based on manual experience, so that the existing accounting methods for buffer accounting are not flexible enough during configuration, and rely on manual experience, which involves risks. It can be seen that the various accounting methods of the prior art still have many shortcomings 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 faced with highly parallel transaction services, it is necessary to configure an account for buffer accounting in advance, and the configuration parameters also need to rely on manual experience. The problem of multiple defects. The embodiments of this specification adopt the following technical solutions: A method of accounting, including: For each billing request received, determine the account to which the billing request is directed; When there is a pending billing request for the account among other billing requests belonging to the same transaction as the billing request, according to the billing request and the pending billing request, it is determined whether the balance of the account needs to be deducted, If yes, acquire 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 acquired; When there is no pending billing request for the account in other billing requests that belong 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, and if so, the account is obtained To 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 billing device, including: The request determination module determines, for each accounting request received, the account to which the accounting request is directed; The billing and storage module, when there is a pending billing request for the account among other billing requests that belong to the same transaction as the billing request, determine whether a deduction is required based on the billing request and the pending billing request If the balance of the account is yes, then obtain the resource lock of the account to perform the accounting operation; if not, when the resource lock of the account cannot be acquired, store the accounting request as a pending accounting request; The billing and storage module, 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 the balance of the account needs to be deducted based on the billing request If it is, then acquire the resource lock of the account to perform the accounting operation; if not, store the accounting request as a pending accounting request when the resource lock of the account cannot be acquired. A server, wherein the server includes: one or more processors and a memory, the memory stores a program, and is configured to be executed by one or more processors to perform the following steps: For each billing request received, determine the account to which the billing request is directed; When there is a pending billing request for the account among other billing requests belonging to the same transaction as the billing request, according to the billing request and the pending billing request, it is determined whether the balance of the account needs to be deducted, If yes, acquire 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 acquired; When there is no pending billing request for the account in other billing requests that belong 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, and if so, the account is obtained To 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. The above 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 billing request received, the account to which the billing request is directed is determined first. After that, you can first determine whether there is a pending accounting request that belongs to the same transaction as the accounting request and is 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 deduct the balance of the account. If it exists, it is necessary to determine whether the accounting request can be stored as a pending accounting request according to the accounting request and the accounting request to be processed. In other words, if there are several pending accounting requests that do not need to be deducted from the account balance, you can store the pending accounting requests first without obtaining the account's resource lock without waiting in line for the accounting operation. When the transaction concurrency rate is high, the accounting operation is more flexible, while ensuring that the account will not be exposed to risks. Moreover, there is no need to manually configure the account, so that the efficiency of the billing operation is improved and the risk is reduced.

為使本說明書的目的、技術方案和優點更加清楚,下面將結合本說明書具體實施例及相應的附圖對本發明技術方案進行清楚、完整地描述。顯然,所描述的實施例僅是本發明一部分實施例,而不是全部的實施例。基於說明書中的實施例,本領域普通技術人員在沒有做出進步性勞動前提下所獲得的所有其他實施例,都屬於本發明保護的範圍。 以下結合附圖,詳細說明本發明各實施例提供的技術方案。 圖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 表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 solutions and advantages of the description clearer, the technical solutions of the present invention will be described clearly and completely in conjunction with the specific embodiments of the description and the accompanying 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 specification, and may specifically include the following steps: S100: For each billing request received, determine an account to which the billing request is directed. In one or more embodiments of this specification, the billing system may accept the billing request and perform the operations of the subsequent steps. Wherein, the accounting system may include: a server for performing accounting operations, and a database storing accounting-related data 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 following description will use the accounting system as the main body to execute the accounting process. Thus, in this specification, the billing system can receive billing requests. Among them, since accounting is a record of economic activity, which is generated according to the accounting needs when the business is executed, the accounting system usually also receives the accounting request sent by the system that performs the business. Of course, this specification does not limit how the billing request is specifically generated. Since 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 that performs the business may 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, business identifier, etc.). In addition, the billing process provided in this specification is mainly used to solve the problems existing in the scenario of highly parallel billing requests in the prior art. Therefore, this specification has also used the scene of highly parallel billing requests as an example for subsequent description. Therefore, the billing system can receive several billing requests, and for each billing request received, the account to which the billing request is directed can be determined. 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 accounts that are not exactly the same, and may also be performing different transactions. Generated at the time, so the billing system can first determine the account for each billing request received in order to determine the operation of the subsequent steps. For example, assume that the billing system receives the billing request shown in Table 2 at a certain moment. Billing request Targeted account Corresponding transaction content Accounting request n Account a Transaction 001 Pay 10 yuan Accounting request n+1 Account c Transaction 001 Freeze 100 yuan ... ... ... ... Accounting request m Account f Transaction 101 Income 20 yuan Table 2 The billing requests received by the billing system at the same time can correspond to incomplete accounts and incomplete transactions. Therefore, the billing system can determine the account to which the billing request is directed for each billing request, so as to facilitate the operation of the subsequent steps. S102: When there is a billing request that is pending for the account among other billing requests that belong to the same transaction as the billing request, it is determined whether the account needs to be deducted based on the billing request and the pending billing request The balance, if it is, acquires the resource lock of the account to perform the accounting operation, and if not, stores the accounting request as a pending accounting request when the resource lock of the account cannot be acquired. In this specification, since each accounting request received in step S100 determines the account to which the accounting request is directed, in step S102, the explanation is still based on the accounting request. In addition, in this specification, according to the different contents of the billing request, the billing operation corresponding to the billing request can be divided into four types of operations, namely, freezing operation, unfreezing operation, outflow operation, and inflow operation. The reason why the accounting operation corresponding to the accounting request in the prior art needs to be performed synchronously is: if the accounting is not performed synchronously, the transaction execution result may cause the value of the deduction amount to be greater than the value of the balance in the account, which may cause an error or exception 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 operation type and corresponding content corresponding to the accounting request. If it is, then 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 the corresponding accounting operation is performed before the transaction to which the accounting request belongs ends. That is, the accounting operation is performed asynchronously, and the accounting operation corresponding to the accounting request is not completed from the highly parallel scenario solved, and the transaction will not continue to be executed, resulting in various problems (such as long transaction waiting time, affecting efficiency, or transaction (Timeout causes transaction execution failure and so on). Specifically, since the billing requests corresponding to different transactions cannot be settled together, and the billing requests for different accounts cannot be settled together, the billing system can determine whether there is the same transaction as the billing request according to the billing request determined in step S100, And the billing request is for a pending billing request of the same account. If yes, step S102 is executed; otherwise, step S104 is executed. In step S102 of the present specification, the case where there is a pending billing request that belongs to the same transaction and is directed to the same account as the billing request is described. 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 billing operation. After that, according to the billing details of the billing request and the billing details of the pending billing request, the total amount of the detail is determined, and finally whether the expenditure of the total amount of the detail is greater than the income is determined. If yes, the account balance needs to be deducted, indicating that if the accounting operation is not performed synchronously, the account balance may be wrong. Therefore, the accounting system can obtain the resource lock of the account according to the accounting request and the pending accounting request to perform the accounting operation. Of course, if it is impossible to obtain the resource lock of the account, it can be in line with the standard accounting process, waiting in line to obtain the lock. If not, it means that there is no need to deduct the account balance for each billing request for the account in the current transaction. If the billing operation is not performed synchronously, the account balance will be wrong, so the billing system can remove the account’s resource lock when 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 the accounting operation can be performed according to the accounting request and the pending accounting request. It should be noted that, in this specification, there may be multiple billing requests determined by the billing system to be processed. For example, suppose that during the execution of a thing, in accordance with the chronological order, accounting request 1 ~ accounting request 3 are generated, respectively: account b balance increases by 100 yuan, account b balance increases by 50 yuan, and account b balance spends 10 yuan . It can be seen that the total amount of detail of the above three accounting requests is: the balance of account b is increased by 140 yuan. as shown in Table 3. Billing request Targeted account Corresponding transaction Billing details Total breakdown Accounting request 1 Account b Transaction 002 Inflow operation, 100 yuan $100 increase Accounting request 2 Account b Transaction 002 Inflow operation, 50 yuan 150 yuan increase Accounting request 3 Account b Transaction 002 Expenditure operation, 10 yuan Increase by 140 yuan Table 3 The total amount of detail corresponding to the accounting request for each line in Table 2 is the total amount of detail determined for the current accounting request of account b in transaction 002. Therefore, when the billing system receives the above billing requests 1 to 3, if none of the resource locks of the account b can be obtained, the three billing requests can be sequentially stored as pending billing requests. Further suppose that during the execution of the transaction, an accounting request 4 was generated as follows: the balance of account b increased by 50 yuan, then the accounting system can further determine that the total expenditure of the detail 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. Suppose, during the execution of the transaction, the generated accounting request 4 is: the account b balance is deducted by 200 yuan, then the accounting system can determine that the total amount of expenditure is greater than the income, then at this time, the accounting system needs to obtain the resource lock of account b, and Perform accounting operations. It can be seen that, in this specification, as long as it corresponds to the same transaction, and the total amount of expenditures for several accounting requests for the same account is not greater than income, the accounting system can use the accounting request as pending storage when it cannot obtain the resource lock for the account 'S accounting request is stored. It is because the execution of the transaction can continue, and the efficiency of the transaction execution will not decrease because of waiting in line for the resource lock. At the same time, it can also reduce the number of threads waiting in line to obtain resource locks, reducing the operating pressure of the database. S104: When there is no pending billing request for the account among other billing requests that belong 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. The resource lock of the account is used to perform 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, based on the judgment step described in the foregoing step S102, if the billing system can determine that other billing requests that belong to the same transaction as the billing request, there is no pending billing request for the account, the billing system can According to the type of billing operation of the billing request, it is determined whether the resource lock of the account needs to be acquired. As for each type of billing operation, except for the inflow operation, there are cases where the amount of money is spent from the account balance in other billing operations, so the billing system determines that there are no pending billing requests, and can only bill based on the billing request Operation type, to determine whether the type of the accounting operation is other than the inflow operation. If it is, it is consistent with the description in step S102. The accounting system can use the process of marking the account to perform the accounting operation. 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 billing process shown in FIG. 1, when the billing system receives the billing request, it can determine whether to perform the billing operation asynchronously when the resource lock of the account cannot be obtained according to the billing details corresponding to the billing request. Or, when there is a pending billing request that belongs to the same transaction as the billing request and is for the same account, it is determined whether the asynchronous billing operation can be performed according to the total amount of details of the billing request and the pending billing request. This eliminates the need to configure in advance whether the account can perform asynchronous accounting operations. In addition to reducing the cost of manual configuration, it also avoids the account risk caused by the existing buffer accounting. In addition, for accounts with a majority of inflow operations, the number of resource locks for the account can be reduced and the operating pressure of the database can be reduced. It solves the problems existing in the existing various billing technologies when facing highly parallel billing 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 has not been performed, the billing system can perform again before the transaction to which the billing belongs belongs ends judgment. Determine whether there is still a pending billing request for the account that belongs to the transaction, and if so, acquire the resource lock for the account and perform the billing operation based on the stored pending billing 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 provides a detailed flowchart of accounting, as shown in FIG. 2. S200: For each billing request received, determine the account to which the billing request is directed. S202: determine whether there is a pending accounting request that belongs to the same transaction as the accounting request and is for the same account, if so, step S204 is executed, and if not, step S206 is executed; S204: according to the accounting request and the determined The pending accounting request determines whether the balance of the account needs to be deducted, if yes, step S208 is executed, and if not, step S210 is executed; S206: According to the accounting request, whether the balance of the account needs to be deducted is determined, if yes Step S212, if not, step S210 is executed; S208: acquiring the resource lock of the account, performing accounting operations according to the accounting request and the determined pending accounting request; S210: unable to acquire the resource lock of the account At this time, 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 specifically include: S2100: determine whether the resource lock of the account is obtained, if step S2102 is executed, if not, step S2104 is executed; S2102: perform accounting operation; S2104: perform the accounting request as pending The processed accounting request is stored. As shown in Figure 3. It should be noted that, the execution body of each step of the method provided in the embodiments of the present specification may be the same device, or the method may also be performed by different devices. For example, the execution subject of step S100 and step 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 step S102 and step S104 may be device 2; and many more. The foregoing describes specific embodiments of the present specification. Other embodiments are within the scope of the attached patent application. 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 embodiment and still achieve the desired result. In addition, the processes depicted in the drawings do not necessarily require the particular order shown or sequential order to achieve the desired results. In some embodiments, multiplexing and parallel processing are also possible or may be advantageous. Based on the billing method shown in FIG. 1, an embodiment of this specification further provides a billing device, as shown in FIG. 4. 4 is a schematic structural diagram of a billing device provided by an embodiment of the present specification. The device includes: a request determination module 300, for each billing request received, the account to which the billing request is directed is determined; a billing and storage module 302. When there is a pending billing request for the account among other billing requests belonging to the same transaction as the billing request, determine whether the account needs to be deducted based on the billing request and the pending billing request The balance, if it is, acquire 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 acquired; the accounting and storage Module 302, when there is no pending billing request for the account among other billing requests that belong 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, and if so, then Acquire the resource lock of the account and perform the accounting operation. If not, when the resource lock of the account cannot be acquired, store the accounting request as a pending accounting request. Before determining whether it is necessary to deduct the balance of the account, the billing and storage module 302 determines and stores the billing details according to the billing request, where the billing details include the amount of billing operations performed 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 determines the Whether the total expenditure is greater than the income. The operation type of the accounting operation corresponding to the accounting request includes one of freezing, thawing, outflow, and inflow. 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 is a pending billing request for the account among other billing requests that belong to the same transaction as the billing request, the billing and storage module 302 obtains the resource lock of the account, and according to the billing request and The unprocessed billing request performs a billing operation on the account. When there is no pending billing request for the account in other billing requests that belong to the same transaction as the billing request, the billing and storage module 302 obtains the resource lock of the account and based on the billing request Perform a billing operation on the account. The accounting and storage module 302, when it is determined that the balance of the account does not need to be deducted, and the resource lock of the account is acquired, then performs an accounting operation according to the accounting request, or according to the accounting request and the pending Accounting request for accounting operations. The device further includes: a replenishment account module 304, which determines whether the pending accounting request for the account is still stored before the end of the transaction, and if so, acquires the resource lock of the account and checks After storing a number of pending accounting requests for the account after the accounting operation, it is determined that the transaction ends, and if not, it is determined 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 It is configured that one or more processors perform the following steps: For each accounting request received, determine the account to which the accounting request is directed; When other accounting requests that belong to the same transaction as the accounting request exist, there are When a billing request is to be processed, according to the billing request and the billing request to be processed, it is determined whether the balance of the account needs to be deducted. If so, the resource lock of the account is acquired and the billing operation is performed. When the resource lock of the account cannot be obtained, the accounting request is stored as a pending accounting request; when there is no pending accounting request for the account in other accounting requests that belong to the same transaction as the accounting request , According to the accounting request, determine whether the balance of the account needs to be deducted, if so, acquire the resource lock of the account and perform the accounting operation, if not, then request the accounting when the resource lock of the account cannot be obtained Store as a pending billing request. In the 1990s, the improvement of a technology can be clearly distinguished from the improvement of hardware (for example, the improvement of the circuit structure of diodes, transistors, switches, etc.) or the improvement of software (for the process flow 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 get the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method and process cannot be achieved with hardware physical modules. For example, a programmable logic device (Programmable Logic Device, PLD) (such as a field programmable gate array (Field Programmable Gate Array, FPGA)) is such an integrated circuit, and its logic function is determined by the user programming the device. It is up to the designer to program a digital system to "integrate" a PLD without having to ask a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, this kind of programming is also mostly implemented with "logic compiler" software, which is similar to the software compiler used in program development and writing. The original code before compilation must also be written in a specific programming language, which is called the hardware description language (Hardware Description Language, HDL), and HDL is not only one, but there are many, 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 VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that it is easy to obtain the hardware circuit that implements the logic method flow by only slightly programming the method flow using the above hardware description languages and programming it into the integrated circuit. The controller can be implemented in any suitable manner, for example, the controller can take, for example, a microprocessor or processor and a computer-readable program code (such as software or firmware) that can be executed 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 a pure computer-readable code, the logic steps can be completely programmed by the method steps to make the controller with logic gates, switches, integrated circuits for special applications, and programmable Logic controller and embedded microcontroller to achieve the same function. Therefore, such a controller can be regarded as a hardware component, and the device for implementing various functions included therein can also be regarded as a structure within the hardware component. Or even, the device for realizing various functions can be regarded as both a software module of the implementation method and a structure in the hardware component. The system, device, module or unit explained in the above embodiments may be implemented by a computer chip or entity, or by a product with a certain function. A typical implementation device is a computer. Specifically, the computer may 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, and 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 can be implemented in one or more software and/or hardware. Those skilled in the art should understand that the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of computer program products implemented on one or more computer usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer usable program code . 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 programming instructions can be provided to the processor of a general purpose computer, dedicated computer, embedded processor, or other programmable data processing device to produce a machine that is executed by the processor of the computer or other programmable data processing device The instruction generation means for realizing the function specified in one block or multiple blocks of one flow or multiple flows of the flowchart and/or one block of the block diagram. These computer program instructions can also be stored in a 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 produce a manufactured product including an instruction device The instruction device implements the functions specified in one block or multiple blocks in one flow or multiple processes in the flowchart and/or one block in the block diagram. These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operating steps can be performed on the computer or other programmable device to generate computer-implemented processing, and thus on the computer or other programmable device The instructions executed on provide steps for implementing the functions specified in one block or multiple blocks of the flowchart one flow or multiple flows and/or block diagrams. In a typical configuration, the computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory. Memory may include non-permanent 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 computer-readable media. Computer-readable media, including permanent and non-permanent, removable and non-removable media, can be stored by any method or technology. The 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), 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 cassette tapes, magnetic tape magnetic tape storage or other magnetic storage devices or any other non-transmission media can be used to store information that can be accessed by computing devices. As defined 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 "include", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device that includes a series of elements includes not only those elements, but also includes Other elements not explicitly listed, or include elements inherent to this process, method, commodity, or equipment. Without more restrictions, the element defined by the sentence "include one..." does not exclude that there are other identical elements in the process, method, commodity, or equipment that includes the element. Those skilled in the art should understand that the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of computer program products implemented on one or more computer usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer usable program code . The invention can be described in the general context of computer executable instructions executed by a computer, such as a program module. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices. The embodiments in this specification are described in a progressive manner. The same or similar parts between the 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, and the relevant part can be referred to the description of the method embodiment. The above are only the embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. 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:步驟 S200-S212:步驟 S2100-S2104:步驟 300:請求確定模組 302:記帳以及儲存模組 304:補帳模組 S100-S104: Steps S200-S212: Steps S2100-S2104: Steps 300: Request to determine the module 302: Accounting and storage module 304: Make-up account module

此處所說明的附圖用來提供對本發明的進一步理解,構成本發明的一部分,本發明的示意性實施例及其說明用於解釋本發明,並不構成對本發明的不當限定。在附圖中: 圖1為本說明書實施例提供的一種記帳的過程; 圖2為本說明書實施例提供記帳的詳細過程的示意圖; 圖3為本說明書實施例提供的另一種記帳的詳細過程的示意圖; 圖4為本說明書實施例提供的一種記帳的裝置的結構示意圖; 圖5為本說明書實施例提供的一種伺服器的結構示意圖。 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 their descriptions are used to explain the present invention and do not constitute an undue limitation on the present invention. In the drawings: FIG. 1 is a billing process provided by an embodiment of this specification; 2 is a schematic diagram of a detailed process of providing accounting for an embodiment of this specification; 3 is a schematic diagram of another detailed billing process provided by an embodiment of the present specification; 4 is a schematic structural diagram of a billing device provided by an embodiment of the present specification; FIG. 5 is a schematic structural diagram of a server provided by an embodiment of the present specification.

Claims (19)

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

Applications Claiming Priority (3)

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

Publications (2)

Publication Number Publication Date
TW201942843A TW201942843A (en) 2019-11-01
TWI684944B true 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 (6)

* 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

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7219347B1 (en) * 1999-03-15 2007-05-15 British Telecommunications Public Limited Company Resource scheduling
US20090076876A1 (en) * 2003-02-21 2009-03-19 Mtrex, Inc. Method of Scheduling and Event Processing in Computer Operating System
CN101639792A (en) * 2008-07-29 2010-02-03 阿里巴巴集团控股有限公司 Method and device for processing concurrent data and electronic accounting system
TW201627937A (en) * 2015-01-19 2016-08-01 Alibaba Group Services Ltd System for efficient processing of transaction requests related to an account in a database
CN106127568A (en) * 2016-06-15 2016-11-16 中国人民银行清算总中心 The clearing operation queue rescue method of inter-bank payment system and device
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

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101620703B (en) * 2008-07-04 2013-10-16 阿里巴巴集团控股有限公司 Buffer bookkeeping 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
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
CN108615184B (en) * 2018-03-29 2020-12-18 创新先进技术有限公司 Accounting method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7219347B1 (en) * 1999-03-15 2007-05-15 British Telecommunications Public Limited Company Resource scheduling
US20090076876A1 (en) * 2003-02-21 2009-03-19 Mtrex, Inc. Method of Scheduling and Event Processing in Computer Operating System
CN101639792A (en) * 2008-07-29 2010-02-03 阿里巴巴集团控股有限公司 Method and device for processing concurrent data and electronic accounting system
TW201627937A (en) * 2015-01-19 2016-08-01 Alibaba Group Services Ltd System for efficient processing of transaction requests related to an account in a database
CN106127568A (en) * 2016-06-15 2016-11-16 中国人民银行清算总中心 The clearing operation queue rescue method of inter-bank payment system and device
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

Also Published As

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

Similar Documents

Publication Publication Date Title
TWI684944B (en) Accounting method and device
WO2018177235A1 (en) Block chain consensus method and device
CA3048740C (en) Blockchain-based data processing method and device
CN110008018B (en) Batch task processing method, device and equipment
TWI767106B (en) Method, device and device for configuring payment process and executing payment process
TWI694342B (en) Data cache method, device and system
TWI679597B (en) Consensus verification method, device and equipment
CN108566420A (en) Data processing method, equipment and computer readable storage medium for block chain
CN110297837B (en) Data updating method and device and data query method and device
WO2021244537A1 (en) Resource transfer
WO2020019892A1 (en) Bookkeeping method and device, and integrated transaction and finance system
WO2021143397A1 (en) Resource reuse method, apparatus and device based on gpu virtualization
WO2021239087A1 (en) Data processing method, apparatus and device, and medium
TWI712879B (en) Disaster tolerance data processing method, device, equipment and system
CN108346039B (en) Service processing method, device and equipment of Internet financial settlement system
CN110134735A (en) The storage method and device of distributed transaction log
WO2024055779A1 (en) Bill processing method and apparatus
TWI721422B (en) Cross-border transaction declaration method and device
TWI701631B (en) Method and device for fund recovery
CN109598511B (en) Account risk identification method, device and equipment
CN110046877B (en) Account checking method and device and server
CN106548331A (en) A kind of method and device for determining distribution order
WO2016165543A1 (en) Data processing method and platform
CN113435992A (en) Accounting method, device and equipment
US20240135343A1 (en) Methods and systems for transactions transfer