/
DeliveredOrder Cron

DeliveredOrder Cron

 

Steps:

Fetch CreateOrder Service Response having current status as dispatched

Query:

SELECT orders.customerOrderNumber, SUBSTRING_INDEX(GROUP_CONCAT(shipment_status_logs.status ORDER BY shipment_status_logs.id DESC), ',', 1) AS latestStatus, orders.channel_id, shipments.id, shipments.externalShipmentID FROM orders LEFT JOIN shipments ON shipments.order_id = orders.id LEFT JOIN shipment_status_logs ON shipment_status_logs.shipment_id = shipments.id WHERE orders.created_at >=( CURDATE()-INTERVAL 1 MONTH ) AND orders.channel_id IN ( ?, ? ) GROUP BY orders.id HAVING latestStatus='dispatched'

if OrderItems contains delivered items make an entry in ShipmentStatusLogs table

 

ShipmentStatusLogs ss = new ShipmentStatusLogs(); ss.setShipment_id(shipmentId); ss.setStatus("delivered"); Date d= LocalDateTime.now().toDate(); Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.HOUR,5); cal.add(Calendar.MINUTE, 30); ss.setExternal_updated_at(d); ss.setIsForwardTransaction("0"); ss.setRemarks("delivered"); ss.setTrack_payload("delivered"); session.saveOrUpdate(ss);

 

Related content