Service - Sell Offer Plan: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 63: Line 63:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
priceFilterListId: "xx",
priceFilterId: "xx",
resultId: "xx",
resultId: "xx",
logicalElement: {}, // needed for logicalTag after priceFilterList completes
logicalElement: {}, // needed for logicalTag after priceFilterList completes
Line 81: Line 81:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
priceFilterListId: "xx",
priceFilterId: "xx",
status: "xx" // "processing"|"complete"
status: "xx" // "processing"|"complete"
expiryTime: "xx",
expiryTime: "xx",
Line 89: Line 89:
* partition key: priceFilterId
* partition key: priceFilterId
* sort key: none
* sort key: none
* priceFilterListId comes from a hash of deliverToLocationIds / orderQuantity / paymentMethodIds / deliveryMethodIds
* priceFilterId comes from a hash of deliverToLocationIds / orderQuantity / paymentMethodIds / deliveryMethodIds


== PriceFilterSellOfferPlanPending ==
== PriceFilterSellOfferPlanPending ==
Line 97: Line 97:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
priceFilterListId: "xx",
priceFilterId: "xx",
SellOfferPlanId: "xx",
SellOfferPlanId: "xx",
}
}
</syntaxhighlight>
</syntaxhighlight>


* partition key: priceFilterListId
* partition key: priceFilterId
* sort key: SellOfferPlanId
* sort key: SellOfferPlanId


Line 111: Line 111:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
priceFilterListId: "xx",
priceFilterId: "xx",
price: "xx",
price: "xx",
SellOfferPlanId: "xx",
SellOfferPlanId: "xx",
priceRangeOnePriceId: "xx",
priceId: "xx",
}
}
</syntaxhighlight>
</syntaxhighlight>


* partition key: priceFilterListId
* partition key: priceFilterId
* sort key: price
* sort key: price


== PriceRange ==
== SellOfferPlanPriceRange ==


Manages a range of order price calculations that include Payment and Delivery method costs, all combinations of the requested deliverToLocationIds, paymentMethodIds, deliveryMethodIds, for the given orderQuantity
Manages a range of order price calculations for one sellOfferPlanId that include Payment and Delivery method costs, all combinations of the requested deliverToLocationIds, paymentMethodIds, deliveryMethodIds, for the given orderQuantity


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
priceRangeId: "xx",
priceFilterId: "xx",
sellOfferPlanId: "xx",
sellOfferPlanId: "xx",
deliverToLocationIds: ["xx","yy"], // array of locationIds
// (not needed?) deliverToLocationIds: ["xx","yy"], // array of locationIds
orderQuantity: x,
// (not needed?) orderQuantity: x,
paymentMethodIds: ["xx","yy"], // array of paymentMethodIds(strings), empty array means all available paymentMethods
// (not needed?) paymentMethodIds: ["xx","yy"], // array of paymentMethodIds(strings), empty array means all available paymentMethods
deliveryMethodIds: ["xx","yy"], // array of deliveryMethodIds(strings), empty array means all available deliveryMethods
// (not needed?) deliveryMethodIds: ["xx","yy"], // array of deliveryMethodIds(strings), empty array means all available deliveryMethods
status: "xx", // "processing"|"complete"
status: "xx", // "processing"|"complete"
expiryTime: "xx"
expiryTime: "xx"
Line 138: Line 138:
</syntaxhighlight>
</syntaxhighlight>


* partition key: priceRangeId
* partition key: priceFilterId
* sort key: sellOfferPlanId
 
== SellOfferPlanPriceRangePricePending ==
 
Is pending calculation for one sellOfferPlan combination of one deliverToLocationId, paymentMethodId, deliveryMethodId, and orderQuantity. Once complete record is removed from this table and inserted into SellOfferPlanPriceRangePriceComplete table
 
<syntaxhighlight lang="JavaScript">
{
priceId: "xx",
paymentIdDeliveryId: "xx"
}
</syntaxhighlight>
 
* partition key: priceId
* sort key: none
* sort key: none
* priceRangeId is a hash of sellOfferPlanId / deliverToLocationIds / orderQuantity / paymentMethodIds / deliveryMethodIds
* priceId is {sellOfferPlanId_deliverToLocationId_orderQuantity}
* paymentIdDeliveryId is {sellOfferPlanUserPaymentMethodLinkId_sellOfferPlanDeliveryMethodLinkId}


