Order processing method and device
By using the chain of responsibility design pattern and recursive algorithms to process order requests, the problem of poor flexibility in the order of discount asset deduction in the calculation of actual payment amount for offline store orders has been solved, achieving efficient and flexible order processing and improved user experience.
Patent Information
- Application Number
- CN202410967354.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2026-01-20
AI Technical Summary
In existing technologies, the deduction order of preferential assets is not flexible and the code coupling is high during the calculation of the actual payment amount of offline store orders, resulting in low calculation efficiency and poor user experience.
By employing the chain of responsibility design pattern and a recursive algorithm, an asset processing chain is generated. The chain is generated according to the order of user identifier and asset identifier, and order requests are processed step by step, reducing hard coding and code coupling.
It improves order processing efficiency, reduces code coupling, enhances user experience, supports flexible configuration of asset usage order, and reduces development costs and time.
Smart Images

Figure CN121366014A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to an order processing method and device. BACKGROUND
[0002] In the offline store scene, there will be a customer bargaining scene, so that the offline store provides a variety of preferential assets to promote customer order conversion, such as designated store coupons, store manager approved coupons and other virtual asset marketing products; in addition, when calculating the actual payment amount of the order, different stores have different needs for the deduction order of the preferential assets.
[0003] In the related art, the process of calculating the actual payment amount of the order adopts a hard-coded manner, which has poor flexibility, and the asset deduction process has more repeated codes and high code coupling degree, which reduces the calculation efficiency of the actual payment amount of the order. SUMMARY
[0004] Therefore, the embodiments of the present application provide an order processing method and device, which uses a chain of responsibility design pattern and a recursive algorithm to realize order processing, reduces system hard coding, realizes asset use without affecting each other, reduces code coupling degree, improves order processing efficiency, and improves user experience.
[0005] To achieve the above object, according to an aspect of the embodiments of the present application, an order processing method is provided, comprising:
[0006] obtaining a user identifier and each target asset identifier from an order processing request;
[0007] obtaining each asset identifier corresponding to the user identifier and the order of each asset identifier;
[0008] generating a responsibility processing chain according to each asset identifier and the order of each asset identifier, the responsibility processing chain comprising an asset processing node corresponding to each asset identifier and an execution order of each asset processing node;
[0009] transferring the order processing request along each asset processing node in the responsibility processing chain, and processing the order processing request by a target asset node corresponding to the target asset identifier.
[0010] Optionally, before obtaining each asset identifier corresponding to the user identifier and the order of each asset identifier, comprising:
[0011] obtaining each asset identifier corresponding to the user identifier and the order of each asset identifier pre-configured;
[0012] storing the user identifier and each asset identifier and the order of each asset identifier in a configuration center.
[0013] Optionally, a responsibility processing chain is generated according to the respective asset identifiers and the order identifiers of each asset identifier, including:
[0014] For each asset identifier, an asset processing node corresponding to each asset identifier is acquired;
[0015] An execution order of the respective asset processing nodes is determined according to the order identifier of each asset identifier;
[0016] The respective asset processing nodes are concatenated according to the execution order, and the responsibility processing chain is generated.
[0017] Optionally, the order processing request is transmitted along the respective asset processing nodes in the responsibility processing chain, and the order processing request is processed by a target asset node corresponding to the target asset identifier, including:
[0018] When the order processing request is transmitted to any asset processing node in the responsibility processing chain, it is determined whether there is a first asset identifier corresponding to the any asset processing node in the respective target asset identifiers;
[0019] In response to the fact that there is no first asset identifier in the respective target asset identifiers, the order processing request is transmitted to a next asset processing node of the any asset processing node;
[0020] In response to the fact that there is the first asset identifier in the respective target asset identifiers, the any asset processing node is taken as a target asset processing node to process the order processing request.
[0021] Optionally, the target asset processing node includes an asset processing class that implements asset processing logic corresponding to a target asset identifier, and the any asset processing node is taken as a target asset processing node to process the order processing request, including:
[0022] An order processing result of a previous asset processing node corresponding to the target asset processing node is acquired;
[0023] An asset processing parent class corresponding to the asset processing class is acquired; the asset processing parent class includes an asset execution method corresponding to each asset identifier in the respective asset identifiers;
[0024] The asset processing logic is executed, the asset execution method corresponding to the first asset identifier is called, and the order processing request is processed according to the asset execution method corresponding to the target asset identifier and the order processing result of the previous asset processing node, to obtain an order processing result of the target asset processing node.
[0025] Optionally, before the asset processing parent class corresponding to the asset processing class is acquired, the following further includes:
[0026] defining the asset processing parent class, the asset processing parent class being used to define the asset execution method of each asset processing node in the responsibility processing chain and the next asset processing node of each asset processing node and the asset identification corresponding to each asset processing node;
[0027] defining the asset processing class corresponding to each asset identification, the asset processing class including the asset processing logic of the corresponding asset identification, the asset processing logic being used to invoke the asset execution method when executed.
[0028] Optionally, the method further comprises:
[0029] receiving an increase request of a second asset identification, the increase request including the sequence identification of the second asset identification;
[0030] updating the sequence identification of each asset identification corresponding to the user identification and each asset identification in the configuration center according to the sequence identification of the second asset identification.
[0031] According to still another aspect of the embodiments of the present application, there is provided an order processing apparatus, comprising:
[0032] a first obtaining module, used to obtain the user identification and each target asset identification from an order processing request;
[0033] a second obtaining module, used to obtain each asset identification corresponding to the user identification and the sequence identification of each asset identification;
[0034] a generating module, used to generate a responsibility processing chain according to each asset identification and the sequence identification of each asset identification, the responsibility processing chain including the asset processing node corresponding to each asset identification and the execution sequence of each asset processing node;
[0035] a processing module, used to pass the order processing request along each asset processing node in the responsibility processing chain and process the order processing request by the target asset node corresponding to the target asset identification.
[0036] According to another aspect of the embodiments of the present application, there is provided an electronic device, comprising:
[0037] one or more processors;
[0038] a storage device, used to store one or more programs,
[0039] when the one or more programs are executed by the one or more processors, the one or more processors implement the order processing method provided by the present application.
[0040] According to still another aspect of the embodiments of the present application, a computer readable medium is provided, which has stored thereon a computer program, the program being executed by a processor to implement the order processing method provided by the present application.
[0041] An embodiment of the above-mentioned application has the following advantages or beneficial effects: The order processing method of the embodiments of the present application obtains a user identifier and each target asset identifier from an order processing request; then obtains each asset identifier corresponding to the user identifier and the order of each asset identifier; then generates a responsibility processing chain based on each asset identifier and the order of each asset identifier; and transmits the order processing request along each asset processing node in the responsibility processing chain to process the order processing request by the target asset processing node corresponding to the target asset identifier. The method uses the responsibility chain design pattern and recursive algorithm to implement order processing, reduces the hard coding of the business system, realizes the mutual non-influence of asset use, reduces the code coupling degree, improves the development efficiency, reduces the development cost, improves the order processing efficiency, and further improves the user experience.
[0042] The further effects of the above-mentioned non-conventional optional mode will be described in the following in combination with the specific embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0043] The accompanying drawings are used to better understand the present application and do not constitute an improper limitation on the present application. Among them:
[0044] Figure 1 is a schematic diagram of the main flow of an order processing method according to an embodiment of the present application;
[0045] Figure 2 is a schematic diagram of the main flow of an order processing method according to an embodiment of the present application;
[0046] Figure 3 is a structural schematic diagram of a responsibility processing chain according to an embodiment of the present application;
[0047] Figure 4 is a schematic diagram of the system architecture of an order processing method according to an embodiment of the present application;
[0048] Figure 5 is a schematic diagram of the main modules of an order processing device according to an embodiment of the present application;
[0049] Figure 6 is an exemplary system architecture diagram to which the embodiments of the present application can be applied;
[0050] Figure 7 is a structural schematic diagram of a computer system of a terminal device or a server suitable for implementing the embodiments of the present application. DETAILED DESCRIPTION
[0051] The exemplary embodiments of this application are described herein making reference to the accompanying drawings, which include various details of embodiments of the application to facilitate an understanding; however, these should be considered in a descriptive sense only and not limiting. Therefore, various changes and modifications to the embodiments described herein can be made which do not depart from the scope and spirit of the application. Likewise, the description is not to be considered as limited to the described embodiments, but rather, the scope of the application is defined by the appended claims. Also, for clarity and conciseness, the description is divided into sections, which are not intended to limit the scope of the application.
[0052] Figure 1 is a schematic diagram of the main flow of an order processing method according to an embodiment of the application, as shown in Figure 1 The order processing method comprises the following steps:
[0053] Step S101: obtaining a user identifier and each target asset identifier from an order processing request;
[0054] Step S102: obtaining each asset identifier corresponding to the user identifier and the order of each asset identifier;
[0055] Step S103: generating a responsibility processing chain according to each asset identifier and the order of each asset identifier, the responsibility processing chain comprising an asset processing node corresponding to each asset identifier and the execution order of each asset processing node;
[0056] Step S104: transmitting the order processing request along each asset processing node in the responsibility processing chain, and processing the order processing request by a target asset node corresponding to the target asset identifier.
[0057] In the embodiment of the present application, the order processing method can be used to calculate the actual payment amount of the order according to the asset use sequence corresponding to the offline store. In this method, first, an order processing request is received, which can be an order settlement request to make the backend service settle the order and obtain the actual payment amount of the order. The client that sends the order processing request is the business request end, and the consumer can send the order processing request on the settlement page through a terminal device such as a mobile phone, a computer, etc. or through the terminal settlement device of the offline store. The backend service, such as the backend order actual payment amount calculation service, obtains the user identifier and each target asset identifier from the order processing request after receiving the order processing request. The user identifier can be the store identifier of the offline store or the tenant identifier of the tenant corresponding to the offline store, and each tenant can correspond to one or more offline stores. Each target asset identifier can include the target asset identifier selected by the customer when placing an order on the settlement page, and can also include the target asset identifier provided by the offline store for the customer. The target asset identifier is used to identify the target asset, which is a preferential asset that can be used for deduction, such as a full-category discount coupon, a limited-category coupon, a store manager direct discount coupon, a store coupon, a red envelope, a prepayment coupon, a gift card, etc. The actual payment amount of the order is obtained according to the order amount and the preferential asset used for deduction.
[0058] In the embodiment of the present application, before obtaining the user identifier and each target asset identifier from the order processing request, it is verified whether the input parameters in the order processing request are complete, and it is confirmed that the input parameters are complete. The input parameters include the order identifier such as the order number, the product identifier, the product quantity corresponding to each product identifier, each target asset identifier, the asset type of each target asset identifier, the use amount corresponding to each target asset identifier, and the list of product identifiers that can be used for each target asset identifier.
[0059] In the embodiment of the present application, before obtaining each asset identifier corresponding to the user identifier and the sequence identifier of each asset identifier, it includes: obtaining each asset identifier corresponding to the user identifier and the sequence identifier of each asset identifier pre-configured; and storing the user identifier and each asset identifier and the sequence identifier of each asset identifier in the configuration center.
[0060] In the embodiment of the present application, after the user identifier is acquired, the respective asset identifiers corresponding to the user identifier and the order identifiers of the respective asset identifiers are acquired, that is, the respective asset identifiers corresponding to different user identifiers can be different, and the arrangement order of the respective user identifiers can also be different, therefore, the respective asset identifiers corresponding to different user identifiers and the order identifiers of the respective asset identifiers need to be pre-configured. Firstly, the enumeration values of all asset identifiers are defined, then the asset information corresponding to each user identifier is configured, the asset information includes the respective asset identifiers corresponding to the user identifier and the order identifiers of the respective asset identifiers, then the user identifier and the asset information are stored in the configuration center in correspondence, and subsequently the respective asset identifiers corresponding to the user identifier and the order identifiers of the respective asset identifiers can be flexibly adjusted in the configuration center, the flexibility is improved.
[0061] The order identifier can be a sorting value of the asset identifier, used for indicating the serial number of the arrangement order of the respective asset identifiers, and can be determined according to the total quantity of the respective asset identifiers corresponding to the user identifier, for example, if the quantity of the asset identifiers corresponding to the user identifier is 10, the order identifier of each asset identifier is set to a value between 1 and 10 according to the arrangement order of the respective asset identifiers.
[0062] In the embodiment of the present application, the responsibility processing chain is generated according to the respective asset identifiers and the order identifiers of the respective asset identifiers, including: for each asset identifier, acquiring the asset processing node corresponding to each asset identifier; determining the execution order of the respective asset processing nodes according to the order identifier of each asset identifier; and connecting the respective asset processing nodes in series according to the execution order to generate the responsibility processing chain.
[0063] In the embodiment of the present application, after the respective asset identifiers corresponding to the user identifier and the order identifiers of the respective asset identifiers are acquired, the responsibility processing chain corresponding to the user identifier can be generated, and the responsibility processing chain is designed based on the responsibility chain mode. Specifically, the asset processing node corresponding to each asset identifier is acquired, the asset processing node includes the asset processing class corresponding to the asset identifier, that is, the asset processing node is the processor corresponding to the asset identifier, used for executing the asset processing logic corresponding to the asset identifier. The arrangement order of the respective asset identifiers can be determined according to the order identifier of the respective asset identifiers, the execution order of the asset processing node corresponding to each asset identifier can be determined according to the arrangement order of the respective asset identifiers, the respective asset processing nodes are connected in series according to the execution order of the respective asset processing nodes to generate the responsibility processing chain, that is, the asset processing logic of each asset processing node is connected in series to generate the responsibility processing chain, and the responsibility processing chain can automatically associate and call the processing logic of the next asset processing node after the asset processing logic of each asset processing node is called. The asset processing node corresponding to each asset identifier and the execution order of the respective asset processing nodes are included in the responsibility processing chain.
[0064] The responsibility processing chain connects the various asset processing nodes in a chain structure, allowing order processing requests to be passed along the chain until an asset processing node processes the order processing request. This responsibility processing chain allows each asset processing node to have the opportunity to process the order processing request, thereby avoiding the coupling relationship between the receiver and sender of the order processing request and achieving decoupling between the receiver and sender.
[0065] In this embodiment of the invention, the order processing request is transmitted along each asset processing node in the responsibility processing chain, and the order processing request is processed using the target asset node corresponding to the target asset identifier, including:
[0066] When an order processing request is passed to any asset processing node in the responsibility processing chain, it is determined whether there is a first asset identifier corresponding to any asset processing node among the target asset identifiers;
[0067] If the first asset identifier is not found among the target asset identifiers, the order processing request is passed to the next asset processing node of any asset processing node.
[0068] In response to the existence of a first asset identifier among the various target asset identifiers, any asset processing node is used as the target asset processing node to process the order processing request.
[0069] In this embodiment of the invention, after generating the responsibility processing chain, the order processing request is processed using the responsibility processing chain. That is, the order processing request is passed along each asset processing node in the responsibility processing chain. The order processing request is passed according to the order of each asset processing node. Specifically, the order processing request is first matched with the first asset processing node of the responsibility processing chain. If the match is successful, the first asset processing node processes the order processing request. If the match fails, the order processing request is passed to the second asset processing node, and then matched with the second asset processing node. The above process is repeated until the last asset processing node completes the matching and processing of the order processing request, that is, until there is no next asset processing node.
[0070] For any asset processing node in the responsibility processing chain, the order processing request is matched with that asset processing node. That is, it is determined whether there is a first asset identifier corresponding to any asset processing node among the target asset identifiers. In other words, it is determined whether the first asset identifier corresponding to any asset processing node is any of the target asset identifiers. If so, the match is successful, and the order processing request is processed by that asset processing node as the target asset processing node. If not, the order processing request is passed to the next asset processing node.
[0071] In the embodiment of the present application, the target asset processing node comprises an asset processing class implementing asset processing logic corresponding to the first asset identifier, and any asset processing node is taken as the target asset processing node to process the order processing request, which comprises:
[0072] obtaining the order processing result of the previous asset processing node corresponding to the target asset processing node;
[0073] obtaining an asset processing parent class corresponding to the asset processing class; the asset processing parent class comprises an asset execution method corresponding to each asset identifier in the asset identifiers;
[0074] executing the asset processing logic, calling the asset execution method corresponding to the first asset identifier, processing the order processing request according to the asset execution method corresponding to the target asset identifier and the order processing result of the previous asset processing node, and obtaining the order processing result of the target asset processing node.
[0075] In the embodiment of the present application, the target asset processing node comprises an asset processing class implementing asset processing logic corresponding to the target asset identifier, that is, a processor corresponding to the target asset identifier, and when the target asset processing node is used to process the order processing request, if the target asset processing node is not the first asset processing node in the responsibility processing chain, the order processing result of the previous asset processing node of the target asset processing node needs to be obtained.
[0076] Then, the asset processing parent class of the asset processing class is obtained, the processing logic of the asset processing class is executed, the asset execution method in the asset processing parent class is called, the order processing request is processed in combination with the order processing result of the previous asset processing node, and the order processing result of the target asset processing node is obtained. Wherein, the target asset processing node is used to process the order processing request, that is, the target asset is used to process the order processing request, that is, the order amount is split and deducted by the target asset, that is, the amount of each commodity applicable to the target asset is split and deducted, and the order processing result corresponding to the target asset processing node is obtained, which is the order settlement result of the target asset processing node, that is, the order actual payment amount, the deduction amount of each commodity, etc. after the order is split and deducted by the target asset, and after all the target asset processing nodes are recursively processed, the order settlement result is obtained, which comprises order settlement details, that is, the order actual payment amount, the actual payment amount and the deduction amount of each commodity, etc. after the order is split and deducted by all the target assets.
[0077] In the embodiment of the present application, before the asset processing parent class corresponding to the asset processing class is acquired, the asset processing parent class is defined, the asset processing parent class is used to define the next asset processing node of each asset processing node in the responsibility processing chain and the asset execution method corresponding to each asset processing node and the asset identification; the asset processing class corresponding to each asset identification is defined, the asset processing class includes the asset processing logic corresponding to the asset identification, and the asset processing logic calls the asset execution method when executed.
[0078] In the embodiment of the present application, before the asset processing parent class of the asset processing class is acquired, or before the asset processing node corresponding to each asset identification is acquired, the asset processing parent class and the asset processing class are defined, the asset processing class can be a price calculation abstract class, that is, a price calculation method, the asset processing parent class includes the next asset processing node of each asset processing node in the responsibility processing chain, and further includes the asset execution method corresponding to each asset identification, the asset execution method being a public code; the asset processing class is defined, each asset identification corresponds to an asset processing class, the asset processing logic of the asset is implemented, and the asset processing logic of the asset can be the splitting deduction logic of the asset, and the deduction of each asset depends on the result of the previous asset deduction to implement the splitting deduction logic of itself.
[0079] In the embodiment of the present application, each asset processing class can correspond to multiple asset processing parent classes, in the process of executing the asset processing logic of the asset, the asset execution method in the multiple asset processing parent classes can be called, the asset execution method in the asset processing parent class is called to reduce repeated codes and meet the DRY (Don't Repeat Yourself) principle. For example, the asset type corresponding to each target asset identification can be included in the order processing request, the asset type can include a first category asset and a second category asset, for example, the first category asset can be a limited category asset, and the second category asset can be an unlimited category asset, the limited category asset can be used only for a specified commodity range, to prevent asset misuse, asset waste and the like, the asset execution method corresponding to the limited category asset needs to be called again, that is, the public part code of the limited category asset deduction is extracted, the processing logic is ensured to be uniform, and repeated codes are reduced.
[0080] By recursively calling each asset processing node, when the asset identification of the asset processing node is the target asset identification, the asset processing node is the target asset processing node, the asset processing logic corresponding to the target asset processing node is executed, the order processing result is obtained, the order processing results of each target asset processing node are summarized after the recursion is ended, the summarized order processing result is obtained, and then the order dimension amount processing logic is executed on the summarized order processing result, the order processing result corresponding to the order processing request is obtained, and the order processing result is returned. The order dimension amount processing logic is the amount that does not need to be split and deducted to the commodity, such as the freight of the order. The order processing result can include the asset used by each commodity in the order and the allocation of each asset to each commodity, which is determined according to the needs of the front end.
[0081] In the embodiment of the application, the order processing method further comprises: receiving an increase request of a second asset identification; the increase request comprising a sequence identification of the second asset identification; updating each asset identification corresponding to the user identification and the sequence identification of each asset identification in the configuration center according to the sequence identification of the second asset identification.
[0082] In the embodiment of the application, for the case of adding assets to an offline store, an increase request of a second asset identification is received, the increase request indicates the second asset identification and the sequence identification of the second asset identification, the second asset identification is added to the asset information corresponding to the user identification, and the sequence identification of each asset identification corresponding to the user identification is updated according to the sequence identification of the second asset identification. The sequence identification of the second asset identification is the sorting value of the second asset identification, and the sorting value of the second asset identification can be appended after the sorting values of the asset identifications corresponding to the user identification, such as the sorting values of the asset identifications being 1-10, the sorting value of the second asset identification can be 11, or if the sorting value of the second asset identification is 5, the sorting values of the asset identifications after the sorting value are updated, that is, the sorting value of the asset identification with the original sorting value of 5 is updated to 6, thereby realizing the update of each asset identification corresponding to the user identification and the sequence identification thereof in the configuration center, and improving the efficiency of adding assets.
[0083] After the second asset identification is added, an asset processing class inheriting the asset processing parent class is developed to implement the asset processing logic corresponding to the second asset identification, and the asset processing logic can call the asset execution method in the asset processing parent class.
[0084] When the backend computing actual payment amount service is called, the newly added asset processing node is automatically arranged into the responsibility processing chain to execute the split deduction logic of the actual payment amount, without changing the original code structure and logic, only extending the new asset processing class, improving the development efficiency, and shortening the development time.
[0085] Figure 2 A flowchart of an order processing method according to an embodiment of the present application. The method comprises: receiving an order processing request sent by a front end, checking whether the input parameters in the order processing request are complete, if the input parameters are complete, obtaining the store identifier and each target preferential asset in the order processing request, reading the deduction order of the preferential asset corresponding to the store identifier configured in the configuration center, initializing the order price calculation responsibility processing chain, and then processing the order processing request using the responsibility processing chain, executing the price calculation method, and in the execution of the price calculation method, the order processing request is passed along the responsibility processing chain using a recursive call algorithm. The responsibility processing chain is composed of various preferential asset processors, as shown in Figure 3 The responsibility processing chain composed of various preferential asset processors. For the processors in the responsibility processing chain, it is judged whether the preferential asset corresponding to the processor is the target preferential asset, if it is the target preferential asset, the splitting deduction logic of the target preferential asset is executed, and it is judged whether the processing is successful, if the processing is not successful, the result indicating the processing failure is returned, if the processing is successful, it is judged whether there is a next processor, if it is not the target preferential asset, it is judged whether there is a next processor, until all processors are executed, and the results are summarized; the order dimension amount logic is performed on the summarized results to obtain the order processing result, and the order processing result is returned to the front end.
[0086] Figure 4 A system architecture diagram of an order processing method according to an embodiment of the present application. The front end sends an order processing request, and the back end computing service initializes the responsibility chain after receiving the order processing request; the preferential asset deduction order of the store is read from the configuration center, which is the order defined by the front end user store operation; each processor of the responsibility processing chain is recursively called, and the corresponding preferential asset processor is used to process the order processing request, and the splitting deduction logic of the corresponding preferential asset is executed, and in the execution of the splitting deduction logic, the common code is extracted and executed by the public module.
[0087] The order processing method of the embodiment of the application obtains a user identifier and each target asset identifier from an order processing request, then obtains each asset identifier corresponding to the user identifier and an order identifier of each asset identifier, and generates a responsibility processing chain based on each asset identifier and the order identifier of each asset identifier. The order processing request is transmitted along each asset processing node in the responsibility processing chain to process the order processing request by using a target asset processing node corresponding to the target asset identifier. The method uses a responsibility chain design pattern and a recursive algorithm to realize order processing, reduces business system hard coding, realizes asset use without affecting each other, reduces code coupling degree, improves order processing efficiency, and improves user experience. The method supports configuring the use order of each asset according to different user identifiers through a configuration center, realizes flexible configuration, and does not need to modify the original code when adding new assets. The asset processing class corresponding to the new assets can realize rapid response to business requirements, follows the open-closed principle, reduces the code amount of personnel, improves the extensibility of the program, improves the development efficiency, and reduces the development cost. The method integrates common asset execution methods in the order processing process by using the asset processing node, reduces repeated code, follows the DRY principle, and improves the code neatness.
[0088] According to another aspect of the embodiment of the application, as shown in the figure, an order processing device 500 is provided, which comprises: Figure 5
[0089] The first obtaining module 501 obtains a user identifier and each target asset identifier from an order processing request.
[0090] The second obtaining module 502 obtains each asset identifier corresponding to the user identifier and an order identifier of each asset identifier.
[0091] The generating module 503 generates a responsibility processing chain according to each asset identifier and the order identifier of each asset identifier. The responsibility processing chain comprises an asset processing node corresponding to each asset identifier and an execution order of each asset processing node.
[0092] The processing module 504 transmits the order processing request along each asset processing node in the responsibility processing chain, and processes the order processing request by using a target asset node corresponding to the target asset identifier.
[0093] In the embodiment of the application, the second obtaining module 502 is further configured to: before obtaining each asset identifier corresponding to the user identifier and the order identifier of each asset identifier, obtain each asset identifier corresponding to the user identifier and the order identifier of each asset identifier pre-configured; and store the user identifier and each asset identifier and the order identifier of each asset identifier in a configuration center.
[0094] In the embodiment of the present application, the generating module 503 is further used to: for each asset identifier, acquire the asset processing node corresponding to each asset identifier; determine the execution order of the asset processing nodes according to the order identifiers of each asset identifier; and concatenate the asset processing nodes according to the execution order to generate the responsibility processing chain.
[0095] In the embodiment of the present application, the processing module 504 is further used to: when the order processing request is delivered to any asset processing node in the responsibility processing chain, judge whether there is any first asset identifier corresponding to the asset processing node in each target asset identifier; in response to the fact that there is no first asset identifier in each target asset identifier, deliver the order processing request to the next asset processing node of the asset processing node; and in response to the fact that there is a first asset identifier in each target asset identifier, process the order processing request by using the asset processing node as a target asset processing node.
[0096] In the embodiment of the present application, the target asset processing node includes an asset processing class that implements the asset processing logic corresponding to the target asset identifier, and the processing module 504 is further used to: acquire the order processing result of the previous asset processing node corresponding to the target asset processing node; acquire the asset processing parent class corresponding to the asset processing class; the asset processing parent class includes the asset execution method corresponding to each asset identifier; execute the asset processing logic, call the asset execution method corresponding to the target asset identifier, process the order processing request according to the asset execution method corresponding to the first asset identifier and the order processing result of the previous asset processing node, and obtain the order processing result of the target asset processing node.
[0097] In the embodiment of the present application, the processing module 504 is further used to: before acquiring the asset processing parent class corresponding to the asset processing class, define the asset processing parent class, which is used to define the next asset processing node of each asset processing node in the responsibility processing chain and the asset execution method of each asset identifier corresponding to each asset processing node; and define the asset processing class corresponding to each asset identifier, which includes the asset processing logic corresponding to the asset identifier, and the asset processing logic calls the asset execution method when executed.
[0098] In the embodiment of the present application, the first acquiring module 501 is further used to: receive an increase request of a second asset identifier; the increase request includes the order identifier of the second asset identifier; and update the order identifiers of each asset identifier and each asset identifier corresponding to the user identifier in the configuration center according to the order identifier of the second asset identifier.
[0099] According to another aspect of the embodiments of the present application, an electronic device is provided, which includes one or more processors; and a storage storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the order processing method provided by the present application.
[0100] According to still another aspect of the embodiments of the present application, a computer readable medium is provided, which stores a computer program, when the program is executed by a processor, the processor implements the order processing method provided by the present application.
[0101] Figure 6 An exemplary system architecture 600 to which the order processing method or the order processing apparatus provided by the embodiments of the present application can be applied is shown.
[0102] As shown in Figure 6 The system architecture 600 can include terminal devices 601, 602, 603, a network 604 and a server 605. The network 604 is a medium to provide communication links between the terminal devices 601, 602, 603 and the server 605. The network 604 can include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0103] A user can use the terminal devices 601, 602, 603 to interact with the server 605 through the network 604 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 601, 602, 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0104] The terminal devices 601, 602, 603 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers and desktop computers, etc.
[0105] The server 605 can be a server providing various services, such as a background management server supporting a shopping website browsed by a user using the terminal devices 601, 602, 603 (only as an example). The background management server can analyze and process received product information query requests and other data, and feed back the processing results (such as target push information, product information - only as examples) to the terminal devices.
[0106] It should be noted that the order processing method provided by the embodiments of the present application is generally executed by the server 605, and correspondingly, the order processing apparatus is generally provided in the server 605.
[0107] It should be understood that Figure 6The number of terminal devices, networks and servers in the system is merely illustrative. Depending on the implementation needs, there can be any number of terminal devices, networks and servers.
[0108] Reference will now be made to the drawings, in which Figure 7 Fig. 7 shows a schematic diagram of a computer system 700 suitable for use in implementing the terminal device of the embodiments of the present application. Figure 7 The terminal device shown is merely an example and should not impose any limitation on the functions and scope of use of the embodiments of the present application.
[0109] As shown in Fig. 7, the computer system 700 includes a central processing unit (CPU) 701 which can perform various appropriate actions and processes according to programs stored in a read only memory (ROM) 702 or programs loaded from a storage section 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702 and the RAM 703 are connected to each other through a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704. Figure 7 The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as necessary. A removable media 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 710 as necessary, so that a computer program read therefrom is installed into the storage section 708 as necessary.
[0110] In particular, the processes described above with reference to the flow charts can be implemented as a computer software program according to the embodiments disclosed herein. For example, the embodiments disclosed herein include a computer program product comprising a computer program carried on a computer readable medium, the computer program comprising program code for performing the methods illustrated in the flow charts. In such embodiments, the computer program can be downloaded and installed from a network via the communication section 709 and / or installed from the removable media 711. When the computer program is executed by the central processing unit (CPU) 701, the above-described functions defined in the system of the present application are performed.
[0111]
[0112] It should be noted that the computer-readable medium shown in the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or component. In the present application, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or component. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0113] The flow diagrams and block diagrams in the drawings are schematic illustrations of possible architectures, functions and operations of systems, methods and computer program products in accordance with various embodiments of the present application. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flow diagrams, and combinations of blocks in the block diagrams or flow diagrams, can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.
[0114] The modules described in the embodiments of the present application can be implemented in the form of software or in the form of hardware. The described modules can also be arranged in a processor, for example, a processor can be described as including a first acquisition module, a second acquisition module, a generation module, and a processing module. In some cases, the names of these modules do not constitute a limitation on the modules themselves, for example, the first acquisition module can also be described as a module that "acquires a user identifier and various target asset identifiers from an order processing request".
[0115] As another aspect, the present application also provides a computer readable medium, which can be included in the device described in the above embodiments, or can exist independently without being assembled into the device. The computer readable medium carries one or more programs, which, when executed by the device, cause the device to include: acquiring a user identifier and various target asset identifiers from an order processing request; acquiring various asset identifiers corresponding to the user identifier and the order of each asset identifier; generating a responsibility processing chain based on the various asset identifiers and the order of each asset identifier, the responsibility processing chain including asset processing nodes corresponding to each asset identifier and the execution order of the various asset processing nodes; and transmitting the order processing request along the various asset processing nodes in the responsibility processing chain, and processing the order processing request by using the target asset processing node corresponding to the target asset identifier.
[0116] According to the technical solutions of the embodiments of the present application, the order processing method of the embodiments of the present application acquires a user identifier and various target asset identifiers from an order processing request, then acquires various asset identifiers corresponding to the user identifier and the order of each asset identifier, then generates a responsibility processing chain based on the various asset identifiers and the order of each asset identifier, and transmits the order processing request along the various asset processing nodes in the responsibility processing chain to process the order processing request by using the target asset processing node corresponding to the target asset identifier. This method uses the responsibility chain design pattern and recursive algorithm to implement order processing, reduces business system hard coding, realizes asset use without affecting each other, reduces code coupling, improves order processing efficiency, and improves user experience; this method supports configuring the use order of each asset according to different user identifiers through a configuration center, and realizes flexible configuration; this method does not need to modify the original code when adding new assets, and the asset processing class corresponding to the new assets can realize rapid response to business requirements, follow the open-closed principle, reduce the code amount of personnel, improve the extensibility of the program, improve the development efficiency, and reduce the development cost; this method integrates common asset execution methods in the order processing process by using the asset processing node, reduces repeated code, follows the DRY principle, and improves code neatness.
[0117] The foregoing detailed description has set forth various embodiments of the devices and / or processes via the use of specific terminology. However, embodiments thereof can be practiced with the exact description not being presented in detail. The term "device" should be understood to encompass devices operating in various modes, such as active mode, sleep mode, hibernate mode, and the like. The terms "coupled" and "connected," along with their derivatives, can be used. It should be understood that these terms are not intended as synonyms for each other. Rather, particular circuitry that can be said to be coupled or connected can be coupled and connected via some transmission medium.
Claims
1. An order processing method, characterized by, The method comprises the following steps: obtaining a user identifier and a plurality of target asset identifiers from an order processing request; obtaining a plurality of asset identifiers corresponding to the user identifier and a sequence identifier of each asset identifier; generating a responsibility processing chain according to the plurality of asset identifiers and the sequence identifier of each asset identifier, wherein the responsibility processing chain comprises an asset processing node corresponding to each asset identifier and an execution sequence of the plurality of asset processing nodes; passing the order processing request along the plurality of asset processing nodes in the responsibility processing chain, and processing the order processing request by a target asset node corresponding to the target asset identifier.
2. The method of claim 1, wherein, Before the step of obtaining a plurality of asset identifiers corresponding to the user identifier and a sequence identifier of each asset identifier, the method comprises the following steps: obtaining a plurality of asset identifiers corresponding to the user identifier and a sequence identifier of each asset identifier which are pre-configured; storing the user identifier and the plurality of asset identifiers and the sequence identifier of each asset identifier in a configuration center.
3. The method of claim 1, wherein, The step of generating a responsibility processing chain according to the plurality of asset identifiers and the sequence identifier of each asset identifier comprises the following steps: for each asset identifier, obtaining an asset processing node corresponding to the asset identifier; determining an execution sequence of the plurality of asset processing nodes according to the sequence identifier of each asset identifier; serially connecting the plurality of asset processing nodes according to the execution sequence to generate the responsibility processing chain.
4. The method of claim 1, wherein, The step of passing the order processing request along the plurality of asset processing nodes in the responsibility processing chain, and processing the order processing request by a target asset node corresponding to the target asset identifier comprises the following steps: when the order processing request is passed to any asset processing node in the responsibility processing chain, determining whether there is a first asset identifier corresponding to the any asset processing node in the plurality of target asset identifiers; in response to the absence of the first asset identifier in the plurality of target asset identifiers, passing the order processing request to a next asset processing node of the any asset processing node; in response to the presence of the first asset identifier in the plurality of target asset identifiers, processing the order processing request by taking the any asset processing node as a target asset processing node.
5. The method of claim 4, wherein, The target asset processing node comprises an asset processing class which implements asset processing logic corresponding to the target asset identifier, and the step of processing the order processing request by taking the any asset processing node as a target asset processing node comprises the following steps: obtaining an order processing result of a previous asset processing node corresponding to the target asset processing node; obtaining an asset processing parent class corresponding to the asset processing class, wherein the asset processing parent class comprises an asset execution method corresponding to each asset identifier in the plurality of asset identifiers; executing the asset processing logic, calling the asset execution method corresponding to the first asset identifier, processing the order processing request according to the asset execution method corresponding to the target asset identifier and the order processing result of the previous asset processing node to obtain an order processing result of the target asset processing node.
6. The method of claim 5, wherein, Before the step of obtaining an asset processing parent class corresponding to the asset processing class, the method further comprises the following steps: defining the asset processing parent class, the asset processing parent class being used to define the next asset processing node of each asset processing node in the responsibility processing chain and an asset execution method of each asset processing node corresponding to an asset identifier; defining an asset processing class corresponding to each asset identifier, the asset processing class including asset processing logic of the corresponding asset identifier, the asset processing logic being invoked when executed to call the asset execution method.
7. The method of claim 2, wherein, The method further includes: receiving an increase request of a second asset identifier; the increase request including a sequence identifier of the second asset identifier; updating each asset identifier corresponding to the user identifier and the sequence identifier of each asset identifier in the configuration center according to the sequence identifier of the second asset identifier.
8. An order processing apparatus characterized by comprising: comprising: a first obtaining module, obtaining a user identifier and each target asset identifier from an order processing request; a second obtaining module, obtaining each asset identifier corresponding to the user identifier and the sequence identifier of each asset identifier; a generating module, generating a responsibility processing chain according to each asset identifier and the sequence identifier of each asset identifier, the responsibility processing chain including an asset processing node corresponding to each asset identifier and the execution sequence of each asset processing node; a processing module, passing the order processing request along each asset processing node in the responsibility processing chain, and processing the order processing request by a target asset node corresponding to the target asset identifier.
9. An electronic device, comprising: comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method of any one of claims 1-7.
10. A computer readable medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method of any one of claims 1-7.