Service - Sell Offer Manager: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 9: Line 9:
https://bitbucket.org/izara-market-products/izara-market-products-sell-offer-manager/src/master/
https://bitbucket.org/izara-market-products/izara-market-products-sell-offer-manager/src/master/


= DynamoDB tables =
= Object Schemas =
; Additional Information: [[Per Service Schemas]]


== [[Standard Config Table Per Service]] ==
== objType ==


=== Configuration tags ===
=== sellOffer ===


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
configKey: "ProductGraphServiceName"
objectType: "sellOffer",
configTag: "ProductGraphServiceName"
canDelete: false,
configValue: xxx // eg: "ProductGraph"
belongTo: {
serviceTag: "user",
objectType: "user"
},
addOnDataStructure: [ // optional, add for additional setting to objectType
{
  type: "attributeTree",   
  attributeTreeTag: "sellOfferTerms"
},
],
storageResources: {
myGraph: {
storageType: "graph",
graphServerTag: "GraphHandler"
}
    },
    fieldNames: {
sellOfferId: {
type: "string",
randomOnCreate: true,
storageResourceTags: ['myGraph']
},
    },
    identifiers: [
{
type: "identifier",
fieldName: "sellOfferId"
}
    ]
}
}
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="JavaScript">
== Object Relationships ==
{
 
configKey: "SellOfferHandlerService"
=== hasSellOffer ===
configTag: xxx // sellOfferHandlerServiceNameTag, eg: "SellOfferStandard", this is what is saved in each catalog record
configValue: {
serviceName: xxx // eg: "SellOfferStandard", this is the actual deployed service name}
}
}
</syntaxhighlight>


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
configKey: "TranslateIdsType"
hasSellOffer: {
configTag: xxx // eg SellOffer > Product would be sellOffer_product
canChangeToRelTypes: [
configValue: {
{
ttl: 64000 // number of seconds TranslateIdsCache records live for
serviceTag:"sellOfferManager",
relationshipTag: "disabledSellOffer"
},
],
storageResources: {
myGraph: {
storageType: "graph",
graphServerTag: "GraphHandler"
}
},
links: [
{
storageResourceTags: ["myGraph"],
from: {
objType: {
serviceTag: "ProductManager",
objectType: "product"
},
linkType: "one",
},
to: {
objType: {
serviceTag: "sellOfferManager",
objectType: "sellOffer"
},
linkType: "many"
}
}
]
}
}
}
}
</syntaxhighlight>
</syntaxhighlight>


== SellOffers ==
=== disabledSellOffer ===
 
Records which Handler manages each sell offer


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
sellOfferId
disabledSellOffer: {
sellOfferHandlerServiceNameTag
canChangeToRelTypes: [
{
serviceTag:"sellOfferManager",
relationshipTag: "hasSellOffer"
},
],
storageResources: {
myGraph: {
storageType: "graph",
graphServerTag: "GraphHandler"
}
},
links: [
{
storageResourceTags: ["myGraph"],
from: {
objType: {
serviceTag: "ProductManager",
objectType: "product"
},
linkType: "one",
},
to: {
objType: {
serviceTag: "sellOfferManager",
objectType: "sellOffer"
},
linkType: "many"
}
}
]
}
}
}
</syntaxhighlight>
</syntaxhighlight>


* partition key: sellOfferId
=== soldByUser ===
* sort key: (none)
 
== TranslateIdsCache ==
 
Stores a record for one translateId data which can be queried as a cache rather than performing the translateIDs logic


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
cacheId // fromType + "_" + fromDataId + "_" + toType
soldByUser: {
toDataId
storageResources: {
expiryTime
myGraph: {
storageType: "graph",
graphServerTag: "GraphHandler"
}
},
links: [
{
storageResourceTags: ["myGraph"],
from: {
objType: {
serviceTag: "sellOfferManager",
objectType: "sellOffer"
},
linkType: "many",
},
to: {
objType: {
serviceTag: "user",
objectType: "user"
},
linkType: "one"
}
}
]
}
}
}
</syntaxhighlight>
</syntaxhighlight>


* partition key: cacheId
=== usesSellOfferPlan ===
* sort key: toDataId
* expireTime is set as an automatic DynamoDB TTL attibute
 
== LogicalResultsMain ==
 
