Commit 280ce3cc by guanzhenshan

月销售利润统计增加平台物流费

parent bc5a00af
......@@ -7,29 +7,29 @@ namespace Bailun.DC.DailyPurchaseSellStock
{
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();
var start = DateTime.Parse("2019-10-30");
while (start.AddDays(1) < DateTime.Now)
Console.WriteLine("启动服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
Console.WriteLine(start);
_services.Init(start);
start = start.AddDays(1);
}
services.AddHostedService<Services>();
});
await builder.RunConsoleAsync();
}
//static void Main(string[] args)
//{
// var _services = new Services();
// var start = DateTime.Parse("2019-10-01");
// while (start.AddDays(1) < DateTime.Now)
// {
// Console.WriteLine(start);
// _services.Init(start);
// start = start.AddDays(1);
// }
//}
}
}
......@@ -76,10 +76,9 @@ namespace Bailun.DC.DailyPurchaseSellStock
page = 1;
pagesize = 5000;
var objStock = new List<mStock>();
sql = $@"select t1.bailun_sku,t1.warehouse_code,t2.warehouse_name,sum(t1.usable_stock+t1.occupy_stock) count,sum((t1.usable_stock+t1.occupy_stock)*t3.unit_price) as amount from dc_base_stock t1
sql = $@"select t1.bailun_sku,t1.warehouse_code,t2.warehouse_name,sum(t1.usable_stock+t1.occupy_stock) count,sum((t1.usable_stock+t1.occupy_stock)*t1.unit_price) as amount from dc_daily_stock t1
left join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code
left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku
where t1.usable_stock>0 or t1.occupy_stock>0 group by t1.bailun_sku,t1.warehouse_code order by t1.warehouse_code desc,t1.bailun_sku desc";
where t1.record_time='{day.ToString("yyyy-MM-dd")}' group by t1.bailun_sku,t1.warehouse_code";
temp = cn.Query<mStock>(sql + " limit " + (page - 1) * pagesize + "," + pagesize, null, null, true, 2 * 60);
while (temp.Count() > 0)
{
......@@ -107,11 +106,9 @@ namespace Bailun.DC.DailyPurchaseSellStock
//在途库存
var objOnWay = new List<mStock>();
page = 1;
sql = $@"select t1.bailun_sku,t1.warehouse_code,t2.warehouse_name,sum(t1.quantity_purchase+t1.quantity_transfer) count,sum((t1.quantity_purchase+t1.quantity_transfer)*t3.unit_price) as amount from dc_mid_transit t1
sql = $@"select t1.bailun_sku,t1.warehouse_code,t2.warehouse_name,sum(t1.quantity_purchase+t1.quantity_transfer) count,sum((t1.quantity_purchase+t1.quantity_transfer)*t1.unit_price) as amount from dc_daily_transit t1
left join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code
left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku
where (t1.quantity_purchase>0 or t1.quantity_transfer>0)
group by t1.bailun_sku,t1.warehouse_code
where t1.record_time='{day.ToString("yyyy-MM-dd")}' and (t1.quantity_purchase>0 or t1.quantity_transfer>0) group by t1.bailun_sku,t1.warehouse_code
";
temp = cn.Query<mStock>(sql + " limit " + (page - 1) * pagesize + "," + pagesize, null, null, true, 2 * 60);
while (temp.Count() > 0)
......
......@@ -22,7 +22,7 @@ namespace Bailun.DC.MonthSaleProfit
//{
// var _services = new Services();
// var start = DateTime.Parse("2019-09-01");
// var start = DateTime.Parse("2019-11-01");
// _services.Init(start);
//}
}
......
......@@ -111,7 +111,7 @@ namespace Bailun.DC.MonthSaleProfit
var objOrder = cn.QueryFirstOrDefault<Models.Orders.dc_base_oms_order>(sql, null, null, 6 * 60);
sql = $@"select sum(amount_sales*seller_order_exchange_rate) as amount_sales,sum(cost_product) as cost_product,sum(cost_platform_fee*seller_order_exchange_rate) as cost_platform_fee,sum(cost_first) as cost_first,sum(cost_logistics) as cost_logistics from dc_base_oms_order tb where tb.company_id=1 and tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('None','Failed') and tb.platform_type='FBA' and tb.create_time>='{day.ToString("yyyy-MM-dd")}' and tb.create_time<'{day.AddMonths(1).ToString("yyyy-MM-dd")}'";
sql = $@"select sum(amount_sales*seller_order_exchange_rate) as amount_sales,sum(cost_product) as cost_product,sum(cost_platform_fee*seller_order_exchange_rate) as cost_platform_fee,sum(cost_first) as cost_first,sum(cost_logistics) as cost_logistics,sum(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee from dc_base_oms_order tb where tb.company_id=1 and tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('None','Failed') and tb.platform_type='FBA' and tb.create_time>='{day.ToString("yyyy-MM-dd")}' and tb.create_time<'{day.AddMonths(1).ToString("yyyy-MM-dd")}'";
var objFBA = cn.QueryFirstOrDefault<Models.Orders.dc_base_oms_order>(sql, null, null, 6 * 60);
decimal? obj = 0;
......@@ -144,7 +144,7 @@ namespace Bailun.DC.MonthSaleProfit
m.pt_paypal_fee = objOrder.cost_paypal_fee;
//平台物流费
m.pt_platform_logistics_fee = objFBA.cost_fba_fee;
//广告费
......@@ -183,6 +183,47 @@ namespace Bailun.DC.MonthSaleProfit
m.ls_platform_operation_fee = objOrder.cost_handle_platform;
//平台扣费及退款=平台费+ebay刊登费+paypal费用+平台物流费+广告及宣传费|订阅费+平台仓储费+退款
m.pt_count = m.pt_platformfee + m.pt_ebay_postingfee + m.pt_paypal_fee + (m.pt_platform_logistics_fee + m.pt_platform_logistics_fee_) + (m.pt_platform_ad_subscribe_fee + m.pt_platform_ad_subscribe_fee_) + m.pt_platform_storage_fee + m.pt_refund_amount;
//回款=销售额-平台扣费及退款
m.pt_incoming = m.amount_sale - m.pt_count;
//物流仓储费用=头程运输+尾程物流+海外仓的仓储费+平台操作费
m.ls_count = (m.ls_head_cost + m.ls_head_cost_) + (m.ls_tail_cost + m.ls_tail_cost_) + m.ls_oversea_storage + m.ls_platform_operation_fee;
//销售费用合计=平台扣费及退款+物流仓储费用
m.sale_fee_count = m.pt_count + m.ls_count;
//销售利润=销售额-成本-销售费用合计
m.sale_profit = m.amount_sale - (m.cost_sale + m.cost_sale_) - m.sale_fee_count;
//销售毛利率 = 销售利润/销售额
m.sale_profit_rate = m.amount_sale>0?m.sale_profit / m.amount_sale:0;
//销售相关的管理成本=处理费+直接支付的与销售平台相关费用
m.sale_manager_cost = m.handlingcharges + m.payfor_platform_related_fee;
//直接管理成本=管理成本香港百伦+管理成本广州百伦+管理成本成品仓+财务费用
m.direct_manager_cost = m.manager_cost_hkbailun + m.manager_cost_gzbailun + m.manager_cost_finish_wh + m.finance_fee;
//管理成本合计=直接管理成本+销售相关的管理成本
m.manager_cost_count = m.direct_manager_cost + m.sale_manager_cost;
//营业利润=销售利润-管理成本合计
m.business_profit = m.sale_profit - m.manager_cost_count;
//营业毛利率=营业利润/销售额
m.business_profit_rate = m.amount_sale>0? m.business_profit / m.amount_sale:0;
//实际利润=营业利润+其他收入+营业外收入-营业外支出
m.actual_profit = m.business_profit + m.other_incoming + m.nonbusiness_income - m.nonbusiness_pay;
//利润结余=实际利润-分红
m.balance_of_profit = m.actual_profit - m.participation_in_profit;
cn.Execute("delete from dc_month_sale_profit where month='" + m.month + "'");
sql = $@"insert dc_month_sale_profit (actual_profit,amount_sale,balance_of_profit,business_profit,business_profit_rate,cost_sale,createtime,direct_manager_cost,finance_fee,handlingcharges,lastupdatetime,lastupdateuserid,lastupdateusername,ls_count,ls_head_cost,ls_oversea_storage,ls_platform_operation_fee,ls_tail_cost,manager_cost_count,manager_cost_finish_wh,manager_cost_gzbailun,manager_cost_hkbailun,month,nonbusiness_income,nonbusiness_pay,other_incoming,participation_in_profit,payfor_platform_related_fee,pt_count,pt_ebay_postingfee,pt_incoming,pt_paypal_fee,pt_platformfee,pt_platform_ad_subscribe_fee,pt_platform_logistics_fee,pt_platform_storage_fee,pt_refund_amount,sale_fee_count,sale_manager_cost,sale_profit,sale_profit_rate) values
({m.actual_profit},{m.amount_sale},{m.balance_of_profit},{m.business_profit},{m.business_profit_rate},{m.cost_sale},'{m.createtime.ToString("yyyy-MM-dd HH:mm:ss")}',{m.direct_manager_cost},{m.finance_fee},{m.handlingcharges},'{m.lastupdatetime.ToString("yyyy-MM-dd HH:mm:ss")}',{m.lastupdateuserid},'{m.lastupdateusername}',{m.ls_count},{m.ls_head_cost},{m.ls_oversea_storage},{m.ls_platform_operation_fee},{m.ls_tail_cost},{m.manager_cost_count},{m.manager_cost_finish_wh},{m.manager_cost_gzbailun},{m.manager_cost_hkbailun},'{m.month}',{m.nonbusiness_income},{m.nonbusiness_pay},{m.other_incoming},{m.participation_in_profit},{m.payfor_platform_related_fee},{m.pt_count},{m.pt_ebay_postingfee},{m.pt_incoming},{m.pt_paypal_fee},{m.pt_platformfee},{m.pt_platform_ad_subscribe_fee},{m.pt_platform_logistics_fee},{m.pt_platform_storage_fee},{m.pt_refund_amount},{m.sale_fee_count},{m.sale_manager_cost},{m.sale_profit},{m.sale_profit_rate})";
......
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