public object Any(SaleCount request)
        {
            var resp    = new Dto <long>();
            var handler = new SaleHandler(Db, CurrentSession);

            resp.Result = handler.Count();

            return(resp);
        }
示例#2
0
        public DataCollectionResponse <SaleCount> GetSaleCount(long shopId, OrderType type, int timeType, DateTime startTime, DateTime endTime, int pageIndex, int pageSize)
        {
            ISession session = null;

            try
            {
                String contenthsql = "select order.Id,orderGoods.Id,orderGoods.Image,orderGoods.Count,orderGoods.PopPrice,order.PopSellerGetMoney, orderGoods.Price,order.DeliveryMoney,orderGoods.Vendor,orderGoods.Number,orderGoods.GoodsId,order.PopPayTime,order.DeliveryTime,order.State,order.ShopId,orderGoods.Color,orderGoods.Size,orderGoods.Edtion ";
                String hsqlWhere   = String.Format(" from Order order,OrderGoods orderGoods where order.Id=orderGoods.OrderId and order.CreateType=1 ");
                hsqlWhere += string.Format(" and order.{0} >='{1}' and order.{0} <='{2}'", (timeType == 0) ? "PopPayTime" : "DeliveryTime", this.FormatDateTime(startTime), this.FormatDateTime(endTime));

                if (shopId > 0)
                {
                    hsqlWhere += " and order.ShopId=" + shopId;
                }
                if (type != OrderType.NONE)
                {
                    hsqlWhere += " and order.Type=" + (int)type;
                }

                string hsqlData  = contenthsql + hsqlWhere;
                string hsqlCount = "select count(orderGoods.id) " + hsqlWhere;
                session = OpenSession();
                var query = session.CreateQuery(hsqlData);
                if (pageSize > 0)
                {
                    query.SetFirstResult(pageIndex * pageSize);
                    query.SetMaxResults(pageSize);
                }
                var rs = query.List <object>();
                List <SaleCount> counts = new List <SaleCount>();
                foreach (Object list in rs)
                {
                    Object[]  l  = (Object[])list;
                    SaleCount gc = new SaleCount();
                    gc.OrderId               = (long)l[0];
                    gc.OrderGoodsId          = (long)l[1];
                    gc.Image                 = (string)l[2];
                    gc.Count                 = (int)l[3];
                    gc.PopPrice              = (float)l[4];
                    gc.PopSellerGetMoney     = (float)l[5];
                    gc.ERPOrderGoodsMoney    = (float)l[6];
                    gc.ERPOrderDeliveryMoney = (float)l[7];
                    gc.Vendor                = (string)l[8];
                    gc.Number                = (string)l[9];
                    gc.GoodsId               = (long)l[10];
                    gc.PopPayTime            = (DateTime)l[11];
                    gc.DeliveryTime          = (DateTime)l[12];
                    gc.State                 = (OrderState)l[13];
                    gc.ShopId                = (long)l[14];
                    gc.Color                 = (string)l[15];
                    gc.Size   = (string)l[16];
                    gc.Edtion = (string)l[17];
                    counts.Add(gc);
                }
                var  countQuery = session.CreateQuery(hsqlCount);
                long count      = (long)(countQuery.UniqueResult());
                DataCollectionResponse <SaleCount> ret = new DataCollectionResponse <SaleCount>(counts, (int)count);
                return(ret);
            }
            finally
            {
                if (session != null)
                {
                    session.Close();
                }
            }
        }