public CommonRtnEntity GetBuyOrderInfo([FromBody] SearchBase <string> searchInfo) { IBuyOrderInfoServices services = new BuyOrderInfoServices(); BuyOrderInfo orderInfo = services.QueryByID(searchInfo.Data); List <WareInfo> wareList = new List <WareInfo>(); if (orderInfo != null) { wareList = (new WareInfoServices()).Query(ware => ware.OrderID == orderInfo.ID); } CommonRtnEntity rtnInfo = new CommonRtnEntity() { Success = orderInfo != null, Data = new { Info = orderInfo, WareList = wareList }, Message = orderInfo != null ? "查询成功!" : "查询失败!" }; return(rtnInfo); }
public CommonRtnEntity Delete([FromBody] object [] ids) { IBuyOrderInfoServices services = new BuyOrderInfoServices(); bool result = services.DeleteByIds(ids); if (result) { //删除订单也需要删除商品 WareInfoServices wareServices = new WareInfoServices(); List <string> orderIDList = new List <string>(); for (int i = 0; i < ids.Length; i++) { orderIDList.Add(ids[i] + ""); } wareServices.DeleteByOrderID(orderIDList); } CommonRtnEntity rtnInfo = new CommonRtnEntity() { Success = result, Data = result, Message = result ? "删除成功!":"删除失败" }; return(rtnInfo); }
public CommonRtnEntity GetOrderSituation([FromBody] SearchBase <BuyOrderSearch> searchInfo) { IBuyOrderInfoServices services = new BuyOrderInfoServices(); DateTime start = DateTime.Parse(DateTime.Now.AddDays(-15).ToString("yyyy-MM-dd")); DateTime end = DateTime.Now; List <BuyOrderInfo> list = null; list = services.Query(d => d.CreateTime >= start && d.CreateTime <= end ); List <string> xList = new List <string>(); Dictionary <string, List <double> > data = new Dictionary <string, List <double> >(); data.Add("PO", new List <double>()); data.Add("SO", new List <double>()); IEnumerable <IGrouping <string, BuyOrderInfo> > query = list.GroupBy(pet => pet.CreateTime.Value.ToString("MM-dd"), pet => pet); for (int i = 0; i < (end - start).TotalDays; i++) { string dayStr = start.AddDays(i).ToString("MM-dd"); xList.Add(dayStr); List <BuyOrderInfo> todayList = new List <BuyOrderInfo>(); IGrouping <string, BuyOrderInfo> groupToday = query.Where(x => x.Key == dayStr).FirstOrDefault(); if (groupToday != null) { todayList = groupToday.ToList(); } double poTotalMoney = todayList.Where(x => x.OrderType == "PO").Sum(x => x.TotalMoney); double soTotalMoney = todayList.Where(x => x.OrderType == "SO").Sum(x => x.TotalMoney); data["PO"].Add(poTotalMoney); data["SO"].Add(soTotalMoney); } CommonRtnEntity rtnInfo = new CommonRtnEntity() { Success = list.Count > 0, Data = new { XList = xList, Data = data }, Message = "查询成功!" }; return(rtnInfo); }
public CommonRtnEntity SetIsInvoice([FromBody] object[] ids) { BuyOrderInfoServices services = new BuyOrderInfoServices(); bool result = services.SetIsInvoice(ids, true); CommonRtnEntity rtnInfo = new CommonRtnEntity() { Success = result, Data = result, Message = result ? "标记开票成功!" : "标记开票失败" }; return(rtnInfo); }
public CommonRtnEntity Add([FromBody] InOrderInfo info) { IBuyOrderInfoServices services = new BuyOrderInfoServices(); int result = 0; //编辑 if (info.Info.ID > 0) { info.Info.UpdateTime = DateTime.Now; services.Update(info.Info); result = info.Info.ID; List <WareInfo> wareList = (new WareInfoServices()).Query(ware => ware.OrderID == info.Info.ID); if (wareList.Count > 0) { (new WareInfoServices()).DeleteByIds(wareList.Select(x => x.ID + "").ToArray()); } } else { result = services.Add(info.Info); } if (result > 0) { foreach (var item in info.WareList) { item.OrderID = result; (new WareInfoServices()).Add(item); } } CommonRtnEntity rtnInfo = new CommonRtnEntity() { Success = result > 0, Data = result, Message = result > 0 ? "添加成功!":"添加失败!" }; return(rtnInfo); }
public CommonRtnEntity GetList([FromBody] SearchBase <BuyOrderSearch> searchInfo) { BuyOrderInfoServices services = new BuyOrderInfoServices(); int totalCount = 0; //string name= CurrentUserInfo.Name ; List <BuyOrderInfo> list = services.QueryPage(searchInfo, out totalCount); CommonRtnEntity rtnInfo = new CommonRtnEntity() { Success = list.Count > 0, Data = new { TotalCount = totalCount, Data = list }, Message = "查询成功!" }; return(rtnInfo); }