示例#1
0
        /// <summary>
        /// 生成厨房单图片
        /// </summary>
        protected Bitmap generateKitchenOrderBmp(DineForPrinting protocol, DineMenu dineMenu, SetMealMenu setMealMenu)
        {
            Bitmap   bmp        = new Bitmap(protocol.PrinterFormat.PaperSize, maxHeight);
            Graphics g          = Graphics.FromImage(bmp);
            int      realHeight = drawKitchenOrder(g, protocol, dineMenu, setMealMenu);

            return(cutBmp(bmp, realHeight));
        }
示例#2
0
        /// <summary>
        /// 根据Graphics绘制厨房单
        /// </summary>
        protected int drawKitchenOrder(Graphics g, DineForPrinting protocol, DineMenu dineMenu, SetMealMenu setMealMenu)
        {
            PrinterGraphics printerG = new PrinterGraphics(g, protocol.PrinterFormat.PaperSize, protocol.PrinterFormat.Font, protocol.PrinterFormat.PaddingRight);

            printerG.DrawStringLine(dineMenu.Menu.DepartmentName, protocol.PrinterFormat.KitchenOrderFontSize);

            printerG.DrawStringLine($"单号: {protocol.Dine.Id}", protocol.PrinterFormat.KitchenOrderSmallFontSize);
            printerG.DrawStringLine($"时间: {protocol.Dine.BeginTime.ToString("M-d HH:mm")}", protocol.PrinterFormat.KitchenOrderSmallFontSize);

            if (dineMenu.Status == HotelDAO.Models.DineMenuStatus.Returned)
            {
                string returnStr = "退菜";
                if (dineMenu.ReturnedReason != null)
                {
                    returnStr += $", 理由: {dineMenu.ReturnedReason}";
                }
                printerG.DrawStringLine(returnStr, protocol.PrinterFormat.KitchenOrderFontSize);
            }

            printerG.DrawStringLine($"餐桌: {protocol.Dine.Desk.Name}", protocol.PrinterFormat.KitchenOrderFontSize);

            printGrid82(printerG, new string[] { dineMenu.Menu.Name, dineMenu.Count.ToString() }, protocol.PrinterFormat.KitchenOrderFontSize);

            if (setMealMenu != null)
            {
                printGrid82(printerG, new string[] { $"└ {setMealMenu.Name}", setMealMenu.Count.ToString() }, protocol.PrinterFormat.KitchenOrderFontSize);
            }

            // 打印菜品的备注信息
            var remarks = dineMenu.Remarks.ToList();

            for (int i = 0; i < dineMenu.Remarks.Count; i++)
            {
                char tab = '├';
                if (i == dineMenu.Remarks.Count - 1)
                {
                    tab = '└';
                }
                printGrid82(printerG, new string[] { $"{tab} {remarks[i].Name}", null, }, protocol.PrinterFormat.KitchenOrderFontSize);
            }

            printEnd(printerG);

            return(printerG.GetHeight());
        }
示例#3
0
        /// <summary>
        /// 处理每个菜品
        /// </summary>
        private async Task <FunctionResult> handleDineMenu(List <MenuExtensionWithGift> menuExtensionWithGifts, Dine dine)
        {
            List <DineMenu> addedDineMenus = new List <DineMenu>();

            foreach (MenuExtensionWithGift menuExtensionWithGift in menuExtensionWithGifts)
            {
                MenuExtension menuExtension = menuExtensionWithGift.MenuExtension;
                Menu          menu          = await ctx.Menus
                                              .Include(p => p.MenuPrice)
                                              .FirstOrDefaultAsync(p => p.Id == menuExtension.Id);

                // 菜品判断
                if (menu == null)
                {
                    return(new FunctionResult(false, "未找到菜品", $"No Menu {menuExtension.Id}"));
                }
                if (!menu.Usable)
                {
                    return(new FunctionResult(false, $"{menu.Name} 不可用", $"Menu Disabled {menu.Id}: {menu.Name}"));
                }
                if (menu.Status == MenuStatus.SellOut)
                {
                    return(new FunctionResult(false, $"{menu.Name} 已售完", $"Menu SellOut {menu.Id}: {menu.Name}"));
                }

                DineMenu dineMenu = new DineMenu {
                    Count       = menuExtension.Ordered,
                    OriPrice    = menu.MenuPrice.Price,
                    Price       = menuExtensionWithGift.IsGift ? 0 : menu.MenuPrice.Price,
                    RemarkPrice = 0,

                    Menu    = menu,
                    Remarks = new List <Remark>(),
                    Type    = menuExtensionWithGift.IsGift ? DineMenuType.Gift : DineMenuType.None
                };

                if (!menuExtensionWithGift.IsGift)
                {
                    // 是否排除在总单打折之外
                    bool excludePayDiscount = menu.MenuPrice.ExcludePayDiscount;

                    // 是否打折
                    if (menu.MenuPrice.Discount < 1)
                    {
                        excludePayDiscount = true;
                        dineMenu.Price     = menu.MenuPrice.Price * (decimal)menu.MenuPrice.Discount;
                        dineMenu.Type      = DineMenuType.MenuDiscount;
                    }
                    // 是否为特价菜
                    DayOfWeek  week        = DateTime.Now.DayOfWeek;
                    MenuOnSale menuOnSales = await ctx.MenuOnSales.FirstOrDefaultAsync(p => p.Id == menu.Id && p.OnSaleWeek == week);

                    if (menuOnSales != null)
                    {
                        excludePayDiscount = true;
                        dineMenu.Price     = menuOnSales.Price;
                        dineMenu.Type      = DineMenuType.OnSale;
                    }
                    // 是否为套餐
                    var menuSetMeals = await ctx.MenuSetMeals.FirstOrDefaultAsync(p => p.MenuSetId == menu.Id && p.Menu.IsSetMeal);

                    if (menuSetMeals != null)
                    {
                        excludePayDiscount = true;
                        dineMenu.Type      = DineMenuType.SetMeal;
                    }

                    if (!excludePayDiscount)
                    {
                        dineMenu.Price = menu.MenuPrice.Price * (decimal)dine.Discount;
                        switch (dine.DiscountType)
                        {
                        case DiscountType.PayKind:
                            dineMenu.Type = DineMenuType.PayKindDiscount;
                            break;

                        case DiscountType.Vip:
                            dineMenu.Type = DineMenuType.VipDiscount;
                            break;

                        case DiscountType.Time:
                            dineMenu.Type = DineMenuType.TimeDiscount;
                            break;

                        case DiscountType.Custom:
                            dineMenu.Type = DineMenuType.CustomDiscount;
                            break;
                        }
                    }
                }

                // 菜品备注处理
                foreach (int remarkId in menuExtension.Remarks)
                {
                    Remark remark = await ctx.Remarks.FirstOrDefaultAsync(p => p.Id == remarkId);

                    if (remark == null)
                    {
                        return(new FunctionResult(false, "未找到备注信息", $"No Remark {remarkId}"));
                    }

                    if (!menuExtensionWithGift.IsGift)
                    {
                        dineMenu.RemarkPrice += remark.Price;
                    }

                    dineMenu.Remarks.Add(remark);
                }

                dine.Price    += dineMenu.Price * dineMenu.Count + dineMenu.RemarkPrice;
                dine.OriPrice += dineMenu.OriPrice * dineMenu.Count + dineMenu.RemarkPrice;

                addedDineMenus.Add(dineMenu);
                dine.DineMenus.Add(dineMenu);
            }

            return(new FunctionResult(true, addedDineMenus));
        }