Accounting method, electronic device, storage medium and program product

By pulling accounting flows from the message queue, merging the flows, and performing accounting operations asynchronously, the problem of low throughput of high concurrent accounting system caused by locking resources in the existing technology is solved, and more efficient accounting processing is achieved.

CN119762253APending Publication Date: 2025-04-04KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411898157.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

In the prior art, in order to ensure the consistency of data, each data write operation involves locking resources, and locking resources will cause a large amount of waiting time under high concurrency, thereby reducing the overall throughput of the accounting system.

Method used

By pulling accounting flows from the message queue, merging the flows, and performing accounting operations asynchronously, the operation of locking resources is avoided and the system's concurrent processing capabilities are improved.

Benefits of technology

This method effectively reduces the waiting time of the accounting system in high concurrency situations, improves the system throughput, and solves the performance bottleneck problem caused by locking resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119762253A_ABST
    Figure CN119762253A_ABST
Patent Text Reader

Abstract

The present disclosure provides an accounting method, an electronic device, a storage medium and a program product. The accounting method of the present disclosure includes: pulling accounting flow from a message queue, the accounting flow in the message queue is generated according to an accounting request triggered by a financial transaction event; merging the pulled accounting flow according to an identifier in the pulled accounting flow to obtain a summary flow; and performing an accounting operation according to the summary flow.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of computers and the like, and in particular to an accounting method, an electronic device, a storage medium and a program product. Background Art

[0002] In the modern financial and corporate environment, accounting systems play a vital role. Whether it is a bank, securities company, e-commerce platform or small and medium-sized enterprises, they all need to rely on efficient accounting systems to record every transaction and ensure the accuracy, consistency and integrity of financial data. With the development of the Internet and the popularization of e-commerce, the transaction frequency has increased significantly, and the performance requirements for accounting systems have also increased.

[0003] In the prior art, accounting is usually implemented using a traditional accounting system based on a relational database. This system uses a structured query language to perform data operations, such as data writing operations, data updating operations, data query operations, data deletion operations, etc., and relies on the four major characteristics of database transactions: "atomicity, consistency, isolation and persistence" to ensure the correct processing of data.

[0004] To ensure data consistency, each data write operation involves locking resources, which can cause a lot of waiting time in high concurrency situations, thereby reducing the overall throughput of the accounting system. Summary of the invention

[0005] The present disclosure provides an accounting method, an electronic device, a storage medium and a program product.

[0006] According to one aspect of the present disclosure, there is provided an accounting method, comprising: Pulling accounting records from a message queue, where the accounting records in the message queue are generated based on accounting requests triggered by financial transaction events; The pulled accounting flow is merged according to the identifier in the pulled accounting flow to obtain the summary flow; The bookkeeping operation is performed according to the summary flow.

[0007] According to at least one embodiment of the present disclosure, the accounting method further includes, before pulling accounting records from the message queue: Get accounting requests triggered by financial transaction events; Processing the accounting request to obtain accounting flow; Put the accounting flow into the message queue.

[0008] According to the accounting method of at least one embodiment of the present disclosure, the processing of the accounting request includes: Verifying the accounting request and obtaining a verification result; When the verification result is successful, the accounting request is processed.

[0009] According to the accounting method of at least one embodiment of the present disclosure, the accounting operation according to the summary flow includes: Obtaining the identifier of the summary flow; Obtaining the thread pointed to by the identifier of the summary flow according to a thread allocation strategy, wherein the thread allocation strategy is used to ensure that operations on the same account are processed by the same thread; The thread is used to perform accounting operations according to the summary flow.

[0010] According to the accounting method of at least one embodiment of the present disclosure, the accounting operation according to the summary flow includes: Obtain multiple sub-operations of the accounting operation; The multiple sub-operations are performed according to the summary pipeline.

[0011] According to the accounting method of at least one embodiment of the present disclosure, the multiple sub-operations include: Inserting the summary flow into the accounting voucher, updating the balance of the related account according to the summary flow, and updating the accounting flow related to the summary flow; Optionally, the performing accounting operation according to the summary flow further includes: Determining whether the updating of the accounting flow related to the summary flow is successful; If unsuccessful, the updating of the accounting records related to the summary records is performed again until it succeeds or the termination condition is reached.

[0012] According to the accounting method of at least one embodiment of the present disclosure, the step of merging the pulled accounting flow according to the identifier in the pulled accounting flow includes: Put the pulled accounting records into the cache; When the accounting flow associated with any identifier stored in the cache meets the trigger condition, the accounting flow associated with the identifier is merged; Optionally, when all accounting records related to the identifiers stored in the cache do not meet the triggering condition, the method further includes: Execute the method of pulling accounting records from the message queue; Optionally, the trigger condition includes: Time trigger condition, quantity trigger condition or amount trigger condition; Optionally, pulling accounting records from the message queue includes: Pull a bookkeeping record from the message queue one by one; or, Use batch pull to pull multiple accounting records from the message queue.

