Commit a4fab023 by guanzhenshan

调整月销售利润报表统计服务的公式

parent 3c1f93ae
......@@ -7,26 +7,26 @@ namespace Bailun.DC.MonthSaleProfit
{
class Program
{
//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)
static async Task 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("2021-1-01");
//_services.Init(start);
_services.InitNew(start);
//_services.InitNew4K(start);
//_services.InitNew4K(start);
await builder.RunConsoleAsync();
}
//static void Main(string[] args)
//{
// var _services = new Services();
// var start = DateTime.Parse("2021-1-01");
// //_services.Init(start);
// _services.InitNew(start);
// //_services.InitNew4K(start);
// //_services.InitNew4K(start);
//}
}
}
......@@ -29,7 +29,7 @@ namespace Bailun.DC.MonthSaleProfit
{
var now = DateTime.Now;
if (now.Day == 1 && now.Hour == 0 && now.Minute == 45 && now.Second==1) //每个月的1日0点1分启动
if (now.Day == 1 && now.Hour == 0 && now.Minute == 45 && now.Second==3) //每个月的1日0点1分启动
{
Console.WriteLine("开始启动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var start = DateTime.Parse(now.AddMonths(-1).ToShortDateString());
......@@ -37,15 +37,15 @@ namespace Bailun.DC.MonthSaleProfit
Init(start);
Console.WriteLine("开始启动新销售利润报表计算 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
InitNew(start);
//Console.WriteLine("开始启动新销售利润报表计算 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//InitNew(start);
Console.WriteLine("开始启动4K销售利润报表计算 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
InitNew4K(start);
Console.WriteLine("任务运行完成 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
else if(now.Day==5 && now.Hour == 0 && now.Minute == 45 && now.Second == 1)
else if(now.Day==5 && now.Hour == 0 && now.Minute == 45 && now.Second == 3)
{
Console.WriteLine("开始启动新销售利润报表计算 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var start = DateTime.Parse(DateTime.Parse(now.ToString("yyyy-MM")+"-01").AddMonths(-1).ToShortDateString());
......@@ -545,7 +545,7 @@ namespace Bailun.DC.MonthSaleProfit
objOrder = cn.Query<dc_month_sales_profit_orderdetail>(sql).ToList();
//FBA订单明细
sql = $@"select sum(amount_sales*quantity_shipped*seller_order_exchange_rate) as amount_sales,sum(cost_product*quantity_shipped) as cost_product,sum(cost_platform_fee*(if(platform_type='Ebay',seller_other_exchange_rate,seller_order_exchange_rate))*quantity_shipped) as cost_platform_fee,sum(cost_paypal_fee*seller_order_exchange_rate*quantity_shipped) as cost_paypal_fee,sum(cost_first*quantity_shipped) as cost_first,sum(cost_logistics*quantity_shipped) as cost_logistics,sum(cost_handle_platform*quantity_shipped) as cost_handle_platform,if(financecategoryname is null,'',financecategoryname) as financecategoryname,((total_fee-shipping)*wms_to_cny_exchange_rate*quantity_shipped) as total_fee from dc_month_sales_profit_orderdetail where month='{day.ToString("yyyy-MM")}' and platform_type='FBA' group by financecategoryname";
sql = $@"select sum(amount_sales*quantity_shipped*seller_order_exchange_rate) as amount_sales,sum(cost_product*quantity_shipped) as cost_product,sum(cost_platform_fee*(if(platform_type='Ebay',seller_other_exchange_rate,seller_order_exchange_rate))*quantity_shipped) as cost_platform_fee,sum(cost_paypal_fee*seller_order_exchange_rate*quantity_shipped) as cost_paypal_fee,sum(cost_first*quantity_shipped) as cost_first,sum(cost_logistics*quantity_shipped) as cost_logistics,sum(cost_handle_platform*quantity_shipped) as cost_handle_platform,if(financecategoryname is null,'',financecategoryname) as financecategoryname,sum((total_fee-shipping)*wms_to_cny_exchange_rate*quantity_shipped) as total_fee,sum(cost_fba_fee*quantity_shipped*seller_order_exchange_rate) as cost_fba_fee from dc_month_sales_profit_orderdetail where month='{day.ToString("yyyy-MM")}' and platform_type='FBA' group by financecategoryname";
objFBA = cn.Query<dc_month_sales_profit_orderdetail>(sql).ToList();
decimal? obj = 0;
......@@ -626,8 +626,8 @@ join dc_base_warehouse t3 on t1.warehouse_code=t3.warehouse_code
//物流仓储费用 = 头程运输+直邮物流费(国内发货)+尾程物流费(国外发货)+海外仓仓储+海外仓杂费
//头程运输费改为从调拨系统读取,预估费用,交运确认时间
var objFirst = cn.QueryFirstOrDefault<decimal>($"select sum(estimatedcost) from dc_base_transfer_info where isdeleted=0 and stateid>1 and deliverytime >='{day.ToString("yyyy-MM-dd")}' and deliverytime<'{day.AddMonths(1).ToString("yyyy-MM-dd")}'");
m.fee_logistics_first = objFirst; //objOrder.Sum(a => a.cost_first??0) + objFBA.Sum(a => a.cost_first??0);
//var objFirst = cn.QueryFirstOrDefault<decimal>($"select sum(estimatedcost) from dc_base_transfer_info where isdeleted=0 and stateid>1 and deliverytime >='{day.ToString("yyyy-MM-dd")}' and deliverytime<'{day.AddMonths(1).ToString("yyyy-MM-dd")}'");
m.fee_logistics_first = objOrder.Sum(a => a.cost_first) + objFBA.Sum(a => a.cost_first);//objFirst; //
m.fee_logistics_direct = objLogistics.Where(a => a.hq_type == "国内仓")?.Sum(b => b.cost_logistics) ?? 0; //objOrder.Sum(a => a.cost_logistics??0);
m.fee_logistics_tail = objLogistics.Where(a => a.hq_type != "国内仓")?.Sum(b => b.cost_logistics) ?? 0;
m.fee_storage = objOrder.Sum(a => a.total_fee);
......@@ -636,8 +636,8 @@ join dc_base_warehouse t3 on t1.warehouse_code=t3.warehouse_code
//付现销售费用
m.managecost_bl_xg = (list.Where(a => a.company_name.Contains("香港百伦"))?.Sum(a => a.amount_rmb) ?? 0);
m.fee_paycash_sales = list.Where(a => (a.fee_super_type == "推广费" || a.fee_super_type == "物流费用") && !a.company_name.Contains("香港百伦") && !a.company_name.Contains("四千里") && !a.company_name.Contains("YOUNGTOP INTERNATIONAL LIMITED") && !a.company_name.Contains("miles") && !a.company_name.Contains("拉古娜") && !a.company_name.Contains("哈倪蔓"))?.Sum(a => a.amount_rmb) ?? 0;
m.managecost_bl_xg = (list.Where(a => a.company_name.Contains("香港百伦") && a.fee_super_type != "物流费")?.Sum(a => (a.manage_cost_type==2?-a.amount_rmb:a.amount_rmb)) ?? 0);
m.fee_paycash_sales = 0; //list.Where(a => (a.fee_super_type == "推广费") && !a.company_name.Contains("香港百伦") && !a.company_name.Contains("四千里") && !a.company_name.Contains("YOUNGTOP INTERNATIONAL LIMITED") && !a.company_name.Contains("miles") && !a.company_name.Contains("拉古娜") && !a.company_name.Contains("哈倪蔓"))?.Sum(a => a.amount_rmb) ?? 0;
//付现销售费用加上香港百伦的管理成本金额
//Add by Allan at 20210102
m.fee_paycash_sales += m.managecost_bl_xg;
......@@ -898,7 +898,7 @@ join dc_base_warehouse t3 on t1.warehouse_code=t3.warehouse_code
var str = "insert dc_month_sales_profit_orderdetail (month,pickid,orderskuid,bailun_sku,amount_sales,cost_product,cost_platform_fee,cost_paypal_fee,cost_first,cost_logistics,cost_handle_platform,total_fee,shipping,seller_order_exchange_rate,seller_other_exchange_rate,wms_to_cny_exchange_rate,quantity_shipped,shipping_time,platform_type,cost_fba_fee,financecategoryname) values ";
foreach(var item in tempList)
{
str += $"('{day.ToString("yyyy-MM")}',{item.pickid},{item.orderskuid},'{item.bailun_sku}',{item.amount_sales},{item.cost_product},{item.cost_platform_fee},{item.cost_paypal_fee},{item.cost_first},{item.cost_logistics},{item.cost_handle_platform},{item.total_fee},{item.shipping},{item.seller_order_exchange_rate},{item.seller_other_exchange_rate},{item.wms_to_cny_exchange_rate},{item.quantity_shipped},'{item.shipping_time}','{item.platform_type}',{item.cost_fba_fee},'{item.financecategoryname}'),";
str += $"('{day.ToString("yyyy-MM")}',{item.pickid},{item.orderskuid},'{item.bailun_sku}',{item.amount_sales},{item.cost_product},{item.cost_platform_fee},{item.cost_paypal_fee},{item.cost_first},{item.cost_logistics},{item.cost_handle_platform},{item.total_fee},{item.shipping},{item.seller_order_exchange_rate},{item.seller_other_exchange_rate},{item.wms_to_cny_exchange_rate},{item.quantity_shipped},'{item.shipping_time.ToString("yyyy-MM-dd HH:mm:ss")}','{item.platform_type}',{item.cost_fba_fee},'{item.financecategoryname}'),";
}
Console.WriteLine($"总记录数:{objOrder.Count},第{(page + 1)}页,记录数:{tempList.Count} {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
......@@ -922,7 +922,7 @@ join dc_base_warehouse t3 on t1.warehouse_code=t3.warehouse_code
var str = "insert dc_month_sales_profit_orderdetail (month,pickid,orderskuid,bailun_sku,amount_sales,cost_product,cost_platform_fee,cost_paypal_fee,cost_first,cost_logistics,cost_handle_platform,total_fee,shipping,seller_order_exchange_rate,seller_other_exchange_rate,wms_to_cny_exchange_rate,quantity_shipped,shipping_time,platform_type,cost_fba_fee,financecategoryname) values ";
foreach (var item in tempList)
{
str += $"('{day.ToString("yyyy-MM")}',{item.pickid},{item.orderskuid},'{item.bailun_sku}',{item.amount_sales},{item.cost_product},{item.cost_platform_fee},{item.cost_paypal_fee},{item.cost_first},{item.cost_logistics},{item.cost_handle_platform},{item.total_fee},{item.shipping},{item.seller_order_exchange_rate},{item.seller_other_exchange_rate},{item.wms_to_cny_exchange_rate},{item.quantity_shipped},'{item.shipping_time}','{item.platform_type}',{item.cost_fba_fee},'{item.financecategoryname}'),";
str += $"('{day.ToString("yyyy-MM")}',{item.pickid},{item.orderskuid},'{item.bailun_sku}',{item.amount_sales},{item.cost_product},{item.cost_platform_fee},{item.cost_paypal_fee},{item.cost_first},{item.cost_logistics},{item.cost_handle_platform},{item.total_fee},{item.shipping},{item.seller_order_exchange_rate},{item.seller_other_exchange_rate},{item.wms_to_cny_exchange_rate},{item.quantity_shipped},'{item.shipping_time.ToString("yyyy-MM-dd HH:mm:ss")}','{item.platform_type}',{item.cost_fba_fee},'{item.financecategoryname}'),";
}
Console.WriteLine($"总记录数:{objFBA.Count},第{(page + 1)}页,记录数:{tempList.Count} {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