Пример #1
0
 public IEnumerable <CashierRevenueStatisticModel> GetCashierRevenueStatistic(DateTime fromCreatedDate, DateTime toCreatedDate, int Type, out List <DateTime> LstDate)
 {
     try
     {
         var lstOrder = _orderDal.GetList((short)OrderStatusEnum.Success, fromCreatedDate, toCreatedDate);
         if (lstOrder.Any())
         {
             LstDate = EachDay(fromCreatedDate, toCreatedDate).ToList();
             var lstCashier = lstOrder.Select(x => x.cashier_receive).GroupBy(x => x).OrderBy(x => x.Key).ToList();
             var result     = new List <CashierRevenueStatisticModel>();
             foreach (var cashier in lstCashier)
             {
                 var total             = 0;
                 var cashierRevenueObj = new CashierRevenueStatisticModel {
                     CashierName = cashier.Key
                 };
                 foreach (DateTime day in EachDay(fromCreatedDate, toCreatedDate))
                 {
                     var revenueByDay = new CashierRevenueStatisticByDayModel {
                         Day = day
                     };
                     var RevenueOfDishes = lstOrder.Where(x => x.cashier_receive == cashier.Key &&
                                                          x.created_date.Date.CompareTo(day) == 0).Sum(x => x.price);
                     var ShippingFee = lstOrder.Where(x => x.cashier_receive == cashier.Key &&
                                                      x.created_date.Date.CompareTo(day) == 0).Sum(x => x.ship_fee);
                     if (Type == 0)
                     {
                         revenueByDay.Revenue = RevenueOfDishes;
                     }
                     else if (Type == 1)
                     {
                         revenueByDay.Revenue = ShippingFee;
                     }
                     else
                     {
                         revenueByDay.Revenue = ShippingFee + RevenueOfDishes;
                     }
                     cashierRevenueObj.lstDay.Add(revenueByDay);
                     total += revenueByDay.Revenue;
                 }
                 cashierRevenueObj.TotalStr = StringUtils.ConvertNumberToCurrency(total);
                 result.Add(cashierRevenueObj);
             }
             return(result);
         }
     }
     catch (Exception ex)
     {
         Logger.WriteLog(Logger.LogType.Error, ex.ToString());
     }
     LstDate = new List <DateTime>();
     return(new List <CashierRevenueStatisticModel>());
 }
Пример #2
0
 public IEnumerable <CashierRevenueStatisticModel> GetCashierRevenueStatisticByPaymentType(DateTime fromCreatedDate, DateTime toCreatedDate, int Type)
 {
     try
     {
         var lstOrder = _orderDal.GetList((short)OrderStatusEnum.Success, fromCreatedDate, toCreatedDate);
         if (lstOrder.Any())
         {
             var lstPaymentType = EnumHelper.Instance.ConvertEnumToList <PaymentTypeEnum>().ToList();
             var result         = new List <CashierRevenueStatisticModel>();
             foreach (var item in lstPaymentType)
             {
                 var total             = 0;
                 var cashierRevenueObj = new CashierRevenueStatisticModel {
                     CashierName = item.Name
                 };
                 foreach (DateTime day in EachDay(fromCreatedDate, toCreatedDate))
                 {
                     var revenueByDay = new CashierRevenueStatisticByDayModel {
                         Day = day
                     };
                     var RevenueOfDishes = lstOrder.Where(x => x.source_type == item.Id &&
                                                          x.created_date.Date.CompareTo(day) == 0).Sum(x => x.price);
                     var ShippingFee = lstOrder.Where(x => x.source_type == item.Id &&
                                                      x.created_date.Date.CompareTo(day) == 0).Sum(x => x.ship_fee);
                     if (Type == 0)
                     {
                         revenueByDay.Revenue = RevenueOfDishes;
                     }
                     else if (Type == 1)
                     {
                         revenueByDay.Revenue = ShippingFee;
                     }
                     else
                     {
                         revenueByDay.Revenue = ShippingFee + RevenueOfDishes;
                     }
                     cashierRevenueObj.lstDay.Add(revenueByDay);
                     total += revenueByDay.Revenue;
                 }
                 cashierRevenueObj.TotalStr = StringUtils.ConvertNumberToCurrency(total);
                 result.Add(cashierRevenueObj);
             }
             return(result);
         }
     }
     catch (Exception ex)
     {
         Logger.WriteLog(Logger.LogType.Error, ex.ToString());
     }
     return(new List <CashierRevenueStatisticModel>());
 }
