コード例 #1
0
        /// <summary>
        /// 根据查询条件过滤数据
        /// </summary>
        /// <param name="dailyQuery"></param>
        /// <returns></returns>
        private List <DailyRecord> FilterRecordInfo(DailyQueryMod dailyQuery, int pageIndex)
        {
            List <DailyRecord>        records    = DailyRecordHelper.DailyRecordList();
            IEnumerable <DailyRecord> temRecords = records.Where(item => item.StaffId != "");

            if (!string.IsNullOrEmpty(dailyQuery.StaffId))
            {
                temRecords = temRecords.Where(item => item.StaffId == dailyQuery.StaffId);
            }
            if (!string.IsNullOrEmpty(dailyQuery.CustomerId))
            {
                temRecords = temRecords.Where(item => item.CustomerId == dailyQuery.CustomerId);
            }
            if (dailyQuery.DateBegin > Convert.ToDateTime("2017-01-01"))
            {
                temRecords = temRecords.Where(item => item.VisitDate >= dailyQuery.DateBegin);
            }
            if (dailyQuery.DateBegin > Convert.ToDateTime("2017-01-01"))
            {
                temRecords = temRecords.Where(item => item.VisitDate <= dailyQuery.DateEnd.AddHours(8));
            }
            temRecords = temRecords.Where(item => item.SendBucketAmount > 0 || item.ReceiveEmptyBucketAmount > 0);
            //获取页条数
            int pageSize       = PageSize();
            var currentRecords = temRecords
                                 .OrderByDescending(item => item.VisitDate)
                                 .Skip((pageIndex - 1) * pageSize)
                                 .Take(pageSize);

            TempData["currentPage"] = pageIndex;
            TempData["DailyRecord"] = temRecords.ToList();

            return(currentRecords.ToList <DailyRecord>());
        }
コード例 #2
0
        /// <summary>
        /// 截至到现在,公司的所有送水记录及汇总记录
        /// </summary>
        /// <returns></returns>
        public ActionResult CompanyRecordsUptonow()
        {
            var records             = DailyRecordHelper.DailyRecordList();
            var customers           = CustomerHelper.CustomerList();
            var companyDailyRecords = records.GroupBy(item => item.CustomerId).Select(p => new CustomerAccessory()
            {
                CustomerId          = p.First().CustomerId,
                SendBuckets         = p.Sum(i => i.SendBucketAmount),
                ReceiveEmptyBuckets = p.Sum(i => i.ReceiveEmptyBucketAmount),
                WaterDispenser      = p.Sum(i => i.WaterDispenser),
                WaterHolder         = p.Sum(i => i.WaterHolder),
                PushPump            = p.Sum(i => i.PushPump)
            }).Join(customers, x => x.CustomerId, y => y.Id, (x, y) => new { x, y }).Select(p => new CustomerAccessory
            {
                CustomerId          = p.x.CustomerId,
                CustomerName        = p.y.CustomerName,
                SendBuckets         = p.x.SendBuckets,
                ReceiveEmptyBuckets = p.x.ReceiveEmptyBuckets,
                WaterDispenser      = p.x.WaterDispenser,
                WaterHolder         = p.x.WaterHolder,
                PushPump            = p.x.PushPump
            });

            ViewBag.flag = "CompanyRecordsUptonow";
            return(View(companyDailyRecords));
        }
コード例 #3
0
        /// <summary>
        /// 工资发放
        /// </summary>
        /// <param name="staffSalary"></param>
        /// <returns></returns>
        public ActionResult PaySalary(StaffSalary staffSalary)
        {
            //检查该月份该员工是否已经发过工资
            var staffSal = SalaryHelper.CheckIfPaid(staffSalary.StaffId, staffSalary.SalaryMonth);

            if (staffSal != null)
            {
                TempData["CheckErr"] = "该员工" + staffSalary.SalaryMonth.Year + "-" + staffSalary.SalaryMonth.Month + "的薪资已经发放,请核查";
                return(RedirectToAction("SalaryList"));
            }

            //获取该员工该薪资月的送水记录,统计提成用
            var dailyRecords = DailyRecordHelper.DailyRecordList()
                               .Where(item => item.VisitDate.Year == staffSalary.SalaryMonth.Year &&
                                      item.VisitDate.Month == staffSalary.SalaryMonth.Month &&
                                      item.StaffId == staffSalary.StaffId);
            //判断是否需要薪资发放类型
            var salaryType = CompanyPayTypeHelper.GetById(SalaryPayType);

            if (salaryType == null)
            {
                MongoBase.Insert(new CompanyPayType
                {
                    Id      = SalaryPayType,
                    PayType = "员工薪资支出"
                });
            }

            staffSalary.Id         = ObjectId.NewObjectId().ToString();
            staffSalary.Commission = dailyRecords.Sum(i => i.SendBucketAmount) * Commission(); //提成

            MongoBase.Insert(staffSalary);
            //公司当月支出增多相应金额
            CompanyPayRecord companyRecord = new CompanyPayRecord()
            {
                Id        = ObjectId.NewObjectId().ToString(),
                IsPayType = true,
                PayTypeId = SalaryPayType,
                StaffId   = staffSalary.StaffId,
                TransSum  = staffSalary.Salary,
                TransTime = Convert.ToDateTime(staffSalary.SalaryMonth + "-28")
            };

            MongoBase.Insert(companyRecord);
            return(RedirectToAction("SalaryList"));
        }
