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 }, {