OrderPrepareCmdImpl
This step helps preparing the order for submission by determining its final prices( if we have to make a real time price call then this is the place), discounts, shipping charges, and taxes with the help of PrepareOrderCmd task command doProcess() method.
It picks up all the current pending orders of the user in the store if no order reference number is specified. The remerge, merge, check, allocate, backorder and reverse parameters are applicable only if ATP inventory is enabled (STORE Table INVENTORYSYSTEM column value -1).
OrderPrepareCmd calls the following task commands in the sequence-
1.ValidateShippingAdjustmentCmd
2.ValidateShippingMethodCmd
3.PrepareOrderCmd
a. Validates the order is in the correct status which must be any one of the P, I, E, W, or N.
b. If the value of the input request property "commit" is 1(default is 0), a new database transaction is started for every order to be prepared. Otherwise, all orders are prepared in one transaction (the default behavior).
code snippet-
if(ibCommit){
MiscCmd.startNewTransaction(getCommandContext());
lockItemSpecificationsInOrders(abOrder);
}
c. ValidateShippingAdjustmentCmd is invoked to validate that the order hasn't changed since a shipping adjustment was added.
d. Finally PrepareOrderCmd task command is called to do pricing, calculation and inventory actions.
doProcess()-
a. Delete generated order items (refer to the PREPAREFLAGS column in the ORDERITEMS table).
b. Check that all order items in the order are buyable (refer to the BUYABLE column in the CATENTRY table).
c. Call DoInventoryActionCmd to check the availability of the products with action CHECK_INVENTORY.
d. Obtain latest unit price for each order item, except those with manually overridden prices or are quotations. (refer to PREPAREFLAGS column of the ORDERITEMS table).
e. Re-calculate the amounts for the order.
f. Lock the order to indicate that it is ready for the OrderProcess command. The lock can be reset either by expiry, by changing the Order (for example, by using the OrderItemUpdate command), or explicitly by using the OrderUnlock command. The expiry period for a lock is stored in the QUOTEGOODFOR column of the STORE table.
Code Snippet-
if(iATPParameters != null && isLockItemSpecInATP())
lockItemSpecs(iATPParameters.getAllocate(), iATPParameters.getBackorder(), iATPParameters.getReverse());
aOrderProcessingUtility.removeGeneratedOrderItems();
ensureAllOrderItemsAreBuyable(aOrderProcessingUtility);
aOrderProcessingUtility.updateOrderItemAddresses();
aOrderProcessingUtility.updateOrderItemConfigurations(getCommandContext());
updateOrderItemPrices(aOrderProcessingUtility);
if(iATPParameters != null)
iATPParameters.refreshAll();
calculateOrderForFreeGifts(aOrderProcessingUtility);
aOrderProcessingUtility.checkOrderInventory();
InventoryManagementHelper.flush();
calculateOrder(aOrderProcessingUtility);
aOrderProcessingUtility.saveOrder();
OrderProcessCmdImpl
processOrders() -> processOrderComments() -> OrderCommentRecordContrlCmd
-> processOrderChannelId() -> order.BuschnId
-> processPIAdd(ibPerformPIAdd=true) -> PIAddCmd, validatePaymentMethodCmd
-> callProcessOrder(isUBFEnabled()) -> BusinessFlowUrlEventCmd -> PreProcessOrderCmdImpl
-> validateOrderState
-> validateContract() -> CheckCatalogEntryEntitlementCmd
-> validateShippingAddress()
-> allocateInventory() -> DoInventoryActionCmd
-> checkorder() -> CheckOrderCmd
-> CheckOrderAcceptanceCmd
-> updateBillingAddress() -> ValidateOrderAddressCmd
-> CheckPaymentTCsCmd
-> ProcessOrderCmdImpl
-> mergeShopperPayInfo
-> handleOrderFraud()
-> checkOrderAndItemTotals()
-> updateInventory()
-> getInitialAmount() throws exception if dInitialAmount.compareTo(dOrderTotal)
-> UpdateSpendingLimitCmd
This step helps preparing the order for submission by determining its final prices( if we have to make a real time price call then this is the place), discounts, shipping charges, and taxes with the help of PrepareOrderCmd task command doProcess() method.
It picks up all the current pending orders of the user in the store if no order reference number is specified. The remerge, merge, check, allocate, backorder and reverse parameters are applicable only if ATP inventory is enabled (STORE Table INVENTORYSYSTEM column value -1).
OrderPrepareCmd calls the following task commands in the sequence-
1.ValidateShippingAdjustmentCmd
2.ValidateShippingMethodCmd
3.PrepareOrderCmd
a. Validates the order is in the correct status which must be any one of the P, I, E, W, or N.
b. If the value of the input request property "commit" is 1(default is 0), a new database transaction is started for every order to be prepared. Otherwise, all orders are prepared in one transaction (the default behavior).
code snippet-
if(ibCommit){
MiscCmd.startNewTransaction(getCommandContext());
lockItemSpecificationsInOrders(abOrder);
}
c. ValidateShippingAdjustmentCmd is invoked to validate that the order hasn't changed since a shipping adjustment was added.
d. Finally PrepareOrderCmd task command is called to do pricing, calculation and inventory actions.
doProcess()-
a. Delete generated order items (refer to the PREPAREFLAGS column in the ORDERITEMS table).
b. Check that all order items in the order are buyable (refer to the BUYABLE column in the CATENTRY table).
c. Call DoInventoryActionCmd to check the availability of the products with action CHECK_INVENTORY.
d. Obtain latest unit price for each order item, except those with manually overridden prices or are quotations. (refer to PREPAREFLAGS column of the ORDERITEMS table).
e. Re-calculate the amounts for the order.
f. Lock the order to indicate that it is ready for the OrderProcess command. The lock can be reset either by expiry, by changing the Order (for example, by using the OrderItemUpdate command), or explicitly by using the OrderUnlock command. The expiry period for a lock is stored in the QUOTEGOODFOR column of the STORE table.
Code Snippet-
if(iATPParameters != null && isLockItemSpecInATP())
lockItemSpecs(iATPParameters.getAllocate(), iATPParameters.getBackorder(), iATPParameters.getReverse());
aOrderProcessingUtility.removeGeneratedOrderItems();
ensureAllOrderItemsAreBuyable(aOrderProcessingUtility);
aOrderProcessingUtility.updateOrderItemAddresses();
aOrderProcessingUtility.updateOrderItemConfigurations(getCommandContext());
updateOrderItemPrices(aOrderProcessingUtility);
if(iATPParameters != null)
iATPParameters.refreshAll();
calculateOrderForFreeGifts(aOrderProcessingUtility);
aOrderProcessingUtility.checkOrderInventory();
InventoryManagementHelper.flush();
calculateOrder(aOrderProcessingUtility);
aOrderProcessingUtility.saveOrder();
OrderProcessCmdImpl
processOrders() -> processOrderComments() -> OrderCommentRecordContrlCmd
-> processOrderChannelId() -> order.BuschnId
-> processPIAdd(ibPerformPIAdd=true) -> PIAddCmd, validatePaymentMethodCmd
-> callProcessOrder(isUBFEnabled()) -> BusinessFlowUrlEventCmd -> PreProcessOrderCmdImpl
-> validateOrderState
-> validateContract() -> CheckCatalogEntryEntitlementCmd
-> validateShippingAddress()
-> allocateInventory() -> DoInventoryActionCmd
-> checkorder() -> CheckOrderCmd
-> CheckOrderAcceptanceCmd
-> updateBillingAddress() -> ValidateOrderAddressCmd
-> CheckPaymentTCsCmd
-> ProcessOrderCmdImpl
-> mergeShopperPayInfo
-> handleOrderFraud()
-> checkOrderAndItemTotals()
-> updateInventory()
-> getInitialAmount() throws exception if dInitialAmount.compareTo(dOrderTotal)
-> UpdateSpendingLimitCmd
Thanks Nipun for wonderful post
ReplyDelete