Exemplo n.º 1
0
        public async Task <JsonResult> UpdateList([FromBody] FDAParams fdaParams)
        {
            if (fdaParams.Ids.Count > 0)
            {
                _context.BrhExpendRecord.Where(x => fdaParams.Ids.Contains(x.ExpendRecordId) && !x.IsFinance).ToList().ForEach(x =>
                {
                    x.IsFinance = true;
                    _context.Update(x);
                });
                await _context.SaveChangesAsync();
            }

            var expendList = await _context.BrhExpendRecord.Where(x => x.Branch == fdaParams.BranchName && DateTime.Compare(fdaParams.StartDate, x.EnteringDate) <= 0 && DateTime.Compare(x.EnteringDate, fdaParams.EndDate) < 0).ToListAsync();

            var pie1List = expendList.GroupBy(x => new { x.ExpendType }).Select(x => new
            {
                ExpendType = x.Key.ExpendType,
                Total      = x.Sum(s => s.Amount),
            }).ToList();

            var days = (fdaParams.EndDate - fdaParams.StartDate).Days;
            List <FncMonthData> dailyList = new List <FncMonthData>();

            for (var i = 0; i < days; i++)
            {
                var daily = new FncMonthData();
                daily.Month       = fdaParams.StartDate.AddDays(i).Date;
                daily.HouseAmount = expendList.Where(x => DateTime.Compare(x.EnteringDate.Date, daily.Month) == 0).Select(x => x.Amount).Sum();
                dailyList.Add(daily);
            }
            return(Json(new { expendList, pie1List, dailyList }));
        }
Exemplo n.º 2
0
        public async Task <JsonResult> GetFrontList([FromBody] FDAParams fdaParams)
        {
            var payList   = new List <BrhFrontPaymentDetial>();
            var frontList = await _context.BrhFrontDeskAccounts.Include(x => x.BrhFrontPaymentDetial).Where(x => x.Branch == fdaParams.BranchName && x.State != StateType.已删除 && DateTime.Compare(fdaParams.StartDate, x.StartDate) <= 0 && DateTime.Compare(x.StartDate, fdaParams.EndDate) < 0).ToListAsync();

            foreach (var fr in frontList)
            {
                if (fr.BrhFrontPaymentDetial.Count > 0)
                {
                    payList.AddRange(fr.BrhFrontPaymentDetial);
                }
            }
            var pie1List = frontList.GroupBy(x => new { x.Channel }).Select(x => new
            {
                Channel = x.Key.Channel,
                CTotal  = x.Sum(s => s.Count),
                ATotal  = x.Sum(s => s.BrhFrontPaymentDetial.Select(b => b.PayAmount).Sum())
            }).ToList();
            var pie2List = payList.GroupBy(x => new { x.PayWay }).Select(x => new
            {
                PayWay = x.Key.PayWay,
                Total  = x.Sum(s => s.PayAmount),
            }).ToList();

            var days = (fdaParams.EndDate - fdaParams.StartDate).Days;
            List <FncMonthData> dailyList = new List <FncMonthData>();

            for (var i = 0; i < days; i++)
            {
                var daily = new FncMonthData();
                daily.Month       = fdaParams.StartDate.AddDays(i).Date;
                daily.HouseTotal  = fdaParams.Count;
                daily.HouseAmount = frontList.Where(x => DateTime.Compare(x.StartDate.Date, daily.Month) <= 0 && DateTime.Compare(daily.Month, x.EndDate.Date) < 0).Select(x => x.UnitPrice).Sum();
                daily.HouseCount  = frontList.Where(x => DateTime.Compare(x.StartDate.Date, daily.Month) <= 0 && DateTime.Compare(daily.Month, x.EndDate.Date) < 0).Select(x => x.Count).Count();
                if (daily.HouseTotal != 0)
                {
                    daily.Rate         = (double)daily.HouseCount / (double)daily.HouseTotal;
                    daily.ValidAverage = daily.HouseAmount / daily.HouseTotal;
                }
                else
                {
                    daily.Rate         = 0;
                    daily.ValidAverage = 0;
                }
                if (daily.HouseCount != 0)
                {
                    daily.Average = daily.HouseAmount / daily.HouseCount;
                }
                else
                {
                    daily.Average = 0;
                }
                dailyList.Add(daily);
            }
            return(Json(new { frontList, pie1List, pie2List, dailyList }));
        }
Exemplo n.º 3
0
        public async Task <JsonResult> GetFrontList([FromBody] FDAParams fdaParams)
        {
            var frontList = await _context.BrhScalp.Where(x => x.Branch == fdaParams.BranchName && DateTime.Compare(fdaParams.StartDate, x.StartDate) <= 0 && DateTime.Compare(x.StartDate, fdaParams.EndDate) < 0).ToListAsync();

            var pie1List = frontList.GroupBy(x => new { x.Channel }).Select(x => new
            {
                Channel = x.Key.Channel,
                CTotal  = x.Count(),
                ATotal  = x.Sum(s => s.TotalPrice)
            }).ToList();

            return(Json(new { frontList, pie1List }));
        }
Exemplo n.º 4
0
        public async Task <JsonResult> UpdateList([FromBody] FDAParams fdaParams)
        {
            if (fdaParams.Ids.Count > 0)
            {
                _context.BrhFrontDeskAccounts.Where(x => fdaParams.Ids.Contains(x.FrontDeskAccountsId) && !x.IsFinance).ToList().ForEach(x =>
                {
                    x.IsFinance = true;
                    _context.Update(x);
                });
                await _context.SaveChangesAsync();
            }

            var frontList = await _context.BrhScalp.Where(x => x.Branch == fdaParams.BranchName && DateTime.Compare(fdaParams.StartDate, x.StartDate) <= 0 && DateTime.Compare(x.StartDate, fdaParams.EndDate) < 0).ToListAsync();

            var pie1List = frontList.GroupBy(x => new { x.Channel }).Select(x => new
            {
                Channel = x.Key.Channel,
                CTotal  = x.Count(),
                ATotal  = x.Sum(s => s.TotalPrice)
            }).ToList();

            return(Json(new { frontList, pie1List }));
        }