A transaction interface processing method and device, and a storage medium
By loading field templates for standardized validation and differentiated database transaction processing, the problems of resource waste and data consistency in transaction interface exception handling are solved, thereby improving transaction success rate and system stability.
Patent Information
- Application Number
- CN202611236237.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-14
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies cannot finely distinguish the types of transaction interface exceptions, resulting in rollback operations being triggered incorrectly in exception scenarios that do not require rollback. This causes interruptions to normal business processes, reduces transaction success rates and system availability, makes it impossible to achieve partial business rollback or compensatory rollback processing, and makes it difficult to ensure the consistency and integrity of transaction data.
The system performs standardized validation of the field set in the transaction request by loading a preset field template, determines the start method of the database transaction based on the validation results, and executes differentiated database transaction rollback strategies based on the stage and type of the exception, including partial rollback or compensatory rollback processing.
It improved the data processing standardization and system stability of the transaction interface, reduced resource waste, increased transaction success rate and system availability, and ensured the consistency and integrity of transaction data.
Smart Images

Figure CN123178140A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of interface processing technology, and in particular to a method, apparatus and storage medium for processing a transaction interface. Background Technology
[0002] In key business areas such as finance, payment, and e-commerce, cross-system transaction data interaction generally adopts standardized message formats for transmission. As the core hub for transaction request access, message parsing, field validation, and database data storage, the transaction interface's processing logic standardization, transaction control accuracy, and fault tolerance directly determine the overall transaction system's operational stability, concurrent processing capabilities, and business data consistency. It is a key link in ensuring the safe and efficient flow of online transactions.
[0003] The current transaction interface processing method is as follows: after obtaining the transaction request, the corresponding target transaction interface is identified, and all fields are extracted from the request message. All fields are uniformly validated according to custom rules. After the validation is completed, the database transaction is started directly, and database operations such as query, add or update are performed. If the database operation is abnormal, the started transaction is rolled back as a whole, and the transaction processing result is returned.
[0004] However, existing technologies cannot finely differentiate between anomaly types, nor can they differentiate processing based on the specific handling stage of the anomaly, the transaction initiation status, or the data write completion status. Regardless of the stage at which the anomaly occurs, a full transaction rollback is uniformly executed. This results in numerous anomaly scenarios that do not require rollback being erroneously triggered, causing unwarranted interruptions to normal business processes, reducing transaction success rates and system availability. Furthermore, for complex transaction scenarios where some writes are successful, partial business rollback or compensatory rollback processing cannot be implemented, making it difficult to ensure the consistency and integrity of transaction data with high precision. Summary of the Invention
[0005] This application discloses a method, apparatus, and storage medium for processing a transaction interface, which can improve the data processing standardization, transaction security, and system stability of the transaction interface.
[0006] The first aspect of this application discloses a method for processing a transaction interface, including: Determine the target transaction interface for the current transaction request, and extract the set of fields corresponding to the target transaction interface from the transaction request; Load the pre-established field template corresponding to the target transaction interface. The field template includes preset field validation rules, field dependencies, and field priorities. Based on the field template, perform field validation on the field set to obtain the validation result; The database transaction initiation method is determined based on the verification result, and the database operation corresponding to the target transaction interface is executed based on the initiation method. If the database operation is abnormal, the corresponding database transaction rollback strategy will be executed according to the stage and type of the abnormality, and a processing result will be generated.
[0007] Optionally, determining the database transaction initiation method based on the verification result includes: When the verification result indicates that a key field is missing or a key condition is not met, the startup mode is determined to be not to start a database transaction, and an error message is returned. When the verification result is passed and it is determined according to the database operation division rules that only a read-only query operation needs to be performed, the startup method is determined to be either delayed startup of database transaction or no startup of database transaction. When the verification result is passed and a data write operation needs to be performed, the startup method is determined to be to start a database transaction after the preconditions are met.
[0008] Optionally, the database operation classification rules are pre-configured within the target transaction interface. The database operation classification rules are used to classify the database operation types corresponding to different target transaction interfaces. The database operation types include read-only query operations and data write operations.
[0009] Optionally, the step of executing the corresponding database transaction rollback strategy based on the stage of the exception and the exception type includes: If an exception occurs and the database transaction has not yet been started, the transaction rollback operation will not be performed; If an exception occurs and the database transaction has been started but a write operation has not yet been performed, the subsequent processing flow of the current transaction request will be terminated, and a processing failure result will be returned. If an exception occurs, the database transaction has been started, and there are uncommitted write operations, then a full transaction rollback will be performed on the database transaction. If an exception occurs and some write operations have already been committed, a partial rollback or compensatory rollback will be performed on the corresponding business logic.
[0010] Optionally, the step of performing field validation on the field set based on the field template includes: Based on the field priority order in the field template, the following validations are performed on the fields in the field set: Perform existence checks on fields that belong to high priority; Perform length, character type, range, and enumeration value validation on format-sensitive fields; Perform condition dependency validation on fields that are part of the conditions; Perform combination integrity checks on fields that are part of a combination; Perform preliminary validation on fields that require validation before database queries; Fields that are of low priority and do not affect subsequent queries will be validated later.
[0011] Optionally, the step of performing database operations corresponding to the target transaction interface based on the startup method includes: If it is determined that the startup method is to start the database transaction, then query whether the target record matching the target transaction interface exists in the database; If the query result indicates that the target record exists, an update operation is performed on the corresponding target record in the database according to the preset update rules; If the query result is not found, a new target record is generated and inserted into the database.
[0012] Optionally, the method further includes: If the database operation is successful, a database transaction commit operation is performed, and the corresponding operation log is recorded and the transaction processing result is returned.
[0013] A second aspect of this application provides a processing apparatus for a transaction interface, comprising: The determining unit is used to determine the target transaction interface of the current transaction request and extract the set of fields corresponding to the target transaction interface from the transaction request. The loading unit is used to load a pre-established field template corresponding to the target transaction interface. The field template includes preset field validation rules, field dependencies, and field priorities. A verification unit is used to perform field verification on the field set based on the field template and obtain a verification result. An execution unit is used to determine the startup method of a database transaction based on the verification result, and to execute database operations corresponding to the target transaction interface based on the startup method. The generation unit is used to generate a processing result by executing the corresponding database transaction rollback strategy according to the stage of the exception and the exception type if the database operation is abnormal.
[0014] A third aspect of this application provides a processing apparatus for a transaction interface, comprising: Processor, memory, input / output units, and bus; The processor is connected to memory, input / output units, and a bus; The memory holds a program, which the processor calls to execute, as in the first aspect and any optional method of the first aspect.
[0015] The fourth aspect of this application provides a computer-readable storage medium on which a program is stored, which, when executed on a computer, performs the methods of the first aspect and any optional methods of the first aspect.
[0016] As can be seen from the above technical solutions, this application has the following advantages: By loading pre-defined field templates, the system standardizes and validates the field sets in transaction requests, improving the standardization and accuracy of field validation and reducing transaction anomalies. Simultaneously, based on the validation results, it determines database transaction initiation rules and executes corresponding database operations, avoiding resource waste caused by blindly initiating database transactions and improving system efficiency. Furthermore, it executes corresponding database transaction rollback strategies based on the anomaly type and processing stage, overcoming the drawbacks of traditional full-scale rollbacks. This allows for precise handling of transaction anomalies across different scenarios, effectively ensuring data consistency and business stability during transaction processing. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A schematic flowchart of an embodiment of a transaction interface processing method provided in this application; Figure 2 A schematic flowchart illustrating an embodiment of determining the initiation method of a database transaction provided in this application; Figure 3 A schematic diagram of an embodiment of the database transaction rollback strategy provided in this application; Figure 4 A schematic diagram of an embodiment of field validation provided in this application; Figure 5 A schematic flowchart illustrating an embodiment of the database operations provided in this application; Figure 6 A structural diagram of an embodiment of a transaction interface processing device provided in this application; Figure 7 Another embodiment of a transaction interface processing apparatus provided in this application is shown in the structural diagram. Detailed Implementation
[0019] It should be noted that the transaction interface processing method provided in this application can be applied to servers, devices, terminals, or other devices with logical processing capabilities, and this application does not limit it. For ease of description, the following description takes a system that manages the transaction interface as the executing entity.
[0020] Please see Figure 1 This application provides an embodiment of a transaction interface processing method, comprising: 101. Determine the target transaction interface for the current transaction request, and extract the set of fields corresponding to the target transaction interface from the transaction request; The system receives transaction requests initiated by clients, identifies and determines the target transaction interface corresponding to the current pending transaction request. Different types of transaction services have their own pre-configured independent transaction interfaces, each with its own specific business field specifications. After determining the target transaction interface, the system parses the received transaction request according to the business field definitions corresponding to that interface, extracting all the field information required for the business processing of the target transaction interface from the transaction request message content, forming a field set matching the current transaction request.
[0021] 102. Load the pre-built field template corresponding to the target transaction interface. The field template contains preset field validation rules, field dependencies, and field priorities. After identifying the target transaction interface and extracting the corresponding field set, a pre-built field template uniquely corresponding to the current target transaction interface is loaded. Specifically, a dedicated field template is pre-configured and stored independently for each type of transaction interface. Transaction interfaces for different business scenarios correspond to differentiated field templates, which are independently adaptable to each other, with no general reuse. For example, the transfer transaction interface, balance query transaction interface, and fund recharge transaction interface are each matched with their own dedicated field template, and each template is customized and generated according to the compliance requirements and data specifications of the corresponding business.
[0022] Specifically, the pre-built field templates are pre-configured with three core rule parameters: field validation rules, field dependencies, and field priorities. Field validation rules standardize the legal data format of each field, including validation criteria such as field character type, data length, value range, and valid enumerated values. Field dependencies define the linkage constraints between different fields; for example, when the transaction type field is interbank transfer, the corresponding opening bank field must be matched and filled, forming a conditional dependency constraint between fields. Field priorities hierarchically classify all business fields, distinguishing between high-priority key fields, format-sensitive fields, conditional fields, combined fields, database pre-validation fields, and low-priority fields. After the field template is loaded, all rules of that field template will be used as the sole validation standard to perform standardized validation processing on the field set corresponding to the current transaction request.
[0023] 103. Perform field validation on the field set based on the field template and obtain the validation results; Based on the preset field priorities, field validation rules, and field dependencies in the field template, the extracted field set is subjected to comprehensive field validation in a hierarchical and categorized manner, and the corresponding validation results are finally output.
[0024] This step does not use a uniform batch verification mode, but executes verification logic differently according to the priority of fields, ensuring that key business fields are verified first and problematic data is intercepted first for pre-verification fields, thereby improving the verification efficiency and accuracy of transaction requests.
[0025] Specifically, existence checks are performed on high-priority fields first. These high-priority fields are mostly core, mandatory fields for transactions, such as transaction serial number, transaction type, and user identification. If such key fields are missing, the check will fail. Secondly, more refined compliance checks are performed on format-sensitive fields. The checks include field character type, data length, numerical range, and enumerated values. For example, the transaction amount field is limited to positive characters, a length not exceeding 12 characters, and a value greater than zero. The transaction status field is only allowed to have limited enumerated values to prevent illegal format data.
[0026] Furthermore, preliminary validation is performed on prerequisite fields that are essential for database queries to prevent subsequent database queries from failing due to field anomalies; deferred validation is performed on low-priority fields that do not affect preliminary queries and core transaction logic to complete format compliance verification without blocking the main process. After completing validation of all levels of fields, the validation results of all validation items are integrated to generate the final validation result.
[0027] 104. Determine the database transaction startup method based on the verification results, and execute the database operation corresponding to the target transaction interface based on the startup method; The database transaction startup method is determined based on the different states of the verification results. Specifically, differentiated transaction startup control logic is configured for three scenarios: verification failure, verification success requiring only a query operation, and verification success requiring a data write operation. This avoids resource waste and blocking issues caused by uniformly starting transactions.
[0028] After determining the corresponding database transaction initiation method, the database operations corresponding to the target transaction interface are executed according to the rule, including querying the target transaction records in the database and selectively performing record update or record insertion operations based on the query results, thus completing the data processing flow corresponding to the current transaction request.
[0029] 105. If a database operation is abnormal, the corresponding database transaction rollback strategy will be executed according to the stage and type of the abnormality, and the processing result will be generated. During database operation execution, when a database operation anomaly is detected, the fixed logic of a uniform full rollback is no longer used. Instead, the stage at which the anomaly occurred and its corresponding anomaly type are identified. A suitable database transaction rollback strategy is then executed based on the current transaction running status, and standardized transaction processing results are generated. The stages at which the anomaly occurred include the parameter validation stage before the transaction starts, the data write preprocessing stage, the uncommitted write stage after the transaction starts, and the stage where some business writes have been completed. The anomaly types include parameter anomalies, business condition anomalies, database connection anomalies, data write failure anomalies, and business process interruption anomalies.
[0030] 106. If the database operation is successful, execute the database transaction commit operation, record the corresponding operation log, and return the transaction processing result.
[0031] If database operations such as adding and updating data are completed successfully without any detected anomalies, the database operation is considered successful, and a database transaction commit operation is triggered. For an already initiated database transaction, the transaction commit operation officially solidifies all data changes generated by the transaction, persistently saving the temporary database write and update operation results to the business database, completing data persistence and ensuring the integrity and consistency of transaction data. For example, in a recharge transaction, after the database operations of updating the user account balance and adding a recharge transaction record are successfully executed, the account data and transaction ledger data officially take effect through transaction commit; in a transfer transaction, after the changes to the account amounts of both parties and the writing of the transfer record are completed, all data changes are solidified through transaction commit.
[0032] After the transaction commit operation is completed, complete transaction information is collected, and corresponding operation logs are generated and stored. The operation logs record, but are not limited to, the current target transaction interface number, transaction operation type, transaction execution time, database operation result, transaction request serial number, and final processing status, forming a complete transaction operation trajectory. After logging is complete, the execution status, data path, version information, and processing result of this transaction are integrated to generate a standardized transaction response message, and the final transaction processing result is returned to the client that initiated the transaction request.
[0033] In this embodiment, a pre-defined field template is loaded to standardize and validate the field set in the transaction request, improving the standardization and accuracy of field validation and reducing transaction anomalies. Simultaneously, database transaction initiation rules are determined based on the validation results, and corresponding database operations are executed, avoiding resource waste caused by blindly initiating database transactions and improving system efficiency. Furthermore, corresponding database transaction rollback strategies are executed based on the anomaly type and processing stage, overcoming the drawbacks of traditional full-scale rollback. This allows for precise handling of transaction anomalies across different scenarios, effectively ensuring data consistency and business stability during transaction processing.
[0034] In step 104 above, the database transaction initiation method is determined based on the verification results. Please refer to [link / reference needed]. Figure 2 This application provides an embodiment for determining the initiation method of a database transaction, the embodiment including: 201. When the validation result indicates that a key field is missing or a key condition is not met, determine that the startup mode is not to start a database transaction and return an error message; After field validation is completed, the validation result is first checked. If it is found that key fields are missing or core business conditions are not met, the database transaction will not be initiated. At the same time, the corresponding error information is assembled and returned, and the subsequent database interaction process will not be initiated. For example, if a transfer transaction request lacks core key fields such as the payee's account or transaction amount, or if a refund transaction does not carry the original transaction number or does not meet the preset business dependency conditions, the validation will be deemed unsuccessful, the creation of the database transaction will be abandoned, and a field exception error message will be returned to avoid initiating invalid database read and write requests and save database resources.
[0035] 202. When the verification result is passed and it is determined according to the database operation division rules that only read-only query operation needs to be performed, determine the startup method as either delaying the start of database transactions or not starting database transactions. If all field validations pass, it means that the field format, integrity, and dependencies of the current transaction request all conform to the preset specifications, meeting the basic conditions for normal processing. At this point, based on the preset database operation classification rules, the business operation type of the current target transaction interface is determined to see if this transaction only requires a read-only query operation. Specifically, a read-only query operation refers to a business type that only reads database inventory data and does not perform any addition, modification, or deletion operations on any business data in the database.
[0036] If it is determined that this transaction only requires a read-only query operation, then the database transaction can be started with a delayed start or without starting a database transaction at all. Since this type of query transaction does not modify the database data and does not require database transaction resources, the overhead of creating and destroying database transactions can be effectively reduced by using transaction-free or delayed start methods, thereby reducing system load and improving transaction processing efficiency.
[0037] Specifically, database operation classification rules are pre-configured within the target transaction interface. These rules are used to classify the database operation types corresponding to different target transaction interfaces. The database operation types include read-only query operations and data write operations.
[0038] Each target transaction interface has pre-configured database operation classification rules. These rules serve as a judgment benchmark to uniformly define the database operation types corresponding to different target transaction interfaces. They can classify the database operations of all transaction interfaces into two categories: read-only query operations and data write operations. The rules are pre-fixed and stored, eliminating the need for real-time dynamic judgment, thus ensuring the uniformity and standardization of transaction processing.
[0039] 203. When the verification result is passed and a data write operation needs to be performed, the startup method is determined to be to start the database transaction after the preconditions are met.
[0040] Based on the pre-configured database operation classification rules in the target transaction interface, the database operation type corresponding to the current transaction request is determined to be a data write operation. Data write operations refer to business behaviors that require adding, updating, or modifying existing business data in the database. These operations alter the persistent data content in the database and have high requirements for data consistency and transaction security; therefore, they are not suitable for transaction-free or delayed transaction strategies.
[0041] For transaction scenarios that pass validation and require data write operations, this step is configured to formally start the database transaction after meeting preset preconditions, rather than starting the transaction unconditionally and immediately. These preconditions include, but are not limited to, core field validation passing, legal and compliant business parameters, normal upstream and downstream call status, and complete basic transaction context. Screening based on these preconditions effectively filters out illegal write requests with valid parameters but abnormal business scenarios, preventing invalid transaction initiation and erroneous data from being written to the database.
[0042] If all preconditions are met, an independent database transaction corresponding to this transaction is initiated, and the atomicity, consistency and rollback of subsequent data write and update operations are guaranteed based on the transaction mechanism.
[0043] For example, transaction scenarios that require the storage of business data, such as account top-ups, fund transfers, transaction status updates, and new transaction records, all fall under the category of data writing operations. After verification is passed and the preconditions are verified to be correct, database transactions are initiated uniformly.
[0044] In this embodiment, a layered and scenario-based database transaction startup control strategy is adopted to adapt differentiated transaction start and stop logic to different transaction verification results and business operation types. This overcomes the rigid defects of the traditional transaction interface that uniformly forces the start of database transactions, and has outstanding technical advantages. It realizes refined and dynamic management and control of database transactions, takes into account both transaction data security and system operation efficiency, and improves the overall stability and operation performance of the transaction processing system.
[0045] If a database operation fails in step 105 above, the corresponding database transaction rollback strategy will be executed based on the stage and type of the exception. Please refer to [link to relevant documentation]. Figure 3 This application provides an embodiment for executing a corresponding database transaction rollback strategy, which includes: 301. If an exception occurs and a database transaction has not yet been started, no transaction rollback operation will be performed; If an anomaly is detected during transaction processing, and a database transaction has not yet been initiated in the current process, no transaction rollback operation will be performed. Since no database transaction has been created, and no uncommitted data changes have occurred in the database, there are no issues of dirty writes, data inconsistencies, or transaction remnants. Therefore, there is no need to trigger a rollback mechanism, and the processing of this abnormal branch will be terminated directly.
[0046] 302. If an exception occurs and a database transaction has been started but a write operation has not yet been performed, the subsequent processing flow of the current transaction request will be terminated, and a processing failure result will be returned. If an anomaly occurs while the current transaction process has completed preliminary logic such as field validation and transaction determination, and has entered the preparation stage before database writing, but has not yet performed the actual data writing operation, then all subsequent processing of the current transaction request will be immediately terminated. The process will not proceed to data query, data update, data insertion, or transaction commit stages, and a processing failure result will be returned to the requesting end. This approach can promptly intercept abnormal requests, preventing the abnormal process from continuing and causing resources to be wasted. For example, if anomalies such as database connection timeout, business permission verification failure, or transaction limit risk control interception occur in the pre-write stage, the system will directly terminate the transaction chain and end the current transaction processing.
[0047] 303. If an exception occurs, a database transaction has been started, and there are uncommitted write operations, then a full transaction rollback will be performed on the database transaction. If an anomaly occurs while a database transaction has been successfully started, and there are executed but uncommitted database write operations within the current transaction context, a full transaction rollback will be performed on the current database transaction. A full rollback can undo all new and updated data changes within this transaction, completely restoring the database data to its consistent state before the transaction started. This ensures that all business operations within a single transaction are rendered invalid, avoiding data inconsistencies where some data is written to the database while others are not. For example, in a transfer transaction, if a deduction write operation has been performed, but a balance verification anomaly, network interruption anomaly, or database execution anomaly is caught before commit, a full rollback of the transfer transaction will be performed, undoing the executed account deduction data changes.
[0048] 304. If an exception occurs and some write operations have already been committed, then perform partial rollback or compensatory rollback processing on the business corresponding to the exception.
[0049] If an anomaly occurs while some write operations for certain business processes within the current transaction have already been completed and are effective, resulting in some valid written data, a full rollback of the entire transaction will not be performed. Instead, a partial rollback or compensatory rollback will be executed for the abnormal business node corresponding to the anomaly. This approach can accurately locate the anomaly chain, restoring or compensating only the erroneous business data, preserving the valid data changes of normal business processes, and avoiding the failure of normal business processes due to large-scale data rollbacks. To further illustrate, in a multi-step combined transaction, if the preceding transaction log writing and ledger record operations have been successfully stored, and only the subsequent status update step encounters an anomaly, then only the abnormal status update business will be rolled back or compensated, preserving the normally generated log data and maximizing the integrity of valid business data.
[0050] In this embodiment, for abnormal scenarios where transactions have not yet started, rollback operations are directly abandoned to avoid executing invalid database rollback commands, reduce unnecessary database interaction overhead, lower system resource consumption, and improve interface response efficiency. For exceptions in the pre-write stage, the transaction process is terminated promptly and a failure result is returned, intercepting abnormal requests in advance, avoiding unnecessary execution of subsequent business and database logic, and preventing resource waste caused by invalid business processing. For scenarios where database transactions have started and there are uncommitted write operations, a full transaction rollback is performed, completely undoing all data changes within the transaction, strictly ensuring the atomicity of database transactions, avoiding uncommitted dirty data, and maintaining the consistency and accuracy of transaction data. For scenarios where some write operations have been committed, a refined processing method of partial rollback or compensatory rollback is adopted, abandoning the one-size-fits-all full rollback mode. Normal and valid business write data can be retained, and only abnormal business nodes are corrected, avoiding the unnecessary loss of valid business data and improving the rationality of data processing and business fault tolerance in complex combined transaction scenarios.
[0051] In step 103 above, field validation is performed on the field set based on the field template. Please refer to [link / reference needed]. Figure 4 This application provides an embodiment for performing field validation, which includes: 401. Based on the field priority order in the field template, perform the following validations on the fields in the field set; 402. Perform existence checks on fields that belong to high priority; 403. Perform length, character type, range, and enumeration value validation on format-sensitive fields; 404. Perform condition dependency validation on fields that are part of the conditions; 405. Perform combination integrity checks on fields that are part of a combination; 406. Perform preliminary validation on fields that require validation before database querying; 407. Perform delayed validation on fields that are of low priority and do not affect subsequent queries.
[0052] After obtaining the field set corresponding to the transaction request and the matching field template, the various fields within the field set undergo tiered and categorized fine-grained validation based on the preset field priority order in the field template. Specifically, existence checks are performed on high-priority fields first. These high-priority fields are core, mandatory fields that ensure the normal operation of the transaction, such as transaction serial number, transaction account, and transaction amount. Existence checks quickly identify abnormal requests with missing key fields, intercepting illegal transactions in advance. Subsequently, compliance checks are performed on format-sensitive fields, sequentially verifying field data length, character type, numerical value range, and valid enumeration values. For example, the transaction status field only allows preset enumeration values, and the mobile phone number and ID number fields are limited to specified character lengths and formats to prevent illegally formatted data from entering subsequent processing.
[0053] Furthermore, conditional dependency validation is performed on conditional fields with linked constraints. The matching relationship between fields is verified according to the pre-defined field dependency rules in the template. For example, when the transaction type is interbank transfer, the opening bank field is checked to ensure it is filled in correctly, guaranteeing that the business logic between fields matches. Simultaneously, the integrity of combined fields with multiple linked effects is verified to ensure that all associated fields are complete and to avoid incomplete business logic due to missing combined fields. To ensure smooth execution of subsequent database operations, fields to be validated before database queries are pre-validated to identify and prevent errors in preconditions and avoid subsequent database query failures. Finally, for low-priority fields that do not affect pre-queries or hinder the core transaction process, a deferred validation approach is adopted, with compliance verification performed only after the core validation process is completed.
[0054] In this embodiment, by using a hierarchical and layered differentiated field verification method, the accuracy and timeliness of the verification of core transaction fields are ensured, and the verification process sequence is reasonably optimized, effectively improving the overall verification efficiency and standardization of transaction requests.
[0055] In step 104 above, the database transaction initiation method is determined based on the verification result, and the database operation corresponding to the target transaction interface is executed based on the initiation method; please refer to [link to relevant documentation]. Figure 5 This application provides an embodiment for performing corresponding database operations, which includes: 501. If the startup method is determined to be to start a database transaction, then query whether the target record matching the target transaction interface exists in the database; After confirming that the database transaction startup method requires initiating a database transaction and completing the pre-validation of fields and business conditions, the process enters the database processing phase within the transaction. This step first uses unique keywords such as transaction serial number, user identifier, and business order number as the query criteria to search the business database based on the business matching conditions corresponding to the current target transaction interface, and determines whether there exists a target business record in the database that precisely matches the current transaction request.
[0056] 502. If the query result indicates that the target record exists, then perform an update operation on the corresponding target record in the database according to the preset update rules; If step 501 retrieves a matching target record from the database, a data update operation is performed on that target record according to preset update rules. These preset update rules predefine the range of fields that can be modified by the current transaction interface, the field assignment logic, data overwrite priority, and update constraints. Only dynamic fields that are allowed to be iteratively changed by the business are modified, while the core, immutable basic fields are retained, ensuring the integrity and traceability of historical business data. For example, in an order status update transaction, the system modifies the order status, transaction completion time, and business remarks fields according to the update rules, without altering the original fixed fields such as order number and creation time, thus achieving compliant iteration of existing business records.
[0057] 503. If the query result is not found, a new target record is generated and inserted into the database.
[0058] If the query result in step 501 indicates that no matching target record exists in the database, it means that the current transaction is a completely new business request, and there is no corresponding existing data to iteratively update. At this time, based on the valid field data that has passed the verification of this transaction request, a complete new target record is assembled and generated according to the database table structure specifications, and this new target record is inserted into the corresponding business database table to complete the persistent writing of the new data.
[0059] In this embodiment, the differentiated database processing logic of querying first, updating if existing data exists, and adding if not, offers the following advantages. First, it adapts to various write-type transaction interface business scenarios, achieving idempotent processing of transaction data, avoiding redundant data insertion caused by repeated requests, and ensuring the cleanliness and uniqueness of database data. Second, it uses preset update rules for targeted updates of existing target records, iteratively modifying only allowed business fields while retaining the original core fields. This achieves dynamic updates of business data while ensuring the integrity and traceability of historical transaction data, improving the standardization and security of data processing. Third, it adaptively distinguishes between update and add logic based on query results, eliminating the need for manual configuration of write strategies for different businesses. This high degree of adaptability and automation simplifies the database processing logic of the transaction interface, reducing system development and maintenance costs. Fourth, all add and update operations are executed within an already opened database transaction. Combined with the aforementioned transaction rollback mechanism, this ensures the atomicity of data operations, avoiding data inconsistencies where some data is updated while others are not, thus improving the reliability of data processing and system stability of the transaction interface.
[0060] Please see Figure 6 This application provides an embodiment of a transaction interface processing apparatus, comprising: The determining unit 601 is used to determine the target transaction interface of the current transaction request and extract the set of fields corresponding to the target transaction interface from the transaction request. The loading unit 602 is used to load a pre-established field template corresponding to the target transaction interface. The field template contains preset field validation rules, field dependencies, and field priorities. Verification unit 603 is used to perform field verification on the field set based on the field template and obtain the verification result; Optionally, the verification unit 603 is also used for: Based on the field priority order in the field template, perform the following field validations on the fields in the field set: Perform existence checks on fields that belong to high priority; Perform length, character type, range, and enumeration value validation on format-sensitive fields; Perform condition dependency validation on fields that are part of the conditions; Perform combination integrity checks on fields that are part of a combination; Perform preliminary validation on fields that require validation before database queries; Fields that are of low priority and do not affect subsequent queries will be validated later.
[0061] The execution unit 604 is used to determine the start mode of the database transaction based on the verification result, and to execute the database operation corresponding to the target transaction interface based on the start mode; Optionally, execution unit 604 is also used for: When the verification result indicates that a key field is missing or a key condition is not met, the startup mode is determined to be not to start a database transaction, and an error message is returned. When the verification result is passed and it is determined according to the database operation division rules that only read-only query operations need to be performed, the startup method is determined to be either delayed in starting database transactions or no database transactions are started. When the verification result is successful and a data write operation needs to be performed, the startup method is determined to be to start the database transaction after the preconditions are met.
[0062] Optionally, execution unit 604 is also used for: Database operation classification rules are pre-configured within the target transaction interface. These rules are used to classify the database operation types corresponding to different target transaction interfaces. The database operation types include read-only query operations and data write operations.
[0063] Optionally, execution unit 604 is also used for: If the startup method is determined to be to start a database transaction, then query the database to see if the target record that matches the target transaction interface exists. If the query result indicates that the target record exists, then the corresponding update operation is performed on the database according to the preset update rules; If the query result is not found, a new target record is generated and inserted into the database.
[0064] The generation unit 605 is used to generate processing results by executing the corresponding database transaction rollback strategy according to the stage and type of the exception if the database operation is abnormal.
[0065] Optionally, the generating unit 605 is also used for: If an exception occurs and a database transaction has not yet been started, the transaction rollback operation will not be performed. If an exception occurs and a database transaction has been started but a write operation has not yet been performed, the subsequent processing flow of the current transaction request will be terminated, and a processing failure result will be returned. If an exception occurs, a database transaction has been started, and there are uncommitted write operations, then a full transaction rollback will be performed on the database transaction. If an exception occurs and some write operations have already been committed, a partial rollback or compensatory rollback will be performed on the corresponding business logic.
[0066] Optionally, a submission unit 606 is also included, for: If the database operation is successful, the database transaction is committed, and the corresponding operation log is recorded and the transaction processing result is returned.
[0067] For detailed implementation methods, please refer to... Figures 1 to 5 Examples are not detailed here.
[0068] Please see Figure 7 This application provides a power consumption control device for palmprint recognition, comprising: Processor 701, memory 702, input / output unit 703, and bus 704.
[0069] The processor 701 is connected to the memory 702, the input / output unit 703, and the bus 704.
[0070] The memory 702 stores a program, and the processor 701 calls the program to execute it, such as... Figure 1 , Figure 2 , Figure 3 , Figure 4 as well as Figure 5 The method in the middle.
[0071] This application provides a computer-readable storage medium on which a program is stored, and when the program is executed on a computer, it performs the following... Figure 1 , Figure 2 , Figure 3 , Figure 4 as well as Figure 5 The method in the middle.
[0072] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0073] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0074] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0075] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0076] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method for processing a transaction interface, characterized in that, include: Determine the target transaction interface for the current transaction request, and extract the set of fields corresponding to the target transaction interface from the transaction request; Load the pre-established field template corresponding to the target transaction interface. The field template includes preset field validation rules, field dependencies, and field priorities. Based on the field template, perform field validation on the field set to obtain the validation result; The database transaction initiation method is determined based on the verification result, and the database operation corresponding to the target transaction interface is executed based on the initiation method. If the database operation is abnormal, the corresponding database transaction rollback strategy will be executed according to the stage and type of the abnormality, and a processing result will be generated.
2. The processing method according to claim 1, characterized in that, The step of determining the database transaction initiation method based on the verification result includes: When the verification result indicates that a key field is missing or a key condition is not met, the startup mode is determined to be not to start a database transaction, and an error message is returned. When the verification result is passed and it is determined according to the database operation division rules that only a read-only query operation needs to be performed, the startup method is determined to be either delayed startup of database transaction or no startup of database transaction. When the verification result is passed and a data write operation needs to be performed, the startup method is determined to be to start a database transaction after the preconditions are met.
3. The processing method according to claim 2, characterized in that, The database operation classification rules are pre-configured within the target transaction interface. These rules are used to classify the database operation types corresponding to different target transaction interfaces. The database operation types include read-only query operations and data write operations.
4. The processing method according to claim 1, characterized in that, The step of executing the corresponding database transaction rollback strategy based on the stage and type of the exception includes: If an exception occurs and the database transaction has not yet been started, the transaction rollback operation will not be performed; If an exception occurs and the database transaction has been started but a write operation has not yet been performed, the subsequent processing flow of the current transaction request will be terminated, and a processing failure result will be returned. If an exception occurs, the database transaction has been started, and there are uncommitted write operations, then a full transaction rollback will be performed on the database transaction. If an exception occurs and some write operations have already been committed, a partial rollback or compensatory rollback will be performed on the corresponding business logic.
5. The processing method according to claim 1, characterized in that, The field validation based on the field template for the field set includes: Based on the field priority order in the field template, the following validations are performed on the fields in the field set: Perform existence checks on fields that belong to high priority; Perform length, character type, range, and enumeration value validation on format-sensitive fields; Perform condition dependency validation on fields that are part of the conditions; Perform combination integrity checks on fields that are part of a combination; Perform preliminary validation on fields that require validation before database queries; Fields that are of low priority and do not affect subsequent queries will be validated later.
6. The processing method according to claim 1, characterized in that, The execution of the database operation corresponding to the target transaction interface based on the startup method includes: If it is determined that the startup method is to start the database transaction, then query whether the target record matching the target transaction interface exists in the database; If the query result indicates that the target record exists, an update operation is performed on the corresponding target record in the database according to the preset update rules; If the query result is not found, a new target record is generated and inserted into the database.
7. The processing method according to any one of claims 1 to 6, characterized in that, The method further includes: If the database operation is successful, a database transaction commit operation is performed, and the corresponding operation log is recorded and the transaction processing result is returned.
8. A processing apparatus for a transaction interface, characterized in that, The device includes: The determining unit is used to determine the target transaction interface of the current transaction request and extract the set of fields corresponding to the target transaction interface from the transaction request. The loading unit is used to load a pre-established field template corresponding to the target transaction interface. The field template includes preset field validation rules, field dependencies, and field priorities. A verification unit is used to perform field verification on the field set based on the field template and obtain a verification result. An execution unit is used to determine the startup method of a database transaction based on the verification result, and to execute database operations corresponding to the target transaction interface based on the startup method. The generation unit is used to generate a processing result by executing the corresponding database transaction rollback strategy according to the stage of the exception and the exception type if the database operation is abnormal.
9. A processing device for a transaction interface, characterized in that, The device includes: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to execute the processing method of the transaction interface as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a program stored thereon, the program, when executed on a computer, performing a processing method of the transaction interface as described in any one of claims 1 to 7.
