Commit f6376a7d by jianshuqin

调整逻辑:新月销售利润

parent 5c230fa3
...@@ -8040,9 +8040,12 @@ group by currency"; ...@@ -8040,9 +8040,12 @@ group by currency";
,IFNULL(t1.account_name,'') AS account_name ,IFNULL(t1.account_name,'') AS account_name
,t1.data_json AS data_json ,t1.data_json AS data_json
FROM amazon_fba_summary t1 FROM amazon_fba_summary t1
LEFT JOIN amazon_account_map t2 LEFT JOIN (
ON t1.market = t2.site SELECT DISTINCT ShopName,AccountName FROM amazon_account_map
AND t1.account_name = t2.shopname )
AS t2
ON 1 = 1
AND t1.account_name = t2.shopname
WHERE 1 = 1 WHERE 1 = 1
AND t1.account_name in @accountName AND t1.account_name in @accountName
AND t1.report_month >= @startReportMonth AND t1.report_month >= @startReportMonth
...@@ -8062,14 +8065,25 @@ group by currency"; ...@@ -8062,14 +8065,25 @@ group by currency";
{ {
foreach (dc_base_fba_shipping_detail dto in list) foreach (dc_base_fba_shipping_detail dto in list)
{ {
var data = JsonConvert.DeserializeObject<dynamic>(dto.data_json); var data = JsonConvert.DeserializeObject<dynamic>(dto.data_json, new JsonSerializerSettings() { DateParseHandling = DateParseHandling.DateTimeOffset });
dto.order_id = data["Amazon Order Id"] ?? ""; dto.order_id = data["Amazon Order Id"] ?? "";
DateTime dt = DateTime.Parse("1991-01-01 00:00:00"); DateTimeOffset dt = DateTimeOffset.Parse("1991-01-01 00:00:00");
if (data["Shipment Date"] != null && DateTime.TryParse(data["Shipment Date"].ToString(), out dt)) if (data["Shipment Date"] != null && DateTimeOffset.TryParse(data["Shipment Date"].ToString(), out dt))
{ {
dto.shipment_date = dt.AddHours(-8); dto.shipment_date = dt.DateTime;
} }
dto.reporting_date = data["Reporting Date"]; else
{
dto.shipment_date = data["Shipment Date"];
}
if (data["Reporting Date"] != null && DateTimeOffset.TryParse(data["Reporting Date"].ToString(), out dt))
{
dto.reporting_date = dt.DateTime;
}
else
{
dto.reporting_date = data["Reporting Date"];
}
dto.currency = data["Currency"] ?? ""; dto.currency = data["Currency"] ?? "";
dto.sku = data["Merchant SKU"] ?? ""; dto.sku = data["Merchant SKU"] ?? "";
} }
...@@ -8110,10 +8124,10 @@ group by currency"; ...@@ -8110,10 +8124,10 @@ group by currency";
} }
sql = @"UPDATE `dc_base_oms_sku` SET shipment_date=@shipment_date WHERE platform_type = 'FBA' AND origin_order_id = @order_id AND website = @website AND seller_account = @seller_account"; sql = @"UPDATE `dc_base_oms_sku` SET shipment_date=@shipment_date WHERE platform_type = 'FBA' AND origin_order_id = @order_id AND website = @website AND seller_account = @seller_account";
db.Execute(sql, list); int count = db.Execute(sql, list);
sql = @"UPDATE `dc_base_oms_order` SET shipment_date=@shipment_date WHERE platform_type = 'FBA' AND origin_order_id = @order_id AND website = @website AND seller_account = @seller_account"; sql = @"UPDATE `dc_base_oms_order` SET shipment_date=@shipment_date WHERE platform_type = 'FBA' AND origin_order_id = @order_id AND website = @website AND seller_account = @seller_account";
db.Execute(sql, list); count = db.Execute(sql, list);
transaction.Commit(); transaction.Commit();
} }
......
...@@ -502,7 +502,7 @@ SUM(t1.cost_product * t1.quantity_shipped) AS total_amount_sales,COUNT(0) total_ ...@@ -502,7 +502,7 @@ SUM(t1.cost_product * t1.quantity_shipped) AS total_amount_sales,COUNT(0) total_
sql.Append(@"SELECT t1.platform_type, SUM(t1.amount_sales * t1.quantity_shipped) AS original_amount, sql.Append(@"SELECT t1.platform_type, SUM(t1.amount_sales * t1.quantity_shipped) AS original_amount,
SUM(t1.amount_sales * (IFNULL(t3.exchange_rate,t1.seller_order_exchange_rate)) * t1.quantity_shipped) AS total_amount_sales,COUNT(0)AS total_order FROM dc_month_sales_profit_orderdetail AS t1 "); SUM(t1.amount_sales * (IFNULL(t3.exchange_rate,t1.seller_order_exchange_rate)) * t1.quantity_shipped) AS total_amount_sales,COUNT(0)AS total_order FROM dc_month_sales_profit_orderdetail AS t1 ");
} }
sql.Append("INNER JOIN dc_base_oms_sku AS t2 ON t1.orderskuid = t2.id "); sql.Append("LEFT JOIN dc_base_oms_sku AS t2 ON t1.orderskuid = t2.id ");
sql.Append("LEFT JOIN dc_exchange_rate_finance t3 ON t1.order_currency = t3.`code` and t1.`month` = t3.`month` "); sql.Append("LEFT JOIN dc_exchange_rate_finance t3 ON t1.order_currency = t3.`code` and t1.`month` = t3.`month` ");
sql.Append($"WHERE t1.`month` ='{month}' "); sql.Append($"WHERE t1.`month` ='{month}' ");
if (!string.IsNullOrEmpty(financecategory) && financecategory != "其他") if (!string.IsNullOrEmpty(financecategory) && financecategory != "其他")
...@@ -560,12 +560,12 @@ SUM(t1.amount_sales * (IFNULL(t3.exchange_rate,t1.seller_order_exchange_rate)) * ...@@ -560,12 +560,12 @@ SUM(t1.amount_sales * (IFNULL(t3.exchange_rate,t1.seller_order_exchange_rate)) *
StringBuilder sqlText = new StringBuilder(); StringBuilder sqlText = new StringBuilder();
sqlText.Append($@"SELECT t1.*, t2.origin_order_id, t2.bailun_order_id, t3.exchange_rate as finance_order_exchange_rate sqlText.Append($@"SELECT t1.*, t2.origin_order_id, t2.bailun_order_id, t3.exchange_rate as finance_order_exchange_rate
FROM dc_month_sales_profit_orderdetail t1 FROM dc_month_sales_profit_orderdetail t1
JOIN dc_base_oms_sku t2 ON t1.orderskuid = t2.id LEFT JOIN dc_base_oms_sku t2 ON t1.orderskuid = t2.id
LEFT JOIN dc_exchange_rate_finance t3 ON t1.order_currency = t3.`code` and t1.`month` = t3.`month` LEFT JOIN dc_exchange_rate_finance t3 ON t1.order_currency = t3.`code` and t1.`month` = t3.`month`
WHERE WHERE
t1. MONTH = @Month "); t1. MONTH = @Month ");
parameters.Add("Month", input.Month); parameters.Add("Month", input.Month);
if (!string.IsNullOrWhiteSpace(input.PlatformType)) if (input.PlatformType != null)
{ {
sqlText.Append(" AND t1.platform_type = @PlatformType "); sqlText.Append(" AND t1.platform_type = @PlatformType ");
parameters.Add("PlatformType", input.PlatformType); parameters.Add("PlatformType", input.PlatformType);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment