Commit 063cc67b by 泽锋 李

初始化一波商品平台销量统计

parent 583e24e4
......@@ -4424,5 +4424,62 @@ where (t1.gmt_purchase_modified>=@start_time and t1.gmt_purchase_modified<=@end_
total = _connection.QueryFirstOrDefault<int>(countSql, parameters);
return _connection.Query<dc_report_goods_dto>(sql, parameters).AsList();
}
/// <summary>
/// 平台报表生成
/// </summary>
public static void GenerateReportPlatformGoods()
{
try
{
var datas = _connection.Query<dc_report_goods_platform_temp>(@"
select
t2.product_code as 'product_code',
t2.sku_title_cn as 'product_title',
t2.product_type_desc as 'product_type',
t1.platform_type as 'platform_type',
t2.unit_price as 'unit_price',
t2.weight as 'weight',
t2.buyer_name as 'buyer_name',
0 as 'sales_amount_usd',
sum( case when t1.paid_time>=@b1 and t1.paid_time<=@e1 then t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday',
sum( case when t1.paid_time>=@b1 and t1.paid_time<=@e1 then t1.amount_sales * t1.order_to_usd_exchange_rate * t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday_amount_usd',
sum( case when t1.paid_time>=@b7 and t1.paid_time<=@e1 then t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday_7',
sum( case when t1.paid_time>=@b7 and t1.paid_time<=@e1 then t1.amount_sales * t1.order_to_usd_exchange_rate * t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday_amount_usd_7',
sum( case when t1.paid_time>=@b30 and t1.paid_time<=@e1 then t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday_30',
sum( case when t1.paid_time>=@b30 and t1.paid_time<=@e1 then t1.amount_sales * t1.order_to_usd_exchange_rate * t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday_amount_usd_30'
from dc_base_oms_sku_30 as t1
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_base_warehouse as t3 on t1.warehouse_code = t3.warehouse_code
where t1.paid_time>=@b30
GROUP BY t2.product_code,t1.platform_type
", new
{
b30 = DateTime.Now.AddDays(-31).ToDayHome(),
e1 = DateTime.Now.AddDays(-1).ToDayEnd(),
b1 = DateTime.Now.AddDays(-1).ToDayHome(),
b7 = DateTime.Now.AddDays(-8).ToDayHome()
}, commandTimeout: 0).ToList();
_connection.Execute(" TRUNCATE table dc_report_goods_platform_temp; ");
foreach (var item in datas)
{
_connection.Insert<dc_report_goods_platform_temp>(item);
}
_connection.Execute(@"
alter table dc_report_goods_platform rename dc_report_goods_platformTemp;
alter table dc_report_goods_platform_temp rename dc_report_goods_platform;
alter table dc_report_goods_platformTemp rename dc_report_goods_platform_temp;
truncate table dc_report_goods_platform_temp;
");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
}
}
}
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.Report
{
public class dc_report_goods_platform
{
public int id { get; set; }
public string product_code { get; set; }
public string product_title { get; set; }
public string product_type { get; set; }
public string platform_type { get; set; }
public decimal unit_price { get; set; }
public decimal weight { get; set; }
public string buyer_name { get; set; }
public decimal sales_amount_usd { get; set; }
public int sales_yesterday { get; set; }
public decimal sales_yesterday_amount_usd { get; set; }
public int sales_yesterday_7 { get; set; }
public decimal sales_yesterday_amount_usd_7 { get; set; }
public int sales_yesterday_30 { get; set; }
public decimal sales_yesterday_amount_usd_30 { get; set; }
}
public class dc_report_goods_platform_temp: dc_report_goods_platform
{
}
}
......@@ -32,7 +32,7 @@ namespace ResetOutofstock
//dc_aims_transfer_warehouse_dao.TransferWarehouseTask();
//daily.ResetFbaExtendReview(DateTime.Now);
//report.PurchaseWeekBackUp();
report.SynchroReportGoodsOnTheWayData();
report.GenerateReportPlatformGoods();
//dc_auto_turnover.ResetHistory();
}
......
......@@ -17,9 +17,9 @@ namespace ResetOutofstock
Task.Factory.StartNew(() =>
{
//Console.WriteLine($"init 开始 ,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
//report.GenerateReportGoods();
//Console.WriteLine($"init 结束,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
Console.WriteLine($"init 开始 ,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.GenerateReportPlatformGoods();
Console.WriteLine($"init 结束,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
});
......
......@@ -54,6 +54,7 @@ namespace ResetOutofstock
{
Console.WriteLine($"开始 生成商品报表,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.GenerateReportGoods();
report.GenerateReportPlatformGoods();
Console.WriteLine($"结束 生成商品报表,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
......
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