/// <summary> /// 根据请购买申请单重新初始化购物车 /// </summary> /// <param name="ApplyID"></param> /// <returns></returns> public static ORD_OrderCartBLL InitByOrderApply(int OrderID) { ORD_OrderBLL Order = new ORD_OrderBLL(OrderID); if (Order.Model == null) { return(null); } ORD_PublishBLL publish = new ORD_PublishBLL(Order.Model.PublishID); if (publish.Model == null) { return(null); } ORD_OrderCartBLL cart = new ORD_OrderCartBLL(Order.Model.AccountMonth, Order.Model.PublishID, Order.Model.Client, Order.Model.Supplier, Order.Model.Classify, Order.Model.PayMode, Order.Model.ReqWarehouse, Order.Model.ReqArrivalDate); int quotaid = ORD_QuotaBLL.GetQuotaByClientAndMonth(cart.Client, cart.AccountMonth); ORD_QuotaBLL quota = new ORD_QuotaBLL(quotaid); foreach (ORD_OrderDetail item in Order.Items) { ORD_PublishDetail _m = publish.Items.FirstOrDefault(m => m.Product == item.Product); if (_m == null) { continue; } ORD_OrderCartItem cartitem = new ORD_OrderCartItem(); cartitem.ID = _m.ID; cartitem.Product = _m.Product; cartitem.MinQuantity = _m.MinQuantity; cartitem.MaxQuantity = _m.MaxQuantity; cartitem.Price = item.Price; cartitem.AvailableQuantity = _m.AvailableQuantity; cartitem.SubmitQuantity = ORD_OrderBLL.GetSubmitQuantity(Order.Model.AccountMonth, Order.Model.Client, _m.Product, Order.Model.Classify == 1 ? 1 : 0); cartitem.BookQuantity = item.BookQuantity; cartitem.Points = item.Points; #region 获取配额数量 if (quota.Model != null) { ORD_QuotaDetail d = quota.Items.FirstOrDefault(p => p.Product == _m.Product); if (d != null) { cartitem.QuotaQuantity = d.StdQuota + d.AdjQuota; } } #endregion cart.Items.Add(cartitem); } return(cart); }
/// <summary> /// 根据请购买申请单重新初始化购物车 /// </summary> /// <param name="ApplyID"></param> /// <returns></returns> public static ORD_OrderCartBLL InitByOrderApply(int OrderID) { ORD_OrderBLL Order = new ORD_OrderBLL(OrderID); if (Order.Model == null) return null; ORD_PublishBLL publish = new ORD_PublishBLL(Order.Model.PublishID); if (publish.Model == null) return null; ORD_OrderCartBLL cart = new ORD_OrderCartBLL(Order.Model.AccountMonth, Order.Model.PublishID, Order.Model.Client, Order.Model.Supplier, Order.Model.Classify, Order.Model.PayMode, Order.Model.ReqWarehouse, Order.Model.ReqArrivalDate); int quotaid = ORD_QuotaBLL.GetQuotaByClientAndMonth(cart.Client, cart.AccountMonth); ORD_QuotaBLL quota = new ORD_QuotaBLL(quotaid); foreach (ORD_OrderDetail item in Order.Items) { ORD_PublishDetail _m = publish.Items.FirstOrDefault(m => m.Product == item.Product); if (_m == null) continue; ORD_OrderCartItem cartitem = new ORD_OrderCartItem(); cartitem.ID = _m.ID; cartitem.Product = _m.Product; cartitem.MinQuantity = _m.MinQuantity; cartitem.MaxQuantity = _m.MaxQuantity; cartitem.Price = item.Price; cartitem.AvailableQuantity = _m.AvailableQuantity; cartitem.SubmitQuantity = ORD_OrderBLL.GetSubmitQuantity(Order.Model.AccountMonth, Order.Model.Client, _m.Product, Order.Model.Classify == 1 ? 1 : 0); cartitem.BookQuantity = item.BookQuantity; cartitem.Points = item.Points; #region 获取配额数量 if (quota.Model != null) { ORD_QuotaDetail d = quota.Items.FirstOrDefault(p => p.Product == _m.Product); if (d != null) cartitem.QuotaQuantity = d.StdQuota + d.AdjQuota; } #endregion cart.Items.Add(cartitem); } return cart; }