Commit 297b34c9 by guanzhenshan

调整计算平台订单利润率

parent d1f44cc9
...@@ -174,11 +174,11 @@ namespace Bailun.DC.DailyItemNoAdGMV ...@@ -174,11 +174,11 @@ namespace Bailun.DC.DailyItemNoAdGMV
switch(website) switch(website)
{ {
case "UK": //英国 case "UK": //英国
return 0; return 1;
case "CA": //加拿大和美国取太平洋时间 case "CA": //加拿大和美国取太平洋时间
case "US": case "US":
return -5; return -7;
case "AU": //澳大利亚 case "AU": //澳大利亚
return 10; return 10;
case "DE": //德国 case "DE": //德国
...@@ -187,7 +187,7 @@ namespace Bailun.DC.DailyItemNoAdGMV ...@@ -187,7 +187,7 @@ namespace Bailun.DC.DailyItemNoAdGMV
case "NL": //荷兰 case "NL": //荷兰
case "SE": //瑞典 case "SE": //瑞典
case "IT": //意大利 case "IT": //意大利
return 1; return 2;
case "JP": //日本 case "JP": //日本
return 9; return 9;
case "ID": //印度尼西亚 case "ID": //印度尼西亚
......
...@@ -10,19 +10,19 @@ namespace Bailun.DC.DailyItemNoProfitRate ...@@ -10,19 +10,19 @@ namespace Bailun.DC.DailyItemNoProfitRate
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
//Console.WriteLine("启动服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("启动服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//var builder = new HostBuilder().ConfigureServices((hostContext, services) => var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
//{ {
// services.AddHostedService<Services>(); services.AddHostedService<Services>();
//}); });
//await builder.RunConsoleAsync(); await builder.RunConsoleAsync();
var _service = new Services(); //var _service = new Services();
var day = DateTime.Parse(DateTime.Now.AddDays(-2).ToShortDateString()); //var day = DateTime.Parse(DateTime.Now.AddDays(-2).ToShortDateString());
//_service.Init(day.AddDays(-20), day); //_service.Init(day.AddDays(-20), day);
//_service.OneDayItemNoProfitRate(day.AddDays(-1), day); ////_service.OneDayItemNoProfitRate(day.AddDays(-1), day);
_service.SaveProfitRate(day.AddDays(-20), day); //_service.SaveProfitRate(day.AddDays(-20), day);
} }
} }
} }
...@@ -84,15 +84,15 @@ namespace Bailun.DC.DailyItemNoProfitRate ...@@ -84,15 +84,15 @@ namespace Bailun.DC.DailyItemNoProfitRate
cn.Open(); cn.Open();
} }
listBaseOrder = cn.Query<dc_mid_itemno_profit_order>($@"select distinct t3.id as order_sku_id,t1.bailun_order_id,t1.origin_order_id,t1.item_id,t1.platform_sku,t1.platform_sku_quantity_ordered,t2.count,t3.bailun_sku,t3.paid_time,(t3.amount_sales*t1.platform_sku_quantity_ordered*t2.count) as amount_sales,(t3.cost_product*t1.platform_sku_quantity_ordered*t2.count) cost_product,(t3.cost_platform_fee*t1.platform_sku_quantity_ordered*t2.count) cost_platform_fee,(t3.cost_paypal_fee*t1.platform_sku_quantity_ordered*t2.count) cost_paypal_fee,(t3.cost_fba_fee*t1.platform_sku_quantity_ordered*t2.count) cost_fba_fee,(t3.cost_first*t1.platform_sku_quantity_ordered*t2.count) cost_first,(t3.cost_logistics*t1.platform_sku_quantity_ordered*t2.count) cost_logistics,(t3.cost_handle_platform*t1.platform_sku_quantity_ordered*t2.count) cost_handle_platform,(t3.cost_handle_bailun*t1.platform_sku_quantity_ordered*t2.count) cost_handle_bailun,t3.warehouse_code,t3.shipping_status,t3.seller_order_exchange_rate,t1.platform_type,t1.website,t1.bailun_account_id from dc_base_oms_platform_sku t1 listBaseOrder = cn.Query<dc_mid_itemno_profit_order>($@"select distinct t3.id as order_sku_id,t1.bailun_order_id,t1.origin_order_id,t1.item_id,t1.platform_sku,t1.platform_sku_quantity_ordered,t3.bailun_sku,t3.paid_time,(t3.amount_sales*t1.platform_sku_quantity_ordered) as amount_sales,(t3.cost_product*t1.platform_sku_quantity_ordered) cost_product,(t3.cost_platform_fee*t1.platform_sku_quantity_ordered) cost_platform_fee,(t3.cost_paypal_fee*t1.platform_sku_quantity_ordered) cost_paypal_fee,(t3.cost_fba_fee*t1.platform_sku_quantity_ordered) cost_fba_fee,(t3.cost_first*t1.platform_sku_quantity_ordered) cost_first,(t3.cost_logistics*t1.platform_sku_quantity_ordered) cost_logistics,(t3.cost_handle_platform*t1.platform_sku_quantity_ordered) cost_handle_platform,(t3.cost_handle_bailun*t1.platform_sku_quantity_ordered) cost_handle_bailun,t3.warehouse_code,t3.shipping_status,t3.seller_order_exchange_rate,t1.platform_type,t1.website,t1.bailun_account_id from dc_base_oms_platform_sku t1
join dc_base_sku_mapping t2 on t1.item_id=t2.item_id and t2.platform_sku=t1.platform_sku and t1.website=t2.site and t2.has_deleted=0 join dc_base_sku_mapping_online t2 on t1.item_id=t2.item_id and t2.item_sku=t1.platform_sku and t1.website=t2.site
join dc_base_oms_sku_30 t3 on t1.bailun_order_id=t3.bailun_order_id and t2.bailun_sku=t3.bailun_sku and t2.account_id=t3.bailun_account_id join dc_base_oms_sku_30 t3 on t1.bailun_order_id=t3.bailun_order_id and t2.sku_code=t3.bailun_sku and t2.account_id=t3.bailun_account_id
where t1.platform_type in ('Ebay','FBA','Amazon') and t3.has_delete=0 and t3.company_id=1 and t1.paid_time>='{start.ToString("yyyy-MM-dd")}' and t1.paid_time<'{end.AddDays(1).ToString("yyyy-MM-dd")}'", null, null, true, 6 * 60).ToList(); where t1.platform_type in ('Ebay','FBA','Amazon') and t3.has_delete=0 and t3.company_id=1 and t1.paid_time>='{start.AddHours(-15).ToString("yyyy-MM-dd")}' and t1.paid_time<'{end.AddHours(16).AddDays(1).ToString("yyyy-MM-dd")}'", null, null, true, 6 * 60).ToList();
} }
if(listBaseOrder.Count>0) if(listBaseOrder.Count>0)
{ {
var sql = $@"insert dc_mid_itemno_profit_order (day,order_sku_id,bailun_order_id,origin_order_id,item_id,platform_sku,platform_sku_quantity_ordered,count,bailun_sku,paid_time,amount_sales,cost_product,cost_platform_fee,cost_paypal_fee,cost_fba_fee,cost_first,cost_logistics,cost_handle_platform,cost_handle_bailun,warehouse_code,shipping_status,seller_order_exchange_rate,platform_type,website,bailun_account_id) values var sql = $@"insert dc_mid_itemno_profit_order (day,order_sku_id,bailun_order_id,origin_order_id,item_id,platform_sku,platform_sku_quantity_ordered,count,bailun_sku,paid_time,amount_sales,cost_product,cost_platform_fee,cost_paypal_fee,cost_fba_fee,cost_first,cost_logistics,cost_handle_platform,cost_handle_bailun,warehouse_code,shipping_status,seller_order_exchange_rate,platform_type,website,bailun_account_id,platform_paid_time) values
"; ";
...@@ -111,7 +111,12 @@ namespace Bailun.DC.DailyItemNoProfitRate ...@@ -111,7 +111,12 @@ namespace Bailun.DC.DailyItemNoProfitRate
var index = 1; var index = 1;
foreach (var item in listBaseOrder) foreach (var item in listBaseOrder)
{ {
str += $"('{end.ToString("yyyy-MM-dd")}',{item.order_sku_id},'{item.bailun_order_id}','{item.origin_order_id}','{item.item_id}','{item.platform_sku}',{item.platform_sku_quantity_ordered},{item.count},'{item.bailun_sku}','{item.paid_time.ToString("yyyy-MM-dd HH:mm:ss")}',{item.amount_sales},{item.cost_product},{item.cost_platform_fee},{item.cost_paypal_fee},{item.cost_fba_fee},{item.cost_first},{item.cost_logistics},{item.cost_handle_platform},{item.cost_handle_bailun},'{item.warehouse_code}','{item.shipping_status}','{item.seller_order_exchange_rate}','{item.platform_type}','{item.website}','{item.bailun_account_id}'),"; item.count = 1; //设置默认数量为 1
//转换为平台站点时间
item.platform_paid_time = ToPlatformTime(item.website.ToUpper(),item.paid_time);
str += $"('{end.ToString("yyyy-MM-dd")}',{item.order_sku_id},'{item.bailun_order_id}','{item.origin_order_id}','{item.item_id}','{item.platform_sku}',{item.platform_sku_quantity_ordered},{item.count},'{item.bailun_sku}','{item.paid_time.ToString("yyyy-MM-dd HH:mm:ss")}',{item.amount_sales},{item.cost_product},{item.cost_platform_fee},{item.cost_paypal_fee},{item.cost_fba_fee},{item.cost_first},{item.cost_logistics},{item.cost_handle_platform},{item.cost_handle_bailun},'{item.warehouse_code}','{item.shipping_status}','{item.seller_order_exchange_rate}','{item.platform_type}','{item.website}','{item.bailun_account_id}','{item.platform_paid_time.ToString("yyyy-MM-dd HH:mm:ss")}'),";
if (index % 1000 == 0 || index == list.Count) if (index % 1000 == 0 || index == list.Count)
{ {
//保存数据 //保存数据
...@@ -149,6 +154,9 @@ namespace Bailun.DC.DailyItemNoProfitRate ...@@ -149,6 +154,9 @@ namespace Bailun.DC.DailyItemNoProfitRate
where (t1.shipping_status='UnShipping' or t2.area_id=18) and t1.day='{end.ToString("yyyy-MM-dd")}'", null, null, 6 * 60); where (t1.shipping_status='UnShipping' or t2.area_id=18) and t1.day='{end.ToString("yyyy-MM-dd")}'", null, null, 6 * 60);
Console.WriteLine("完成尾程字段是否预估更新" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("完成尾程字段是否预估更新" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//删除多余的订单数据,按平台时间过滤
cn.Execute($"delete from dc_mid_itemno_profit_order where day ='{end.ToString("yyyy-MM-dd")}' and platform_paid_time>='{start.ToString("yyyy-MM-dd")}' and platform_paid_time<'{end.AddDays(1).ToString("yyyy-MM-dd")}'");
} }
Console.WriteLine("完成订单基础数据保存 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("完成订单基础数据保存 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
} }
...@@ -174,19 +182,19 @@ namespace Bailun.DC.DailyItemNoProfitRate ...@@ -174,19 +182,19 @@ namespace Bailun.DC.DailyItemNoProfitRate
} }
//取出订单明细 //取出订单明细
listOrders = cn.Query<Models.dc_mid_itemno_profit_order>($"select * from dc_mid_itemno_profit_order where day>='{start.ToString("yyyy-MM-dd")}' and day<'{end.AddDays(1).ToString("yyyy-MM-dd")}' and item_id='263702031471'", null, null, true, 6 * 60).AsList(); listOrders = cn.Query<Models.dc_mid_itemno_profit_order>($"select * from dc_mid_itemno_profit_order where day>='{start.ToString("yyyy-MM-dd")}' and day<'{end.AddDays(1).ToString("yyyy-MM-dd")}'", null, null, true, 6 * 60).AsList();
Console.WriteLine("完成取出订单数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("完成取出订单数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//取出item no的广告GMV //取出item no的广告GMV
listItemAdGMV = cn.Query<Models.dc_daily_itemno_ad_gmv>($"select * from dc_daily_itemno_ad_gmv where sale_date_bj>='{start.ToString("yyyy-MM-dd")}' and sale_date_bj<'{end.AddDays(1).ToString("yyyy-MM-dd")}' and item_id='263702031471'").AsList(); listItemAdGMV = cn.Query<Models.dc_daily_itemno_ad_gmv>($"select * from dc_daily_itemno_ad_gmv where sale_date>='{start.ToString("yyyy-MM-dd")}' and sale_date<'{end.AddDays(1).ToString("yyyy-MM-dd")}'").AsList();
Console.WriteLine("完成取出itemno的广告GMV数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("完成取出itemno的广告GMV数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//取出所有ebay的广告费 //取出所有ebay的广告费
listAdEbay = cn.Query<Models.dc_base_finance_ebay>($@"select * from dc_base_finance_ebay where bj_date>='{start.ToString("yyyy-MM-dd")}' and bj_date<'{end.AddDays(1).ToString("yyyy-MM-dd")}' and account_entry_type='FeeAd' and item_id='263702031471'").ToList(); listAdEbay = cn.Query<Models.dc_base_finance_ebay>($@"select * from dc_base_finance_ebay where gmt_date>='{start.ToString("yyyy-MM-dd")}' and gmt_date<'{end.AddDays(1).ToString("yyyy-MM-dd")}' and account_entry_type='FeeAd'").ToList();
Console.WriteLine("完成取出ebay广告费数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("完成取出ebay广告费数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//取出所有亚马逊的广告费 //取出所有亚马逊的广告费
listAdAmazon = cn.Query<Models.dc_base_finance_amazon_ad_product>($@"select * from dc_base_finance_amazon_ad_product where report_date>='{start.ToString("yyyy-MM-dd")}' and report_date<'{end.AddDays(1).ToString("yyyy-MM-dd")}' and asin='263702031471'").ToList(); listAdAmazon = cn.Query<Models.dc_base_finance_amazon_ad_product>($@"select * from dc_base_finance_amazon_ad_product where report_date>='{start.ToString("yyyy-MM-dd")}' and report_date<'{end.AddDays(1).ToString("yyyy-MM-dd")}'").ToList();
Console.WriteLine("完成取出亚马逊广告数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("完成取出亚马逊广告数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
} }
...@@ -301,15 +309,15 @@ namespace Bailun.DC.DailyItemNoProfitRate ...@@ -301,15 +309,15 @@ namespace Bailun.DC.DailyItemNoProfitRate
} }
//取出订单明细 //取出订单明细
listOrders = cn.Query<Models.dc_mid_itemno_profit_order>($"select * from dc_mid_itemno_profit_order where paid_time>='{start.ToString("yyyy-MM-dd")}' and paid_time<'{end.AddDays(1).ToString("yyyy-MM-dd")}'").AsList(); listOrders = cn.Query<Models.dc_mid_itemno_profit_order>($"select * from dc_mid_itemno_profit_order where platform_paid_time>='{start.ToString("yyyy-MM-dd")}' and platform_paid_time<'{end.AddDays(1).ToString("yyyy-MM-dd")}'").AsList();
Console.WriteLine("完成取出订单数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("完成取出订单数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//取出item no的广告GMV //取出item no的广告GMV
listItemAdGMV = cn.Query<Models.dc_daily_itemno_ad_gmv>($"select * from dc_daily_itemno_ad_gmv where day>='{start.ToString("yyyy-MM-dd")}' and day<'{end.AddDays(1).ToString("yyyy-MM-dd")}'").AsList(); listItemAdGMV = cn.Query<Models.dc_daily_itemno_ad_gmv>($"select * from dc_daily_itemno_ad_gmv where sale_date>='{start.ToString("yyyy-MM-dd")}' and sale_date<'{end.AddDays(1).ToString("yyyy-MM-dd")}'").AsList();
Console.WriteLine("完成取出itemno的广告GMV数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("完成取出itemno的广告GMV数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//取出所有ebay的广告费 //取出所有ebay的广告费
listAdEbay = cn.Query<Models.dc_base_finance_ebay>($@"select * from dc_base_finance_ebay where bj_date>='{start.ToString("yyyy-MM-dd")}' and bj_date<'{end.AddDays(1).ToString("yyyy-MM-dd")}' and account_entry_type='FeeAd'").ToList(); listAdEbay = cn.Query<Models.dc_base_finance_ebay>($@"select * from dc_base_finance_ebay where gmt_date>='{start.ToString("yyyy-MM-dd")}' and gmt_date<'{end.AddDays(1).ToString("yyyy-MM-dd")}' and account_entry_type='FeeAd'").ToList();
Console.WriteLine("完成取出ebay广告费数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("完成取出ebay广告费数据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//取出所有亚马逊的广告费 //取出所有亚马逊的广告费
...@@ -419,5 +427,46 @@ namespace Bailun.DC.DailyItemNoProfitRate ...@@ -419,5 +427,46 @@ namespace Bailun.DC.DailyItemNoProfitRate
return cn.Query<dc_platform_and_site>("select english_name,Loss_withdrawal_percent from dc_platform_and_site where type=1").AsList(); return cn.Query<dc_platform_and_site>("select english_name,Loss_withdrawal_percent from dc_platform_and_site where type=1").AsList();
} }
} }
/// <summary>
/// 北京时间转平台时间
/// </summary>
/// <param name="website"></param>
/// <param name="time"></param>
/// <returns></returns>
private DateTime ToPlatformTime(string website,DateTime time)
{
switch(website)
{
case "UK": //英国
return time.AddHours(-7);
case "CA": //加拿大和美国取太平洋时间
case "US":
return time.AddHours(-15);
case "AU": //澳大利亚
return time.AddHours(2);
case "DE": //德国
case "ES": //西班牙
case "FR": //法国
case "NL": //荷兰
case "SE": //瑞典
case "IT": //意大利
return time.AddHours(-6);
case "JP": //日本
return time.AddHours(1);
case "ID": //印度尼西亚
case "MY": //马来西亚
case "PH": //菲律宾
case "SG": //新加坡
case "CN": //中国
return time;
case "TH": //泰国
return time.AddHours(-1);
default:
return time;
}
}
} }
} }
...@@ -62,6 +62,11 @@ namespace Bailun.DC.Models ...@@ -62,6 +62,11 @@ namespace Bailun.DC.Models
public DateTime paid_time { get; set; } public DateTime paid_time { get; set; }
/// <summary> /// <summary>
/// 平台付款时间
/// </summary>
public DateTime platform_paid_time { get; set; }
/// <summary>
/// 销售额 /// 销售额
/// </summary> /// </summary>
public decimal amount_sales { get; set; } public decimal amount_sales { get; set; }
......
...@@ -7,24 +7,24 @@ namespace Bailun.DC.MonthSaleProfit ...@@ -7,24 +7,24 @@ namespace Bailun.DC.MonthSaleProfit
{ {
class Program class Program
{ {
static async Task Main(string[] args) //static async Task Main(string[] args)
{
Console.WriteLine("启动服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Services>();
});
await builder.RunConsoleAsync();
}
//static void Main(string[] args)
//{ //{
// var _services = new Services(); // Console.WriteLine("启动服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
// var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
// {
// services.AddHostedService<Services>();
// });
// var start = DateTime.Parse("2020-11-01"); // await builder.RunConsoleAsync();
// //_services.InitNew(start);
// _services.InitNew4K(start);
//} //}
static void Main(string[] args)
{
var _services = new Services();
var start = DateTime.Parse("2020-11-01");
_services.InitNew(start);
//_services.InitNew4K(start);
}
} }
} }
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