This commit is contained in:
2023-01-23 22:25:54 +00:00
parent 09f2f3be2f
commit ffdf5070b4
4 changed files with 365 additions and 327 deletions

View File

@@ -105,7 +105,7 @@ namespace Sockeye.Biz
if (jData["order_notification"]["purchase"]["is_test"] != null && jData["order_notification"]["purchase"]["is_test"].Value<bool>() == true)
{
//during debugging allow it to process as a test but normally test orders should stop here
//during debugging allow it to process as a test but normally test orders should stop here
#if (!DEBUG)
return true;
#endif
@@ -123,14 +123,18 @@ namespace Sockeye.Biz
#region CUSTOMER MAKE OR LOCATED
///////////////////////////////////////////////////////////////////////////////////////////
var jCustomerName = jData["order_notification"]["purchase"]["customer_data"]["reg_name"].Value<string>() ?? throw new System.FormatException($"Vendor data empty reg_name:{vn.VendorData}");
var jCustomerEmail = jData["order_notification"]["purchase"]["customer_data"]["delivery_contact"]["email"].Value<string>() ?? throw new System.FormatException($"Vendor data empty email:{vn.VendorData}");
if (jData["order_notification"]["purchase"]["customer_data"]["delivery_contact"]["email"] == null)//we can't process orders with no email at all hard no
throw new System.FormatException($"Vendor data empty email:{vn.VendorData}");
var jCustomerEmail = jData["order_notification"]["purchase"]["customer_data"]["delivery_contact"]["email"].Value<string>();
var jCustomerAccountNumber = jData["order_notification"]["purchase"]["customer_data"]["shopper_id"].Value<string>();//appears to be mycommerce customer id number hopefully static between orders
var customerBiz = CustomerBiz.GetBiz(ct);
//attempt to match to existing customer
//account number is most ideal match, name second but could be multiple in sockeye from rockfish sites so name will start the same, finally email if nothing else
Customer customer = await ct.Customer.FirstOrDefaultAsync(z => z.AccountNumber == jCustomerAccountNumber) ?? await ct.Customer.FirstOrDefaultAsync(z => z.Name.StartsWith(jCustomerName)) ?? await ct.Customer.FirstOrDefaultAsync(z => z.EmailAddress == jCustomerEmail);
Customer customer = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.AccountNumber == jCustomerAccountNumber)
?? await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.Name.StartsWith(jCustomerName))
?? await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.EmailAddress == jCustomerEmail);
if (customer == null)
{
//New customer