コード例 #4
0
        // GET: Home_ProCost
        public ActionResult Index(string productId, string yearMonth)
        {
            var products     = ProductHelper.ProductList();
            var dailyRecords = DailyRecordHelper.DailyRecordList();
            int year         = DateTime.Now.Year;
            int month        = DateTime.Now.AddMonths(-1).Month;//默认查上一个月

            if (!string.IsNullOrEmpty(productId))
            {
                dailyRecords      = dailyRecords.Where(item => item.SendProductId == productId).ToList();
                ViewBag.productId = productId;
            }
            if (!string.IsNullOrEmpty(yearMonth))
            {
                year  = int.Parse(yearMonth.Split('-')[0]);
                month = int.Parse(yearMonth.Split('-')[1]);
            }
            ViewBag.yearMonth = year + "-" + month;

            List <ProductCostModel> proCosts = (from d in dailyRecords
                                                join p in products
                                                on d.SendProductId equals p.Id
                                                where d.VisitDate.Year == year && d.VisitDate.Month == month
                                                select new ProductCostModel()
            {
                ProductName = p.ProductName,
                SumCost = d.SendBucketAmount * p.CostPrice,
                YearMonth = year + "-" + month
            }).ToList();

            proCosts = proCosts.GroupBy(item => item.ProductName).Select(item => new ProductCostModel()
            {
                ProductName = item.First().ProductName,
                YearMonth   = item.First().YearMonth,
                SumCost     = item.Sum(i => i.SumCost)
            }).ToList();
            ViewBag.Products = products;
            ViewBag.flag     = "ProductCost";

            return(View(proCosts));
        }
コード例 #5
0
        // GET: Home_Accessory
        public ActionResult Index()
        {
            var records   = DailyRecordHelper.DailyRecordList();
            var customers = CustomerHelper.CustomerList();

            var recordsAccessory = records.GroupBy(item => item.CustomerId)
                                   .Select(t => new CustomerAccessory
            {
                CustomerId     = t.First().CustomerId,
                WaterDispenser = t.Sum(i => i.WaterDispenser),
                WaterHolder    = t.Sum(i => i.WaterHolder),
                PushPump       = t.Sum(i => i.PushPump)
            }).Join(customers, x => x.CustomerId, y => y.Id, (x, y) => new { x, y }).Select(p => new CustomerAccessory
            {
                CustomerName   = p.y.CustomerName,
                WaterDispenser = p.x.WaterDispenser,
                WaterHolder    = p.x.WaterHolder,
                PushPump       = p.x.PushPump
            }).ToList();

            ViewBag.flag = "CustomerAccessory";
            return(View(recordsAccessory));
        }
コード例 #6
0
        public ActionResult CompanyDailyRecordsDetails(string customerId, string customerName, int pageIndex)
        {
            //该公司的所有日常交易记录
            var records = DailyRecordHelper.DailyRecordList()
                          .Where(item => item.CustomerId == customerId)
                          .OrderByDescending(item => item.VisitDate)
                          .ToList();
            CustomerAccessory sumaryMod = records.GroupBy(item => item.CustomerId).Select(p => new CustomerAccessory()
            {
                SendBuckets         = p.Sum(i => i.SendBucketAmount),
                ReceiveEmptyBuckets = p.Sum(i => i.ReceiveEmptyBucketAmount),
                WaterDispenser      = p.Sum(i => i.WaterDispenser),
                WaterHolder         = p.Sum(i => i.WaterHolder),
                PushPump            = p.Sum(i => i.PushPump)
            }).First();

            //获取页条数
            int pageSize       = PageSize();
            var currentRecords = records
                                 .OrderByDescending(item => item.VisitDate)
                                 .Skip((pageIndex - 1) * pageSize)
                                 .Take(pageSize);

            //记录分页相关字段
            ViewBag.totalPage = records.Count() % pageSize == 0
               ? records.Count() / pageSize
               : Math.Ceiling(Convert.ToDouble(records.Count()) / pageSize);
            ViewBag.totalSize   = records.Count();
            ViewBag.currentPage = pageIndex;

            ViewBag.customerName = customerName;
            ViewBag.customerId   = customerId;
            ViewBag.sumaryInfo   = sumaryMod;
            ViewBag.recordsAll   = records;
            ViewBag.flag         = "CompanyRecordsUptonow";
            return(View(currentRecords));
        }
コード例 #7
0
 public ActionResult Delete(string id)
 {
     ProductHelper.Delete(id);
     DailyRecordHelper.DeleteMany(id);//日常记录中与该产品相关的记录都会删除
     return(RedirectToAction("Index"));
 }
