This commit is contained in:
@@ -54,22 +54,69 @@ namespace Sockeye.Biz
|
|||||||
&& z.LicenseId == null
|
&& z.LicenseId == null
|
||||||
&& z.CustomerId != null
|
&& z.CustomerId != null
|
||||||
&& (z.PGroup == ProductGroup.AyaNova7 || z.PGroup == ProductGroup.RavenPerpetual || z.PGroup == ProductGroup.RavenSubscription))
|
&& (z.PGroup == ProductGroup.AyaNova7 || z.PGroup == ProductGroup.RavenPerpetual || z.PGroup == ProductGroup.RavenSubscription))
|
||||||
.OrderByDescending(z => z.PurchaseDate)
|
.OrderByDescending(z => z.PurchaseDate)
|
||||||
.ToListAsync()).GroupBy(z => (long)z.CustomerId);
|
.ToListAsync()).GroupBy(z => (long)z.CustomerId);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var purchaseGroup in purchaseList)
|
foreach (var purchaseGroup in purchaseList)
|
||||||
{
|
{
|
||||||
//vet the group if v7 to be sure no item is less than 5 minutes old to ensure multiple add-on's have all arrived from mycommerce
|
//Iterate the group and qualify it
|
||||||
foreach(var purchase in purchaseGroup){
|
bool isRavenPerpetual = false;
|
||||||
if (purchase.PGroup == ProductGroup.AyaNova7 && DateTime.UtcNow - purchase.PurchaseDate < PROCESS_V7_AGE)
|
bool isRavenSubscription = false;
|
||||||
|
bool isV7 = false;
|
||||||
|
bool isLessThanV7Age = false;
|
||||||
|
|
||||||
|
foreach (var purchase in purchaseGroup)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (purchase.PGroup == ProductGroup.AyaNova7)
|
||||||
|
isV7 = true;
|
||||||
|
|
||||||
|
if (purchase.PGroup == ProductGroup.RavenPerpetual)
|
||||||
|
isRavenPerpetual = true;
|
||||||
|
|
||||||
|
if (purchase.PGroup == ProductGroup.RavenSubscription)
|
||||||
|
isRavenSubscription = true;
|
||||||
|
|
||||||
|
if (DateTime.UtcNow - purchase.PurchaseDate < PROCESS_V7_AGE)
|
||||||
|
isLessThanV7Age = true; ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//sanity checks should never be mixed
|
||||||
|
if ((isRavenPerpetual && isV7))
|
||||||
|
{
|
||||||
|
var err = $"SockBotProcessPurchasesIntoLicenses both raven perpetual and v7 in same customer's purchase group First record order number: {purchaseGroup.First().SalesOrderNumber}";
|
||||||
|
//serious issue requires immediate notification
|
||||||
|
await NotifyEventHelper.AddOpsProblemEvent(err);
|
||||||
|
log.LogError(err);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LEFT OFF HERE, the stuff below here is old stuff rom copied code so wipe adn repurpose as required
|
if ((isRavenSubscription && isV7))
|
||||||
//was about to encode
|
{
|
||||||
|
var err = $"SockBotProcessPurchasesIntoLicenses both raven subscription and v7 in same customer's purchase group First record order number: {purchaseGroup.First().SalesOrderNumber}";
|
||||||
|
//serious issue requires immediate notification
|
||||||
|
await NotifyEventHelper.AddOpsProblemEvent(err);
|
||||||
|
log.LogError(err);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((isRavenPerpetual && isRavenSubscription))
|
||||||
|
{
|
||||||
|
var err = $"SockBotProcessPurchasesIntoLicenses both raven perpetual and raven subscription in same customer's purchase group First record order number: {purchaseGroup.First().SalesOrderNumber}";
|
||||||
|
//serious issue requires immediate notification
|
||||||
|
await NotifyEventHelper.AddOpsProblemEvent(err);
|
||||||
|
log.LogError(err);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if v7 skip for this iteration to ensure multiple add-on's have all arrived from mycommerce
|
||||||
|
if (isV7 && isLessThanV7Age)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//if v7 license then lookup last license for same pgroup for same customer, if none then consider it a new license fresh
|
//if v7 license then lookup last license for same pgroup for same customer, if none then consider it a new license fresh
|
||||||
//if there is one and it's not entirely expired then duplicate and fixup from purchases in this group
|
//if there is one and it's not entirely expired then duplicate and fixup from purchases in this group
|
||||||
|
|
||||||
@@ -84,7 +131,7 @@ namespace Sockeye.Biz
|
|||||||
|
|
||||||
// log.LogDebug($"Processing purchase id:{purchaseGroup[0].Id},purchasedate:{purchaseGroup.PurchaseDate}, custid:{purchaseGroup.CustomerId}");
|
// log.LogDebug($"Processing purchase id:{purchaseGroup[0].Id},purchasedate:{purchaseGroup.PurchaseDate}, custid:{purchaseGroup.CustomerId}");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user