diff --git a/CoreCms.Net.Services/Financial/CoreCmsReportsServices.cs b/CoreCms.Net.Services/Financial/CoreCmsReportsServices.cs index 8fe9728e..f100c0e6 100644 --- a/CoreCms.Net.Services/Financial/CoreCmsReportsServices.cs +++ b/CoreCms.Net.Services/Financial/CoreCmsReportsServices.cs @@ -19,6 +19,7 @@ using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.ViewModels.Basics; using CoreCms.Net.Model.ViewModels.Echarts; using CoreCms.Net.Model.ViewModels.UI; +using CoreCms.Net.Utility.Helper; using SqlSugar; @@ -73,22 +74,21 @@ namespace CoreCms.Net.Services else if (dbTypeString == DbType.MySql.ToString()) { sqlStr = @"select tmp_x.x,ifnull(sum(o.orderAmount),0) as val,count(o.orderId) as num - from - (SELECT @xi:=@xi+1 as x from - (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) x1, - (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) x2, - (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) x3, - (SELECT @xi:=-1) x0 limit 0," + num + @") tmp_x - left join ( - select * from CoreCmsOrder - where 1 = 1 - " + where + @" - ) o on tmp_x.x = ((cast(date(o." + joinVal + @") as signed) - " + sTime.ToString("yyyyMMdd") + @") div(" + section + @")) - group by tmp_x.x - "; + from + (SELECT @xi:=@xi+1 as x from + (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) x1, + (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) x2, + (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) x3, + (SELECT @xi:=-1) x0 limit 0," + num + @") tmp_x + left join ( + select * from CoreCmsOrder + where 1 = 1 + " + where + @" + ) o on tmp_x.x = ((unix_timestamp(o." + joinVal + @") - " + CommonHelper.ConvertDateTimeToInt(sTime) + @") div(" + section + @")) + group by tmp_x.x + "; } - - + Console.WriteLine(sqlStr); var sp = new List(); var list = _dal.SqlQuery(sqlStr, sp); @@ -141,7 +141,7 @@ namespace CoreCms.Net.Services select * from CoreCmsBillPayments where 1 = 1 " + where + @" - ) o on tmp_x.x = ((cast(date(o." + joinVal + @") as signed) - " + sTime.ToString("yyyy-MM-dd") + @") div(" + section + @")) + ) o on tmp_x.x = ((unix_timestamp(o." + joinVal + @") - " + CommonHelper.ConvertDateTimeToInt(sTime) + @") div(" + section + @")) group by tmp_x.x "; } @@ -201,7 +201,7 @@ namespace CoreCms.Net.Services select* from CoreCmsBillRefund where 1 = 1 " + where + @" - ) o on tmp_x.x = ((cast(date(o." + joinVal + @") as signed) - " + sTime.ToString("yyyy-MM-dd") + @") div(" + section + @")) + ) o on tmp_x.x = ((unix_timestamp(o." + joinVal + @") - " + CommonHelper.ConvertDateTimeToInt(sTime) + @") div(" + section + @")) group by tmp_x.x "; } @@ -258,7 +258,7 @@ namespace CoreCms.Net.Services select * from CoreCmsUserTocash where 1 = 1 " + where + @" - ) o on tmp_x.x = ((cast(date(o." + joinVal + @") as signed) - " + sTime.ToString("yyyy-MM-dd") + @") div(" + section + @")) + ) o on tmp_x.x = ((unix_timestamp(o." + joinVal + @") - " + CommonHelper.ConvertDateTimeToInt(sTime) + @") div(" + section + @")) group by tmp_x.x "; } diff --git a/CoreCms.Net.Utility/Helper/CommonHelper.cs b/CoreCms.Net.Utility/Helper/CommonHelper.cs index 370117c5..69386c3d 100644 --- a/CoreCms.Net.Utility/Helper/CommonHelper.cs +++ b/CoreCms.Net.Utility/Helper/CommonHelper.cs @@ -733,5 +733,19 @@ namespace CoreCms.Net.Utility.Helper // 如果上传文件大于限定的容量 return !(fileSize > size); } + + /// + /// 10位时间戳 转化 + /// + /// + /// + public static long ConvertDateTimeToInt(System.DateTime time) + { + System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0)); + long t = (time.Ticks - startTime.Ticks) / 10000000; //除10000000调整为10位 + return t; + } + + } } diff --git a/CoreCms.Net.Utility/Helper/ReportsHelper.cs b/CoreCms.Net.Utility/Helper/ReportsHelper.cs index c09338fe..0c5b5590 100644 --- a/CoreCms.Net.Utility/Helper/ReportsHelper.cs +++ b/CoreCms.Net.Utility/Helper/ReportsHelper.cs @@ -110,29 +110,29 @@ namespace CoreCms.Net.Utility.Helper case 3600: //小时 if (dateArr.num <= 24) { - xType = "H时"; + xType = "d日H时"; } else if (dateArr.num <= 720) { - xType = "d日H时"; + xType = "M月d日H时"; } else { - xType = "m月d日H时"; + xType = "M月d日H时"; } break; case 86400: //天 if (dateArr.num <= 31) { - xType = "d号"; + xType = "M月d号"; } else if (dateArr.num <= 365) { - xType = "m.d"; + xType = "yyyy年M月dd日"; } else { - xType = "Y.m.d"; + xType = "yyyy年M月dd日"; } break; } diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/content/reports/order.html b/CoreCms.Net.Web.Admin/wwwroot/views/content/reports/order.html index b74f4a87..34c824cc 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/content/reports/order.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/content/reports/order.html @@ -84,8 +84,8 @@ defaultToolbar: ['filter', 'print', 'exports'], //height: 'full-127', page: false, - limit: 30, - limits: [10, 15, 20, 25, 30, 50, 100, 200], + limit: 8760, + //limits: [10, 15, 20, 25, 30, 50, 100, 200], text: { none: '暂无相关数据' }, totalRow: true, cols: [ diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/content/reports/payments.html b/CoreCms.Net.Web.Admin/wwwroot/views/content/reports/payments.html index a5ce775b..73b23753 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/content/reports/payments.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/content/reports/payments.html @@ -85,8 +85,8 @@ //height: 'full-127', page: false, cellMinWidth: '80', - limit: 30, - limits: [10, 15, 20, 25, 30, 50, 100, 200], + limit: 8760, + //limits: [10, 15, 20, 25, 30, 50, 100, 200], text: { none: '暂无相关数据' }, totalRow: true, cols: [