コード例 #8
0
        // GET: Summary
        public ActionResult Index(string yearMonth)
        {
            int year;
            int month;

            if (string.IsNullOrEmpty(yearMonth))
            {
                //默认显示上一个月的月底结算情况
                year      = DateTime.Now.AddMonths(-1).Year;
                month     = DateTime.Now.AddMonths(-1).Month;
                yearMonth = year + "-" + month;
            }
            else
            {
                year  = int.Parse(yearMonth.Split('-')[0]);
                month = int.Parse(yearMonth.Split('-')[1]);
            }

            var records  = DailyRecordHelper.DailyRecordList().Where(item => item.VisitDate.Year == year && item.VisitDate.Month == month);
            var products = ProductHelper.ProductList();

            var dailyRecords =
                DailyRecordHelper.DailyRecordList()
                .Where(item => item.VisitDate.Year == year && item.VisitDate.Month == month);
            var companyRecords =
                CompanyRecordHelper.CompanyList()
                .Where(item => item.TransTime.Year == year && item.TransTime.Month == month);
            MonthEndSummary monthEnd = new MonthEndSummary();
            //员工汇总
            MonthEndSummary monthEnd1 = dailyRecords.GroupBy(item => new { item.VisitDate.Year, item.VisitDate.Month })
                                        .Select(g => new MonthEndSummary()
            {
                StaffEarn =
                    g.Sum(x => x.EarnMonthEndPrice) + g.Sum(x => x.EarnWaterCardPrice) + g.Sum(x => x.EarnDeposit),
                StaffPay = g.Sum(x => x.PayDeposit)
            }).FirstOrDefault();

            ////公司汇总
            //公司支出动态加入员工提成
            double commission   = Commission();
            double sumBucketCom = dailyRecords.Sum(i => i.SendBucketAmount) * commission;

            MonthEndSummary monthEnd2 = companyRecords.GroupBy(item => new { item.TransTime.Year, item.TransTime.Month })
                                        .Select(g => new MonthEndSummary()
            {
                CompanyEarn = g.Where(item => item.IsPayType == false).Sum(x => x.TransSum),
                CompanyPay  = g.Where(item => item.IsPayType).Sum(x => x.TransSum) + sumBucketCom    //进水支出不计入公司盈利运算   2018.03.14:进水支出计入公司盈利运算
            }).FirstOrDefault();

            //计算员工月送水成本
            double sumCost = records.Join(products, x => x.SendProductId, y => y.Id, (x, y) => new { x, y })
                             .Select(item => new SumSendbucketCost
            {
                SumCost = item.x.SendBucketAmount * item.y.CostPrice
            }).Sum(item => item.SumCost);


            monthEnd.CompanyEarn  = (monthEnd2?.CompanyEarn ?? 0) + (monthEnd1?.StaffEarn ?? 0);                                   //仅保留公司收入/公司支出
            monthEnd.CompanyPay   = (monthEnd2?.CompanyPay ?? 0) + (monthEnd1?.StaffPay ?? 0);
            monthEnd.MonthEndEarn = monthEnd.StaffEarn + monthEnd.CompanyEarn - monthEnd.StaffPay - monthEnd.CompanyPay - sumCost; //2018.03.28改动:月底盈利减去员工送水成本
            monthEnd.YearMonth    = year + "-" + month;

            //计算员工提成,作为发工资的参考
            var staffs = StaffHelper.StaffList();
            List <StaffCommissionViewModel> staffCommission = new List <StaffCommissionViewModel>();

            foreach (var staff in staffs)
            {
                int bucketCount = dailyRecords.Where(item => item.StaffId == staff.Id).Sum(i => i.SendBucketAmount);
                staffCommission.Add(new StaffCommissionViewModel
                {
                    StaffName   = staff.StaffName,
                    BucketCount = bucketCount,
                    Comission   = bucketCount * commission
                });
            }
            ViewBag.staffCommission = staffCommission;

            ViewBag.queryPam = JsonConvert.SerializeObject(new { YearMonth = yearMonth });
            ViewBag.flag     = "EndSummary";
            ViewBag.staffs   = staffs;
            ViewBag.sumCost  = sumCost;
            return(View(monthEnd));
        }