[0013] According to another aspect of the present disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, so that the processor executes the accounting method of any one embodiment of the present disclosure.

[0014] According to another aspect of the present disclosure, a readable storage medium is provided, wherein the readable storage medium stores execution instructions, and when the execution instructions are executed by a processor, the execution instructions are used to implement the accounting method of any embodiment of the present disclosure.

[0015] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the accounting method of any one of the embodiments of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0017] Figure 1 It is a schematic diagram of an application scenario of the accounting method according to an embodiment of the present disclosure.

[0018] Figure 2 This is a flow chart of an accounting method according to an embodiment of the present disclosure. Figure 1 .

[0019] Figure 3 This is a flow chart of an accounting method according to an embodiment of the present disclosure. Figure 2 .

[0020] Figure 4 yes Figure 3 A flowchart of a request processing method in the accounting method shown.

[0021] Figure 5 yes Figure 2 The process of accounting operation method in the accounting method shown Figure 1 .

[0022] Figure 6 yes Figure 2 The process of accounting operation method in the accounting method shown Figure 2 .

[0023] Figure 7 yes Figure 2 The process of accounting operation method in the accounting method shown Figure 3 .

[0024] Figure 8 yes Figure 2 Flow chart of the running water merging method in the accounting method shown.

[0025] Fig. 9 This is a flow chart of an accounting method according to an embodiment of the present disclosure. Figure 3 .

[0026] Fig.10 This is a flow chart of an accounting method according to an embodiment of the present disclosure. Figure 4 .

[0027] Fig.11 This is a flow chart of an accounting method according to an embodiment of the present disclosure. Figure 5 .

[0028] Fig.12 It is a schematic flow chart of an accounting method according to an embodiment of the present disclosure.

[0029] Fig.13 The figure is a schematic block diagram of the structure of an accounting device according to an embodiment of the present disclosure.

[0030] Fig.14 It is a schematic block diagram of the structure of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0031] The present disclosure is further described in detail below in conjunction with the accompanying drawings and examples. It is understood that the specific examples described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.

[0032] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0033] Take a large e-commerce platform as an example. During the shopping festival, the platform faces extremely high transaction volume, with thousands of orders generated every second. These orders involve accounting operations such as user payment, merchant payment, and platform commission settlement. In order to process these orders, the platform uses a traditional accounting system based on a relational database to perform the following operations: receive order information, lock the user account and merchant account involved in the order information; perform accounting operations based on the accounting information related to the order information; and unlock the user account and merchant account when the accounting operation is completed. When multiple orders are generated almost at the same time and attempt to operate the same user account or merchant account, only the first order to obtain the lock can be processed immediately, and the rest must wait. This processing method significantly reduces the concurrent processing capability of the accounting system, resulting in a low throughput of the accounting system.

[0034] To this end, the present disclosure proposes an accounting method, electronic device, storage medium and program product, which can be implemented by accounting software set on electronic devices such as mobile phones, tablets, computers, servers, etc.

[0035] Figure 1 The application scenario of the accounting method of an embodiment of the present disclosure is shown. In this application scenario, a user terminal 100 and an accounting platform 200 may be included, and the user terminal 100 communicates with the accounting platform 200 through a network. The user terminal 100 is used to trigger an accounting request based on user behavior or system events and send it to the accounting platform 200, such as the user completing a certain transaction operation through the user terminal 100 and clicking "Confirm" or "Submit", the user initiating a change involving funds or points, a scheduled task or status detection through the user terminal 100, etc.; the accounting platform 200 is used to process the accounting request.

[0036] For the convenience of description and to make the technical solutions of the specific implementation methods of the present disclosure easier to understand, before describing the accounting method implemented by the present disclosure, the technical terms involved in the specific implementation methods of the present disclosure are explained as follows: Message queue is a middleware technology used in distributed systems or asynchronous processing scenarios.

[0037] A posting request is a packet of information used to notify the accounting system that a specific transaction needs to be recorded or some adjustment needs to be made.

[0038] A bookkeeping journal (also called a transaction journal, account journal or accounting journal) is a series of entries that record detailed information about all economic activities (such as income, expenditure, transfers, etc.) within a certain period of time.

[0039] Thread allocation strategy refers to the rules and methods for allocating tasks or resources to threads for execution.

[0040] Figure 2 FIG. 1 is a schematic diagram showing the overall process of an accounting method M100 according to an embodiment of the present disclosure. Figure 2 The method shown includes steps S110 to S130. The method can be executed by electronic devices such as mobile phones and computers.

[0041] Specifically, Figure 2 The accounting methods shown include: Step S110, pulling accounting records from the message queue.

