public IHttpActionResult GetExpensesBy(string username, [FromUri] string firstday, [FromUri] string lastday)
        {
            var expenses = tiService.GetExpenses(username, firstday, lastday);

            //tjek det her
            return(Content(HttpStatusCode.OK, expenses));

            //return Content(HttpStatusCode.OK, new List<KeyValuePair<string, float>>());
        }
        /// <summary>
        ///     获取店铺今日运营概况
        /// </summary>
        /// <param name="userContext"></param>
        /// <returns></returns>
        public AccountOverview GetAccountOverViewToday(UserContext userContext)
        {
            var accountBusiness = _accountBusinessDapperRepository.Find(x => x.accountid == userContext.AccId);

            //销售情况
            var strSqlCoupon =
                @"SELECT @SalesMoney=cast(sum(RealMoney) as decimal(18, 2)),@GoodsSalesCount=SUM(saleNum) FROM dbo.T_SaleInfo 
                                WHERE accID=@AccountId AND saleTime BETWEEN @sDate AND @eDate;
                                IF @SalesMoney IS NULL SET @SalesMoney=0;
                                IF @GoodsSalesCount IS NULL SET @GoodsSalesCount=0;
                                ";

            var sDate = DateTime.Now.ToShortDateString();
            var eDate = DateTime.Now.ToShortDateString();

            sDate = sDate + " 00:00:00";
            eDate = eDate + " 23:59:59";
            var sqlParams = new
            {
                AccountId = userContext.AccId,
                sDate,
                eDate
            };
            var dapperParam = new DynamicParameters(sqlParams);

            dapperParam.Add("SalesMoney", dbType: DbType.Decimal, direction: ParameterDirection.Output);
            dapperParam.Add("GoodsSalesCount", dbType: DbType.Int32, direction: ParameterDirection.Output);
            var sqlQuery = new SqlQuery(strSqlCoupon, dapperParam);

            _salesDapperRepository.FindAll(sqlQuery);
            var salesMoney      = dapperParam.Get <decimal>("SalesMoney");
            var goodsSalesCount = dapperParam.Get <int>("GoodsSalesCount");

            //库存警告
            var strSqlGoodsWarning = new StringBuilder();

            strSqlGoodsWarning.Append("SELECT @GoodsWarning=COUNT( DISTINCT a.gid) ");
            strSqlGoodsWarning.Append("from T_GoodsInfo ");
            strSqlGoodsWarning.Append("a left join T_Goods_Sku b ");
            strSqlGoodsWarning.Append("on a.gid=b.gid ");
            strSqlGoodsWarning.Append("where a.accID=@accId and  ISNULL(a.isDown,0)=0  ");
            strSqlGoodsWarning.Append(
                "and ((a.IsExtend=1 and ( b.gsQuantity>=b.LimitUpper or b.gsQuantity<=b.LimitLower)) ");
            strSqlGoodsWarning.Append(
                "or (ISNULL(a.IsExtend,0)=0 and (a.gQuantity>=a.LimitUpper or a.gQuantity<=a.LimitLower))) ");
            var sqlParamsGoodsWarning = new
            {
                accId = userContext.AccId
            };
            var dapperParamGoodsWarning = new DynamicParameters(sqlParamsGoodsWarning);

            dapperParamGoodsWarning.Add("GoodsWarning", dbType: DbType.Int32, direction: ParameterDirection.Output);
            var sqlQueryGoodsWarning = new SqlQuery(strSqlGoodsWarning.ToString(), dapperParamGoodsWarning);

            _salesDapperRepository.FindAll(sqlQueryGoodsWarning);
            var goodsWarning = dapperParamGoodsWarning.Get <int>("GoodsWarning");


            //店铺会员生日
            var userBirthdayCount = 0;
            var responseUser      = _userService.GetBirthdayUsers(userContext,
                                                                  DateTime.Parse(DateTime.Now.ToShortDateString()));

            if (responseUser.Code == (int)ErrorCodeEnum.Success)
            {
                userBirthdayCount = ((IEnumerable <BirthdayUsersResult>)responseUser.Data).Count();
            }

            var expenseService  = new ExpensesService();
            var accountOverview = new AccountOverview
            {
                SalesMoney        = salesMoney,
                GoodsSalesCount   = goodsSalesCount,
                UserBirthdayCount = userBirthdayCount,
                GoodsStockCount   = goodsWarning,
                SmsCount          = accountBusiness.dxunity
            };
            var searchParams = new ExpensesSearchParam
            {
                StartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1, 0, 0, 0),
                EndDate   = DateTime.Now
            };

            //本月支出总额
            var expenseResult = expenseService.GetExpenses(userContext, searchParams);

            if (expenseResult.Code == (int)ErrorCodeEnum.Success)
            {
                accountOverview.ThisMonthExpense = ((ExpensesSearchResult)expenseResult.Data).TotalExpensesAmount;
            }
            //资金账户可提现余额
            accountOverview.TotalMoeny =
                ((AccountBalanceResponse)_accountbookService.GetWithdrawingBalance(userContext).Data).TotalBalance;

            //会员总数
            accountOverview.UsersNum = _userInfoDapperRepository.FindAll(x => x.AccId == userContext.AccId).Count();

            //今日手机橱窗订单总数
            var ordersStrSql = new StringBuilder();
            var searchDate   = Convert.ToDateTime(DateTime.Now.ToShortDateString());

            ordersStrSql.Append(
                "SELECT COUNT(bid) as TotalOrdersNum FROM T_Goods_Booking WHERE accid=@accId AND payType=1 AND bState IN (4,6) AND bInsertTime BETWEEN @StartDate AND @EndDate;");
            var sqlParamMobileOrdersNum = new
            {
                accId     = userContext.AccId,
                StartDate = searchDate,
                EndDate   = searchDate.AddDays(1).AddSeconds(-1)
            };
            var dapperParamMobileOrdersNum = new DynamicParameters(sqlParamMobileOrdersNum);
            var sqlQueryMobileOrdersNum    = new SqlQuery(ordersStrSql.ToString(), dapperParamMobileOrdersNum);

            accountOverview.TodayMobileOrdersNum = Convert.ToInt32(_getRepository.FindAll(sqlQueryMobileOrdersNum).FirstOrDefault());

            return(accountOverview);
        }