コード例 #9
0
        /// <summary>
        /// 1. 水厂库存明细,统计字段:交易年月 产品名称 库存 空桶库存
        /// 2. 水厂交易明细 支付总押金 退还总押金 进水总支出
        /// </summary>
        /// <returns></returns>
        public ActionResult TransRecord(string yearMonth, string factoryId)
        {
            int year;
            int month;
            if (string.IsNullOrEmpty(yearMonth))
            {
                //默认显示上一个月的月底结算情况
                year = DateTime.Now.AddMonths(-1).Year;
                month = DateTime.Now.AddMonths(-1).Month;
                yearMonth = year + "-" + month;
            }
            else
            {
                year = int.Parse(yearMonth.Split('-')[0]);
                month = int.Parse(yearMonth.Split('-')[1]);
            }
            var factories = FactoryHelper.FactoryList();
            var products = ProductHelper.ProductList();
            var payTypes = CompanyPayTypeHelper.PayTypeList();
            //选定年月下的日常、公司交易记录
            var companyRecords = CompanyRecordHelper.CompanyList();
            var dailyRecords = DailyRecordHelper.DailyRecordList();
            //1.库存明细
            var factoryStocks = (from r in dailyRecords
                                 join p in products
                                 on r.SendProductId equals p.Id
                                 where r.VisitDate.Year == year && r.VisitDate.Month == month
                                 join f in factories
                                 on p.FactoryId equals f.Id
                                 where f.Id == (string.IsNullOrEmpty(factoryId) ? f.Id : factoryId)
                                 group
                                 new { p.FactoryId, p.Id, r.SendBucketAmount, r.ReceiveEmptyBucketAmount, p.ProductName, f.FactoryName } by
                                 new { p.FactoryId, p.Id }
                into t
                                 select new FactoryStock
                                 {
                                     FactoryName = t.First().FactoryName,
                                     TransMonth = yearMonth,
                                     ProductName = t.First().ProductName,
                                     BucketStock = t.Sum(i => i.SendBucketAmount),
                                     EmptyBucketStock = t.Sum(i => i.ReceiveEmptyBucketAmount)
                                 }).OrderByDescending(item => item.FactoryName);

            //2.交易明细
            var factoryTrans = (from c in companyRecords
                                join f in factories
                                on c.FactoryId equals f.Id
                                where c.TransTime.Year == year && c.TransTime.Month == month && f.Id == (string.IsNullOrEmpty(factoryId) ? f.Id : factoryId)
                                join p in payTypes
                                on c.PayTypeId equals p.Id
                                group new { c.IsPayType, c.TransSum, f.FactoryName, p.PayType } by
                                new { c.FactoryId, c.PayTypeId }
                into t
                                select new FactoryTrans
                                {
                                    FactoryName = t.First().FactoryName,
                                    TransType = t.First().PayType,
                                    IsPayType = t.First().IsPayType,
                                    TransSum = t.Sum(i => i.TransSum),
                                    TransMonth = yearMonth
                                }).OrderByDescending(item => item.FactoryName);

            FactorySumaryViewModel factorySumary = new FactorySumaryViewModel
            {
                FactoryStock = factoryStocks.ToList(),
                FactoryTrans = factoryTrans.ToList()
            };

            ViewBag.queryPam = JsonConvert.SerializeObject(new { YearMonth = yearMonth, FactoryId = factoryId });
            factories.Insert(0, new Factory { Id = "", FactoryName = "" });
            ViewBag.factories = factories;
            ViewBag.flag = "FactoryTransRecord";
            ViewBag.YearMonth = yearMonth;
            return View(factorySumary);
        }
コード例 #10
0
        /// <summary>
        /// 公司结算汇总
        /// </summary>
        /// <returns></returns>
        public ActionResult CompanyEnd(string payTypeId, string yearMonth)
        {
            var companyRecords = TempData["companyRecords"] != null
                ? TempData["companyRecords"] as List <CompanyPayRecord>
                : CompanyRecordHelper.CompanyList();

            var payType = CompanyPayTypeHelper.PayTypeList();
            //日常记录信息,用于统计提成
            var dailyRecords = DailyRecordHelper.DailyRecordList();

            //按年月分组
            var comRecordsMonth = companyRecords
                                  .OrderByDescending(item => item.TransTime)
                                  .GroupBy(item => new { item.TransTime.Year, item.TransTime.Month })
                                  .Select(g => new CompanyPayRecord
            {
                TransTime = g.First().TransTime,
                TransSum  = g.Sum(i => i.IsPayType ? -i.TransSum : i.TransSum)
            }).ToList();

            //按年月、消费类型分组
            var comRecordsMonType = companyRecords
                                    .OrderByDescending(item => item.TransTime)
                                    .GroupBy(item => new { item.TransTime.Year, item.TransTime.Month, item.PayTypeId })
                                    .Select(g => new CompanyPayRecord
            {
                TransTime = g.First().TransTime,
                TransSum  = g.Sum(i => i.IsPayType ? -i.TransSum : i.TransSum),
                PayTypeId = g.First().PayTypeId
            }).Join(payType, x => x.PayTypeId, y => y.Id, (x, y) => new { x, y })
                                    .Select(p => new CompanyPayRecordDesc
            {
                TransTime   = p.x.TransTime,
                TransSum    = p.x.TransSum,
                PayTypeDesc = p.y.PayType
            }).ToList();

            //公司月底结算,动态加入员工提成
            double commission = Commission();

            foreach (var item in comRecordsMonth)
            {
                int sumBucket =
                    dailyRecords.Where(i => i.VisitDate.Year == item.TransTime.Year && i.VisitDate.Month == item.TransTime.Month)
                    .Sum(i => i.SendBucketAmount);
                //当月总支出减去员工提成
                item.TransSum -= sumBucket * commission;

                //年月消费类型集合中添加该月员工统计提成条目
                int index =
                    comRecordsMonType.FindLastIndex(t => t.TransTime.Year == item.TransTime.Year && t.TransTime.Month == item.TransTime.Month);
                comRecordsMonType.Insert(index + 1, new CompanyPayRecordDesc
                {
                    PayTypeDesc = "员工提成(" + commission + "元/桶)",
                    TransTime   = item.TransTime,
                    TransSum    = -sumBucket * commission
                });
            }

            CompanyPayRecordViewModel viewModel = new CompanyPayRecordViewModel()
            {
                CompanyPayRecord     = comRecordsMonth,
                CompanyPayRecordDesc = comRecordsMonType
            };

            //记录查询条件
            ViewBag.queryPam = JsonConvert.SerializeObject(new { YearMonth = yearMonth, PayTypeId = payTypeId });
            ViewBag.flag     = "CompanyEnd";
            ViewBag.PayType  = payType;
            return(View(viewModel));
        }
