Ajio RTO Flow
This case will happen when at ajio the return is not created and at warehouse we receive the returned order item.
We will be implementing a cron to fetch the RTO data from DB and create the return on Ajio and mark it acknowledged as well.
Cron: _ah/api/esb/v1/ajioPullRtoOrders
Cron name: ajio-rto-orders-cron
Step 1:
We will use the below query to fetch the returns details from DB:
SELECT orders.customerOrderNumber, order_items.itemID ,order_items.orderItemID , order_items.quantity , order_items.qcRejectionReason, order_items.returnReason
FROM order_items
INNER JOIN orders ON orders.id = order_items.order_id
INNER JOIN channels ON channels.id = orders.channel_id
INNER JOIN shipments ON shipments.id = order_items.shipment_id
INNER JOIN shipment_status_logs ON shipment_status_logs.shipment_id = shipments.id
WHERE channels.integrationType = '16' AND shipment_status_logs.status ='rto_delivered_warehouse'
AND order_items.returnFlag = '1' AND order_items.warehouseInboundStatus = 'COMPLETE'
AND DATE(shipment_status_logs.created_at) >= latestSyncTime
Step 2:
We will further loop through the returns we fetched from DB and map them to Ajio’s create RTO API.
Key | Mapping value |
---|---|
| orders.customerOrderNumber |
|
|
| order_items.itemID |
| orders.customerOrderNumber + order_items.lineItemSequenceNumber |
| Total quantity of an itemID |
| order_items.reversePickupReason |
| order_items.returnReason |
order_items.reversePickUpReason | QC_CODE |
---|---|
|
|
|
|
|
|
Step 3: Once the request body is prepared, We will call the Ajio create RTO API to create a return on Ajio.
URL
POST : http://116.50.64.106:8080/ds/eshopbox/return/rto
Headers :
Keys | Values |
---|---|
| ajioAccessToken |
RequestBody :
{
"order_id": "string",
"order_items": [
{
"item_id": "string",
"order_item_id": "string",
"quantity": 0,
"qc_code": "string",
"reason": "string"
}
]
}
Response :
{
"error_message": "string",
"return_order_id": "string",
"status": "enum (SUCCESS, FAILED)"
}
Step 4: Mark the return as acknowledged as well after creating RTO on Ajio.
POST API:
http://116.50.64.106:8080/ds/eshopbox/return/qc
Request Body:
order_items.reversePickUpReason | QC_CODE |
---|---|
|
|
|
|
|
|
{
"return_order_id": "{{return_shipments.customerReturnNumber}}",
"return_order_items": [
{
"return_item_id": "{{order_items.lineItemSequenceNumber}}",
"quantity": {{order_items.quantity}},
"qc_code": "string",
"reason": "string"
}
]
}
Response:
{
"error_message": "string",
"status": "enum (SUCCESS, FAILED)"
}