Service - Cart: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
(Created page with "= Overview = Manages a shopping cart of sell offers prior to confirming as order/s. = Repository = https://bitbucket.org/izara-market-orders/izara-market-orders-cart = Dyn...")
 
No edit summary
 
(17 intermediate revisions by the same user not shown)
Line 5: Line 5:
= Repository =
= Repository =


https://bitbucket.org/izara-market-orders/izara-market-orders-cart
https://bitbucket.org/izara-market-services/izara-market-orders-cart


= DynamoDB tables =
= DynamoDB tables =
Line 23: Line 23:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
configTag: "SellOfferPlanServiceName"
configTag: "DeliveryMethodManagerServiceName"
configKey: "SellOfferPlanServiceName"
configKey: "DeliveryMethodManagerServiceName"
configValue: xxx // eg: "DeliveryMethodManager"
configValue: xxx // eg: "DeliveryMethodManager"
}
}
Line 31: Line 31:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
configTag: "DeliveryMethodManagerServiceName"
configTag: "PaymentMethodManagerServiceName"
configKey: "DeliveryMethodManagerServiceName"
configKey: "PaymentMethodManagerServiceName"
configValue: xxx // eg: "DeliveryMethodManager"
configValue: xxx // eg: "PaymentMethodManager"
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 39: Line 39:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
configTag: "PaymentMethodManagerServiceName"
configTag: "SellOfferPlanServiceName"
configKey: "PaymentMethodManagerServiceName"
configKey: "SellOfferPlanServiceName"
configValue: xxx // eg: "PaymentMethodManager"
configValue: xxx // eg: "SellOfferPlan"
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 55: Line 55:
= Graph database =  
= Graph database =  


== [[Service - Orders Graph]]==
== [[Service - Orders Graph]] ==


=== Nodes ===
=== Nodes ===
Line 70: Line 70:
identifier: true, // create unique id from request params and uniqueMessageId
identifier: true, // create unique id from request params and uniqueMessageId
},
},
totalQuantity: {},
totalValue: {}, // will be in the currency of the deliveryMethod selected (sellOffer/sellOfferPlans must match deliveryMethod currency or are invalid)
name: {},
status: {}, // validating|valid|invalid|partiallyValid
timeValidated: {}, // date last time validated
},
},
}
}
Line 77: Line 82:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
nodeLabel: "{SellOfferPlanLib.SELLOFFERPLAN_DELIVERYMETHODLINK_GRAPH_NODE_LABEL}", // "sellOfferPlanDeliveryMethodLink"
nodeLabel: "{CartPlanLib.CART_SELLOFFERLINK_GRAPH_NODE_LABEL}", // "cartSellOfferLink"
schema: {
schema: {
identifier: true,
identifier: true,
Line 83: Line 88:
restrictRelationships: true,
restrictRelationships: true,
properties: {
properties: {
sellOfferPlanDeliveryMethodLinkId: {
cartSellOfferLinkId: {
identifier: true, // create unique id from request params and uniqueMessageId
identifier: true, // create unique id from request params and uniqueMessageId
},
},
quantity: {},
},
},
}
}
Line 93: Line 99:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
nodeLabel: "{SellOfferPlanLib.SELLOFFERPLAN_PAYMENTMETHODLINK_GRAPH_NODE_LABEL}", // "sellOfferPlanPaymentMethodLink"
nodeLabel: "{CartPlanLib.CARTORDER_GRAPH_NODE_LABEL}", // "cartOrder"
schema: {
schema: {
identifier: true,
identifier: true,
Line 99: Line 105:
restrictRelationships: true,
restrictRelationships: true,
properties: {
properties: {
sellOfferPlanPaymentMethodLinkId: {
cartOrderId: {
identifier: true, // create unique id from request params and uniqueMessageId
identifier: true, // create unique id from request params and uniqueMessageId
},
},
status: {}, // processing|complete|error
errors: {}, // array of errors found
totalQuantity: {},
totalValue: {}, // will be in the currency of the deliveryMethod selected (when change deliveryMethod need to re-calculate cart)
},
},
}
}
Line 107: Line 117:
</syntaxhighlight>
</syntaxhighlight>


=== Versioned data ===
=== Relationships ===
 
==== sellOfferPlanDeliveryMethodLinkSettings ====