コード例 #11
0
        /// <summary>
        /// 月底结算
        /// </summary>
        /// <returns></returns>
        public ActionResult MonthEnd(string yearMonth, string staffId, int pageSize = 1)
        {
            var records   = DailyRecordHelper.DailyRecordList();
            var customers = CustomerHelper.CustomerList();
            var products  = ProductHelper.ProductList();
            var staffs    = StaffHelper.StaffList();

            if (!string.IsNullOrEmpty(yearMonth))
            {
                int year  = int.Parse(yearMonth.Split('-')[0]);
                int month = int.Parse(yearMonth.Split('-')[1]);
                records = records.Where(item => item.VisitDate.Year == year && item.VisitDate.Month == month).ToList();
            }
            if (!string.IsNullOrEmpty(staffId))
            {
                records = records.Where(item => item.StaffId == staffId.ToString()).ToList();
            }

            //按月份、人员分组,计算员工的月送水成本
            List <MonthEndStaffwaterCost> staffCost = records
                                                      .Join(products, x => x.SendProductId, y => y.Id, (x, y) => new { x, y })
                                                      .GroupBy(item => new
            {
                item.x.VisitDate.Year,
                item.x.VisitDate.Month,
                item.x.StaffId,
                item.x.SendProductId,
                item.x.SendBucketAmount,
                item.y.CostPrice,
                item.x.CustomerId
            })
                                                      .Select(p => new MonthEndStaffwaterCost()
            {
                VisitYear  = p.First().x.VisitDate.Year.ToString(),
                VisitMonth = p.First().x.VisitDate.Month.ToString(),
                StaffId    = p.First().x.StaffId,
                WaterCost  = p.First().x.SendBucketAmount *p.First().y.CostPrice
            }).GroupBy(item => new { item.VisitYear, item.VisitMonth, item.StaffId }).Select(p =>
                                                                                             new MonthEndStaffwaterCost()
            {
                VisitYear  = p.First().VisitYear,
                VisitMonth = p.First().VisitMonth,
                StaffId    = p.First().StaffId,
                WaterCost  = p.Sum(item => item.WaterCost)
            }).Join(staffs, x => x.StaffId, y => y.Id, (x, y) => new { x, y }).Select(p =>
                                                                                      new MonthEndStaffwaterCost
            {
                VisitYear  = p.x.VisitYear,
                VisitMonth = p.x.VisitMonth,
                StaffName  = p.y.StaffName,
                WaterCost  = p.x.WaterCost
            }).ToList();

            //按月份、公司分组
            List <SumDailyRecordByCP> sumRecordsByCP = records.OrderByDescending(i => i.VisitDate)
                                                       .GroupBy(item => new { item.VisitDate.Year, item.VisitDate.Month, item.CustomerId })
                                                       .Select(g => new SumDailyRecordByCP
            {
                SumSendBucketAmount         = g.Sum(x => x.SendBucketAmount),         //送水桶数
                SumReceiveEmptyBucketAmount = g.Sum(x => x.ReceiveEmptyBucketAmount), //收回空桶数
                SumEarnDeposit        = g.Sum(x => x.EarnDeposit),                    //收取押金
                SumPayDeposit         = g.Sum(x => x.PayDeposit),                     //退还押金
                SumEarnMonthEndPrice  = g.Sum(x => x.EarnMonthEndPrice),              //收入月底结算
                SumEarnWaterCardPrice = g.Sum(x => x.EarnWaterCardPrice),             //收入水卡金额
                VisitMonth            = g.First().VisitDate.Month + "月",              //交易月份
                CustomerName          = g.First().CustomerId,
                ProductName           = g.First().SendProductId
            }).Join(customers, x => x.CustomerName, y => y.Id, (x, y) => new { x, y }).Select(p => new SumDailyRecordByCP()
            {
                CustomerName                = p.y.CustomerName,
                SumSendBucketAmount         = p.x.SumSendBucketAmount,
                SumReceiveEmptyBucketAmount = p.x.SumReceiveEmptyBucketAmount,
                SumEarnDeposit              = p.x.SumEarnDeposit,
                SumPayDeposit               = p.x.SumPayDeposit,
                SumEarnMonthEndPrice        = p.x.SumEarnMonthEndPrice,
                SumEarnWaterCardPrice       = p.x.SumEarnWaterCardPrice,
                VisitMonth = p.x.VisitMonth
            }).ToList();


            //按月份分组
            List <SumDailyRecord> sumRecords = records.OrderByDescending(i => i.VisitDate)
                                               .GroupBy(item => new { item.VisitDate.Year, item.VisitDate.Month })
                                               .Select(g => new SumDailyRecord
            {
                SumSendBucketAmount         = g.Sum(x => x.SendBucketAmount),         //送水桶数
                SumReceiveEmptyBucketAmount = g.Sum(x => x.ReceiveEmptyBucketAmount), //收回空桶数
                SumEarnDeposit        = g.Sum(x => x.EarnDeposit),                    //收取押金
                SumPayDeposit         = g.Sum(x => x.PayDeposit),                     //退还押金
                SumEarnMonthEndPrice  = g.Sum(x => x.EarnMonthEndPrice),              //收入月底结算
                SumEarnWaterCardPrice = g.Sum(x => x.EarnWaterCardPrice),             //收入水卡金额
                VisitYear             = g.First().VisitDate.Year + "年",
                VisitMonth            = g.First().VisitDate.Month + "月"               //交易月份
            }).ToList();

            SumDailyRecordViewModel viewModel = new SumDailyRecordViewModel
            {
                SumDailyRecord     = sumRecords,
                SumDailyRecordByCP = sumRecordsByCP,
                SumSendWatercost   = staffCost
            };

            ViewBag.queryPam = JsonConvert.SerializeObject(new { YearMonth = yearMonth, StaffId = staffId });
            ViewBag.Staffs   = StaffHelper.StaffList();
            ViewBag.flag     = "MonthEnd";
            return(View(viewModel));
        }
