From cc170291673472d3cda8d7ea77f6bd3a3b5dbb83 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期一, 09 九月 2024 14:06:09 +0800 Subject: [PATCH] 增加了一些统计修改 --- CoreCms.Net.Repository/Order/CoreCmsPlanOrderRepository.cs | 22 ++++++++++ CoreCms.Net.IServices/Order/ICoreCmsPlanOrderServices.cs | 2 CoreCms.Net.IRepository/Order/ICoreCmsPlanOrderRepository.cs | 2 CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs | 9 ++++ CoreCms.Net.Services/Order/CoreCmsPlanOrderServices.cs | 4 +- CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrder.cs | 26 +++++++++++++ CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/index.html | 28 ++++++++++--- 7 files changed, 80 insertions(+), 13 deletions(-) diff --git a/CoreCms.Net.IRepository/Order/ICoreCmsPlanOrderRepository.cs b/CoreCms.Net.IRepository/Order/ICoreCmsPlanOrderRepository.cs index dc4d17c..52c6bf8 100644 --- a/CoreCms.Net.IRepository/Order/ICoreCmsPlanOrderRepository.cs +++ b/CoreCms.Net.IRepository/Order/ICoreCmsPlanOrderRepository.cs @@ -92,7 +92,7 @@ /// <returns></returns> Task<IPageList<CoreCmsPlanOrder>> QueryPageAsync( Expression<Func<CoreCmsPlanOrder, bool>> predicate, - Expression<Func<CoreCmsPlanOrder, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1, + Expression<Func<CoreCmsPlanOrder, object>> orderByExpression, OrderByType orderByType, OtherData otherData, int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false); } diff --git a/CoreCms.Net.IServices/Order/ICoreCmsPlanOrderServices.cs b/CoreCms.Net.IServices/Order/ICoreCmsPlanOrderServices.cs index 34866a5..6272094 100644 --- a/CoreCms.Net.IServices/Order/ICoreCmsPlanOrderServices.cs +++ b/CoreCms.Net.IServices/Order/ICoreCmsPlanOrderServices.cs @@ -90,7 +90,7 @@ /// <returns></returns> Task<IPageList<CoreCmsPlanOrder>> QueryPageAsync( Expression<Func<CoreCmsPlanOrder, bool>> predicate, - Expression<Func<CoreCmsPlanOrder, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1, + Expression<Func<CoreCmsPlanOrder, object>> orderByExpression, OrderByType orderByType, OtherData otherData, int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false); #endregion diff --git a/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrder.cs b/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrder.cs index c5408e0..24e318b 100644 --- a/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrder.cs +++ b/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrder.cs @@ -225,5 +225,31 @@ public System.Decimal huaFeiAmount { get; set; } + + + /// <summary> + /// 璋冩暣璁㈠崟閲戦 + /// </summary> + [SugarColumn(IsIgnore = true)] + + + + public System.Decimal orderAmounts { get; set; } + /// <summary> + /// 璁″垝璁㈠崟閲戦 + /// </summary> + [SugarColumn(IsIgnore = true)] + + + + public System.Decimal oldOrderAmounts { get; set; } + /// <summary> + /// 鍙敤浣欓 + /// </summary> + [SugarColumn(IsIgnore = true)] + + + + public System.Decimal keYongAmounts { get; set; } } } diff --git a/CoreCms.Net.Repository/Order/CoreCmsPlanOrderRepository.cs b/CoreCms.Net.Repository/Order/CoreCmsPlanOrderRepository.cs index 8d4409b..74afbef 100644 --- a/CoreCms.Net.Repository/Order/CoreCmsPlanOrderRepository.cs +++ b/CoreCms.Net.Repository/Order/CoreCmsPlanOrderRepository.cs @@ -21,6 +21,7 @@ using CoreCms.Net.Model.ViewModels.UI; using SqlSugar; using CoreCms.Net.Model.Entities.Order; +using CoreCms.Net.Model.Entities.baifenbingfa.puhuo; namespace CoreCms.Net.Repository { @@ -170,7 +171,7 @@ /// <param name="blUseNoLock">鏄惁浣跨敤WITH(NOLOCK)</param> /// <returns></returns> public async Task<IPageList<CoreCmsPlanOrder>> QueryPageAsync(Expression<Func<CoreCmsPlanOrder, bool>> predicate, - Expression<Func<CoreCmsPlanOrder, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1, + Expression<Func<CoreCmsPlanOrder, object>> orderByExpression, OrderByType orderByType, OtherData otherData, int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false) { RefAsync<int> totalCount = 0; @@ -232,9 +233,28 @@ quxianId = p.quxianId, pianqu = p.pianqu, shouhuoAddress = p.shouhuoAddress, + }).ToPageListAsync(pageIndex, pageSize, totalCount); } + + + + var pagetotal = DbClient.Queryable<CoreCmsPlanOrder>() + // .GroupBy(it => new { it.CategoryId, it.CategoryName, it.goodsId, it.goodsName, it.productsId, it.productsName, it.price }) + .WhereIF(predicate != null, predicate) + .Select(p => new CoreCmsPlanOrder + { + oldOrderAmounts = SqlFunc.AggregateSum(p.oldOrderAmount), + orderAmounts = SqlFunc.AggregateSum(p.orderAmount), + keYongAmounts = SqlFunc.AggregateSum(p.keYongAmount), + }) + .First(); // 鎴栬�呬娇鐢� Single/FirstOrDefault 绛夋柟娉曡幏鍙栫粨鏋� + + otherData.heji4 = pagetotal.oldOrderAmounts; + otherData.heji5 = pagetotal.orderAmounts; + otherData.heji6 = pagetotal.keYongAmounts; + var list = new PageList<CoreCmsPlanOrder>(page, pageIndex, pageSize, totalCount); return list; } diff --git a/CoreCms.Net.Services/Order/CoreCmsPlanOrderServices.cs b/CoreCms.Net.Services/Order/CoreCmsPlanOrderServices.cs index 23c778f..08ba982 100644 --- a/CoreCms.Net.Services/Order/CoreCmsPlanOrderServices.cs +++ b/CoreCms.Net.Services/Order/CoreCmsPlanOrderServices.cs @@ -275,10 +275,10 @@ /// <param name="blUseNoLock">鏄惁浣跨敤WITH(NOLOCK)</param> /// <returns></returns> public async Task<IPageList<CoreCmsPlanOrder>> QueryPageAsync(Expression<Func<CoreCmsPlanOrder, bool>> predicate, - Expression<Func<CoreCmsPlanOrder, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1, + Expression<Func<CoreCmsPlanOrder, object>> orderByExpression, OrderByType orderByType, OtherData otherData , int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false) { - return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock); + return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, otherData, pageIndex, pageSize, blUseNoLock); } #endregion diff --git a/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs b/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs index ba42d3f..5a59362 100644 --- a/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs +++ b/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs @@ -260,8 +260,9 @@ { where = where.And(p => p.isdelete == false); } + OtherData otherData = new OtherData(); //鑾峰彇鏁版嵁 - var list = await _CoreCmsPlanOrderServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true); + var list = await _CoreCmsPlanOrderServices.QueryPageAsync(where, orderEx, orderBy, otherData, pageCurrent, pageSize, true); if (list != null && list.Count > 0) { @@ -278,6 +279,12 @@ jm.code = 0; jm.count = list.TotalCount; jm.msg = "鏁版嵁璋冪敤鎴愬姛!"; + + otherData.heji1 = list.Sum(x => x.oldOrderAmount); + otherData.heji2 = list.Sum(x => x.orderAmount); + otherData.heji3 = list.Sum(x => x.keYongAmount); + jm.otherData = otherData; + return jm; } #endregion diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/index.html index 246cb07..07900f9 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/index.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/index.html @@ -306,28 +306,42 @@ text: {none: '鏆傛棤鐩稿叧鏁版嵁'}, cols: [ [ - { type: "checkbox", fixed: "left" }, + { type: "checkbox" }, + { field: 'zizeng', width: 50, title: '搴忓彿', type: 'numbers' }, { field: 'orderId', title: '璁㈠崟鍙�', sort: false,width: 135 }, { field: 'shi', title: '甯�', sort: false, width: 50 }, { field: 'quxian', title: '鍖哄幙', sort: false, width: 50 }, - { field: 'pianqu', title: '鐗囧尯', sort: false, width: 115 }, + { field: 'pianqu', title: '鐗囧尯', sort: false, width: 65 }, /* { field: 'userId', title: '鐢ㄦ埛ID 鍏宠仈user.id', sort: false,width: 105 },*/ { field: 'shipAddress', title: '瀛︽牎', sort: false, width: 135 }, { field: 'shipName', title: '鑱旂郴浜�', sort: false,width: 55 }, { field: 'shipMobile', title: '鑱旂郴鐢佃瘽', sort: false, width: 115 }, - { field: 'shouhuoAddress', title: '鏀惰揣鍦板潃', sort: false, width: 265 }, + { field: 'shouhuoAddress', title: '鏀惰揣鍦板潃', sort: false, width: 165 }, { field: 'oldOrderAmount', title: '璁″垝閲戦', sort: false, width: 75 }, { field: 'orderAmount', title: '璋冩暣閲戦', sort: false, width: 75 }, - { field: 'keYongAmount', title: '鍙敤浣欓', sort: false, width: 75 }, + { field: 'keYongAmount', title: '鍙敤浣欓', sort: false, width: 65 }, { field: 'createTime', title: '寤虹珛鏃堕棿', width: 95, sort: false}, { field: 'upDataTime', title: '淇敼鏃堕棿', width: 95, sort: false}, //{ field: 'createBy', title: '鍒涘缓浜�', sort: false,width: 105 }, //{ field: 'upDataBy', title: '淇敼浜�', sort: false,width: 105 }, //{ field: 'isdelete', title: '鍒犻櫎鏍囧織', width: 95, templet: '#switch_isdelete', sort: false , unresize: true}, - { field: 'statusText', title: '璁㈠崟鐘舵��', sort: false, width: 65 }, - { width: 222, align: 'center', title:'鎿嶄綔', fixed: 'right', toolbar: '#LAY-app-CoreCmsPlanOrder-tableBox-bar' } + { field: 'statusText', title: '璁㈠崟鐘舵��', sort: false, width: 55 }, + { width: 222, align: 'center', title:'鎿嶄綔', toolbar: '#LAY-app-CoreCmsPlanOrder-tableBox-bar' } ] - ] + ], done: function (res, curr, count) { + + console.log(res); + // 鍒涘缓鍚堣琛岀殑HTML + var totalRowHtml = '<tr class="layui-table-total" style="background-color: #f2f2f2; font-weight: bold;">\ + <td></td><td></td><td colspan="8">褰撻〉鍚堣</td><td> '+ res.otherData.heji1 + '</td><td> ' + res.otherData.heji2 + '</td><td> ' + res.otherData.heji3 + '</td><td></td><td></td><td></td><td></td>\ + </tr>\ + <tr class="layui-table-total" style="background-color: #e9e9e9; font-weight: bold;">\ + <td></td><td></td><td colspan="8">鎬诲悎璁�</td><td> '+ res.otherData.heji4 + '</td><td> ' + res.otherData.heji5 + '</td><td> ' + res.otherData.heji6 + '</td><td></td><td></td><td></td><td></td>\ + </tr>'; + + // 灏嗗悎璁¤娣诲姞鍒拌〃鏍煎簳閮� + $('#LAY-app-CoreCmsPlanOrder-tableBox').next().find('.layui-table-body tbody').append(totalRowHtml); + } }); //鐩戝惉鎺掑簭浜嬩欢 table.on('sort(LAY-app-CoreCmsPlanOrder-tableBox)', function(obj){ -- Gitblit v1.9.1