/*********************************************************************** * Project: baifenBinfa * ProjectName: 百分兵法管理系统 * Web: http://chuanyin.com * Author: * Email: * CreateTime: 202403/02 * Description: 暂无 ***********************************************************************/ 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; using CoreCms.Net.IRepository.UnitOfWork; using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.ViewModels.Basics; using CoreCms.Net.Model.ViewModels.UI; using SqlSugar; namespace CoreCms.Net.Repository { /// /// 支付单表 接口实现 /// public class CoreCmsBillPaymentsRepository : BaseRepository, ICoreCmsBillPaymentsRepository { public CoreCmsBillPaymentsRepository(IUnitOfWork unitOfWork) : base(unitOfWork) { } /// /// 支付单7天统计 /// /// public async Task> Statistics() { var dt = DateTime.Now.AddDays(-8); var types = new int[] { (int)GlobalEnumVars.BillPaymentsType.Common, (int)GlobalEnumVars.BillPaymentsType.PinTuan, (int)GlobalEnumVars.BillPaymentsType.Group, (int)GlobalEnumVars.BillPaymentsType.Seckill, (int)GlobalEnumVars.BillPaymentsType.Bargain, (int)GlobalEnumVars.BillPaymentsType.Giveaway, (int)GlobalEnumVars.BillPaymentsType.Solitaire }; var list = await DbClient.Queryable() .Where(p => p.createTime >= dt && p.status == (int)GlobalEnumVars.BillPaymentsStatus.Payed && types.Contains(p.type)) .Select(it => new { it.paymentId, createTime = it.createTime.Date }) .MergeTable() .GroupBy(it => it.createTime) .Select(it => new StatisticsOut { day = it.createTime.ToString("yyyy-MM-dd"), nums = SqlFunc.AggregateCount(it.paymentId) }) .ToListAsync(); return list; } #region 重写根据条件查询分页数据 /// /// 重写根据条件查询分页数据 /// /// 判断集合 /// 排序方式 /// 当前页面索引 /// 分布大小 /// /// 是否使用WITH(NOLOCK) /// public 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((p, sc) => new JoinQueryInfos( JoinType.Left, p.userId == sc.id)) .Select((p, sc) => new CoreCmsBillPayments { paymentId = p.paymentId, money = p.money, userId = p.userId, type = p.type, status = p.status, paymentCode = p.paymentCode, ip = p.ip, parameters = p.parameters, payedMsg = p.payedMsg, tradeNo = p.tradeNo, createTime = p.createTime, updateTime = p.updateTime, userNickName = sc.nickName }) .With(SqlWith.NoLock) .MergeTable() .OrderByIF(orderByExpression != null, orderByExpression, orderByType) .WhereIF(predicate != null, predicate) .ToPageListAsync(pageIndex, pageSize, totalCount); else page = await DbClient.Queryable((p, sc) => new JoinQueryInfos( JoinType.Left, p.userId == sc.id)) .Select((p, sc) => new CoreCmsBillPayments { paymentId = p.paymentId, money = p.money, userId = p.userId, type = p.type, status = p.status, paymentCode = p.paymentCode, ip = p.ip, parameters = p.parameters, payedMsg = p.payedMsg, tradeNo = p.tradeNo, createTime = p.createTime, updateTime = p.updateTime, userNickName = sc.nickName }) .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 } }