Пример #3
0
        public IEnumerable <CashierRevenueStatisticModel> CountOrderAndCustomer(DateTime fromCreatedDate, DateTime toCreatedDate)
        {
            try
            {
                var lstOrder = _orderDal.GetList((short)OrderStatusEnum.Success, fromCreatedDate, toCreatedDate);
                if (lstOrder.Any())
                {
                    var result = new List <CashierRevenueStatisticModel>();

                    var total               = 0;
                    var cusTotal            = 0;
                    var countBillRevenueObj = new CashierRevenueStatisticModel {
                        CashierName = "Số lượng bill"
                    };
                    var countCusRevenueObj = new CashierRevenueStatisticModel {
                        CashierName = "Số lượng khách hàng"
                    };
                    foreach (DateTime day in EachDay(fromCreatedDate, toCreatedDate))
                    {
                        var countBillByDay = new CashierRevenueStatisticByDayModel {
                            Day = day
                        };
                        var countCusByDay = new CashierRevenueStatisticByDayModel {
                            Day = day
                        };
                        //tính số lượng bill
                        var CountBill = lstOrder.Where(x => x.created_date.Date.CompareTo(day) == 0).Count();
                        //tính số lượng khách hàng ko có CustomerId
                        var CountCusNoId = lstOrder.Where(x => x.customer_id == 0 && x.created_date.Date.CompareTo(day) == 0).Count();
                        var CountCus     = lstOrder.Where(x => x.customer_id != 0 && x.created_date.Date.CompareTo(day) == 0).GroupBy(x => x.customer_id).Select(c => c.First()).Count();
                        countBillByDay.Revenue = CountBill;
                        countCusByDay.Revenue  = CountCusNoId + CountCus;
                        countBillRevenueObj.lstDay.Add(countBillByDay);
                        countCusRevenueObj.lstDay.Add(countCusByDay);
                        total    += countBillByDay.Revenue;
                        cusTotal += countCusByDay.Revenue;
                    }
                    countBillRevenueObj.TotalStr = StringUtils.ConvertNumberToCurrency(total);
                    countCusRevenueObj.TotalStr  = StringUtils.ConvertNumberToCurrency(cusTotal);
                    result.Add(countBillRevenueObj);
                    result.Add(countCusRevenueObj);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(Logger.LogType.Error, ex.ToString());
            }
            return(new List <CashierRevenueStatisticModel>());
        }
Пример #4
0
        public IEnumerable <CashierRevenueStatisticModel> CountCashierRevenueStatisticByProduct(DateTime fromCreatedDate, DateTime toCreatedDate)
        {
            try
            {
                var lstOrderDetail = _orderDetailDal.GetList((short)OrderStatusEnum.Success, fromCreatedDate, toCreatedDate);

                if (lstOrderDetail.Any())
                {
                    var result     = new List <CashierRevenueStatisticModel>();
                    var lstProduct = lstOrderDetail.GroupBy(x => x.product_id).Select(c => c.First()).ToList();
                    foreach (var item in lstProduct)
                    {
                        var total             = 0;
                        var cashierRevenueObj = new CashierRevenueStatisticModel {
                            CashierName = item.product_name
                        };
                        foreach (DateTime day in EachDay(fromCreatedDate, toCreatedDate))
                        {
                            var revenueByDay = new CashierRevenueStatisticByDayModel {
                                Day = day
                            };
                            var RevenueOfDishes = lstOrderDetail.Where(x => x.product_id == item.product_id &&
                                                                       x.created_date.Date.CompareTo(day) == 0).Count();
                            revenueByDay.Revenue = RevenueOfDishes;
                            cashierRevenueObj.lstDay.Add(revenueByDay);
                            total += revenueByDay.Revenue;
                        }
                        cashierRevenueObj.TotalStr = StringUtils.ConvertNumberToCurrency(total);
                        result.Add(cashierRevenueObj);
                    }
                    return(result);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(Logger.LogType.Error, ex.ToString());
            }
            return(new List <CashierRevenueStatisticModel>());
        }