コード例 #12
0
        /// <summary>
        /// 日常记录--公司资金交易
        /// </summary>
        /// <returns></returns>
        public ActionResult FundRecord()
        {
            //所有客户
            List <Customer> customers = CustomerHelper.CustomerList();
            //所有产品
            var products = ProductHelper.ProductList();
            //所有员工
            var staffs = StaffHelper.StaffList();
            //所有日常记录
            var dailyRecords = (TempData["DailyRecord"] == null ? DailyRecordHelper.DailyRecordList() : (List <DailyRecord>)TempData["DailyRecord"]).Where(
                item =>
                item.PayDeposit > 0 || item.EarnDeposit > 0 || item.EarnMonthEndPrice > 0 ||
                item.EarnWaterCardPrice > 0).ToList();

            //添加空选项
            customers.Insert(0, new Customer {
                CustomerName = ""
            });
            //获取页条数
            int pageSize = PageSize();

            List <DailyRecord> currentRecords = TempData["currentRecords"] == null
                ? dailyRecords
                                                .OrderByDescending(item => item.VisitDate)
                                                .Skip(0)
                                                .Take(pageSize)
                                                .ToList()
                : TempData["currentRecords"] as List <DailyRecord>;

            //与公司的资金交易--当前页
            List <DailyFundTrans> fundRecordsCurrent = currentRecords
                                                       .Select(item => new DailyFundTrans()
            {
                StaffId            = item.StaffId,
                CustomerId         = item.CustomerId,
                EarnDeposit        = item.EarnDeposit,
                PayDeposit         = item.PayDeposit,
                EarnMonthEndPrice  = item.EarnMonthEndPrice,
                EarnWaterCardPrice = item.EarnWaterCardPrice,
                Description        = item.Description,
                VisitDate          = item.VisitDate
            }).ToList();

            var recordsFundTransCurrent = (from r in fundRecordsCurrent
                                           join c in customers
                                           on r.CustomerId equals c.Id
                                           join s in staffs
                                           on r.StaffId equals s.Id
                                           select new DailyFundTrans
            {
                StaffName = s.StaffName,
                CustomerName = c.CustomerName,
                EarnDeposit = r.EarnDeposit,
                PayDeposit = r.PayDeposit,
                EarnMonthEndPrice = r.EarnMonthEndPrice,
                EarnWaterCardPrice = r.EarnWaterCardPrice,
                Description = r.Description,
                VisitDate = r.VisitDate
            }).ToList();

            //与公司的资金交易--所有
            List <DailyFundTrans> fundRecords = dailyRecords
                                                .Select(item => new DailyFundTrans()
            {
                StaffId            = item.StaffId,
                CustomerId         = item.CustomerId,
                EarnDeposit        = item.EarnDeposit,
                PayDeposit         = item.PayDeposit,
                EarnMonthEndPrice  = item.EarnMonthEndPrice,
                EarnWaterCardPrice = item.EarnWaterCardPrice,
                Description        = item.Description,
                VisitDate          = item.VisitDate
            }).OrderByDescending(item => item.VisitDate).ToList();

            var recordsFundTrans = (from r in fundRecords
                                    join c in customers
                                    on r.CustomerId equals c.Id
                                    join s in staffs
                                    on r.StaffId equals s.Id
                                    select new DailyFundTrans
            {
                StaffName = s.StaffName,
                CustomerName = c.CustomerName,
                EarnDeposit = r.EarnDeposit,
                PayDeposit = r.PayDeposit,
                EarnMonthEndPrice = r.EarnMonthEndPrice,
                EarnWaterCardPrice = r.EarnWaterCardPrice,
                Description = r.Description,
                VisitDate = r.VisitDate
            }).ToList();

            ViewBag.flag      = "DailyRecord";
            ViewBag.customers = customers;
            ViewBag.queryPam  = TempData["dailyQuery"] == null ? "{}" : JsonConvert.SerializeObject(TempData["dailyQuery"]);

            ViewBag.totalPage = dailyRecords.Count() % pageSize == 0
                ? dailyRecords.Count() / pageSize
                : Math.Ceiling(Convert.ToDouble(dailyRecords.Count()) / pageSize);

            ViewBag.totalSize   = dailyRecords.Count;
            ViewBag.currentPage = TempData["currentPage"] == null
                 ? 1
                 : int.Parse(TempData["currentPage"].ToString());

            ViewBag.recordsFundTrans = recordsFundTrans;
            ViewBag.Staffs           = StaffHelper.StaffList();
            return(View(recordsFundTransCurrent));
        }