<syntaxhighlight lang="JavaScript">
{
{
properties: {
relationshipType: "{CartPlanLib.createHasCompletedCartGraphRelationshipType()}", // "hasWorking_cart"
oneTimeAmountSetting: {}, // "value"|"rate", do we add one time cost to the value before calculating, or is it a straight rate added after calculating
schema: {
oneTimeAmount: {}, // value of the one time amount
elementCanBeRemoved: true,
oneTimeAmountAccumulate: {}, // boolean true|false, if TRUE for combined orders then add oneTimeAmount for each included Sell Offer, if FALSE only gets added once
allPropertiesImmutable: true,
valueType: "xx", // quantity|productValue|productAttribute|sellOfferTerm, if set overwrites deliveryMethod defaultValueType
restrictProperties: true,
valueId: "xx", // if set overwrites deliveryMethod defaultValueId
properties: {
},
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
}
 
</syntaxhighlight><syntaxhighlight lang="JavaScript">
 
==== sellOfferPlanPaymentMethodLinkSettings ====
 
{
{
properties: {
relationshipType: "{CartPlanLib.createHasCompletedCartGraphRelationshipType()}", // "hasCompleted_cart"
oneTimeAmountSetting: {}, // "cost"|"percentage", do we add a one time cost, or add a % to the order total
schema: {
oneTimeAmount: {}, // value of the one time amount
elementCanBeRemoved: true,
},
allPropertiesImmutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
}
 
</syntaxhighlight>
==== sellOfferPlanSettings ====
<syntaxhighlight lang="JavaScript">
 
{
{
properties: {
relationshipType: "{CartPlanLib.createHasDeletedCartGraphRelationshipType()}", // "hasDeleted_cart"
combineWins: {}, // true|false
schema: {
},
elementCanBeRemoved: true,
allPropertiesImmutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
}
 
</syntaxhighlight>
=== Relationships ===
* links a user to a cart
* a cart can either be working, completed, or deleted


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
relationshipType: "{SellOfferPlanLib.createOwnsSellOfferPlanGraphRelationshipType()}", // "owns_sellOfferPlan"
relationshipType: "{CartPlanLib.createHasActiveCartGraphRelationshipType()}", // "hasActive_cart"
schema: {
schema: {
elementCanBeRemoved: true,
elementCanBeRemoved: true,
Line 154: Line 173:
}
}
</syntaxhighlight>
</syntaxhighlight>
* links a sell offer to a sell offer plan
* all users should have one cart that is active
* a sell offer has only one sell offer plan


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
relationshipType: "{SellOfferPlanLib.createHasSellOfferPlanGraphRelationshipType()}", // "has_sellOfferPlan"
relationshipType: "{CartPlanLib.cartPaymentMethodGraphRelationshipType()}", // "cart_paymentMethod"
schema: {
schema: {
elementCanBeRemoved: true,
elementCanBeRemoved: true,
Line 170: Line 188:
}
}
</syntaxhighlight>
</syntaxhighlight>
* links a user to one of their sell offer plans
* links a cart to it's current paymentMethod setting


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
relationshipType: "{SellOfferPlanLib.createHasDeliveryMethodLinkGraphRelationshipType()}", // "has_deliveryMethodLink"
relationshipType: "{CartPlanLib.cartDeliveryMethodGraphRelationshipType()}", // "cart_deliveryMethod"
schema: {
schema: {
elementCanBeRemoved: true,
elementCanBeRemoved: true,
Line 185: Line 203:
}
}
</syntaxhighlight>
</syntaxhighlight>
* links a cart to it's current deliveryMethod setting
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
relationshipType: "{SellOfferPlanLib.createDisabledDeliveryMethodLinkGraphRelationshipType()}", // "disabled_deliveryMethodLink"
relationshipType: "{CartPlanLib.cartShipToAddressGraphRelationshipType()}", // "cart_shipToAddress"
schema: {
schema: {
elementCanBeRemoved: true,
elementCanBeRemoved: true,
Line 198: Line 218:
}
}
</syntaxhighlight>
</syntaxhighlight>
* links a cart to it's current ship to address setting


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
relationshipType: "{SellOfferPlanLib.createHasPaymentMethodLinkGraphRelationshipType()}", // "has_paymentMethodLink"
relationshipType: "{CartPlanLib.createHasCartSellOfferLinkGraphRelationshipType()}", // "has_cartSellOfferLink"
schema: {
schema: {
elementCanBeRemoved: true,
elementCanBeRemoved: true,
Line 214: Line 235:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
relationshipType: "{SellOfferPlanLib.createDisabledPaymentMethodLinkGraphRelationshipType()}", // "disabled_paymentMethodLink"
relationshipType: "{CartPlanLib.createCartSellOfferLinkIsSellOfferGraphRelationshipType()}", // "cartSellOfferLinkIs_sellOffer"
schema: {
schema: {
elementCanBeRemoved: true,
elementCanBeRemoved: true,
Line 225: Line 246:
}
}
</syntaxhighlight>
</syntaxhighlight>
* Links cartSellOfferLink to one sellOffer


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
relationshipType: "{SellOfferPlanLib.createIsDeliveryMethodGraphRelationshipType()}", // "is_deliveryMethod"
relationshipType: "{CartPlanLib.createCarthasCartOrderGraphRelationshipType()}", // "has_cartOrder"
schema: {
schema: {
elementCanBeRemoved: true,
elementCanBeRemoved: true,
Line 242: Line 264:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
relationshipType: "{SellOfferPlanLib.createIsPaymentMethodGraphRelationshipType()}", // "is_paymentMethod"
relationshipType: "{CartPlanLib.createCartOrderHasCartSellOfferLinkGraphRelationshipType()}", // "cartOrderHas_cartSellOfferLink"
schema: {
schema: {
elementCanBeRemoved: true,
elementCanBeRemoved: true,
Line 253: Line 275:
}
}
</syntaxhighlight>
</syntaxhighlight>
* links a cartSellOfferLink to a cartOrder
= Cart Orders =
* One cart can have many sellOffers from many sellers, or sell offers that don't combineWins, that cannot be purchased as a single order
* When validating split out into multiple orders according to what can be combined into a single payment/order
== Grouping into orders ==
* Done when validating cart
* Go through each selloffer:
*# does it offer the cart's paymentMethod? If not is invalid
*# does its offer the cart's deliveryMethod? If not is invalid
*# does the quantity chosen validate sellOffer available qty/minimum quantity? If not is invalid
*# if no sellOffers valid then cart status is invalid. If some sellOffers invalid then cart status is partiallyValid
*# if sellOffer does not combine then it gets put into it's own order
*# do all sellOfferPlans for all sellOffers use the same valueType/valueId (either from deliveryMethod or from sellOfferPlanDeliveryMethodLink), if not must split out
*# split sellOffers by seller and stock location
= Data model notes =
* Consider cart details transient and of low importance, no need to have record of changes
= Ideas =
* cart service could have function for testing multiple prices, find all payment methods and delivery methods offered by all sell offers in cart, then find total price for each combination (maybe also check all delivery methods ship to selected destination?)


= Working documents =
= Working documents =


[[:Category:Working_documents - Sell Offer Plan|Sell Offer Plan]]
[[:Category:Working_documents - Cart|Cart]]


[[Category:Backend services| Sell Offer Plan]]
[[Category:Backend services| Cart]]

Latest revision as of 00:35, 9 March 2025

Overview

Manages a shopping cart of sell offers prior to confirming as order/s.

Repository

https://bitbucket.org/izara-market-services/izara-market-orders-cart

DynamoDB tables

Standard Config Table Per Service

Configuration tags

{
	configTag: "SellOfferManagerServiceName"
	configKey: "SellOfferManagerServiceName"
	configValue: xxx // eg: "SellOfferManager"
}
{
	configTag: "DeliveryMethodManagerServiceName"
	configKey: "DeliveryMethodManagerServiceName"
	configValue: xxx // eg: "DeliveryMethodManager"
}
{
	configTag: "PaymentMethodManagerServiceName"
	configKey: "PaymentMethodManagerServiceName"
	configValue: xxx // eg: "PaymentMethodManager"
}
{
	configTag: "SellOfferPlanServiceName"
	configKey: "SellOfferPlanServiceName"
	configValue: xxx // eg: "SellOfferPlan"
}
{
	configTag: "OrderGraphServiceName"
	configKey: "OrderGraphServiceName"
	configValue: xxx // eg: "OrderGraph"
}

Graph database

Service - Orders Graph

Nodes

{
	nodeLabel: "{CartPlanLib.CART_GRAPH_NODE_LABEL}", // "cart"
	schema: {
		identifier: true,
		restrictProperties: true,
		restrictRelationships: true,
		properties: {
			cartId: {
				identifier: true, // create unique id from request params and uniqueMessageId
			},
			totalQuantity: {},
			totalValue: {}, // will be in the currency of the deliveryMethod selected (sellOffer/sellOfferPlans must match deliveryMethod currency or are invalid)
			name: {},
			status: {}, // validating|valid|invalid|partiallyValid
			timeValidated: {}, // date last time validated
		},
	}
}
{
	nodeLabel: "{CartPlanLib.CART_SELLOFFERLINK_GRAPH_NODE_LABEL}", // "cartSellOfferLink"
	schema: {
		identifier: true,
		restrictProperties: true,
		restrictRelationships: true,
		properties: {
			cartSellOfferLinkId: {
				identifier: true, // create unique id from request params and uniqueMessageId
			},
			quantity: {},
		},
	}
}
{
	nodeLabel: "{CartPlanLib.CARTORDER_GRAPH_NODE_LABEL}", // "cartOrder"
	schema: {
		identifier: true,
		restrictProperties: true,
		restrictRelationships: true,
		properties: {
			cartOrderId: {
				identifier: true, // create unique id from request params and uniqueMessageId
			},
			status: {}, // processing|complete|error
			errors: {}, // array of errors found
			totalQuantity: {},
			totalValue: {}, // will be in the currency of the deliveryMethod selected (when change deliveryMethod need to re-calculate cart)
		},
	}
}

Relationships

{
	relationshipType: "{CartPlanLib.createHasCompletedCartGraphRelationshipType()}", // "hasWorking_cart"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
{
	relationshipType: "{CartPlanLib.createHasCompletedCartGraphRelationshipType()}", // "hasCompleted_cart"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
{
	relationshipType: "{CartPlanLib.createHasDeletedCartGraphRelationshipType()}", // "hasDeleted_cart"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • links a user to a cart
  • a cart can either be working, completed, or deleted
{
	relationshipType: "{CartPlanLib.createHasActiveCartGraphRelationshipType()}", // "hasActive_cart"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • all users should have one cart that is active
{
	relationshipType: "{CartPlanLib.cartPaymentMethodGraphRelationshipType()}", // "cart_paymentMethod"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • links a cart to it's current paymentMethod setting
{
	relationshipType: "{CartPlanLib.cartDeliveryMethodGraphRelationshipType()}", // "cart_deliveryMethod"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • links a cart to it's current deliveryMethod setting
{
	relationshipType: "{CartPlanLib.cartShipToAddressGraphRelationshipType()}", // "cart_shipToAddress"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • links a cart to it's current ship to address setting
{
	relationshipType: "{CartPlanLib.createHasCartSellOfferLinkGraphRelationshipType()}", // "has_cartSellOfferLink"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
{
	relationshipType: "{CartPlanLib.createCartSellOfferLinkIsSellOfferGraphRelationshipType()}", // "cartSellOfferLinkIs_sellOffer"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • Links cartSellOfferLink to one sellOffer
{
	relationshipType: "{CartPlanLib.createCarthasCartOrderGraphRelationshipType()}", // "has_cartOrder"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
{
	relationshipType: "{CartPlanLib.createCartOrderHasCartSellOfferLinkGraphRelationshipType()}", // "cartOrderHas_cartSellOfferLink"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • links a cartSellOfferLink to a cartOrder

Cart Orders

  • One cart can have many sellOffers from many sellers, or sell offers that don't combineWins, that cannot be purchased as a single order
  • When validating split out into multiple orders according to what can be combined into a single payment/order

Grouping into orders

  • Done when validating cart
  • Go through each selloffer:
    1. does it offer the cart's paymentMethod? If not is invalid
    2. does its offer the cart's deliveryMethod? If not is invalid
    3. does the quantity chosen validate sellOffer available qty/minimum quantity? If not is invalid
    4. if no sellOffers valid then cart status is invalid. If some sellOffers invalid then cart status is partiallyValid
    5. if sellOffer does not combine then it gets put into it's own order
    6. do all sellOfferPlans for all sellOffers use the same valueType/valueId (either from deliveryMethod or from sellOfferPlanDeliveryMethodLink), if not must split out
    7. split sellOffers by seller and stock location

Data model notes

  • Consider cart details transient and of low importance, no need to have record of changes

Ideas

  • cart service could have function for testing multiple prices, find all payment methods and delivery methods offered by all sell offers in cart, then find total price for each combination (maybe also check all delivery methods ship to selected destination?)


Working documents

Cart