[0042] In some embodiments of the present disclosure, the accounting records in the message queue in step S110 are generated according to the accounting request triggered by the financial transaction event. The accounting records in step S110 may include the relevant transaction timestamp (used to record the specific time when the transaction occurred), the amount (used to record the amount involved in the transaction, which can be a positive number (such as income) or a negative number (such as expenditure)), the transaction type (used to indicate the nature of the transaction, such as cash deposit, online payment, refund, transfer, etc.), account information (including the account information of the transaction parties, such as the identification and type of the transaction initiator (or the transaction initiator and the transaction recipient), description and remarks (used to explain the purpose or background of the transaction), voucher number (used to track and manage transactions, each transaction has a unique voucher number), and transaction status (used to identify the status information of the transaction, such as success, failure, processing, etc.). In particular, in order to accurately manage the execution of accounting tasks, accounting records may also include processing status, such as "pending" indicating that the accounting records have been generated but not yet processed, "processing" indicating that the accounting records are undergoing account updates or other operations, "completed" indicating that all accounting record-related processing has been completed, and "failed" indicating that a problem occurred during the accounting record processing and the operation was unsuccessful.

[0043] Step S110 can use a blocking pull method to pull accounting flow from the message queue, that is, if there is no accounting flow in the message queue, wait until new accounting flow arrives; step S110 can also use a non-blocking pull method to pull accounting flow from the message queue, that is, if there is accounting flow in the message queue, pull it, and perform other operations if there is no accounting flow.

[0044] The accounting records pulled through step S110 may be one or more records.

[0045] Step S120, merging the pulled accounting flow according to the identifiers in the pulled accounting flow to obtain a summary flow.

[0046] In some embodiments of the present disclosure, an overall trigger condition may be set. When the trigger condition is met (such as the time has reached the summary period or the amount of data of the pulled accounting flow has reached a set threshold or the total amount of the pulled accounting flow has reached a set threshold, etc.), step S120 may start to merge each group divided based on the identifier, that is, to add up certain fields (such as amount, quantity, etc.) of the accounting flow in the group divided based on the identifier, and generate a record, namely the summary flow corresponding to the group.

[0047] The trigger condition may also be set based on each group, that is, when a group divided based on the identifier meets the trigger condition, the group is merged.

[0048] In particular, you can also set a threshold such as the maximum number of entries or the upper limit of the amount for a single merge. Once the preset threshold is reached, the subsequent accounting records will be stopped from being merged, and the subsequent accounting records will be processed through another merge operation. By limiting the number or amount, you can ensure that the merge result is controllable and avoid too many accounting records being merged into one, which will affect subsequent processing and analysis.

[0049] In some implementations of the present disclosure, the identifier in step S120 is generally an attribute that can uniquely identify a certain type of accounting flow, and the identifier may be an account identifier, a user identifier, a project identifier, and the like.

[0050] Step S130, perform accounting operations according to the summary flow.

[0051] In some embodiments of the present disclosure, the accounting operation performed in step S130 may include entering the summary flow into an accounting voucher, a balance update process, etc.

[0052] The accounting method provided by the present disclosure decouples the producer and consumer of accounting flow through the message queue, that is, the producer can return after sending the accounting flow to the message queue, and the consumer can consume messages from the message queue asynchronously as needed, thereby supporting the asynchronous processing of accounting flow and reducing complexity; by merging a large number of accounting flows into fewer entries, the amount of data required for accounting operations is greatly reduced, thereby improving accounting efficiency. Since asynchronous operations allow more accounting requests to be processed in parallel, the merging operation reduces the total number of accounting flows. The combination of the two can handle a large number of concurrent accounting requests, reduce system load, and improve throughput. This method solves the problem in the prior art that in order to ensure data consistency, each data write operation involves locking resources, and locking resources will cause a lot of waiting time in high concurrency situations, thereby reducing the overall throughput of the accounting system.

[0053] Further, in some embodiments of the present disclosure, the accounting method provided by the present disclosure may further include the following steps before step S110: Figure 3Steps S140 to S160 are shown.

[0054] Step S140: obtaining an accounting request triggered by a financial transaction event.

[0055] In some embodiments of the present disclosure, the financial transaction events in step S140 are those specific economic business activities or events in the financial activities of enterprises or various economic organizations that can prompt the financial system to start the accounting process and record the changes in the corresponding financial data. The financial transaction event can be the income and expenditure activities of individuals in daily life, such as salary income, shopping consumption, payment of fees, etc.; the financial transaction event can also be the financial transaction activities of enterprises, such as selling products, paying suppliers, and issuing employee salaries, etc.; the financial transaction event can also be changes in accounts of financial institutions such as banks, such as deposits, withdrawals, transfers, loan repayments, etc.

[0056] The process of obtaining the accounting request triggered by the financial transaction event through step S140 may include: first, defining what kind of operations or events in the business can be used as financial transaction events; second, monitoring the occurrence of financial transaction events; and finally, when the occurrence of the financial transaction event is monitored, generating a corresponding accounting request according to the specific content of the financial transaction event.

[0057] Among them, the specific process of generating a corresponding accounting request according to the specific content of a financial transaction event may include: first, obtaining transaction data according to the financial transaction event, including transaction type, transaction amount, transaction party information, date and time, etc. (for example, when the order payment is completed, the obtained transaction data includes the payment amount "1,000 yuan", the payment method "credit card", the payee "customer A", the transaction time "December 9, 2024", etc.); second, determining the accounting subject according to the transaction data (the accounting subject may be determined in combination with the amount, tax information, type and other information of the transaction data, for example, the accounting subject of an income transaction may involve "accounts receivable" and "sales revenue", and the accounting subject of an expenditure transaction may involve "cash" and "purchase expenditure", etc.); third, generating specific debit and credit entries according to the accounting subject and transaction type (for example: debit: accounts receivable 500 yuan (asset increase), credit: sales revenue 500 yuan (revenue increase)); finally, encapsulating the generated debit and credit entries into an accounting request, including a transaction identifier (such as an order number, a transaction number, etc.), detailed debit and credit entries, and a request status (such as pending, processed, or in progress).

[0058] Step S150, process the accounting request to obtain accounting flow.

[0059] In some embodiments of the present disclosure, the process of processing the accounting request through step S150 may include: constructing a transaction record according to the accounting request; formatting the transaction record according to the database table structure storing the accounting transaction to obtain the accounting transaction. The accounting transaction obtained through step S150 may include: accounting transaction ID, request ID, account ID, amount, transaction type, transaction date, transaction status, transaction description, balance and other information.

[0060] Step S160, putting the accounting flow into the message queue.

[0061] In some embodiments of the present disclosure, the technology used by the message queue in step S160 may be RabbitMQ, Apache Kafka, Amazon SQS, Redis Streams, or ActiveMQ, etc.

[0062] In particular, in order to enhance accounting transparency and user trust, after placing the accounting flow into the message queue through step S160, an acceptance notification can also be sent to the initiating user of the financial transaction event to make it clear that the current financial transaction event has entered the accounting stage, avoiding unnecessary waiting or worry.

[0063] Regarding step S150, in some embodiments of the present disclosure, it may include the following steps: Figure 4 Steps S151 to S152 are shown.

[0064] Step S151, verify the accounting request and obtain the verification result.

[0065] In some embodiments of the present disclosure, the method of verifying the accounting request through step S151 may include one or more of integrity verification (i.e., confirming that the accounting request contains all necessary information, such as debit and credit amounts, accounts, transaction time, etc.), consistency verification (i.e., ensuring that the debit and credit amounts are balanced and the accounting accounts are legal) and repeatability verification (i.e., preventing repeated processing of the same accounting request based on transaction identifiers or request IDs, etc.).

[0066] When the verification result obtained through step S151 is a verification failure, the exception can be recorded and the accounting process can be terminated. Recording the exception can support problem tracing and debugging, and enhance the maintainability and security of the accounting software. When the verification result obtained through step S151 is a verification success, execute step S152.

[0067] Step S152: Process the accounting request.

[0068] The accounting request is verified through step S151 and processed through step S152 when the verification is successful, which can ensure the accuracy, compliance and completeness of the accounting request, thereby improving the subsequent processing efficiency, reducing the risk of errors, and enhancing the stability of the accounting software.

[0069] Regarding step S130, in some embodiments of the present disclosure, it may include the following steps: Figure 5 Steps S131 to S133 are shown.

[0070] Step S131, obtaining the identification of the summary flow.

[0071] In some embodiments of the present disclosure, the identifier obtained in step S131 may be one of the identifiers included in the summary flow. A classification rule may be pre-set, and the identifier of the summary flow is obtained in step S131 based on the classification rule.

[0072] Step S132, obtaining the thread pointed to by the identifier of the summary flow according to the thread allocation strategy.

[0073] In some implementations of the present disclosure, the thread allocation policy in step S132 may be pre-set, and the thread allocation policy is used to ensure that operations on the same account are processed by the same thread.

[0074] Step S132 can be implemented through identifier hash mapping, that is, hash calculation is performed on the identifier, and after the hash value is obtained, the hash value is mapped to a specific thread; for example, there are 10 threads, after the hash calculation is performed on the identifier, the hash value is modulo 10, and the obtained result (one of 0-9) corresponds to one of the 10 threads, so that account operations with the same hash value will be assigned to the same thread.

[0075] Step S132 can also be implemented by combining a thread pool with a task queue, that is, establishing a thread pool, each thread in the thread pool has a dedicated task queue, when a task arrives, the task will be placed in the corresponding task queue, and the threads in the thread pool will continuously obtain tasks from their respective task queues for execution until the task queue is empty.

[0076] In particular, if there are a large number of accounts, you can use the thread pool to efficiently manage and allocate threads; to avoid frequent context switching and excessive memory usage caused by too many threads, you can set the maximum number of threads in the thread pool; to ensure that the system can handle more tasks when the load is high and avoid wasting resources when the load is low, you can dynamically adjust the size of the thread pool according to the system load and demand. The thread pool can also set a reuse mechanism to recycle idle threads and reuse them, avoiding the overhead of creating and destroying threads for each account, improving performance, and reducing memory usage.

[0077] Step S133, use the thread to perform accounting operations according to the summary flow.

[0078] By ensuring that operations on the same account are processed by the same thread through steps S131 to S133, problems such as data inconsistency and resource competition that may be caused by multiple threads processing operations on the same account at the same time can be avoided, and the efficiency and accuracy of accounting software in processing accounting operations can be improved.

[0079] Regarding step S130, in some embodiments of the present disclosure, it may include the following steps: Figure 6 Steps S134 to S135 are shown.

[0080] Step S134, obtaining multiple sub-operations of the accounting operation.

[0081] In some embodiments of the present disclosure, the process of obtaining multiple sub-operations of the accounting operation through step S134 may be: splitting the accounting operation according to the operation logic and / or data dimension of the accounting operation to obtain multiple sub-operations. In particular, in order to improve the accounting efficiency, the process of splitting the accounting operation according to the operation logic and / or data dimension of the accounting operation may also be performed in advance, and after obtaining the split result, the multiple sub-operations of the accounting operation are directly obtained through the split result when they need to be obtained.

[0082] In some embodiments of the present disclosure, the multiple sub-operations obtained through step S134 may include inserting the summary flow into the accounting voucher, updating the balance of the related account according to the summary flow, and updating the accounting flow related to the summary flow; by splitting the accounting operation into multiple sub-operations, the accounting operation process can basically be free of hot row competition (i.e., resource contention caused by multiple sub-operations frequently accessing or modifying the same row of data), lock contention (i.e., competition between multiple sub-operations for the same resource (such as row lock, table lock)), etc., which can improve the overall concurrency performance of the accounting software, reduce resource waste, and improve stability.

[0083] The accounting records associated with the summary records refer to the data source of the summary records. These accounting records are combined to obtain the summary records. The summary records can use the "Record ID" field to indicate the accounting records associated with the summary records. The account associated with the summary records refers to the account pointed to by the account ID in the summary records.

[0084] Step S135, executing multiple sub-operations according to the summary flow.

[0085] In some embodiments of the present disclosure, when there are logical dependencies between multiple sub-operations, the process of executing multiple sub-operations according to the summary flow through step S135 can be specifically executed according to the summary flow in the order of operation logic; when there are no logical dependencies between multiple sub-operations, the process of executing multiple sub-operations according to the summary flow through step S135 can be specifically executed in parallel according to the summary flow to improve accounting efficiency.

[0086] In particular, in order to ensure the reliability, consistency and recoverability of multiple sub-operations, the intermediate status of each sub-operation can be recorded after it is completed; when a sub-operation fails, a compensating operation can be performed to roll back or repair the status. In addition, the timeout of the sub-operation can be set. If the timeout occurs, the operation can be retried or aborted; the consistency of multiple sub-operations can be ensured through distributed transaction protocols (such as 2PC, TCC), etc.; the execution time, success status and failure reason of each sub-operation can be monitored, and logs can be recorded for troubleshooting.

[0087] By splitting the accounting operation into multiple operations and executing them later through steps S134 and S135, the overall performance and maintainability of the accounting software can be improved.

[0088] At this time, regarding step S130, in some embodiments of the present disclosure, it may also include the following Figure 7 Steps S136 to S137 are shown.

[0089] Step S136, determining whether the accounting flow related to the summary flow is updated successfully.

[0090] In some embodiments of the present disclosure, when the accounting flow is obtained through step S150, the flow status of the accounting flow is usually "pending"; when a certain accounting flow is successfully updated, the status of the accounting flow is set to "successful". The process of determining whether the accounting flow related to the summary flow is successfully updated in step S136 may include: obtaining all accounting flows related to the summary flow; and determining whether the status of these accounting flows are all "successful".

[0091] In particular, in order to improve the judgment efficiency, a field can also be set in the summary flow to indicate whether all accounting flows related to the summary flow are updated successfully. The initial value of the field is "pending". When all accounting flows related to the summary flow are updated successfully, the value of the field is modified to "success". Therefore, step S136 can directly judge whether the update of the accounting flow related to the summary flow is successful through the value of the field. Furthermore, in order to more accurately reflect the various stages or exceptions of the accounting operation, to adapt to different business needs, and to improve the accuracy and flexibility of accounting operation management, in addition to the above values, the value of this field can also include "processing", "failure", "rollback", "canceled", "timeout", "locked", "partial success", etc.

[0092] When it is determined through step S136 that the accounting flow associated with the update summary flow is successful, no operation can be performed and the accounting process ends; when it is determined through step S136 that the accounting flow associated with the update summary flow fails, the accounting flow operation associated with the update summary flow can be performed again through step S135 until it succeeds or the end condition is reached. Among them, the end condition can be preset, the end condition can be always fixed, or can be adjusted as needed; the end condition can be the maximum update execution number or the maximum update execution time, etc.

[0093] By determining whether the accounting flow related to the update summary flow is successful in step S136, and repeating the process until it succeeds or the end condition is reached, the fault tolerance, reliability and robustness of the accounting software can be increased. In addition, setting a reasonable end condition can also avoid problems such as waste of resources, increased delays and reduced user experience caused by excessive retries.

[0094] Regarding step S120, in some embodiments of the present disclosure, it may include the following steps: Figure 8 Steps S121 to S122 are shown.

[0095] Step S121, putting the pulled accounting flow into the cache.

[0096] In some embodiments of the present disclosure, the cache in step S121 may be a Memcached cache, a Redis cache, etc. Redis cache is usually used because it supports a variety of data structures, such as strings, hashes, lists, sets, etc., has high performance, and is easily integrated with message queues.

[0097] Step S122: When the accounting flow associated with any identifier stored in the cache meets the trigger condition, the accounting flow associated with the identifier is merged.

[0098] In some embodiments of the present disclosure, the trigger condition in step S122 is a rule for triggering the merge, and the trigger condition may be a time trigger condition, that is, an accounting flow associated with an identifier accumulated within a certain time window will trigger the merge; the trigger condition may also be a quantity trigger condition, that is, when the number of entries of accounting flow associated with an identifier accumulated in the cache reaches a certain value, the merge is triggered; the trigger condition may also be an amount trigger condition, etc.

[0099] The accounting flow associated with a certain identifier is the accounting flow with the same identifier as the identifier.

[0100] When the trigger condition is met, the specific method of merging the accounting records related to the identifier through step S122 can be to accumulate the value of the "amount" field in the accounting records and accumulate other fields that may need to be summarized, such as the number of records, the earliest or latest timestamp, etc.

[0101] During the process of merging accounting records related to the identifier in step S122, if some accounting records cannot be merged, the accounting software can record these situations that do not meet the conditions, generate a log or error report, and remind the operator to check and intervene.

[0102] By putting the pulled accounting records into the cache in step S121 and then merging them in step S122, the response speed and concurrent processing capability of the accounting software can be improved. In addition, by merging accounting records related to the same identifier in step S122, the accounting processing operation can be simplified, and the performance can be significantly improved when the number of entries in the accounting records is large.

[0103] In some embodiments of the present disclosure, when all accounting records related to the identifiers stored in the cache do not meet the triggering condition, such as Fig. 9 As shown, the accounting flow can be pulled from the message queue again in step S110, so as to be merged when any accounting flow associated with an identifier stored in the cache meets the trigger condition at a certain time point in the future.

[0104] In particular, in order to avoid the loss of key information and to enable further processing in the future, when the accounting flow associated with a certain identifier continues to fail to meet the triggering conditions, the accounting flow associated with the identifier can be directly recorded as an independent, unmerged transaction. In particular, when the accounting flow associated with the identifier is recorded as an independent, unmerged transaction, a prompt message can be returned or the accounting flow can be marked with a special identification field to explain the reason why it was not merged.

[0105] In order to improve the fault tolerance and adaptability of the accounting software, when most or even all identifier-related accounting transactions continue to fail to meet the trigger conditions, the trigger conditions can also be adjusted, such as relaxing the data or amount thresholds, adjusting the time window, etc., to allow more identifier-related accounting transactions to meet the trigger conditions.

[0106] Regarding step S110, in some embodiments of the present disclosure, it can be replaced by Fig.10 The following steps are shown: Pull a bookkeeping flow from the message queue one by one.

[0107] By pulling accounting records from the message queue one by one through this step, a more precisely controlled and reliable accounting record consumption mechanism can be provided.

[0108] Regarding step S110, in some embodiments of the present disclosure, it can be replaced by Fig.11 The following steps are shown: Use batch pull to pull multiple accounting records from the message queue.

[0109] In some embodiments of the present disclosure, the accounting software may set a maximum number of accounting flows to be pulled at one time, that is, set an upper limit on the number of items in the accounting flow to be pulled, such as 10, 50, etc.; the process of pulling multiple accounting flows through this step may include: the accounting software sends a pull request to the message queue to pull a specified number of accounting flows; if there are enough accounting flows in the message queue, the message queue returns a batch of accounting flows; the accounting software receives these accounting flows.

[0110] If there are not enough accounting transactions in the message queue, the accounting software can choose to block and wait until new accounting transactions arrive at the message queue; the accounting software can also set a short delay, such as a few seconds, and then try to pull the accounting transactions again; the accounting software can also choose to suspend consumption until the number of accounting transaction entries in the message queue reaches a certain threshold before starting consumption. This method can help control the start and pause of consumption based on the queue monitoring mechanism.

[0111] This step pulls multiple accounting records from the message queue at one time, which can improve processing efficiency and throughput, reduce network overhead, reduce latency and response time, improve concurrency, and is suitable for high-concurrency scenarios.

[0112] Fig.12 An exemplary flow chart of an accounting method implemented based on the present disclosure is shown.

[0113] Fig.12In the flowchart shown, taking the e-commerce platform as an example, many users place orders to purchase goods every day. After the payment of each order is successful, accurate financial accounting processing is required to facilitate subsequent financial accounting, reconciliation, and financial report generation. The specific accounting process may include: Step S210: obtaining an accounting request triggered by a financial transaction event.

[0114] In some embodiments of the present disclosure, when a user successfully pays for an order on an e-commerce platform, such as purchasing a laptop computer worth 5,000 yuan, the payment system will send an accounting request to the accounting software, and the accounting software can obtain the accounting request through step S210. The accounting request contains key transaction information, such as order number (such as O12345), transaction amount (5,000 yuan), transaction time (10:30:00 on December 5, 2024), payment method (WeChat payment) and corresponding store information (XX computer specialty store), etc. In particular, in order to ensure that the accounting software can effectively understand the accounting request, the format of the accounting request transmitted between the payment system and the accounting software can be agreed upon, such as Json, XML (eXtensible Markup Language) or CSV (Comma-Separated Values), etc.

[0115] In some embodiments of the present disclosure, for e-commerce platforms, financial transaction events, in addition to successful order payment, may also include events such as a user applying for a refund for purchased goods and the refund process being approved, the need to record the allocation of promotional expenses when a user places an order to meet platform promotional activities (such as full-discount activities, gift activities, etc.), the e-commerce platform purchasing goods from suppliers and settling payments with suppliers after sales, and the e-commerce platform paying logistics fees after providing logistics services to users.

[0116] Step S220, process the accounting request to obtain accounting flow.

[0117] In some embodiments of the present disclosure, after obtaining the accounting request through step S210, the format of the accounting request can be verified. Taking the accounting request in the agreed Json format as an example, it will be verified whether the accounting request complies with the grammatical rules of Json and whether it contains the required fields. The content of the accounting request can also be verified, such as the transaction amount must be a number and greater than 0, the order number must comply with the set numbering rules, etc.

[0118] When the verification result through the above process is passed, the accounting request can be processed through step S220, such as extracting the transaction time from the accounting request as the date and timestamp of the accounting flow, determining the transaction type according to the business scenario, and determining the object information related to the transaction, such as order number, customer number, store number, etc.

[0119] Step S230, putting the accounting flow into the message queue.

[0120] In some implementations of the present disclosure, step S230 may place the accounting flow into a message queue through an SDK or API provided by a message queue service.

[0121] Step S240, pull accounting records from the message queue.

[0122] In some embodiments of the present disclosure, step S240 may pull accounting records from the message queue in the order in which they are sent, or may randomly pull accounting records from the message queue. The accounting records pulled by step S240 may be one or more records.

[0123] Step S250, merging the pulled accounting flow according to the identifiers in the pulled accounting flow to obtain a summary flow.

[0124] In some embodiments of the present disclosure, the identifier in step S250 is a classification rule for merging accounting flows, and the identifier can be either the identifier of the payer or the identifier of the supplier, etc.

[0125] Taking the identifier "XX Computer Store" as an example, assuming that the trigger condition is 10, when the pulled accounting flow includes 10 accounting flows of "XX Computer Store", these 10 accounting flows are merged, such as merging and calculating the numerical fields (such as transaction amount, handling fee amount, etc.) in these 10 accounting flows to obtain a summary flow.

[0126] The merge can be executed based on trigger conditions, such as meeting 200 accounting records or waiting for more than 100ms.

[0127] Step S260, perform accounting operations according to the summary flow.

[0128] In some embodiments of the present disclosure, the accounting operation performed in step S260 may include: inserting summary flow, updating the status of accounting flow and updating the balance of related accounts, etc. By splitting large transactions, the problem of large transactions being too time-consuming can be reduced, and the accuracy of accounting operations can be guaranteed through consistency. This step can also introduce a thread allocation strategy to solve the lock competition problem of hotspot accounts and improve its timeliness. In the case of peak requests, the accounting delay can be controlled within 1 minute.

[0129] The bookkeeping method provided by the present disclosure uses an asynchronous + summary method to generate summary flow, which can increase the throughput of the system, and its deposit peak can support 1W / S. The method can be applied in the fields of finance and banking, corporate accounting and financial management, e-commerce and payment platforms, insurance, supply chain and logistics, government and public services, medical industry, real estate, education industry, tourism and hotel industry, etc., and can help various institutions better manage resources, control costs, improve decision-making efficiency and achieve long-term sustainable development. The bookkeeping method can be used not only for legal currency-related businesses, but also for virtual currency-related businesses.

[0130] Based on any of the above implementations, the present disclosure also provides an accounting device.

[0131] Fig.13 The figure is a schematic block diagram of the structure of an accounting device according to an embodiment of the present disclosure.

[0132] like Fig.13 As shown, the accounting device includes: The transaction flow pulling module 110 is used to pull accounting transactions from the message queue. The accounting transactions in the message queue are generated according to accounting requests triggered by financial transaction events.

[0133] The flow merging module 120 is used to merge the pulled accounting flow according to the identifiers in the pulled accounting flow to obtain a summary flow.

[0134] The accounting operation module 130 is used to perform accounting operations according to the summary flow.

[0135] The above-mentioned accounting device can be in the form of computer software, and each module of the above-mentioned accounting device can be implemented by a computer software module.

[0136] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0137] The executor of the accounting method in the specific implementation manner of the present disclosure may be a mobile phone, tablet computer, computer, server or other electronic device.

