This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -33,7 +33,7 @@
|
|||||||
"SOCKEYE_DB_CONNECTION": "Server=localhost;Username=postgres;Password=sockeye;Database=sockeye;CommandTimeout=300;",
|
"SOCKEYE_DB_CONNECTION": "Server=localhost;Username=postgres;Password=sockeye;Database=sockeye;CommandTimeout=300;",
|
||||||
"SOCKEYE_DATA_PATH": "c:\\temp\\sockeye",
|
"SOCKEYE_DATA_PATH": "c:\\temp\\sockeye",
|
||||||
"SOCKEYE_USE_URLS": "http://*:7676;",
|
"SOCKEYE_USE_URLS": "http://*:7676;",
|
||||||
"SOCKEYE_PERMANENTLY_ERASE_DATABASE": "true",
|
//"SOCKEYE_PERMANENTLY_ERASE_DATABASE": "true",
|
||||||
//"SOCKEYE_REPORT_RENDERING_TIMEOUT":"1",
|
//"SOCKEYE_REPORT_RENDERING_TIMEOUT":"1",
|
||||||
"SOCKEYE_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin"
|
"SOCKEYE_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Sockeye.DataList
|
|||||||
FieldDefinitions.Add(new DataListFieldDefinition
|
FieldDefinitions.Add(new DataListFieldDefinition
|
||||||
{
|
{
|
||||||
TKey = "VendorNotificationCreated",
|
TKey = "VendorNotificationCreated",
|
||||||
FieldKey = "VendorNotificationSalesOrderNumber",
|
FieldKey = "VendorNotificationCreated",
|
||||||
SockType = (int)SockType.VendorNotification,
|
SockType = (int)SockType.VendorNotification,
|
||||||
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
||||||
SqlIdColumnName = "avendornotification.id",
|
SqlIdColumnName = "avendornotification.id",
|
||||||
|
|||||||
@@ -354,6 +354,7 @@ namespace Sockeye.Biz
|
|||||||
vn.VendorId = 1;
|
vn.VendorId = 1;
|
||||||
vn.VendorData = jVendorNotificationItem["data"].Value<string>();
|
vn.VendorData = jVendorNotificationItem["data"].Value<string>();
|
||||||
vn.Processed = vn.Created;//indicate it's been processed
|
vn.Processed = vn.Created;//indicate it's been processed
|
||||||
|
ct.VendorNotification.Add(vn);
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -94,13 +94,6 @@ namespace Sockeye.Biz
|
|||||||
{
|
{
|
||||||
var jData = JObject.Parse(vn.VendorData);
|
var jData = JObject.Parse(vn.VendorData);
|
||||||
|
|
||||||
#if (DEBUG)
|
|
||||||
if (vn.VendorData.Contains("coupon"))
|
|
||||||
{
|
|
||||||
//trying to find out where the coupon code key is located in the order
|
|
||||||
System.Diagnostics.Debugger.Break();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//It's a test purchase, no need to process it any further...or is there??
|
//It's a test purchase, no need to process it any further...or is there??
|
||||||
if (jData["order_notification"]["purchase"]["is_test"] != null && jData["order_notification"]["purchase"]["is_test"].Value<bool>() == true)
|
if (jData["order_notification"]["purchase"]["is_test"] != null && jData["order_notification"]["purchase"]["is_test"].Value<bool>() == true)
|
||||||
{
|
{
|
||||||
@@ -153,23 +146,15 @@ namespace Sockeye.Biz
|
|||||||
//here there could be several potential issues:
|
//here there could be several potential issues:
|
||||||
//name differs because it was a separate site in rockfish, it's not cool to change the name
|
//name differs because it was a separate site in rockfish, it's not cool to change the name
|
||||||
//email differs, this can happen and is ok
|
//email differs, this can happen and is ok
|
||||||
//account number differs if was empty then it's ok. If it wasn't empty and it differs this is a potential problem:
|
//account number differs if was empty then it's ok. If it wasn't empty and it differs this is unfortunately normal as users may re-buy again with new account or buy an addon with a new account
|
||||||
|
//so the vendor account nubmer should just be the most recent for finding them purposes I guess
|
||||||
//
|
//
|
||||||
if (customer.EmailAddress != jCustomerEmail)
|
if (customer.EmailAddress != jCustomerEmail)
|
||||||
{
|
|
||||||
customer.EmailAddress = jCustomerEmail;//assume it was empty or has been recently updated
|
customer.EmailAddress = jCustomerEmail;//assume it was empty or has been recently updated
|
||||||
}
|
|
||||||
|
|
||||||
if (customer.AccountNumber != jCustomerAccountNumber)
|
if (customer.AccountNumber != jCustomerAccountNumber)
|
||||||
{
|
customer.AccountNumber = jCustomerAccountNumber;//see above
|
||||||
if (string.IsNullOrWhiteSpace(customer.AccountNumber))
|
|
||||||
customer.AccountNumber = jCustomerAccountNumber;//this is ok, there wasn't an account number before so we're just adding it
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// this is problematic, it matched but for some reason the account numbers differ, there's no safe way to process this so alert and bail
|
|
||||||
throw new System.ApplicationException($"Not processed due to error updating existing Customer: {customer.Name} Account numbers differ, expected: {customer.AccountNumber} vendor data:{vn.VendorData}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//refresh
|
//refresh
|
||||||
UpdateCustomerFromVendorData(jData, customer);
|
UpdateCustomerFromVendorData(jData, customer);
|
||||||
@@ -185,7 +170,7 @@ namespace Sockeye.Biz
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
var salesOrderNumber = jData["order_notification"]["purchase"]["purchase_id"].Value<string>();
|
var salesOrderNumber = jData["order_notification"]["purchase"]["purchase_id"].Value<string>();
|
||||||
#warning Is this processing the date into UTC properly??
|
|
||||||
//https://www.newtonsoft.com/json/help/html/DatesInJSON.htm
|
//https://www.newtonsoft.com/json/help/html/DatesInJSON.htm
|
||||||
var purchaseDate = jData["order_notification"]["purchase"]["purchase_date"].Value<DateTime>();
|
var purchaseDate = jData["order_notification"]["purchase"]["purchase_date"].Value<DateTime>();
|
||||||
|
|
||||||
@@ -214,9 +199,22 @@ namespace Sockeye.Biz
|
|||||||
p.VendorFee = jPurchase["accounting"]["margin_net"].Value<decimal>();
|
p.VendorFee = jPurchase["accounting"]["margin_net"].Value<decimal>();
|
||||||
p.Revenue = jPurchase["accounting"]["your_revenue"].Value<decimal>();
|
p.Revenue = jPurchase["accounting"]["your_revenue"].Value<decimal>();
|
||||||
}
|
}
|
||||||
p.CouponCode = "UNKNOWN WHERE IN VENDOR DATA CONTAINS COUPON CODE";
|
|
||||||
|
if (jPurchase["promotion_coupon"] != null)
|
||||||
|
p.CouponCode = jPurchase["promotion_coupon"].Value<string>();
|
||||||
|
|
||||||
|
if (jPurchase["promotion"] != null)
|
||||||
|
p.CouponCode += $" {jPurchase["promotion"].Value<string>()}";
|
||||||
|
|
||||||
p.Quantity = jPurchase["quantity"].Value<int>();
|
p.Quantity = jPurchase["quantity"].Value<int>();
|
||||||
p.VendorNotificationId = vn.Id;
|
p.VendorNotificationId = vn.Id;
|
||||||
|
|
||||||
|
//it's a subscription?
|
||||||
|
if (jPurchase["subscription"] != null && jPurchase["subscription"]["expiration_date"] != null)
|
||||||
|
{
|
||||||
|
p.ExpireDate = jPurchase["subscription"]["expiration_date"].Value<DateTime>();
|
||||||
|
}
|
||||||
|
|
||||||
PurchaseBiz pbiz = PurchaseBiz.GetBiz(ct);
|
PurchaseBiz pbiz = PurchaseBiz.GetBiz(ct);
|
||||||
p = await pbiz.CreateAsync(p);
|
p = await pbiz.CreateAsync(p);
|
||||||
if (p == null)
|
if (p == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user