From a90e20c1e2f61c8a6d51e3577a260c07c8aaf315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=81=B0=E7=81=B0?= Date: Wed, 3 Aug 2022 00:19:52 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=88=86=E9=94=80=E5=95=86=E5=88=97=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=B3=E8=AF=B7=E5=88=86=E9=94=80=E7=9A=84?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AD=89=E7=BA=A7=E5=B1=95=E7=A4=BA=E5=8F=8A?= =?UTF-8?q?=E7=AD=89=E7=BA=A7=E7=AD=9B=E9=80=89=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICoreCmsDistributionRepository.cs | 19 +++++ .../ICoreCmsDistributionServices.cs | 24 +++++- .../CoreCmsDistributionPartial.cs | 10 +++ .../CoreCmsDistributionRepository.cs | 81 +++++++++++++++++++ .../CoreCmsDistributionServices.cs | 28 ++++++- .../CoreCmsDistributionController.cs | 7 +- .../views/distribution/distributor/index.html | 25 +++++- 7 files changed, 187 insertions(+), 7 deletions(-) diff --git a/CoreCms.Net.IRepository/Distribution/ICoreCmsDistributionRepository.cs b/CoreCms.Net.IRepository/Distribution/ICoreCmsDistributionRepository.cs index e8d4df66..9142fabb 100644 --- a/CoreCms.Net.IRepository/Distribution/ICoreCmsDistributionRepository.cs +++ b/CoreCms.Net.IRepository/Distribution/ICoreCmsDistributionRepository.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.ViewModels.Basics; using CoreCms.Net.Model.ViewModels.DTO.Distribution; +using SqlSugar; namespace CoreCms.Net.IRepository @@ -34,5 +35,23 @@ namespace CoreCms.Net.IRepository /// Task> QueryRankingPageAsync(int pageIndex = 1, int pageSize = 20); + + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + new Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + + } } diff --git a/CoreCms.Net.IServices/Distribution/ICoreCmsDistributionServices.cs b/CoreCms.Net.IServices/Distribution/ICoreCmsDistributionServices.cs index dc291925..27f6869e 100644 --- a/CoreCms.Net.IServices/Distribution/ICoreCmsDistributionServices.cs +++ b/CoreCms.Net.IServices/Distribution/ICoreCmsDistributionServices.cs @@ -8,12 +8,15 @@ * Description: 暂无 ***********************************************************************/ +using System; using System.Collections.Generic; +using System.Linq.Expressions; using System.Threading.Tasks; using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.ViewModels.Basics; -using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Model.ViewModels.DTO.Distribution; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; namespace CoreCms.Net.IServices { @@ -85,5 +88,24 @@ namespace CoreCms.Net.IServices /// 分布大小 /// Task> QueryRankingPageAsync(int pageIndex = 1, int pageSize = 20); + + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + new Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + #endregion + } } \ No newline at end of file diff --git a/CoreCms.Net.Model/Entities/Distribution/CoreCmsDistributionPartial.cs b/CoreCms.Net.Model/Entities/Distribution/CoreCmsDistributionPartial.cs index 8e93101f..4d5c1a27 100644 --- a/CoreCms.Net.Model/Entities/Distribution/CoreCmsDistributionPartial.cs +++ b/CoreCms.Net.Model/Entities/Distribution/CoreCmsDistributionPartial.cs @@ -124,5 +124,15 @@ namespace CoreCms.Net.Model.Entities [Display(Name = "店铺查询交互数据")] [SugarColumn(IsIgnore = true)] public string Store { get; set; } = ""; + + + /// + /// 用户等级 + /// + [Display(Name = "用户等级")] + [SugarColumn(IsIgnore = true)] + public int UserGradeId { get; set; } = 0; + + } } \ No newline at end of file diff --git a/CoreCms.Net.Repository/Distribution/CoreCmsDistributionRepository.cs b/CoreCms.Net.Repository/Distribution/CoreCmsDistributionRepository.cs index 90596c48..ebcacdb8 100644 --- a/CoreCms.Net.Repository/Distribution/CoreCmsDistributionRepository.cs +++ b/CoreCms.Net.Repository/Distribution/CoreCmsDistributionRepository.cs @@ -117,6 +117,87 @@ namespace CoreCms.Net.Repository #endregion + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + public new async Task> QueryPageAsync(Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false) + { + RefAsync totalCount = 0; + List page; + if (blUseNoLock) + { + page = await DbClient.Queryable() + .Select(p => new CoreCmsDistribution + { + id = p.id, + userId = p.userId, + name = p.name, + gradeId = p.gradeId, + mobile = p.mobile, + weixin = p.weixin, + qq = p.qq, + storeName = p.storeName, + storeLogo = p.storeLogo, + storeBanner = p.storeBanner, + storeDesc = p.storeDesc, + verifyStatus = p.verifyStatus, + createTime = p.createTime, + updateTime = p.updateTime, + verifyTime = p.verifyTime, + isDelete = p.isDelete, + UserGradeId = SqlFunc.Subqueryable().Where(o => o.id == p.userId).Select(p => p.grade) + + }) + .MergeTable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate) + .With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount); + } + else + { + page = await DbClient.Queryable() + .Select(p => new CoreCmsDistribution + { + id = p.id, + userId = p.userId, + name = p.name, + gradeId = p.gradeId, + mobile = p.mobile, + weixin = p.weixin, + qq = p.qq, + storeName = p.storeName, + storeLogo = p.storeLogo, + storeBanner = p.storeBanner, + storeDesc = p.storeDesc, + verifyStatus = p.verifyStatus, + createTime = p.createTime, + updateTime = p.updateTime, + verifyTime = p.verifyTime, + isDelete = p.isDelete, + UserGradeId = SqlFunc.Subqueryable().Where(o => o.id == p.userId).Select(p => p.grade) + }) + .MergeTable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate) + .ToPageListAsync(pageIndex, pageSize, totalCount); + } + var list = new PageList(page, pageIndex, pageSize, totalCount); + return list; + } + + #endregion + + } } diff --git a/CoreCms.Net.Services/Distribution/CoreCmsDistributionServices.cs b/CoreCms.Net.Services/Distribution/CoreCmsDistributionServices.cs index 13fe02eb..6d11e0aa 100644 --- a/CoreCms.Net.Services/Distribution/CoreCmsDistributionServices.cs +++ b/CoreCms.Net.Services/Distribution/CoreCmsDistributionServices.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Threading.Tasks; using CoreCms.Net.Configuration; using CoreCms.Net.IRepository; @@ -19,12 +20,13 @@ using CoreCms.Net.IServices; using CoreCms.Net.Loging; using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.ViewModels.Basics; -using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Model.ViewModels.DTO; using CoreCms.Net.Model.ViewModels.DTO.Distribution; +using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Utility.Extensions; using CoreCms.Net.Utility.Helper; using Newtonsoft.Json.Linq; +using SqlSugar; namespace CoreCms.Net.Services @@ -93,6 +95,7 @@ namespace CoreCms.Net.Services //本月第一天时间 DateTime dtFirst = dt.AddDays(1 - (dt.Day)); dtFirst = new DateTime(dtFirst.Year, dtFirst.Month, dtFirst.Day, 0, 0, 0); + //获得某年某月的天数 int year = dt.Year; int month = dt.Month; @@ -510,7 +513,7 @@ namespace CoreCms.Net.Services var jm = new AdminUiCallBack(); var info = await _dal.QueryByClauseAsync(p => p.userId == userId); - if (info != null && info.gradeId > 0) + if (info is { gradeId: > 0 }) { //找下有没有可以升级的分销商等级 var grade = await _distributionGradeRepository.QueryByClauseAsync(p => p.id > info.gradeId && p.isAutoUpGrade == true); @@ -554,5 +557,26 @@ namespace CoreCms.Net.Services return await _dal.QueryRankingPageAsync(pageIndex, pageSize); } + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + public new async Task> QueryPageAsync(Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false) + { + return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock); + } + #endregion + + } } diff --git a/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs b/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs index a8ed71fd..c880f05e 100644 --- a/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs +++ b/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs @@ -117,6 +117,9 @@ namespace CoreCms.Net.Web.Admin.Controllers //分销等级 int var gradeId = Request.Form["gradeId"].FirstOrDefault().ObjectToInt(0); if (gradeId > 0) where = where.And(p => p.gradeId == gradeId); + //用户等级 int + var userGradeId = Request.Form["userGradeId"].FirstOrDefault().ObjectToInt(0); + if (userGradeId > 0) where = where.And(p => p.UserGradeId == userGradeId); //手机号 nvarchar var mobile = Request.Form["mobile"].FirstOrDefault(); if (!string.IsNullOrEmpty(mobile)) where = where.And(p => p.mobile.Contains(mobile)); @@ -232,10 +235,12 @@ namespace CoreCms.Net.Web.Admin.Controllers var jm = new AdminUiCallBack { code = 0 }; var distributionVerifyStatus = EnumHelper.EnumToList(); var grades = await _distributionGradeServices.GetCaChe(); + var userGrades = await _userGradeServices.QueryAsync(); jm.data = new { distributionVerifyStatus, - grades + grades, + userGrades }; return jm; diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/distribution/distributor/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/distribution/distributor/index.html index 787be468..4ec291d3 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/distribution/distributor/index.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/distribution/distributor/index.html @@ -68,6 +68,16 @@ +
+
+ +
+
@@ -135,9 +145,18 @@ //{ type: "checkbox", fixed: "left" }, { field: 'id', title: '序列', width: 60, sort: false }, { field: 'userId', title: '用户序列', sort: false, width: 65 }, + { + field: 'userGradeId', title: '用户等级', sort: false, width: 90, templet: function (data) { + for (var i = 0; i < d.data.grades.length; i++) { + if (d.data.userGrades[i].id == data.userGradeId) { + return d.data.userGrades[i].title; + } + } + } + }, { field: 'name', title: '分销商名称', sort: false, width: 105 }, { - field: 'gradeId', title: '分销等级', sort: false, width: 65, templet: function (data) { + field: 'gradeId', title: '分销等级', sort: false, width: 90, templet: function (data) { for (var i = 0; i < d.data.grades.length; i++) { if (d.data.grades[i].id == data.gradeId) { return d.data.grades[i].name; @@ -146,8 +165,8 @@ } }, //{ field: 'gradeId', title: '分销等级', sort: false, width: 105 }, - { field: 'mobile', title: '手机号', sort: false, width: 90 }, - { field: 'weixin', title: '微信号', sort: false, width: 90 }, + { field: 'mobile', title: '手机号', sort: false, width: 100 }, + { field: 'weixin', title: '微信号', sort: false, width: 100 }, { field: 'qq', title: 'qq号', sort: false, width: 90 }, { field: 'storeName', title: '店铺名称', sort: false }, {