[0138] Therefore, based on any one of the above embodiments, the present disclosure also provides an electronic device, which can execute the accounting method of any one of the embodiments described above in the present disclosure.

[0139] Fig.14 1 is a schematic block diagram of the structure of an electronic device 1000 according to an embodiment of the present disclosure.

[0140] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnected buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300 and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc.

[0141] The bus 1100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the figure only uses one connecting line, but does not mean that there is only one bus or one type of bus.

[0142] The present disclosure also provides a readable storage medium, in which a computer program is stored, and the computer program is used to implement the above method when executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.

[0143] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed, the process or function of the present disclosure is executed in whole or in part.

[0144] The computer program or instructions may be stored in a readable storage medium or transmitted from one readable storage medium to another readable storage medium, for example, the computer program or instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The readable storage medium may be any available medium that can be accessed or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid state drive. The computer readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.

[0145] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0146] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0147] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0148] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0149] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and features of different embodiments / methods or examples, unless they are contradictory.

[0150] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0151] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.

Claims

1. A bookkeeping method, characterized in that: include: Pulling accounting records from a message queue, where the accounting records in the message queue are generated based on accounting requests triggered by financial transaction events; The pulled accounting flow is merged according to the identifier in the pulled accounting flow to obtain the summary flow; as well as The bookkeeping operation is performed according to the summary flow.

