Exemplo n.º 1
0
		public int GetOrderCount (OrderSearchCondition condition)
		{
			var query = _orderRepository.Table;
			try
			{

				if (condition.AdddateBegin.HasValue)
                {
                    query = query.Where(q => q.Adddate>= condition.AdddateBegin.Value);
                }
                if (condition.AdddateEnd.HasValue)
                {
                    query = query.Where(q => q.Adddate < condition.AdddateEnd.Value);
                }


				if (condition.UpddateBegin.HasValue)
                {
                    query = query.Where(q => q.Upddate>= condition.UpddateBegin.Value);
                }
                if (condition.UpddateEnd.HasValue)
                {
                    query = query.Where(q => q.Upddate < condition.UpddateEnd.Value);
                }


				if (condition.Ordertype.HasValue)
                {
                    query = query.Where(q => q.Ordertype == condition.Ordertype.Value);
                }

                if (condition.Shipstatus.HasValue)
                {
                    query = query.Where(q => q.Shipstatus == condition.Shipstatus.Value);
                }


                if (condition.Shipstatuses != null && condition.Shipstatuses.Any())
                {
                    query = query.Where(q => condition.Shipstatuses.Contains(q.Shipstatus));
                }





				if (!string.IsNullOrEmpty(condition.Ordercode))
                {
                    query = query.Where(q => q.Ordercode.Contains(condition.Ordercode));
                }



				if (!string.IsNullOrEmpty(condition.Busname))
                {
                    query = query.Where(q => q.Busname.Contains(condition.Busname));
                }



				if (!string.IsNullOrEmpty(condition.Agentname))
                {
                    query = query.Where(q => q.Agentname.Contains(condition.Agentname));
                }



				if (!string.IsNullOrEmpty(condition.Agenttel))
                {
                    query = query.Where(q => q.Agenttel.Contains(condition.Agenttel));
                }



				if (!string.IsNullOrEmpty(condition.Customname))
                {
                    query = query.Where(q => q.Customname.Contains(condition.Customname));
                }



				if (!string.IsNullOrEmpty(condition.Remark))
                {
                    query = query.Where(q => q.Remark.Contains(condition.Remark));
                }



				if (!string.IsNullOrEmpty(condition.Adduser))
                {
                    query = query.Where(q => q.Adduser.Contains(condition.Adduser));
                }



				if (!string.IsNullOrEmpty(condition.Upduser))
                {
                    query = query.Where(q => q.Upduser.Contains(condition.Upduser));
                }



				if (condition.OrderDetails != null && condition.OrderDetails.Any())
                {
                    query = query.Where(q => condition.OrderDetails.Contains(q.OrderDetail));
                }



                if (condition.Status.HasValue)
                {
                    query = query.Where(q => q.Status == condition.Status.Value);
                }
                if (condition.BusId.HasValue)
                {
                    query = query.Where(q => q.BusId == condition.BusId.Value);
                }
                if (condition.AgentId.HasValue)
                {
                    query = query.Where(q => q.AgentId == condition.AgentId.Value);
                }



				return query.Count();
			}
			catch(Exception e)
			{
				_log.Error(e,"数据库操作出错");
                return -1;
			}
		}
