Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

What is the purpose of this article?

...

  1. Order sync and return sync happen depending on events.

  2. Whenever we get an update in DB ( either in case of order or in case of return), we sync that data and update their values in Algolia. ( either in case of order or in case of return) , we sync that data and update their values in Algolia.

  3. The problem we are facing is that we don't get the updates every day and DB does not get updated every day. Because of this, the last update remains as the latest status in Database.

For eg., Suppose the order scheduled to be RTS on 10th Jan, 2022 did not get picked up by the courier partner. As a result, there will be no update on DB about RTS getting delayed. On 11th Jan, 2022, order should be considered as " RTS delayed " with is a reason known. Meanwhile, in DB, update of 10th Jan or 9th Jan will be visible (i.e.,previous update) as RTS did not happen on expected date. So it's status couldn't be updated.

  1. To handle this condition, we will make a cron. This cron will listen all the RTS events and check whether the order is delayed or not and save them in Database.

  2. This will help us keep a track on all the orders that got RTS delayed .

What

...

are the steps for Event Flow ?

  1. Every day at a particular time the cron should run which will check all the orders that got RTS delayed for past two days.

...

Code Block
{
   resource=shipment, 
   eventType=PUT,
   eventSubType=packed,
   accountSlug=raymond, 
   actor=SYSTEM, 
   version=v1, 
   request_data=[],
   response_data={
       customerOrderNumber=6727469972, 
       orderSiteID=, 
       vendorOrderNumber=6727469972, 
       externalShipmentID=6727469972-1679-12, 
       externalWarehouseID=ESBMUM_112, 
       externalChannelID=CH1679, 
       externalWmsChannelName=MYNTRA_RAYMOND_MUMBAI_MUM, 
       external_wms_channel_id=1649.0, 
       channelLabel=Myntra PPMP_N, integrationType=5, 
       defaultWarehouseCode=ESBMUM_112, 
       facilityLabel=Mumbai (ZMUM), 
       facilityType=unicommerce, 
       orderDate=2022-02-11 21:31:39, 
       portal_id=3.0, paymentType=cod, 
       expectedShipDate=2022-02-13 12:00:00, 
       order_id=4.2466552E7, channel_id=1679.0, 
       warehouse_id=72.0, channel_account_id=209.0, 
       account_id=126.0, 
       region=National, 
       isMetro=0, 
       isSpecialplace=0, 
       invoiceNumber=SRA212242544, 
       boxType=UNKNOWN,
       isPriorityShipment=0, 
       isGift=0, 
       invoice_url=https://storage.googleapis.com/eshopbox_wms_uploads/myntraLabel/20220212102451727152883.pdf, 
       invoiceDate=2022-02-12 00:00:00, 
       label_url=https://storage.googleapis.com/eshopbox_wms_uploads/myntraLabel/20220212102451548873136.pdf,
       labels=, 
       shippingInfo=[], 
       boxAdditionalRecommendation=[],
       dimension_length=350,
       dimension_width=210, 
       dimension_height=30, 
       weight=546, 
       trackingID=ML0834329651, 
       trackingDomain=, 
       packageID=6727469972,
       barcode=, taxAmount=0.0, 
       shipChargeAmount=0.0, 
       courierName=ML, 
       cp_id=0.0, 
       created_at=2022-02-11 21:31:49, 
       updated_at=2022-02-12 10:24:53,
       status=packed, 
       remarks=, 
       warehousePincode=421302, 
       thirdPartyShipping=true, 
       customerName=Samikshya Parida, 
       customerContactNumber=9999999999, 
       email=xyz@gmail.com, 
       status_updated_at=2022-02-12 10:24:53,
       status_log={created=2022-02-11 21:31:49, 
       packed=2022-02-12 10:24:53}, 
       status_log_count={created=1.0, 
       packed=1.0}, status_log_id=76256538, 
       orderExternalCreatedAt=2022-02-11 21:31:46, 
       shippingAddress={customerName=Samikshya Parida, 
       addressLine1=Dr. Pankaj Parida, 
       Professor colony near Acharya Harihar Cancer center, 
       addressLine2=Medical College  (Cuttack), city=Cuttack, 
       state=OR, 
       postalCode=753007, 
       countryCode=, 
       countryName=India, 
       contactPhone=9999999999, 
       email=xyz@gmail.com}, 
       warehouseAddress={
              addressLine1=Survey no 20/1, Global complex, Godown no. A/6,Village-Kukse Borivali, 
              addressLine2=Near Shangrila Resort, Taluka Bhiwandi, Dist Thane, city=Thane, state=Maharashtra, postalCode=421302, gstin=27AAFCB0498R1ZZ
       }, 
       id=1.0418464E7, 
       isCOD=1, 
       track_payload=[], 
       packed_date=2022-02-12 10:24:53, 
       items=[
		       {
			     lineItemSequenceNumber=3.3735162E7, 
                 orderItemID=6727469972-22742422, itemID=8907921267104,
                 sku=BBAPLPU137458_XXL, 
                 asin=, 
                 productName=Park Avenue Solid Medium Red Regular Fit Regular Collar 3/4th Sleeve Shirts, 
                 quantity=1.0, 
                 customerPrice=599.0, 
                 lineItemTotal=599.0,
                 invoiceTotal=599.0, 
                 cashOnDeliveryCharges=0.0, 
                 discount=0.0, taxRate=0.0,
                 taxAmount=0.0,
                 inventoryItemCode=, 
                 giftMessage=, 
                 giftLabelContent=, 
                 lineItemOrderStatus=, 
                 orderItemIDs=[6727469972-22742422], 
                 productImageUrl=https://s3-eu-west-1.amazonaws.com/imagebucketeshopbox/Flipkart_153_Styles/PWSU01679-B8/1.jpg, 
                 shippingCharges=0.0, 
                 isVirtualKit=0,
                 onhold=0,
                 cancellationAdditionalReason=, 
                 cancellationReason=,
                 customerOrderItemID=
			   }
		]
	}, 
    previous_data=[],
    resource_type=shipment.update,
    account_slug=raymond, 
    custom=[]
}

...

What are the steps to achieve the Cron Implementation ?

  1. v2/orders/algolia/sync/rts API will insert the records in the database with status as 0 and create a Task in Cloud Task orderSyncTrigger.

  2. Once a task is created in orderSyncTrigger, the task queue will hit the orderSyncTrigger API v2/orders/algolia/sync/rts/update.

  3. The orderSycnTrigger API will query the database and fetch the RTS Delayed data for last two days from order_returns_tags table. 3.1. If the numbers of RTS Delayed data fetched is 0 then simply return meaning, the cron is not needed to be run. 3.2. If the numbers of RTS Delayed data fetched is 0 :-