Beispiel #1
0
        /// <summary>
        /// 查询转账明细列表
        /// </summary>
        /// <param name="familyID">家庭ID</param>
        /// <param name="req">条件</param>
        /// <returns></returns>
        public async Task <PageList <AmountAccountTransfer> > QueryTransferRecordAsync(int familyID, TransferRecordReq req)
        {
            using (IOSysContext db = new IOSysContext())
            {
                #region 条件

                //家庭ID
                var q = db.AmountAccountTransfers.AsNoTracking().Where(m => m.FamilyID == familyID);

                //开始日期
                if (req.StartDate.HasValue)
                {
                    q = q.Where(m => m.TransferDate >= req.StartDate.Value);
                }

                //截止日期
                if (req.EndDate.HasValue)
                {
                    q = q.Where(m => m.TransferDate <= req.EndDate.Value);
                }

                //源账户
                if (req.LstFromAmountAccountID != null && req.LstFromAmountAccountID.Count > 0)
                {
                    q = q.Where(m => req.LstFromAmountAccountID.Contains(m.FromAmountAccountID));
                }

                //目标账户
                if (req.LstToAmountAccountID != null && req.LstToAmountAccountID.Count > 0)
                {
                    q = q.Where(m => req.LstToAmountAccountID.Contains(m.ToAmountAccountID));
                }

                //备注(模糊匹配)
                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 <AmountAccountTransfer>(list, totalRecord));
            }
        }
Beispiel #2
0
        /// <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));
        }
Beispiel #3
0
        public async Task <ResultPageList <TransferRecordListInfo> > QueryTransferRecord([FromBody] TransferRecordReq req)
        {
            var list = await this.bll.QueryTransferRecordAsync(req);

            return(new ResultPageList <TransferRecordListInfo>(true, this.bll.Res.Gen.OK, list, (req.GetSkip() + 1), list.TotalRecord));
        }
Beispiel #4
0
        /// <summary>
        /// 查询转账明细列表
        /// </summary>
        /// <param name="req">条件</param>
        /// <returns></returns>
        public async Task <PageList <TransferRecordListInfo> > QueryTransferRecordAsync(TransferRecordReq req)
        {
            //查询
            var taskModel         = ReportDAL.Inst.QueryTransferRecordAsync(this.LoginInfo.FamilyID, req); //明细
            var taskAmountAccount = BasicDAL.Inst.QueryAmountAccountAsync(this.LoginInfo.FamilyID);        //账户

            var lstModel         = await taskModel;                                                        //明细
            var lstAmountAccount = await taskAmountAccount;                                                //账户

            var list = new List <TransferRecordListInfo>();
            var seq  = req.GetSkip() + 1;

            foreach (var model in lstModel)
            {
                var item = new TransferRecordListInfo();
                list.Add(item);

                //源账户
                var fromAmountAccount = lstAmountAccount.Find(m => m.ID == model.FromAmountAccountID);

                //目标账户
                var toAmountAccount = lstAmountAccount.Find(m => m.ID == model.ToAmountAccountID);

                item.Seq                   = seq++;
                item.ID                    = model.ID;
                item.TransferDate          = model.TransferDate;
                item.FromAmountAccountName = fromAmountAccount != null ? fromAmountAccount.Name : "";
                item.ToAmountAccountName   = toAmountAccount != null ? toAmountAccount.Name : "";
                item.Amount                = model.Amount;
                item.Remark                = model.Remark;
            }

            return(new PageList <TransferRecordListInfo>(list, lstModel.TotalRecord));
        }