== PriceRangeOnePrice ==
== SellOfferPlanPriceRangePriceComplete ==


Is the resulting price for one sellOfferPlan combination of one deliverToLocationId, paymentMethodId, deliveryMethodId, and orderQuantity
Is one completed calculation for a sellOfferPlan's combination of one deliverToLocationId, paymentMethodId, deliveryMethodId, and orderQuantity


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
priceRangeOnePriceId: "xx",
priceId: "xx",
deliverToLocationId: "xx"
deliverToLocationId: "xx"
orderQuantity: x,
orderQuantity: x,
Line 156: Line 171:
</syntaxhighlight>
</syntaxhighlight>


* partition key: priceRangeOnePriceId
* partition key: priceId
* sort key: none
* sort key: none
* priceRangeOnePriceId is a hash of sellOfferPlanId / deliverToLocationId / orderQuantity / paymentMethodId / deliveryMethodId
* priceId is a hash of sellOfferPlanId / deliverToLocationId / orderQuantity / paymentMethodId / deliveryMethodId


= Graph database =  
= Graph database =  

Revision as of 14:43, 8 November 2021

Overview

A user's plan that connects a user's sell offer to any number of delivery method links and payment method links, and also to the sell offer's prices.

Each sell offer will have one plan, the plan controls the sell offer's prices, and many sell offers can point to the same plan (if they all share the same prices), so any change in price will mean a new sell offer plan.

The plan also links to delivery methods and payment methods using link nodes, so sell offers that use the same sell offer plan must offer the same delivery method and payment methods and their link settings.

Many sell offer plans can use the same delivery method links and payment method links, so if multiple sell offers have the same delivery and payment method settings but different prices, they can share the links but with separate sell offer plans + pricing.

Repository

https://bitbucket.org/izara-market-products/izara-market-products-sell-offer-plan

DynamoDB tables

Standard Config Table Per Service

Configuration tags

{
	configTag: "DeliveryMethodManagerServiceName"
	configKey: "DeliveryMethodManagerServiceName"
	configValue: xxx // eg: "DeliveryMethodManager"
}
{
	configTag: "PaymentMethodManagerServiceName"
	configKey: "PaymentMethodManagerServiceName"
	configValue: xxx // eg: "PaymentMethodManager"
}
{
	configTag: "ProductGraphServiceName"
	configKey: "ProductGraphServiceName"
	configValue: xxx // eg: "ProductGraph"
}

LogicalResults

Stores results for any requests to perform logical searches on sell offer data

{
	resultId: xxx // eg: filterMainId for a single logical element
	dataId: xxx // one sellofferId
}
  • partition key: resultId
  • sort key: dataId

PriceLogical

Records ProcessLogical requests for pricing based elements, so when pricing flow completes can find results, save into LogicalResults, and send message out for complexFilter service to receive.

{
	priceFilterId: "xx",
	resultId: "xx",
	logicalElement: {}, // needed for logicalTag after priceFilterList completes
	timestamp: "xx", //when record created
}
  • partition key: priceCalcId
  • sort key: resultId
  • links shared priceFilterList records to any number of processLogical resultId requests (probably only comparison and value that differentiate them)
  • is temporary, after save into LogicalResults and send OutProcessLogical can delete record so not keep sending OutProcessLogical when other comparison/value requests complete

PriceFilterList

Records requests that filter sellOfferPlanIds according to pricing values

{
	priceFilterId: "xx",
	status: "xx" // "processing"|"complete"
	expiryTime: "xx",
}
  • partition key: priceFilterId
  • sort key: none
  • priceFilterId comes from a hash of deliverToLocationIds / orderQuantity / paymentMethodIds / deliveryMethodIds

PriceFilterSellOfferPlanPending

SellOfferPlanIds for one PriceFilterList that has not completed yet

{
	priceFilterId: "xx",
	SellOfferPlanId: "xx",
}
  • partition key: priceFilterId
  • sort key: SellOfferPlanId