2. The bookkeeping method according to claim 1, characterized in that: Before pulling the accounting flow from the message queue, the method further includes: Get accounting requests triggered by financial transaction events; Processing the accounting request to obtain accounting records; and Put the accounting flow into the message queue.

3. The bookkeeping method according to claim 2, characterized in that: The processing of the accounting request includes: Verifying the accounting request to obtain a verification result; and When the verification result is successful, the accounting request is processed.

4. The bookkeeping method according to any one of claims 1 to 3, characterized in that: The bookkeeping operation according to the summary flow includes: Obtaining the identifier of the summary flow; Acquiring the thread pointed to by the identifier of the summary flow according to a thread allocation strategy, wherein the thread allocation strategy is used to ensure that operations on the same account are processed by the same thread; and The thread is used to perform accounting operations according to the summary flow.

5. The bookkeeping method according to any one of claims 1 to 3, characterized in that: The bookkeeping operation according to the summary flow includes: Obtaining multiple sub-operations of the accounting operation; and The plurality of sub-operations are executed according to the summary pipeline.

6. The bookkeeping method according to claim 5, characterized in that: The multiple sub-operations include: Inserting the summary flow into the accounting voucher, updating the balance of the related account according to the summary flow, and updating the accounting flow related to the summary flow; Optionally, the performing accounting operation according to the summary flow further includes: Determining whether the updating of the accounting flow related to the summary flow is successful; and If unsuccessful, the updating of the accounting records related to the summary records is performed again until it succeeds or the termination condition is reached.

7. The bookkeeping method according to any one of claims 1 to 3, characterized in that: The step of merging the pulled accounting flow according to the identifier in the pulled accounting flow includes: Put the pulled accounting records into the cache; and When the accounting flow associated with any identifier stored in the cache meets the trigger condition, the accounting flow associated with the identifier is merged; Optionally, when all accounting records related to the identifiers stored in the cache do not meet the triggering condition, the method further includes: Execute the method of pulling accounting records from the message queue; Optionally, the trigger condition includes: Time trigger condition, quantity trigger condition or amount trigger condition; Optionally, pulling accounting records from the message queue includes: Pull a bookkeeping record from the message queue one by one; or, Use batch pull to pull multiple accounting records from the message queue.

8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instructions stored in the memory so that the processor executes the accounting method according to any one of claims 1 to 7.

9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which are used to implement the accounting method according to any one of claims 1 to 7 when executed by the processor.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the accounting method according to any one of claims 1 to 7 is implemented.