Parcel Order in Crossdesk360
Step:1 After Scanning the barcode the details of the order will be displayed as below image.
Step:2 You can change the printer configuration by clicking on the printer option to print the receipt on the respective printer.
Step:3 After that click on the complete order option to finish the parceling and to print the receipt on the printer.
Congratulations! Your order is processed.
Backend Flow for Completing an Order (Finish Parceling)
Upon clicking the Complete Order button on the frontend, a request is made to the backend to finalize the order and complete the parceling process. Below is the step-by-step flow of the backend service call:
- Frontend Initiates the API Call
The frontend triggers an HTTP POST request to the endpoint:- API Endpoint: POST /finish-parceling
- This request includes necessary data, such as the FinishParcelingCommand, which contains the parceling details and order information.
- Backend API Endpoint (FinishParceling)
The finish-parceling API endpoint in the backend receives the request and proceeds with the following actions:- It first extracts the FinishParcelingCommand and any required authToken from the incoming request.
- The backend calls the FinishParcelingAsync service method to process the parceling logic.
- Service Layer: Calling the FinishParceling Method
The FinishParcelingAsync method, located within the service layer, handles the core logic for completing the parceling:- It interacts with an external service via a Refit client to call the old warehouse API:
- API Endpoint: POST /Parceling/FinishParceling360
- The Refit client asynchronously calls this API with the required data from the FinishParcelingCommand.
- It interacts with an external service via a Refit client to call the old warehouse API:
- Processing the Response from Warehouse
After the service sends the request to the warehouse API (FinishParceling360), the response is handled:- If the response is successful (HTTP status code 2xx), the service returns a success result with a message indicating that the parceling is complete.
- If the response is unsuccessful (HTTP error or failure), the service logs the error details, including the exception message, and returns a failure result with an internal server error (HTTP 500) along with the error message.
- Return the Result to Frontend
Based on the outcome of the FinishParcelingAsync service call:- Success: A success message and any relevant data (such as the finished parcel details) are returned to the frontend.
- Failure: An error message and status code are returned to the frontend, indicating that the parceling process could not be completed.
Example Flow:
- Frontend sends a request to /finish-parceling.
- Backend API calls FinishParcelingAsync.
- Service Layer makes a request to /Parceling/FinishParceling360 in the warehouse.
- Warehouse API processes the request and responds with a success or failure.
- Backend processes the warehouse API response, logging any errors or returning a success message.
- Frontend receives the response and updates the UI accordingly.
Estimated Time Taken by Service Breakout (Local):