Unfulfillable Order Cancellation missing details Issue Fix
What is the purpose of this article?
The purpose of this article is to fix the below two issues occurring on the workspace
For unfulfillable orders, cancellation Type, Reason, SubReason and Additional remarks are not getting saved in Algolia.
The cancellation type getting saved is incorrect in some cases.
This document will thoroughly discuss the logic and technical implementation to fix this issue.
Current Implementation
Whenever the Algolia sync Api is called through the task queue, it accepts the order item ids (primary keys) as the request parameters
Api type and path - POST algolia/sync/orderItemIds (order return service) repository - esb client order return gcp project - eshopbox-client-portal-prod API Curl curl --location 'https://order-return-dot-eshopbox-client-portal-prod.appspot.com/_ah/api/esb/v2/algolia/sync/orderItemIds' \ --header 'Content-Type: application/json' \ --data '{ "data": "[31351372, 31351577, 31359295, 31362715]" }'
Now fetch all the details required to be synced in Algolia by the order items ids (primary keys)
Prepare an Algolia model Object
Write the logic to set the details in the algolia model Object (e.g., logic for order status, current status, cancellation etc.)
Once the details are set in the Algolia model Object. Update the object in algolia
The logic for Order Cancellation details to be set in Algolia
If shipment_status_logs is empty, then simply return else
{Iterate over the shipmentLogs
check if the status is cancelled,
a. Check if the remark contains "fulfillment_cancel" then set the cancellationType as seller
b. If the remark does not contain "fulfillment_cancel" then set the cancellationType as customer
c. Get cancellationReason from order_items table.
1. if cancellationReason contains two reasons separated by comma then set First reason as cancellationReason and second reason as cancellationSubReason
2. if cancellationReason contains only one reason then then set it as cancellationReason
d. Get remark from order_items table.If the remarks is not empty or null then set it in Additional remarks
}
issue with the current implementation :-
For unfulfillable orders, cancellation Type, Reason, SubReason and Additional remarks are not getting saved in Algolia.
The cancellation type getting saved is incorrect in some cases.
Below are the issues mentioned in detail in table format
cancellation reason | what is shown on workspace as per current implementation in cancelled By | Expected (cancelled By) |
---|---|---|
Item unavailable | Customer | Seller |
Other | customer | Seller |
Not able to service by shipping partner | customer | Seller |
Flagged as Fraudulent order | customer | Customer |
Order shipped from another location | customer | Customer |
Customer requested | Customer | Customer |
Technical steps to achieve the new task
This logic is for any single order item syncing in algolia.
check if the status is cancelled. i.e., status column of order_items table contains the value “CANCELLED“
If false then return
Store all the 3 reasons of customer cancellation in constants.java in a String variable.
Get cancellation reason from cancellationReason column of order_items table and store it in a String variable named cancellationReason.
If cancellationReason contains comma, then split it by comma
Set the 0th array index as cancellation reason
Set the 1th array index as cancellation sub reason
if cancellationReason does not contains comma,
Set it as cancellation reason directly
Check if the reasons in constants contains cancellationReason
If true, set cancellation type as “customer“ else “seller“
Get the detail of remark column of order_items table
If the remark is not null or emprt, then set it as additional remarks