PriceFilterSellOfferPlanComplete

SellOfferPlanIds for one PriceFilterList that has completed calculating price range, all prices found are saved here

{
	priceFilterId: "xx",
	price: "xx",
	SellOfferPlanId: "xx",
	priceId: "xx",
}
  • partition key: priceFilterId
  • sort key: price

SellOfferPlanPriceRange

Manages a range of order price calculations for one sellOfferPlanId that include Payment and Delivery method costs, all combinations of the requested deliverToLocationIds, paymentMethodIds, deliveryMethodIds, for the given orderQuantity

{
	priceFilterId: "xx",
	sellOfferPlanId: "xx",
	// (not needed?) deliverToLocationIds: ["xx","yy"], // array of locationIds
	// (not needed?) orderQuantity: x,
	// (not needed?) paymentMethodIds: ["xx","yy"], // array of paymentMethodIds(strings), empty array means all available paymentMethods
	// (not needed?) deliveryMethodIds: ["xx","yy"], // array of deliveryMethodIds(strings), empty array means all available deliveryMethods
	status: "xx", // "processing"|"complete"
	expiryTime: "xx"
}
  • partition key: priceFilterId
  • sort key: sellOfferPlanId

SellOfferPlanPriceRangePricePending

Is pending calculation for one sellOfferPlan combination of one deliverToLocationId, paymentMethodId, deliveryMethodId, and orderQuantity. Once complete record is removed from this table and inserted into SellOfferPlanPriceRangePriceComplete table

{
	priceId: "xx",
	paymentIdDeliveryId: "xx"
}
  • partition key: priceId
  • sort key: none
  • priceId is {sellOfferPlanId_deliverToLocationId_orderQuantity}
  • paymentIdDeliveryId is {sellOfferPlanUserPaymentMethodLinkId_sellOfferPlanDeliveryMethodLinkId}

SellOfferPlanPriceRangePriceComplete

Is one completed calculation for a sellOfferPlan's combination of one deliverToLocationId, paymentMethodId, deliveryMethodId, and orderQuantity

{
	priceId: "xx",
	deliverToLocationId: "xx"
	orderQuantity: x,
	paymentMethodId: "xx",
	deliveryMethodId: "xx",
}
  • partition key: priceId
  • sort key: none
  • priceId is a hash of sellOfferPlanId / deliverToLocationId / orderQuantity / paymentMethodId / deliveryMethodId

Graph database

Service - Products Graph

Nodes

{
	nodeLabel: "{SellOfferPlanLib.SELLOFFERPLAN_GRAPH_NODE_LABEL}", // "sellOfferPlan"
	schema: {
		identifier: true,
		restrictProperties: true,
		restrictRelationships: true,
		properties: {
			sellOfferPlanId: {
				identifier: true, // create unique id from request params and uniqueMessageId
			},
			userId: {
				immutable: true, // a sellOfferPlan can only be used by one user (because links to their userPaymentMethods)
			},
			currencyId: {
				immutable: true, // all added deliveryMethods must match
			},
		},
	}
}
{
	nodeLabel: "{SellOfferPlanLib.SELLOFFERPLAN_DELIVERYMETHODLINK_GRAPH_NODE_LABEL}", // "sellOfferPlanDeliveryMethodLink"
	schema: {
		identifier: true,
		restrictProperties: true,
		restrictRelationships: true,
		properties: {
			sellOfferPlanDeliveryMethodLinkId: {
				identifier: true, // create unique id from request params and uniqueMessageId
			},
		},
	}
}
{
	nodeLabel: "{SellOfferPlanLib.SELLOFFERPLAN_USERPAYMENTMETHODLINK_GRAPH_NODE_LABEL}", // "sellOfferPlanUserPaymentMethodLink"
	schema: {
		identifier: true,
		restrictProperties: true,
		restrictRelationships: true,
		properties: {
			sellOfferPlanUserPaymentMethodLinkId: {
				identifier: true, // create unique id from request params and uniqueMessageId
			},
		},
	}
}

Versioned data

sellOfferPlanDeliveryMethodLinkSettings

