Commit cb59d780 by zhouminghui

fix

parent e1a7d1d0
...@@ -1109,22 +1109,32 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' "; ...@@ -1109,22 +1109,32 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
/// <summary> /// <summary>
/// 拉取旧的dc_month_sales_profit表数据到新表,生成新的汇总数据 /// 拉取旧的dc_month_sales_profit表数据到新表,生成新的汇总数据
/// </summary> /// </summary>
public bool SyncMonthSalesProfit(DateTime? date) public bool SyncMonthSalesProfit(string date)
{ {
try try
{ {
//拉取旧表数据 //拉取旧表数据
var time = string.Empty; var time = string.Empty;
if (date.HasValue) if (!string.IsNullOrWhiteSpace(date))
{ {
time = date.Value.ToString("yyyy-MM"); time = Convert.ToDateTime(date).ToString("yyyy-MM");
} }
else else
{ {
time = DateTime.Now.AddMonths(-1).ToString("yyyy-MM"); time = DateTime.Now.AddMonths(-1).ToString("yyyy-MM");
} }
var falg = false;
Console.WriteLine($"{DateTime.Now}开始生成利润报表汇总数据");
var sql = $"select * from dc_month_sales_profit_v2 where isedit != 1 and month = '{time}'"; var sql = $"select * from dc_month_sales_profit_v2 where isedit != 1 and month = '{time}'";
var oldData = SimpleCRUD.Query<dc_month_sales_profit_v2>(sql, null, GlobalConfig.ConnectionString).FirstOrDefault() ?? new dc_month_sales_profit_v2(); var oldData = SimpleCRUD.Query<dc_month_sales_profit_v2>(sql, null, GlobalConfig.ConnectionString).FirstOrDefault();
if (oldData == null)
{
falg = true;
sql = $"select * from dc_month_sales_profit where isedit != 1 and month = '{time}'";
oldData = SimpleCRUD.Query<dc_month_sales_profit_v2>(sql, null, GlobalConfig.ConnectionString).FirstOrDefault();
}
if (oldData != null)
{
//对旧表数据进行赋值新数据 //对旧表数据进行赋值新数据
//var field = new MonthSalesProfitDto(); //var field = new MonthSalesProfitDto();
//var name = field.amount_sales_jingyou.GetType().GetCustomAttribute<System.ComponentModel.DisplayNameAttribute>().DisplayName; //var name = field.amount_sales_jingyou.GetType().GetCustomAttribute<System.ComponentModel.DisplayNameAttribute>().DisplayName;
...@@ -1140,7 +1150,7 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' "; ...@@ -1140,7 +1150,7 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
oldData.amount_sales = Math.Round(oldData.amount_sales_dianzi + oldData.amount_sales_fuzhuang + oldData.amount_sales_jiaju oldData.amount_sales = Math.Round(oldData.amount_sales_dianzi + oldData.amount_sales_fuzhuang + oldData.amount_sales_jiaju
+ oldData.amount_sales_jingyou + oldData.amount_sales_meirongmj + oldData.amount_sales_other + oldData.fee_refund, 2); + oldData.amount_sales_jingyou + oldData.amount_sales_meirongmj + oldData.amount_sales_other + oldData.fee_refund, 2);
//成本 //成本
oldData.cost_jingyou = Math.Abs(Math.Round(GetMonthSalesProfiOrderSummary(time, "精油产品","成本").Sum(x => x.total_amount_sales), 2)) * (-1); oldData.cost_jingyou = Math.Abs(Math.Round(GetMonthSalesProfiOrderSummary(time, "精油产品", "成本").Sum(x => x.total_amount_sales), 2)) * (-1);
oldData.cost_dianzi = Math.Abs(Math.Round(GetMonthSalesProfiOrderSummary(time, "电子产品", "成本").Sum(x => x.total_amount_sales), 2)) * (-1); oldData.cost_dianzi = Math.Abs(Math.Round(GetMonthSalesProfiOrderSummary(time, "电子产品", "成本").Sum(x => x.total_amount_sales), 2)) * (-1);
oldData.cost_jiaju = Math.Abs(Math.Round(GetMonthSalesProfiOrderSummary(time, "家居产品", "成本").Sum(x => x.total_amount_sales), 2)) * (-1); oldData.cost_jiaju = Math.Abs(Math.Round(GetMonthSalesProfiOrderSummary(time, "家居产品", "成本").Sum(x => x.total_amount_sales), 2)) * (-1);
oldData.cost_meirongmj = Math.Abs(Math.Round(GetMonthSalesProfiOrderSummary(time, "美容美甲产品", "成本").Sum(x => x.total_amount_sales), 2)) * (-1); oldData.cost_meirongmj = Math.Abs(Math.Round(GetMonthSalesProfiOrderSummary(time, "美容美甲产品", "成本").Sum(x => x.total_amount_sales), 2)) * (-1);
...@@ -1183,7 +1193,7 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' "; ...@@ -1183,7 +1193,7 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
.Where(m => m.AmountValRmb != null).Sum(x => x.AmountValRmb.Value), 2)) * (-1); .Where(m => m.AmountValRmb != null).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_nologistics_tail = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail( oldData.fee_nologistics_tail = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "尾程物流费-非平台" }) new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "尾程物流费-非平台" })
.Where(m=>m.AmountValRmb != null).Sum(x => x.AmountValRmb.Value), 2)) * (-1); .Where(m => m.AmountValRmb != null).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
oldData.fee_logistics_direct = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail( oldData.fee_logistics_direct = Math.Abs(Math.Round(ExportMonthProfitFeePlatformFeeDetail(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "直邮物流费-平台" }) new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "直邮物流费-平台" })
.Where(m => m.AmountValRmb != null).Sum(x => x.AmountValRmb.Value), 2)) * (-1); .Where(m => m.AmountValRmb != null).Sum(x => x.AmountValRmb.Value), 2)) * (-1);
...@@ -1270,17 +1280,31 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' "; ...@@ -1270,17 +1280,31 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
{ {
cn.Open(); cn.Open();
} }
if (falg)
{
oldData.createtime = DateTime.Now;
oldData.lastupdatetime = DateTime.Now;
cn.Insert(oldData);
Console.WriteLine($"{DateTime.Now}触发了新增操作");
}
else
{
if (oldData.id > 0) if (oldData.id > 0)
{ {
oldData.lastupdatetime = DateTime.Now; oldData.lastupdatetime = DateTime.Now;
cn.Update(oldData); cn.Update(oldData);
Console.WriteLine($"{DateTime.Now}触发了更新操作");
} }
else else
{ {
oldData.createtime = DateTime.Now; oldData.createtime = DateTime.Now;
oldData.lastupdatetime = DateTime.Now; oldData.lastupdatetime = DateTime.Now;
cn.Insert(oldData); cn.Insert(oldData);
Console.WriteLine($"{DateTime.Now}触发了新增操作");
}
}
} }
Console.WriteLine($"{DateTime.Now}开始生成利润报表汇总数据");
} }
return true; return true;
} }
......
...@@ -547,7 +547,7 @@ namespace Bailun.DC.WebApi.Controllers ...@@ -547,7 +547,7 @@ namespace Bailun.DC.WebApi.Controllers
/// <param name="time"></param> /// <param name="time"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("syncMonthSalesProfit")] [HttpGet("syncMonthSalesProfit")]
public bool SyncMonthSalesProfit(DateTime? time) public bool SyncMonthSalesProfit(string time)
{ {
return new FinanceService().SyncMonthSalesProfit(time); return new FinanceService().SyncMonthSalesProfit(time);
//var sql = "select * from dc_month_sales_profit_orderdetail limit 1"; //var sql = "select * from dc_month_sales_profit_orderdetail limit 1";
......
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