/// <summary> /// 清除引用 /// </summary> /// <param name="model"></param> public static void ClearReferences(this TakeoutDetail model) { model.tb_admin = null; model.tb_admin1 = null; model.tb_device = null; model.tb_device1 = null; model.tb_takeout = null; model.tb_product = null; }
/// <summary> /// 计算 /// </summary> /// <param name="details"></param> /// <param name="takeout"></param> /// <param name="IgnoreError"></param> /// <param name="OnlyTotal"></param> /// <param name="IgnoreNotConfirm"></param> /// <param name="IgnoreCanceld"></param> /// <param name="IgnoreCancelId"></param> private void Calc(out List <TakeoutDetail> details, out Takeout takeout, bool IgnoreError = true, bool OnlyTotal = false, bool IgnoreNotConfirm = true, bool IgnoreCanceld = true, long IgnoreCancelId = -999) { details = new List <TakeoutDetail>(); List <TakeoutDetail> detailsAll = new List <TakeoutDetail>(); takeout = new Takeout(); if (!OnlyTotal) { foreach (var item in Selected.CurrentSelectedList) { TakeoutDetail takeoutDetails = new TakeoutDetail(); takeoutDetails.ProductId = item.Product.ProductId; takeoutDetails.IsPack = item.OrderDetail.IsPack; takeoutDetails.Count = item.OrderDetail.Count; if (item.NewPrice.HasValue) { takeoutDetails.Price = item.NewPrice.Value; } else { takeoutDetails.Price = item.OrderDetail.Price; } takeoutDetails.TotalPrice = item.TotalPrice; takeoutDetails.OriginalTotalPrice = Math.Round(item.OrderDetail.Price * item.OrderDetail.Count); takeoutDetails.TotalCostPrice = Math.Round(item.Product.CostPrice * item.OrderDetail.Count); if (item.Product.CostPrice == 0 && null != item.Product.ProductParentId) { Product parentProduct = Resources.GetRes().Products.FirstOrDefault(x => x.ProductId == item.Product.ProductParentId); if (null != parentProduct) { double price = Math.Round(parentProduct.CostPrice / item.Product.ProductParentCount, 2); takeoutDetails.TotalCostPrice = Math.Round(price * takeoutDetails.Count, 2); } } takeoutDetails.TakeoutDetailId = item.OrderDetail.OrderDetailId; takeoutDetails.State = item.OrderDetail.State; takeoutDetails.Request = item.OrderDetail.Request; if (item.IsNew) { details.Add(takeoutDetails); } detailsAll.Add(takeoutDetails); } } IEnumerable <TakeoutDetail> totalDetails = detailsAll; if (IgnoreNotConfirm) { totalDetails = totalDetails.Where(x => x.State != 1); } if (IgnoreCanceld) { totalDetails = totalDetails.Where(x => x.State != 3); } lastTotal = Math.Round(totalDetails.Sum(x => x.TotalPrice), 2); lastOriginalTotalPrice = Math.Round(totalDetails.Sum(x => x.OriginalTotalPrice), 2); if (IgnoreCancelId != -999 && totalDetails.Where(x => x.TakeoutDetailId == IgnoreCancelId).Count() > 0) { lastTotal = Math.Round(lastTotal - totalDetails.Where(x => x.TakeoutDetailId == IgnoreCancelId).FirstOrDefault().TotalPrice, 2); lastOriginalTotalPrice = Math.Round(lastOriginalTotalPrice - totalDetails.Where(x => x.TakeoutDetailId == IgnoreCancelId).FirstOrDefault().OriginalTotalPrice, 2); } takeout.Lang = Language.LanguageMode; takeout.IsPack = 0; takeout.TotalPaidPrice = Math.Round(takeout.MemberPaidPrice + takeout.PaidPrice, 2); Selected.TotalPrice = takeout.TotalPrice = lastTotal; takeout.OriginalTotalPrice = lastOriginalTotalPrice; double balancePrice = 0; balancePrice = Math.Round(takeout.TotalPaidPrice - takeout.TotalPrice, 2); if (balancePrice > 0) { takeout.KeepPrice = balancePrice; takeout.BorrowPrice = 0; } else if (balancePrice < 0) { takeout.BorrowPrice = balancePrice; takeout.KeepPrice = 0; } else if (balancePrice == 0) { takeout.BorrowPrice = 0; takeout.KeepPrice = 0; } // 显示客显(实际客户需要支付的赊账) Common.GetCommon().OpenPriceMonitor(takeout.BorrowPrice.ToString()); // 刷新第二屏幕 if (FullScreenMonitor.Instance._isInitialized) { FullScreenMonitor.Instance.RefreshSecondMonitorList(new Res.View.Models.BillModel(takeout, details, null)); } if (OnlyTotal) { return; } }
/// <summary> /// 计算 /// </summary> /// <param name="details"></param> /// <param name="import"></param> /// <param name="IgnoreError"></param> /// <param name="OnlyTotal"></param> private void Calc(out List <TakeoutDetail> details, out Takeout takeout, bool IgnoreError = true, bool OnlyTotal = false, bool IgnoreNotConfirm = true, bool IgnoreCanceld = true, long IgnoreCancelId = -999) { details = new List <TakeoutDetail>(); List <TakeoutDetail> detailsAll = new List <TakeoutDetail>(); takeout = new Takeout(); if (!OnlyTotal) { foreach (var item in Selected.CurrentSelectedList) { TakeoutDetail orderDetails = new TakeoutDetail(); orderDetails.ProductId = item.Product.ProductId; orderDetails.IsPack = item.OrderDetail.IsPack; orderDetails.Count = item.OrderDetail.Count; if (item.NewPrice.HasValue) { orderDetails.Price = item.NewPrice.Value; } else { orderDetails.Price = item.OrderDetail.Price; } orderDetails.TotalPrice = item.TotalPrice; orderDetails.OriginalTotalPrice = Math.Round(item.OrderDetail.Price * item.OrderDetail.Count); orderDetails.TotalCostPrice = Math.Round(item.Product.CostPrice * item.OrderDetail.Count); if (item.Product.CostPrice == 0 && null != item.Product.ProductParentId) { Product parentProduct = Resources.Instance.Products.FirstOrDefault(x => x.ProductId == item.Product.ProductParentId); if (null != parentProduct) { double price = Math.Round(parentProduct.CostPrice / item.Product.ProductParentCount, 2); orderDetails.TotalCostPrice = Math.Round(price * orderDetails.Count, 2); } } orderDetails.TakeoutDetailId = item.OrderDetail.OrderDetailId; orderDetails.State = item.OrderDetail.State; orderDetails.Request = item.OrderDetail.Request; if (item.IsNew) { details.Add(orderDetails); } detailsAll.Add(orderDetails); } } //if (!OnlyTotal) //{ IEnumerable <TakeoutDetail> totalDetails = detailsAll; if (IgnoreNotConfirm) { totalDetails = totalDetails.Where(x => x.State != 1); } if (IgnoreCanceld) { totalDetails = totalDetails.Where(x => x.State != 3); } lastTotal = Math.Round(totalDetails.Sum(x => x.TotalPrice), 2); lastOriginalTotalPrice = Math.Round(totalDetails.Sum(x => x.OriginalTotalPrice), 2); if (IgnoreCancelId != -999 && totalDetails.Where(x => x.TakeoutDetailId == IgnoreCancelId).Count() > 0) { lastTotal = Math.Round(lastTotal - totalDetails.Where(x => x.TakeoutDetailId == IgnoreCancelId).FirstOrDefault().TotalPrice, 2); lastOriginalTotalPrice = Math.Round(lastOriginalTotalPrice - totalDetails.Where(x => x.TakeoutDetailId == IgnoreCancelId).FirstOrDefault().OriginalTotalPrice, 2); } //} takeout.Lang = Selected.LanguageMode; takeout.IsPack = 0; takeout.TotalPaidPrice = Math.Round(takeout.MemberPaidPrice + takeout.PaidPrice, 2); Selected.TotalPrice = takeout.TotalPrice = lastTotal; takeout.OriginalTotalPrice = lastOriginalTotalPrice; double balancePrice = 0; balancePrice = Math.Round(takeout.TotalPaidPrice - takeout.TotalPrice, 2); if (balancePrice > 0) { takeout.KeepPrice = balancePrice; takeout.BorrowPrice = 0; } else if (balancePrice < 0) { takeout.BorrowPrice = balancePrice; takeout.KeepPrice = 0; } else if (balancePrice == 0) { takeout.BorrowPrice = 0; takeout.KeepPrice = 0; } if (OnlyTotal) { return; } }