2024-11-28 - OrderPrice using linkPath flows

From Izara Wiki
Jump to navigation Jump to search

Service - Sell Offer Manager

notes

  • maybe add more storedCache at points in flows, eg finding values in SellOfferPrice or RateTable, but probably need to add new Dynamo table for each unique request to save the storedCache
  • probably need to discard increment types in ratetable rates, as want to use upToValue ladder for high comparisons

Flow overview

  • Request to calculate orderTotal for existing orderPrice
  • SellOfferManager handles orchestration, responsible for orderPrice object
  • already calculated at time of creating OrderPrice (as never change): sellOfferQuantities/orderQuantity/deliverToLocationIds/sellOfferPlanDeliveryMethodLinkId/sellOfferPlanUserPaymentMethodLinkId
  • use storedCache
  • will validate that all sellOffers in sellOfferQuantities share the same DeliveryMethodLink (and PaymentMethodLink)
  • Create orderSubtotal AwaitingMultipleSteps for each sellOfferId
  • Creates sellOfferIdOrderSubtotalQty AwaitingMultipleSteps for sellOfferQty and orderQty for each sellOfferId, send requests to Order subtotal flow
  • When each completes save value into orderPrice.sellOfferPrices
  • After both sellOfferQty and orderQty complete for one sellOfferId complete, remove orderSubtotal AwaitingMultipleStep and check if all complete
  • If all orderSubtotal AwaitingMultipleSteps complete calculate orderValue by adding up cheapest of sellOfferQty|orderQty for each sellOfferId
  • send orderValue to Order subtotal flow request
  • When completes, if cheaper than previous orderValue, save orderValue into orderPrice, if cheaper than sellOfferQty/orderQty/any previous orderValue, retry until it is not chepaer or reaches retry limit
  • Cheapest price is saved as orderSubtotal
  • save AwaitingStep for Delivery method price and perform flow
  • when completes save price into deliveryPrice
  • save AwaitingStep for Payment method price and perform flow
  • when completes calculate orderTotal (orderSubtotal+deliveryPrice+paymentPrice)
  • save paymentPrice and orderTotal into OrderPrice
  • send message orderPriceCalc complete

Order subtotal

Inital flow

  • per sellOfferId send to SellOffer Handler service (SellOfferStandard)
  • params: sellOfferId, sellOfferPricingType (sellOfferQty/orderQty/orderValue)
  • SellOfferStandard passes to SellOfferPrices service
  • create aggregated SortResult request

Base SortResult request

  • objType: sellOfferPricing
  • translate filter element for sellOfferId
  • logical filter element for sellOfferPricing.type = sellOfferQty|orderQty|orderValue
  • requiredData: linkPath for sellOfferPrice.price
  • sortField: sellOfferPrice.price

LinkPath

  • field: sellOfferPrice.price
  • one LinkPath step, to SellOfferPrice
  • comparison: high
  • comparisonValue: value for sellOfferQty|orderQty|orderValue
  • sort: sellOfferPrice.upToValue

After base SortResult complete

  • aggregate minimum sellOfferPrice.price

Delivery method price

Notes:

  • receives multiple shipTo locationNodeIds, will find all parent locationNodeIds

Inital flow

  • SellOfferManager finds value for each sellOfferId according to sellOfferPlanDeliveryMethodLinkSettings.valueType|deliveryMethodSettings.defaultValueType
  • select value depending on sellOfferPlanDeliveryMethodLinkSettings.accumulateValue |deliveryMethodSettings.defaultAccumulateValue
  • adjust value according to sellOfferPlanDeliveryMethodLinkSettings addToRateTableValuePerOrder and addToRateTableValuePerUnit
  • SellOfferManager sends to DeliveryMethodManager with params: value, locationNodeIds, and deliveryMethodId
  • send to Delivery Method Handler service (DeliveryMethodStandard)
  • DeliveryMethodStandard passes to Delivery Method Rate Table service
  • create aggregated SortResult request

Base SortResult request

  • objType: RateTable
  • translate filter element for deliveryMethodId
  • requiredData: linkPath for rate.price
  • sortField: rate.price

LinkPath

  • field: rate.price
  • one LinkPath step, to rate
  • comparison: high
  • comparisonValue: value
  • sort: rate.upToValue

After base SortResult complete

  • aggregate minimum rate.price

Payment method price

  • SellOfferManager adds orderSubtotal and deliveryPrice together
  • finds paymentPrice using sellOfferPlanUserPaymentMethodLinkSettings.oneTimePercentage and sellOfferPlanUserPaymentMethodLinkSettings.oneTimeAmount
  • if both oneTimePercentage and oneTimeAmount are set, applies oneTimePercentage first