A cached result set for logicals


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
logicalResultId: "xxx", // hash of logical element
usesSellOfferPlan: {
logicalElement: {}, // full element being processed
storageResources: {
logicalType: "xx", // same filterType
myGraph: {
status: "xxx", // "processing"|"complete",
storageType: "graph",
expiryTime: "xx",
graphServerTag: "GraphHandler"
uniqueRequestId: "xx", used for idempotence when first process request called, in case that invocation fails and restarts, can be removed when set to complete
}
}
},
</syntaxhighlight>
links: [
 
{
* partition key: logicalResultId
storageResourceTags: ["myGraph"],
* sort key: (none)
from: {
 
objType: {
== LogicalResultsData ==
serviceTag: "sellOfferManager",
 
objectType: "sellOffer"
Caches found results for logical elements
},
 
linkType: "many",
<syntaxhighlight lang="JavaScript">
},
{
to: {
logicalResultId: xxx,
objType: {
dataId: xxx // eg: one sellofferId
serviceTag: "sellOfferPlan",
}
objectType: "sellOfferPlan"
</syntaxhighlight>
},
 
linkType: "one"
* partition key: resultId
}
* sort key: dataId
}
 
]
== LogicalHandlerRequest ==
}
 
* not yet applied
 
Temporary link/flow records for ProcessLogical requests that get passed to all Sell Offer Handler services as a new handler level complexFilter.
 
<syntaxhighlight lang="JavaScript">
{
logicalResultId: "xx",
logicalElement: {}, // needed for logicalTag (? maybe not, just query LogicalResultMain?)
waitingHandlers: [] // string set, remove each handler from this after copying it's results to SellOfferManager LogicalResults table
timestamp: "xx", //when record created
}
</syntaxhighlight>
 
* partition key: logicalResultId
* is temporary, after waitingHandlers is empty send OutProcessLogical message and delete HandlerLogicalRequests record
* flow starts complexFilter for each handler service, once complete triggers a lambda that copies Handler LogicalResults data to SellOfferManager LogicalResults table, combining all Handler results, removes Handler from waitingHandlers. Once all are complete (waitingHandlers empty) we can send a message saying the SellOfferManager level logical results are complete
* Logical element that gets passed to handler services must match the element received by SellOfferManager, so can match records
 
== LogicalSortedRequest ==
 
* not yet applied, consider as a separate table that can automate/standardize performing filter on sorted search result and saving to LogicalResults
 
Temporary link/flow table for ProcessLogical requests that get passed to a sorted searchResult process, then gets some filtering applied.
 
<syntaxhighlight lang="JavaScript">
{
sortResultId: "xx",
logicalResultId: "xx",
filter: "xx",
sortResultServiceName,
timestamp: "xx", //when record created
uniqueRequestId: "xx", used for idempotence when first process request called, in case that invocation fails and restarts
}
</syntaxhighlight>
 
* partition key: sortResultId
* sort key: logicalResultId
* is temporary, after sortResult/copying is complete send OutProcessLogical message and delete LogicalSortedRequests record
* flow starts searchResult with sortField, once complete triggers a lambda that performs filter and saves data to LogicalResults table
 
== LogicalAwaitingStep ==
 
Temporary link/flow table for ProcessLogical requests that are waiting another step to finish, can save any type of awaiting id here
 
<syntaxhighlight lang="JavaScript">
{
awaitingId: "xx",
logicalResultId: "xx",
timestamp: "xx", //when record created
uniqueRequestId: "xx", optional, used for idempotence when first process request called in a Lambda wants only one request to process, in case first invocation fails and restarts
}
}
</syntaxhighlight>
</syntaxhighlight>


* partition key: awaitingId
== OrderPrice ==
* sort key: logicalResultId
* if different parts of a flow use the same awaitingId we could perhaps prefix it
 
== LogicalSortedSellOfferPricePending ==


Temporary link/flow list of sorted SellOffer orderPrices requests waiting to complete before LogicalResultMain can find aggregate for value each sellOffer, used only to make checking remaining requests more efficient
Cache of one total calculation for list of sellOffer quantities, and one combination of deliverToLocationId, / sellOfferPlanUserPaymentMethodLinkId / sellOfferPlanDeliveryMethodLinkId. Price includes Payment and Delivery method costs.
 
<syntaxhighlight lang="JavaScript">
{
sellOfferPriceSortResultId: "xx",
logicalResultId: "xx",
sellOfferId: "xx"
}
</syntaxhighlight>
 
* partition key: sellOfferPriceSortResultId
* sort key: logicalResultId
* is temporary, after sorted sellOfferPrice complete delete this record, and check if any LogicalSortedSellOfferPricePending records remain for logicalResultId record, if none can move to next step
 
Global secondary index:
* partition key: logicalResultId
* sort key: sellOfferPriceSortResultId
* projected attributes: (none)
* main primary key is used to find parent logicalResultId after a sorted sellOfferPrice completes, GSI is used to check if any pending remain for parent logicalResultId
 
== orderPrice ==
 