Exemplo n.º 2
0
		public IQueryable<OrderEntity> GetOrdersByCondition(OrderSearchCondition condition)
		{
			var query = _orderRepository.Table;
			try
			{

				if (condition.AdddateBegin.HasValue)
                {
                    query = query.Where(q => q.Adddate>= condition.AdddateBegin.Value);
                }
                if (condition.AdddateEnd.HasValue)
                {
                    query = query.Where(q => q.Adddate < condition.AdddateEnd.Value);
                }


				if (condition.UpddateBegin.HasValue)
                {
                    query = query.Where(q => q.Upddate>= condition.UpddateBegin.Value);
                }
                if (condition.UpddateEnd.HasValue)
                {
                    query = query.Where(q => q.Upddate < condition.UpddateEnd.Value);
                }


				if (condition.Ordertype.HasValue)
                {
                    query = query.Where(q => q.Ordertype == condition.Ordertype.Value);
                }


			    if (condition.Shipstatus.HasValue)
			    {
			        query = query.Where(q => q.Shipstatus == condition.Shipstatus.Value);
			    }


                if (condition.Shipstatuses != null && condition.Shipstatuses.Any())
                {
                    query = query.Where(q => condition.Shipstatuses.Contains(q.Shipstatus));
                }



				if (!string.IsNullOrEmpty(condition.Ordercode))
                {
                    query = query.Where(q => q.Ordercode.Contains(condition.Ordercode));
                }



				if (!string.IsNullOrEmpty(condition.Busname))
                {
                    query = query.Where(q => q.Busname.Contains(condition.Busname));
                }



				if (!string.IsNullOrEmpty(condition.Agentname))
                {
                    query = query.Where(q => q.Agentname.Contains(condition.Agentname));
                }



				if (!string.IsNullOrEmpty(condition.Agenttel))
                {
                    query = query.Where(q => q.Agenttel.Contains(condition.Agenttel));
                }



				if (!string.IsNullOrEmpty(condition.Customname))
                {
                    query = query.Where(q => q.Customname.Contains(condition.Customname));
                }



				if (!string.IsNullOrEmpty(condition.Remark))
                {
                    query = query.Where(q => q.Remark.Contains(condition.Remark));
                }



				if (!string.IsNullOrEmpty(condition.Adduser))
                {
                    query = query.Where(q => q.Adduser.Contains(condition.Adduser));
                }



				if (!string.IsNullOrEmpty(condition.Upduser))
                {
                    query = query.Where(q => q.Upduser.Contains(condition.Upduser));
                }



				if (condition.OrderDetails != null && condition.OrderDetails.Any())
                {
                    query = query.Where(q => condition.OrderDetails.Contains(q.OrderDetail));
                }



                if (condition.Status.HasValue)
                {
                    query = query.Where(q => q.Status == condition.Status.Value);
                }
                if (condition.BusId.HasValue)
                {
                    query = query.Where(q => q.BusId == condition.BusId.Value);
                }
                if (condition.AgentId.HasValue)
                {
                    query = query.Where(q => q.AgentId == condition.AgentId.Value);
                }

             




				if(condition.OrderBy.HasValue)
				{
					switch (condition.OrderBy.Value)
                    {

						case EnumOrderSearchOrderBy.OrderById:
							query = condition.IsDescending ?query.OrderByDescending(q=>q.Id):query.OrderBy(q=>q.Id);
							break;
                        case EnumOrderSearchOrderBy.OrderByAddTime:
                            query = condition.IsDescending ? query.OrderByDescending(q => q.Adddate) : query.OrderBy(q => q.Adddate);
                            break;
                        case EnumOrderSearchOrderBy.OrderByCommission:
                            query = condition.IsDescending ? query.OrderByDescending(q => q.OrderDetail.Commission) : query.OrderBy(q => q.OrderDetail.Commission);
                            break;
                        case EnumOrderSearchOrderBy.OrderByPrice:
                            query = condition.IsDescending ? query.OrderByDescending(q => q.OrderDetail.Price) : query.OrderBy(q => q.OrderDetail.Price);
                            break;
                        case EnumOrderSearchOrderBy.OrderByDealcommission:
                            query = condition.IsDescending ? query.OrderByDescending(q => q.OrderDetail.Dealcommission) : query.OrderBy(q => q.OrderDetail.Dealcommission);
                            break;
                        case EnumOrderSearchOrderBy.OrderByRecCommission:
                            query = condition.IsDescending ? query.OrderByDescending(q => q.OrderDetail.RecCommission) : query.OrderBy(q => q.OrderDetail.RecCommission);
                            break;
                      
                    }
					
				}

				else
				{
					query = query.OrderBy(q=>q.Id);
				}

				if (condition.Page.HasValue && condition.PageCount.HasValue)
                {
                    query = query.Skip((condition.Page.Value - 1)*condition.PageCount.Value).Take(condition.PageCount.Value);
                }
				return query;
			}
			catch(Exception e)
			{
				_log.Error(e,"数据库操作出错");
                return null;
			}
		}
Exemplo n.º 3
0
 public HttpResponseMessage GetOrdersByStatus(int status)
 {
     OrderSearchCondition OSC = new OrderSearchCondition()
     {
         Status = status,
         OrderBy = EnumOrderSearchOrderBy.OrderById
     };
     return PageHelper.toJson(_orderService.GetOrdersByCondition(OSC).ToList());
 }
Exemplo n.º 4
0
 public HttpResponseMessage GetAllDealOrders()
 {
     OrderSearchCondition OSC = new OrderSearchCondition()
     {
         Ordertype = EnumOrderType.成交订单,
         OrderBy = EnumOrderSearchOrderBy.OrderById
     };
     return PageHelper.toJson(_orderService.GetOrdersByCondition(OSC).ToList());
 }
Exemplo n.º 5
0
 public HttpResponseMessage GetNegotiateOrders(int page, int pageSize, int status, bool isDes = true, EnumOrderSearchOrderBy orderByAll = EnumOrderSearchOrderBy.OrderByAddTime)
 {            
     OrderSearchCondition OSC = new OrderSearchCondition()
     {                
         Page = page,
         PageCount = pageSize,
         Status = status,
         Shipstatuses = new []{3,-3},
         IsDescending = isDes,
         OrderBy = orderByAll
     };          
     var orderList = _orderService.GetOrdersByCondition(OSC).Select(a => new
     {
         a.Ordercode,
         a.Id,
         a.Ordertype,
         a.Status,
         a.Shipstatus,
         a.Agentname,
         a.Agenttel,
         a.Busname,
         a.Adddate,
         a.OrderDetail.Price,
         a.OrderDetail.RecCommission,
         a.OrderDetail.Commission,
         a.OrderDetail.Dealcommission
     }).ToList();
     var totalCount = _orderService.GetOrderCount(OSC);
     return PageHelper.toJson(new{OrderList=orderList,TotalCount=totalCount,Condition=OSC});
 }
Exemplo n.º 6
0
 public HttpResponseMessage GetAllRecommonOrders(EnumOrderType type, int page = 1, int pageSize = 10, bool isDes = true, EnumOrderSearchOrderBy orderByAll = EnumOrderSearchOrderBy.OrderById)
 {
     OrderSearchCondition OSC = new OrderSearchCondition()
     {
         IsDescending = isDes,
         Ordertype = type,
         OrderBy = orderByAll,
         Page = page,
         PageCount = pageSize
     };          
     var list = _orderService.GetOrdersByCondition(OSC).Select(p => new 
     {
         p.Ordercode,
         p.Ordertype,
         p.Status,
         p.Shipstatus,
         p.Agentname,
         p.Agenttel,
         p.Busname,
         p.OrderDetail.Price,
         p.OrderDetail.RecCommission,
         p.OrderDetail.Commission,
         p.OrderDetail.Dealcommission
     }).ToList();
     var totalCount1 = _orderService.GetOrderCount(OSC);
     return PageHelper.toJson(new { List = list, Condition = OSC, totalCount = totalCount1 });
 }