Commit 5a54f711 by zhouminghui

fix

parent 999b2f6b
......@@ -968,16 +968,24 @@ ON s2.id = s1.order_fee_config_id WHERE s1.month = @month ");
}
public decimal SyncMonthProfitFeePlatformFeeSummary(GetMonthProfitPlatformDetailInput input)
{
var parameters = new DynamicParameters();
var sql = $@"SELECT SUM(s1.amountval_rmb)
var parameters = new DynamicParameters();
var sql = $@"SELECT s2.platform as platform,s1.website as site,SUM(s1.amountval_rmb) as total
from order_fee_value_amazon s1
JOIN order_fee_config s2
ON s2.id = s1.order_fee_config_id
WHERE s1.amountval != 0 AND s1.month = @month
AND s2.datacenter_col like '%{input.FeeName}' ";
AND s2.datacenter_col like '%{input.FeeName}' group by s2.platform,s1.website ";
parameters.Add("month", input.Month);
var data = SimpleCRUD.Query<decimal>(sql, parameters, GlobalConfig.ConnectionString_DW).FirstOrDefault();
return data;
var data = SimpleCRUD.Query<(string platform, string site, decimal total)>(sql, parameters, GlobalConfig.ConnectionString_DW).ToList();
data = data.Select(x =>
{
if (x.platform.Contains("万邑通"))
{
x.total = Math.Abs(x.total);
}
return x;
}).ToList();
return data.Sum(x => x.total);
}
/// <summary>
/// 退款分页明细
......@@ -1210,66 +1218,101 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
+ oldData.cost_meirongmj + oldData.cost_fuzhuang + oldData.cost_other, 2);
//平台费用
oldData.fee_ad = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "广告及宣传费" }), 2)) * (-1);
Console.WriteLine("开始统计平台费用");
oldData.fee_fba = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-亚马逊FBA" }), 2)) * (-1);
oldData.fee_nofba = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-亚马逊非FBA" }), 2)) * (-1);
oldData.fee_ebay = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-Ebay" }), 2)) * (-1);
oldData.fee_ohtre = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-其他平台" }), 2)) * (-1);
//oldData.fee_ad = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "广告及宣传费" }), 2)) * (-1);
Console.WriteLine("开始统计平台费用");
oldData.fee_ad = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "广告及宣传费" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_fba = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-亚马逊FBA" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_nofba = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-亚马逊非FBA" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_ebay = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-Ebay" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_ohtre = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-其他平台" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//Console.WriteLine("开始统计平台费用");
//oldData.fee_ad = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "广告及宣传费" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_fba = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-亚马逊FBA" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_nofba = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-亚马逊非FBA" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_ebay = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-Ebay" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_ohtre = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-其他平台" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//总平台费
oldData.fee_platform = Math.Round(oldData.fee_ad + oldData.fee_fba + oldData.fee_nofba + oldData.fee_ebay + oldData.fee_ohtre, 2);
//物流仓储费用
Console.WriteLine("开始统计物流仓储费用");
oldData.fee_logistics_first = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "头程运输-平台" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_nologistics_first = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "头程运输-非平台" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_logistics_tail = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "尾程物流费-平台" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_nologistics_tail = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "尾程物流费-非平台" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_logistics_direct = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "直邮物流费-平台" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_nologistics_direct = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "直邮物流费-非平台" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_storage = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "仓储费-平台" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_nostorage = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "仓储费-非平台" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_logistics_first = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "头程运输-平台" }), 2)) * (-1);
oldData.fee_nologistics_first = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "头程运输-非平台" }), 2)) * (-1);
oldData.fee_logistics_tail = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "尾程物流费-平台" }), 2)) * (-1);
oldData.fee_nologistics_tail = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "尾程物流费-非平台" }), 2)) * (-1);
oldData.fee_logistics_direct = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "直邮物流费-平台" }), 2)) * (-1);
oldData.fee_nologistics_direct = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "直邮物流费-非平台" }), 2)) * (-1);
oldData.fee_storage = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "仓储费-平台" }), 2)) * (-1);
oldData.fee_nostorage = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "仓储费-非平台" }), 2)) * (-1);
//oldData.fee_logistics_first = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "头程运输-平台" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_nologistics_first = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "头程运输-非平台" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_logistics_tail = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "尾程物流费-平台" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_nologistics_tail = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "尾程物流费-非平台" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_logistics_direct = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "直邮物流费-平台" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_nologistics_direct = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "直邮物流费-非平台" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_storage = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "仓储费-平台" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//oldData.fee_nostorage = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "仓储费-非平台" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//总物流仓储费
oldData.fee_logistics_storage = Math.Round(oldData.fee_logistics_first + oldData.fee_nologistics_first + oldData.fee_logistics_tail + oldData.fee_nologistics_tail
+ oldData.fee_logistics_direct + oldData.fee_nologistics_direct + oldData.fee_storage + oldData.fee_nostorage, 2);
Console.WriteLine("开始统计加:营业外收入");
//加:营业外收入
oldData.incoming_non_operating = Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "营业外收入" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2);
oldData.incoming_non_operating = Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "营业外收入" }), 2);
//oldData.incoming_non_operating = Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "营业外收入" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2);
//减:营业外支出
oldData.pay_non_operating = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "营业外支出" })
.Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.pay_non_operating = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "营业外支出" }), 2)) * (-1);
//oldData.pay_non_operating = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "营业外支出" })
// .Where(m => m.AmountValRmb.HasValue).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
//销售费用-税金
//oldData.fee_sales_taxes = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
......@@ -1315,7 +1358,7 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
Console.WriteLine("开始统计销售费用数据");
//销售费用合计》平台费用+物流仓储费+税金
oldData.fee_sales_count = Math.Round(Math.Abs(oldData.fee_platform) + Math.Abs(oldData.fee_logistics_storage) + Math.Abs(oldData.fee_sales_taxes), 2);
oldData.fee_sales_count = Math.Abs(Math.Round(Math.Abs(oldData.fee_platform) + Math.Abs(oldData.fee_logistics_storage) + Math.Abs(oldData.fee_sales_taxes), 2)) * (-1);
//销售利润》总销售额-总成本-销售费用合计
oldData.profit_sales = Math.Round(Math.Abs(oldData.amount_sales) - Math.Abs(oldData.cost) - Math.Abs(oldData.fee_sales_count), 2);
//销售毛利润》销售利润/总销售额
......@@ -1329,7 +1372,7 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
//净利润》实际利润/总销售额
oldData.rate_profit_actual = Math.Round(oldData.actual_profit / Math.Abs(oldData.amount_sales), 2);
//财务费用
oldData.fee_finance = Math.Abs(oldData.fee_finance * (-1));
oldData.fee_finance = Math.Abs(oldData.fee_finance) * (-1);
//保存
Console.WriteLine("统计完成");
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
......
......@@ -29,7 +29,7 @@ namespace Bailun.DC.SyncMonthSalesProfitNew
try
{
var now = DateTime.Now;
if (now.Hour == 14)
if (now.Hour == 1)
{
Console.WriteLine("同步月利润销售报告开始启动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var result = Init();
......
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