/// <summary> /// 查询借还明细列表 /// </summary> /// <param name="familyID">家庭ID</param> /// <param name="req">条件</param> /// <returns></returns> public async Task <PageList <BorrowRepay> > QueryBorrowRepayRecordAsync(int familyID, BorrowRepayRecordReq req) { using (IOSysContext db = new IOSysContext()) { #region 条件 //家庭ID var q = db.BorrowRepays.AsNoTracking().Where(m => m.FamilyID == familyID); //开始日期 if (req.StartDate.HasValue) { q = q.Where(m => m.BRDate >= req.StartDate.Value); } //截止日期 if (req.EndDate.HasValue) { q = q.Where(m => m.BRDate <= req.EndDate.Value); } //类型 if (req.LstBRType != null && req.LstBRType.Count > 0) { q = q.Where(m => req.LstBRType.Contains(m.BRType)); } //账户 if (req.LstAmountAccountID != null && req.LstAmountAccountID.Count > 0) { q = q.Where(m => req.LstAmountAccountID.Contains(m.AmountAccountID)); } //对方(模糊匹配) if (string.IsNullOrWhiteSpace(req.Target) == false) { q = q.Where(m => m.Target.Contains(req.Target)); } //备注(模糊匹配) if (string.IsNullOrWhiteSpace(req.Remark) == false) { q = q.Where(m => m.Remark.Contains(req.Remark)); } #endregion var totalRecord = 0; //总条数 //是否需要分页 if (req.IsSetPage()) { totalRecord = await q.CountAsync(); } //设置排序和分页 this.SetSortPage(ref q, req); //查询列表 var list = await q.ToListAsync(); //是否需要分页 if (req.IsSetPage() == false) { totalRecord = list.Count; } return(new PageList <BorrowRepay>(list, totalRecord)); } }
/// <summary> /// 查询账户流水 /// </summary> /// <param name="req"></param> /// <returns></returns> public async Task <PageMonthAmountList <AccountTurnoverListInfo> > QueryAccountTurnoverAsync(AccountTurnoverListReq req) { //开始日期 DateTime startDate = new DateTime(req.Month.Year, req.Month.Month, 1); //结束日期 DateTime endDate = startDate.AddMonths(1).AddMilliseconds(-1); #region 查询 //查询收入明细 var reqIn = new InRecordReq() { StartDate = startDate, EndDate = endDate, LstAmountAccountID = req.LstAmountAccountID }; var taskIn = this.QueryInRecordAsync(reqIn); //查询支出明细 var reqOut = new OutRecordReq() { StartDate = startDate, EndDate = endDate, LstAmountAccountID = req.LstAmountAccountID }; var taskOut = this.QueryOutRecordAsync(reqOut); //查询转账转出明细 var reqTransferFrom = new TransferRecordReq() { StartDate = startDate, EndDate = endDate, LstFromAmountAccountID = req.LstAmountAccountID }; var taskTransferFrom = this.QueryTransferRecordAsync(reqTransferFrom); //查询转账转入明细 var reqTransferTo = new TransferRecordReq() { StartDate = startDate, EndDate = endDate, LstToAmountAccountID = req.LstAmountAccountID }; var taskTransferTo = this.QueryTransferRecordAsync(reqTransferTo); //查询借还明细 var reqBR = new BorrowRepayRecordReq() { StartDate = startDate, EndDate = endDate, LstAmountAccountID = req.LstAmountAccountID }; var taskBR = this.QueryBorrowRepayRecordAsync(reqBR); #endregion #region 结果类型转换 //返回结果 var list = new List <AccountTurnoverListInfo>(); //收入 var lstIn = await taskIn; foreach (var record in lstIn) { var item = new AccountTurnoverListInfo(); list.Add(item); item.DataType = EnmDataType.In; item.ID = record.ID; item.Date = record.InDate; item.AmountAccountName = record.AmountAccountName; item.TypeName = record.InTypeName; item.Amount = record.Amount; } //支出 var lstOut = await taskOut; foreach (var record in lstOut) { var item = new AccountTurnoverListInfo(); list.Add(item); item.DataType = EnmDataType.Out; item.ID = record.ID; item.Date = record.OutDate; item.AmountAccountName = record.AmountAccountName; item.TypeName = record.OutTypeName; item.Amount = -record.Amount; } //转账转出 var lstTransferFrom = await taskTransferFrom; foreach (var record in lstTransferFrom) { var item = new AccountTurnoverListInfo(); list.Add(item); item.DataType = EnmDataType.Transfer; item.ID = record.ID; item.Date = record.TransferDate; item.AmountAccountName = record.FromAmountAccountName; item.TypeName = this.Res.Cst.TranDir.TransferOut; item.Amount = -record.Amount; } //转账转入 var lstTransferTo = await taskTransferTo; foreach (var record in lstTransferTo) { var item = new AccountTurnoverListInfo(); list.Add(item); item.DataType = EnmDataType.Transfer; item.ID = record.ID; item.Date = record.TransferDate; item.AmountAccountName = record.ToAmountAccountName; item.TypeName = this.Res.Cst.TranDir.TransferIn; item.Amount = record.Amount; } //借还 var lstBR = await taskBR; foreach (var record in lstBR) { var item = new AccountTurnoverListInfo(); list.Add(item); item.DataType = EnmDataType.BorrowRepay; item.ID = record.ID; item.Date = record.BRDate; item.AmountAccountName = record.AmountAccountName; switch ((EnmBorrowRepayType)record.BRType) { case EnmBorrowRepayType.BorrowIn: item.TypeName = this.Res.Cst.BRT.BorrowIn; item.Amount = record.Amount; break; case EnmBorrowRepayType.RepayIn: item.TypeName = this.Res.Cst.BRT.RepayIn; item.Amount = record.Amount; break; case EnmBorrowRepayType.BorrowOut: item.TypeName = this.Res.Cst.BRT.BorrowOut; item.Amount = -record.Amount; break; case EnmBorrowRepayType.RepayOut: item.TypeName = this.Res.Cst.BRT.RepayOut; item.Amount = -record.Amount; break; } } //总金额 var totalAmount = list.Sum(m => m.Amount); #endregion //排序 list = list.OrderByDescending(m => m.Date).ThenByDescending(m => m.ID).ThenBy(m => m.Amount).ToList(); //是否还有前一个月的数据 var hasPreMonth = startDate > (await InOutDAL.Inst.GetMinTurnoverDate(this.LoginInfo.FamilyID)); return(new PageMonthAmountList <AccountTurnoverListInfo>(list, req.Month, totalAmount, hasPreMonth)); }
public async Task <ResultPageList <BorrowRepayRecordListInfo> > QueryBorrowRepayRecordAsync([FromBody] BorrowRepayRecordReq req) { var list = await this.bll.QueryBorrowRepayRecordAsync(req); return(new ResultPageList <BorrowRepayRecordListInfo>(true, this.bll.Res.Gen.OK, list, (req.GetSkip() + 1), list.TotalRecord)); }
/// <summary> /// 查询借还明细列表 /// </summary> /// <param name="req">条件</param> /// <returns></returns> public async Task <PageList <BorrowRepayRecordListInfo> > QueryBorrowRepayRecordAsync(BorrowRepayRecordReq req) { //查询 var taskModel = ReportDAL.Inst.QueryBorrowRepayRecordAsync(this.LoginInfo.FamilyID, req); //明细 var taskAmountAccount = BasicDAL.Inst.QueryAmountAccountAsync(this.LoginInfo.FamilyID); //账户 var lstModel = await taskModel; //明细 var lstAmountAccount = await taskAmountAccount; //账户 var list = new List <BorrowRepayRecordListInfo>(); var seq = req.GetSkip() + 1; foreach (var model in lstModel) { var item = new BorrowRepayRecordListInfo(); list.Add(item); //账户 var amountAccount = lstAmountAccount.Find(m => m.ID == model.AmountAccountID); item.Seq = seq++; item.ID = model.ID; item.BRDate = model.BRDate; item.Target = model.Target; item.BRType = model.BRType; item.BRTypeName = this.GetBorrowRepayTypeName(model.BRType); item.AmountAccountName = amountAccount != null ? amountAccount.Name : ""; item.Amount = model.Amount; item.Remark = model.Remark; } return(new PageList <BorrowRepayRecordListInfo>(list, lstModel.TotalRecord)); }