{
	properties: {
		addToRateTableValuePerOrder: {}, // added once per order to the value before calculating delivery method price
		addToRateTableValuePerUnit: {}, // added once per orderQuantity to the value before calculating delivery method price
		addToCalculatedValuePerOrder: {}, // added once per order to the value after calculating delivery method price
		addToCalculatedValuePerUnit: {}, // added once per orderQuantity to the value after calculating delivery method price
		valueType: "xx", // orderQuantity|orderValue|productAttributeId|sellOfferTermId, if set overwrites deliveryMethod defaultValueType
		valueId: "xx", // if set overwrites deliveryMethod defaultValueId (used for productAttributeId|sellOfferTermId)
	},
}

sellOfferPlanUserPaymentMethodLinkSettings

{
	properties: {
		oneTimePercentage: {}, // increase paymentMethod price by percentage
		oneTimeAmount: {}, // increase paymentMethod price by set amount
	},
}
  • if both oneTimePercentage and oneTimeAmount are set, applies oneTimePercentage first

sellOfferPlanSettings

{
	properties: {
		combineWins: {}, // true|false
		prices: {
			sellOfferQuantity: [ // sellOfferQuantity type price settings, ordered low to high
				{
					upToValue: "xx.xx",
					price: "xx.xx",
				},
				// ...
			],
			orderQuantity: [ // orderQuantity type price settings, ordered low to high
				{
					upToValue: "xx.xx",
					price: "xx.xx",
				},
				// ...
			]				
			orderValue: [ // orderValue type price settings, ordered low to high
				{
					upToValue: "xx.xx",
					price: "xx.xx",
				},
				// ...
			]					
		},

	},
}

Relationships

{
	relationshipType: "{SellOfferPlanLib.createHasSellOfferPlanGraphRelationshipType()}", // "has_sellOfferPlan"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • links a user to one of their sell offer plans
{
	relationshipType: "{SellOfferPlanLib.createHasDeliveryMethodLinkGraphRelationshipType()}", // "has_deliveryMethodLink"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
{
	relationshipType: "{SellOfferPlanLib.createDisabledDeliveryMethodLinkGraphRelationshipType()}", // "disabled_deliveryMethodLink"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
{
	relationshipType: "{SellOfferPlanLib.createHasUserPaymentMethodLinkGraphRelationshipType()}", // "has_userPaymentMethodLink"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
{
	relationshipType: "{SellOfferPlanLib.createDisabledUserPaymentMethodLinkGraphRelationshipType()}", // "disabled_userPaymentMethodLink"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • many sell offer plans can link to one delivery method link, or one payment method link, this allows user to share settings in the link nodes across multiple sell offer plans
{
	relationshipType: "{SellOfferPlanLib.createIsDeliveryMethodGraphRelationshipType()}", // "is_deliveryMethod"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
{
	relationshipType: "{SellOfferPlanLib.createIsUserPaymentMethodGraphRelationshipType()}", // "is_userPaymentMethod"
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}

Complex Filter requests

{
	filterType: "sellOfferPlan" //unique id is sellOfferPlanId
	type: "group",
	elements:
	[
		{
			type: "logical",
			logicalTag: "userId",
			comparison: "equals",
			value: "xx"
		},
		{
			type: "logical",
			logicalTag: "combineWins",
			comparison: "true",
		},
		{
			type: "logical",
			logicalTag: "maxPrice",
			comparison: "lessThan",
			value: "xx"
		},
		{
			type: "logical",
			logicalTag: "minPrice",
			comparison: "lessThan",
			value: "xx"
		},
		{
			type: "complexFilter",
			complexFilter: {
				filterType: "userPaymentMethod",
				// see [[Service - Payment Method Generic|Complex Filter requests]]
			}
		},		
		{
			type: "complexFilter",
			complexFilter: {
				filterType: "deliveryMethod",
				// see [[Service - Delivery Method Standard|Complex Filter requests]]
			}
		},
		...
	]
}

Translate Ids - userPaymentMethod and deliveryMethod to sellOfferPlan

  • only find sellOfferPlanIds that have has_userPaymentMethodLink or has_deliveryMethodLink relationships (ignore disabled)
  • bypasses link nodes (no complex filterType)

Working documents

Sell Offer Plan