示例#1
0
        public ServiceResult <OrderStatOutModel> GetOrderStat()
        {
            var               component    = new OrderComponent();
            var               fiatCurrency = new MerchantComponent().GetMerchantAccount(WorkContext.MerchantId).FiatCurrency;
            OrderStat         stat         = component.GetOrderStat(WorkContext.MerchantId, 2);
            OrderStatOutModel outputModel  = new OrderStatOutModel()
            {
                TotalCount   = stat.TotalCount,
                TotalMoney   = component.AllActualReceipt(WorkContext.MerchantId),
                TodayCount   = stat.TodayCount,
                TodayMoney   = Convert.ToDecimal(component.DayActualReceipt(WorkContext.MerchantId, DateTime.Today)),
                FiatCurrency = string.IsNullOrWhiteSpace(fiatCurrency) ? "" : fiatCurrency
            };

            return(Result_OK(outputModel));
        }
示例#2
0
        public ServiceResult <List <OrderDayStatDataOutModel> > GetOrderStatInWeek()
        {
            DateTime            date         = DateTime.UtcNow;
            DateTime            today        = date.AddDays(-1).Date;
            DateTime            fromday      = date.AddDays(-7).Date;
            var                 component    = new OrderComponent();
            List <OrderDayStat> list         = component.GetOrderStatInDay(WorkContext.MerchantId, fromday, today);
            var                 fiatCurrency = new MerchantComponent().GetMerchantAccount(WorkContext.MerchantId).FiatCurrency;

            List <OrderDayStatDataOutModel> ouputList = new List <OrderDayStatDataOutModel>();

            for (int i = 7; i > 0; i--)
            {
                bool   bFlag    = false;
                string OrderDay = date.AddDays(-i).ToString("yyyy-MM-dd");
                foreach (OrderDayStat day in list)
                {
                    if (OrderDay.Equals(day.OrderDay))
                    {
                        ouputList.Add(new OrderDayStatDataOutModel()
                        {
                            OrderDay     = day.OrderDay,
                            OrderCount   = day.OrderCount,
                            OrderAmount  = Convert.ToDecimal(component.DayActualReceipt(WorkContext.MerchantId, date.AddDays(-i))),
                            FiatCurrency = string.IsNullOrWhiteSpace(fiatCurrency) ? "" : fiatCurrency
                        });

                        bFlag = true;
                        break;
                    }
                }
                if (!bFlag)
                {//没有数据时
                    ouputList.Add(new OrderDayStatDataOutModel()
                    {
                        OrderDay     = OrderDay,
                        OrderCount   = 0,
                        OrderAmount  = 0,
                        FiatCurrency = string.IsNullOrWhiteSpace(fiatCurrency) ? "" : fiatCurrency
                    });
                }
            }

            return(Result_OK(ouputList));
        }