コード例 #13
0
        /// <summary>
        /// 日常记录--附属产品交易记录
        /// </summary>
        /// <returns></returns>
        public ActionResult AccessRecord()
        {
            //所有客户
            List <Customer> customers = CustomerHelper.CustomerList();
            //所有员工
            var staffs = StaffHelper.StaffList();
            //所有日常记录
            var dailyRecords = (TempData["DailyRecord"] == null
                    ? DailyRecordHelper.DailyRecordList()
                    : (List <DailyRecord>)TempData["DailyRecord"]).Where(
                item =>
                item.WaterHolder != 0 || item.WaterDispenser != 0 || item.PushPump != 0 ||
                item.WaterHolderBack != 0 || item.WaterDispenserBack != 0 || item.PushPumpBack != 0)
                               .GroupBy(item => new { item.VisitDate, item.CustomerId, item.StaffId })
                               .Select(item => new AccessoryProducts()
            {
                StaffId        = item.First().StaffId,
                CustomerId     = item.First().CustomerId,
                WaterDispenser = MakeAccessoryInfo(item.First().WaterDispenser, item.First().WaterDispenserBack),
                PushPump       = MakeAccessoryInfo(item.First().PushPump, item.First().PushPumpBack),
                WaterHolder    = MakeAccessoryInfo(item.First().WaterHolder, item.First().WaterHolderBack),
                VisitDate      = item.First().VisitDate
            });

            //添加空选项
            customers.Insert(0, new Customer {
                CustomerName = ""
            });
            //获取页条数
            int pageSize = PageSize();

            List <AccessoryProducts> currentRecords = TempData["currentRecords"] == null
                ? dailyRecords
                                                      .OrderByDescending(item => item.VisitDate)
                                                      .Skip(0)
                                                      .Take(pageSize)
                                                      .ToList()
                : (List <AccessoryProducts>)TempData["currentRecords"];

            //附属产品交易--所有

            var recordsAccessoryPro = (from r in dailyRecords
                                       join c in customers
                                       on r.CustomerId equals c.Id
                                       join s in staffs
                                       on r.StaffId equals s.Id
                                       select new AccessoryProducts
            {
                StaffName = s.StaffName,
                CustomerName = c.CustomerName,
                WaterHolder = r.WaterHolder,
                WaterDispenser = r.WaterDispenser,
                PushPump = r.PushPump,
                VisitDate = r.VisitDate
            }).ToList();

            //附属产品交易--当前页

            var acceCurrent = (from r in currentRecords
                               join c in customers
                               on r.CustomerId equals c.Id
                               join s in staffs
                               on r.StaffId equals s.Id
                               select new AccessoryProducts
            {
                StaffName = s.StaffName,
                CustomerName = c.CustomerName,
                WaterHolder = r.WaterHolder,
                WaterDispenser = r.WaterDispenser,
                PushPump = r.PushPump,
                VisitDate = r.VisitDate
            }).ToList();

            ViewBag.flag      = "DailyRecord";
            ViewBag.customers = customers;
            ViewBag.queryPam  = TempData["dailyQuery"] == null ? "{}" : JsonConvert.SerializeObject(TempData["dailyQuery"]);

            ViewBag.totalPage = dailyRecords.Count() % pageSize == 0
                ? dailyRecords.Count() / pageSize
                : Math.Ceiling(Convert.ToDouble(dailyRecords.Count()) / pageSize);

            ViewBag.totalSize   = dailyRecords.Count();
            ViewBag.currentPage = TempData["currentPage"] == null
                 ? 1
                 : int.Parse(TempData["currentPage"].ToString());

            ViewBag.Staffs     = StaffHelper.StaffList();
            ViewBag.recordsAll = recordsAccessoryPro;
            return(View(acceCurrent));
        }