Cache of one completed total calculation for list of sellOffer quantities, and one combination of deliverToLocationId, / sellOfferPlanUserPaymentMethodLinkId / sellOfferPlanDeliveryMethodLinkId. Price includes Payment and Delivery method costs.


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
Line 195: Line 211:
sellOfferQuantities: {},
sellOfferQuantities: {},
deliverToLocationId: "xx",
deliverToLocationId: "xx",
price: "xx"
//price: "xx", //removing and using findDataMain process
status: "xx", // "processing"|"complete"|"error"
//expiryTime: "xx", //removing and using findDataMain process
expiryTime: "xx",
// status: "xx", // "recalculating"|"complete"|"error", not really needed, added as a reference
uniqueRequestId: "xx", used for idempotence when first process request called, in case that invocation fails and restarts, can be removed when set to complete/error
// errorsFound: [], // stringSet, when recalculating, will reset to empty, once finished if any errorsFound then status will be "error"
// uniqueRequestId: "xx", (I think no longer used) used for idempotence when first process request called, in case that invocation fails and restarts, can be removed when set to complete/error
orderSubtotal: "xx",
orderQuantity: "xx",
sellOfferPrices: {}
deliveryPrice: "xx",
sellOfferPlanDeliveryMethodLinkId: "xx",
paymentPrice: "xx",
sellOfferPlanUserPaymentMethodLinkId: "xx",
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 206: Line 230:
* orderPriceId is {hash of sellOfferQuantities / orderQuantity / deliverToLocationId / sellOfferPlanDeliveryMethodLinkId / sellOfferPlanUserPaymentMethodLinkId
* orderPriceId is {hash of sellOfferQuantities / orderQuantity / deliverToLocationId / sellOfferPlanDeliveryMethodLinkId / sellOfferPlanUserPaymentMethodLinkId
* sellOfferPlanQuantities works out the combined total for multiple sellOfferPlans, all sellOfferPlans must offer the given payment and delivery Ids, if not will be status error
* sellOfferPlanQuantities works out the combined total for multiple sellOfferPlans, all sellOfferPlans must offer the given payment and delivery Ids, if not will be status error
 
* values found during re-calc are stored here, and can be used to present detailed cart pricing
= Complex Filter requests =
* total price is stored in FindData table, and price is recalculated whenever FindData expires. This will mean should always request price via FindData, cannot request directly from orderPrice table
 
<syntaxhighlight lang="JavaScript">
{
filterType: "sellOffer" //unique id is sellOfferId
type: "group",
elements:
[
{
type: "complexFilter",
complexFilter: {
filterType: "sellOfferPlan",
// see [[Service - Sell Offer Plan|Complex Filter requests]]
}
},
{
type: "complexFilter",
complexFilter: {
filterType: "sellOfferTermLink",
// see [[Service - Sell Offer Terms|Complex Filter requests]]
}
},
{
type: "complexFilter",
complexFilter: {
filterType: "planDeliveryPaymentCombination",
// see [[Service - Sell Offer Plan|Complex Filter requests]]
}
},
{
type: "complexFilter",
complexFilter: {
filterType: "orderPrice",
// see below
}
},
...
]
}
</syntaxhighlight>
 
* TranslateIds from planDeliveryPaymentCombination to sellOffer will find all unique sellOfferIds in the range of combinations
 
<syntaxhighlight lang="JavaScript">
{
filterType: "orderPrice" //unique id is orderPriceId
type: "group",
elements:
[
{
// finds all orderPrices for one sellOfferId according to all combinations of deliverToLocationIds / paymentMethodIds / deliveryMethodIds
type: "logical",
logicalTag: "sellOfferQuantityLocationIdCombinations",
sellOfferId: "xx",
orderQuantity: 1,
deliverToLocationIds: [],
paymentMethodIds: [],
deliveryMethodIds: []
},
{
//will create a set of orderPrices, one per sellOffer according to aggregate function
type: "logical",
logicalTag: "aggregatedSellOfferPrices",
orderQuantity: 1,
deliverToLocationIds: [],
paymentMethodIds: [],
deliveryMethodIds: [],
aggregate: "xx" // "maxPrice"|"minPrice"|"averagePrice"
},
...
]
}
</syntaxhighlight>
 


= Working documents =
= Working documents =

Latest revision as of 23:24, 16 August 2025

Overview

Each sell offer is handled by a Service - Sell Offer (handlers) service.

The Sell Offer Manager service handles shared orchestration of the Sell Offer Handler services.

Repository

https://bitbucket.org/izara-market-products/izara-market-products-sell-offer-manager/src/master/

Object Schemas

Additional Information
Per Service Schemas

objType

sellOffer

{
	objectType: "sellOffer",
	canDelete: false,
	belongTo: { 
		serviceTag: "user",
		objectType: "user"
	},
	addOnDataStructure: [ // optional, add for additional setting to objectType
		{
		  type: "attributeTree",    
		  attributeTreeTag: "sellOfferTerms"
		},
	],
	storageResources: {
		myGraph: {
			storageType: "graph",
			graphServerTag: "GraphHandler"
		}
    },
    fieldNames: {
		sellOfferId: {
			type: "string",
			randomOnCreate: true,
			storageResourceTags: ['myGraph']
		},
    },
    identifiers: [
		{
			type: "identifier",
			fieldName: "sellOfferId"
		}
    ]
}

Object Relationships

hasSellOffer

{
	hasSellOffer: {
		canChangeToRelTypes: [
			{
				serviceTag:"sellOfferManager",
				relationshipTag: "disabledSellOffer"
			},
		],
		storageResources: {
			myGraph: {
				storageType: "graph",
				graphServerTag: "GraphHandler"			
			}
		},
		links: [
			{
				storageResourceTags: ["myGraph"],
				from: {
					objType: {
						serviceTag: "ProductManager",
						objectType: "product"
					},
					linkType: "one",
				},
				to: {
					objType: {
						serviceTag: "sellOfferManager",
						objectType: "sellOffer"
					},
					linkType: "many"
				}
			}
		]
	}
}

disabledSellOffer

{
	disabledSellOffer: {
		canChangeToRelTypes: [
			{
				serviceTag:"sellOfferManager",
				relationshipTag: "hasSellOffer"
			},
		],
		storageResources: {
			myGraph: {
				storageType: "graph",
				graphServerTag: "GraphHandler"			
			}
		},
		links: [
			{
				storageResourceTags: ["myGraph"],
				from: {
					objType: {
						serviceTag: "ProductManager",
						objectType: "product"
					},
					linkType: "one",
				},
				to: {
					objType: {
						serviceTag: "sellOfferManager",
						objectType: "sellOffer"
					},
					linkType: "many"
				}
			}
		]
	}
}

soldByUser

{
	soldByUser: {
		storageResources: {
			myGraph: {
				storageType: "graph",
				graphServerTag: "GraphHandler"			
			}
		},
		links: [
			{
				storageResourceTags: ["myGraph"],
				from: {
					objType: {
						serviceTag: "sellOfferManager",
						objectType: "sellOffer"
					},
					linkType: "many",
				},
				to: {
					objType: {
						serviceTag: "user",
						objectType: "user"
					},
					linkType: "one"
				}
			}
		]
	}
}

usesSellOfferPlan

{
	usesSellOfferPlan: {
		storageResources: {
			myGraph: {
				storageType: "graph",
				graphServerTag: "GraphHandler"			
			}
		},
		links: [
			{
				storageResourceTags: ["myGraph"],
				from: {
					objType: {
						serviceTag: "sellOfferManager",
						objectType: "sellOffer"
					},
					linkType: "many",
				},
				to: {
					objType: {
						serviceTag: "sellOfferPlan",
						objectType: "sellOfferPlan"
					},
					linkType: "one"
				}
			}
		]
	}
}

OrderPrice

Cache of one total calculation for list of sellOffer quantities, and one combination of deliverToLocationId, / sellOfferPlanUserPaymentMethodLinkId / sellOfferPlanDeliveryMethodLinkId. Price includes Payment and Delivery method costs.

{
	orderPriceId: "xx",
	sellOfferQuantities: {},
	deliverToLocationId: "xx",
	//price: "xx", //removing and using findDataMain process
	//expiryTime: "xx", //removing and using findDataMain process
	// status: "xx", // "recalculating"|"complete"|"error", not really needed, added as a reference
	// errorsFound: [], // stringSet, when recalculating, will reset to empty, once finished if any errorsFound then status will be "error"
	// uniqueRequestId: "xx", (I think no longer used) used for idempotence when first process request called, in case that invocation fails and restarts, can be removed when set to complete/error
	orderSubtotal: "xx",
	orderQuantity: "xx",
	sellOfferPrices: {}
	deliveryPrice: "xx",
	sellOfferPlanDeliveryMethodLinkId: "xx",
	paymentPrice: "xx",
	sellOfferPlanUserPaymentMethodLinkId: "xx",
}
  • partition key: orderPriceId
  • sort key: (none)
  • orderPriceId is {hash of sellOfferQuantities / orderQuantity / deliverToLocationId / sellOfferPlanDeliveryMethodLinkId / sellOfferPlanUserPaymentMethodLinkId
  • sellOfferPlanQuantities works out the combined total for multiple sellOfferPlans, all sellOfferPlans must offer the given payment and delivery Ids, if not will be status error
  • values found during re-calc are stored here, and can be used to present detailed cart pricing
  • total price is stored in FindData table, and price is recalculated whenever FindData expires. This will mean should always request price via FindData, cannot request directly from orderPrice table

Working documents

Sell Offer Manager