コード例 #14
0
        /// <summary>
        /// 日常记账记录查看
        /// </summary>
        /// <returns></returns>
        public ActionResult DailyRecord()
        {
            //所有客户
            List <Customer> customers = CustomerHelper.CustomerList();
            //所有产品
            var products = ProductHelper.ProductList();
            //所有员工
            var staffs = StaffHelper.StaffList();
            //所有日常记录
            var dailyRecords = TempData["DailyRecord"] == null?DailyRecordHelper.DailyRecordList() : (List <DailyRecord>)TempData["DailyRecord"];

            //添加空选项
            customers.Insert(0, new Customer {
                CustomerName = ""
            });
            //获取页条数
            int pageSize = PageSize();

            List <DailyRecord> currentRecords = TempData["currentRecords"] == null
                ? dailyRecords
                                                .OrderByDescending(item => item.VisitDate)
                                                .Skip(0)
                                                .Take(pageSize)
                                                .ToList()
                : TempData["currentRecords"] as List <DailyRecord>;

            List <DailyRecordShow> newRecords = (from r in currentRecords
                                                 join c in customers
                                                 on r.CustomerId equals c.Id
                                                 join p in products
                                                 on r.SendProductId equals p.Id
                                                 join s in staffs
                                                 on r.StaffId equals s.Id
                                                 select new DailyRecordShow
            {
                StaffName = s.StaffName,
                CustomerName = c.CustomerName,
                ProductName = p.ProductName,
                SendBucketAmount = r.SendBucketAmount,
                ReceiveEmptyBucketAmount = r.ReceiveEmptyBucketAmount,
                VisitDate = r.VisitDate,
                DailyCost = r.SendBucketAmount * p.CostPrice,
                Description = r.Description
            }).Where(item => item.SendBucketAmount > 0 || item.ReceiveEmptyBucketAmount > 0)
                                                .ToList();

            List <DailyRecordShow> recordsAll = (from r in dailyRecords
                                                 join c in customers
                                                 on r.CustomerId equals c.Id
                                                 join p in products
                                                 on r.SendProductId equals p.Id
                                                 join s in staffs
                                                 on r.StaffId equals s.Id
                                                 select new DailyRecordShow
            {
                StaffName = s.StaffName,
                CustomerName = c.CustomerName,
                ProductName = p.ProductName,
                SendBucketAmount = r.SendBucketAmount,
                ReceiveEmptyBucketAmount = r.ReceiveEmptyBucketAmount,
                VisitDate = r.VisitDate,
                DailyCost = r.SendBucketAmount * p.CostPrice,
                Description = r.Description
            }).Where(item => item.SendBucketAmount > 0 || item.ReceiveEmptyBucketAmount > 0)
                                                .OrderByDescending(item => item.VisitDate)
                                                .ToList();

            //与公司的资金交易
            List <DailyFundTrans> fundRecords = dailyRecords.Where(
                item =>
                item.PayDeposit > 0 || item.EarnDeposit > 0 || item.EarnMonthEndPrice > 0 ||
                item.EarnWaterCardPrice > 0)
                                                //.GroupBy(item => new { item.VisitDate, item.CustomerId, item.StaffId })
                                                .Select(item => new DailyFundTrans()
            {
                StaffId            = item.StaffId,
                CustomerId         = item.CustomerId,
                EarnDeposit        = item.EarnDeposit,
                PayDeposit         = item.PayDeposit,
                EarnMonthEndPrice  = item.EarnMonthEndPrice,
                EarnWaterCardPrice = item.EarnWaterCardPrice,
                Description        = item.Description,
                VisitDate          = item.VisitDate
            }).ToList();

            var recordsFundTrans = (from r in fundRecords
                                    join c in customers
                                    on r.CustomerId equals c.Id
                                    join s in staffs
                                    on r.StaffId equals s.Id
                                    select new DailyFundTrans
            {
                StaffName = s.StaffName,
                CustomerName = c.CustomerName,
                EarnDeposit = r.EarnDeposit,
                PayDeposit = r.PayDeposit,
                EarnMonthEndPrice = r.EarnMonthEndPrice,
                EarnWaterCardPrice = r.EarnWaterCardPrice,
                Description = r.Description,
                VisitDate = r.VisitDate
            }).ToList();

            //附属产品交易
            var accessoryProRecords = dailyRecords.Where(
                item =>
                item.WaterHolder != 0 || item.WaterDispenser != 0 || item.PushPump != 0 ||
                item.WaterHolderBack != 0 || item.WaterDispenserBack != 0 || item.PushPumpBack != 0)
                                      .GroupBy(item => new { item.VisitDate, item.CustomerId, item.StaffId })
                                      .Select(item => new AccessoryProducts()
            {
                StaffId        = item.First().StaffId,
                CustomerId     = item.First().CustomerId,
                WaterDispenser = MakeAccessoryInfo(item.First().WaterDispenser, item.First().WaterDispenserBack),
                PushPump       = MakeAccessoryInfo(item.First().PushPump, item.First().PushPumpBack),
                WaterHolder    = MakeAccessoryInfo(item.First().WaterHolder, item.First().WaterHolderBack),
                VisitDate      = item.First().VisitDate
            });

            var recordsAccessoryPro = (from r in accessoryProRecords
                                       join c in customers
                                       on r.CustomerId equals c.Id
                                       join s in staffs
                                       on r.StaffId equals s.Id
                                       select new AccessoryProducts
            {
                StaffName = s.StaffName,
                CustomerName = c.CustomerName,
                WaterHolder = r.WaterHolder,
                WaterDispenser = r.WaterDispenser,
                PushPump = r.PushPump,
                VisitDate = r.VisitDate
            }).ToList();

            ViewBag.flag      = "DailyRecord";
            ViewBag.customers = customers;
            ViewBag.queryPam  = TempData["dailyQuery"] == null ? "{}" : JsonConvert.SerializeObject(TempData["dailyQuery"]);

            ViewBag.totalPage = recordsAll.Count() % pageSize == 0
                ? recordsAll.Count() / pageSize
                : Math.Ceiling(Convert.ToDouble(recordsAll.Count()) / pageSize);

            ViewBag.totalSize   = recordsAll.Count;
            ViewBag.currentPage = TempData["currentPage"] == null
                 ? 1
                 : int.Parse(TempData["currentPage"].ToString());

            ViewBag.recordsFundTrans    = recordsFundTrans;
            ViewBag.recordsAccessoryPro = recordsAccessoryPro;
            ViewBag.Staffs     = StaffHelper.StaffList();
            ViewBag.recordsAll = recordsAll;
            return(View(newRecords));
        }