示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public DishOrder GetDishOrderById(int orderId)
        {
            string    sql       = "SELECT * FROM DishOrder WHERE OrderId = @OrderId;";
            DishOrder dishOrder = new DishOrder();

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@OrderId", orderId)
            };

            SqlDataReader objReader = SQLHelper.GetReader(sql, param);

            if (objReader.Read())
            {
                dishOrder = new DishOrder()
                {
                    OrderId     = Convert.ToInt32(objReader["OrderId"]),
                    DeskId      = Convert.ToInt32(objReader["DeskId"]),
                    DishDetails = GetDishOrderDetailByOrderId(orderId),
                    SumPrice    = Convert.ToInt32(objReader["SumPrice"]),
                    OrderTime   = Convert.ToDateTime(objReader["OrderTime"])
                };
            }
            objReader.Close();
            return(dishOrder);
        }
示例#2
0
        public void CommandModeTest()
        {
            Console.WriteLine("======== 命令模式測試 =========");

            //開店準備
            Chef      chef       = new Chef();
            Bartender bartender  = new Bartender();
            Order     dishOrder  = new DishOrder(chef);
            Order     drinkOrder = new DrinkOrder(bartender);
            Waitress  cuteGirl   = new Waitress();

            //開始營業 客戶點餐
            cuteGirl.SetOrder(dishOrder);
            cuteGirl.SetOrder(dishOrder);
            cuteGirl.SetOrder(drinkOrder);
            cuteGirl.SetOrder(drinkOrder);

            //飲料還沒賣完
            cuteGirl.SetOrder(drinkOrder);

            Console.WriteLine("===== 客人取消熱炒測試 =====");
            //取消一份熱炒
            cuteGirl.CancelOrder(dishOrder);
            //熱炒又可以賣了
            cuteGirl.SetOrder(dishOrder);

            Console.WriteLine("=== 點餐完成 通知廚房 ===");
            cuteGirl.NotifyKitchen();

            Console.WriteLine("=== 熱炒庫存不足測試 ===");
            cuteGirl.SetOrder(dishOrder);

            Assert.AreEqual(1, 1);
        }
示例#3
0
        /// <summary>
        /// 将订单保存到数据库
        /// </summary>
        /// <param name="dishOrder"></param>
        /// <returns></returns>
        public HttpResult SaveDishOrder(DishOrder dishOrder)
        {
            string sql = string.Format("INSERT INTO DishOrder VALUES(@DeskId,@SumPrice,@OrderTime);SELECT SCOPE_IDENTITY();");

            SqlParameter[] param =
            {
                new SqlParameter("@DeskId",   dishOrder.DeskId),
                new SqlParameter("@SumPrice", dishOrder.SumPrice),
            };
            int orderId = Convert.ToInt32(SQLHelper.GetSingleResult(sql, param));

            if (orderId > 0)
            {
                DataTable dt = DishOrderDetail.TableSchema;
                foreach (DishOrderDetail detail in dishOrder.DishDetails)
                {
                    DataRow dr = dt.NewRow();
                    dr["OrderId"]   = orderId;
                    dr["DishId"]    = detail.DishId;
                    dr["DishCount"] = detail.DishCount;
                    dt.Rows.Add(dr);
                }
                SQLHelper.MultyInsert(dt);
                return(new HttpResult(true, "ok"));
            }
            return(new HttpResult(false, "error"));
        }
示例#4
0
        /// <summary>
        /// 餐饮打印订单
        /// </summary>
        /// <param name="food"></param>
        /// <param name="order"></param>
        /// <param name="carts"></param>
        /// <param name="foodPrintList"></param>
        /// <param name="account">加传参数,打单失败会通过提示该用户,若不想提示,可传null</param>
        /// <returns></returns>
        public static void DishPrintOrder(DishStore store, DishOrder order, List <DishShoppingCart> carts, List <DishPrint> prints)
        {
            if (store == null || order == null || carts == null || !carts.Any() || prints == null || !prints.Any())
            {
                log4net.LogHelper.WriteInfo(typeof(PrinterHelper), $"参数为空导致无法打印:dishStore:{store == null},order :{ order == null }, carts: {carts == null || !carts.Any()}, foodPrintList : {prints == null || !prints.Any()}");
                return;
            }

            prints.ForEach(print =>
            {
                if (print.print_d_type == 1)                                                      //整单打印
                {
                    string totalPrintContent = GetPrintContent_Total(store, order, carts, print); //整单打印内容
                    if (!string.IsNullOrWhiteSpace(totalPrintContent))                            //当此打印的设定打单匹配到有要打印的内容时,才去打印
                    {
                        FoodYiLianYunPrintHelper.printContent(print.apiPrivateKey, print.platform_userId.ToString(), print.print_bianma, print.print_shibiema, totalPrintContent);
                    }
                }
                else //分单打印
                {
                    List <string> singlePrintContentsByGoods = GetPrintContent_Part(store, order, carts, print); //分单(按菜品)打印内容
                    if (singlePrintContentsByGoods?.Count > 0)
                    {
                        foreach (string content in singlePrintContentsByGoods)
                        {
                            if (!string.IsNullOrWhiteSpace(content))//当此打印的设定打单匹配到有要打印的内容时,才去打印
                            {
                                FoodYiLianYunPrintHelper.printContent(print.apiPrivateKey, print.platform_userId.ToString(), print.print_bianma, print.print_shibiema, content);
                            }
                        }
                    }
                }
            });
        }
        public string AddOrUpdateDishOrder(DishOrder order)
        {
            string orderID = (order.OrderID == "") ? GenerateDishOrderID(order) : order.OrderID;
            string err     = AddOrUpdateOrderBasicInfo(order, orderID);

            if (err != "")
            {
                return(err);
            }

            if (order.GetVipID() != "")
            {
                err = AddOrUpdateVIPInOrder(orderID, order.GetVipID(), true);
                if (err != "")
                {
                    return(err);
                }
            }

            err = AddOrUpdateFoodInOrder(orderID, order.OrderItems);
            if (err != "")
            {
                return(err);
            }

            return("");
        }
示例#6
0
        public async Task <IActionResult> Edit(int id, [Bind("DishID,OrderID")] DishOrder dishOrder)
        {
            if (id != dishOrder.DishID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dishOrder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DishOrderExists(dishOrder.DishID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DishID"]  = new SelectList(_context.Dish, "DishID", "DishName", dishOrder.DishID);
            ViewData["OrderID"] = new SelectList(_context.Set <Order>(), "OrderID", "OrderID", dishOrder.OrderID);
            return(View(dishOrder));
        }
示例#7
0
 /// <summary>
 /// 根据参数配置打单
 /// </summary>
 /// <param name="order"></param>
 /// <param name="print_type">打单类型 0:直接所有相关打印机打单 1:下单后打单 2.支付后打单</param>
 public static void DishPrintOrderByPrintType(DishOrder order, DishStore store, List <DishShoppingCart> carts, int print_type = 0, string printerIds = null)
 {
     Task.Factory.StartNew(() =>
     {
         List <DishPrint> prints = string.IsNullOrWhiteSpace(printerIds) ? DishPrintBLL.SingleModel.GetPrintsByParams(store.aid, store.id, print_type) : DishPrintBLL.SingleModel.GetByIds(printerIds);
         DishPrintOrder(store, order, carts, prints);
     });
 }
示例#8
0
        public async Task <IActionResult> Create([Bind("DishID,OrderID")] DishOrder dishOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dishOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DishID"]  = new SelectList(_context.Dish, "DishID", "DishName", dishOrder.DishID);
            ViewData["OrderID"] = new SelectList(_context.Set <Order>(), "OrderID", "OrderID", dishOrder.OrderID);
            return(View(dishOrder));
        }
示例#9
0
        /// <summary>
        /// 根据参数配置打单
        /// </summary>
        /// <param name="order"></param>
        /// <param name="print_type">打单类型 0:直接所有相关打印机打单 1:下单后打单 2.支付后打单</param>
        public static void DishPrintOrderByPrintType(DishOrder order, int print_type = 0, string printerIds = null)
        {
            if (order == null)
            {
                return;
            }
            DishStore store = DishStoreBLL.SingleModel.GetModel(order.storeId);

            if (store == null)
            {
                return;
            }
            List <DishShoppingCart> carts = DishShoppingCartBLL.SingleModel.GetCartsByOrderId(order.id);

            DishPrintOrderByPrintType(order, store, carts, print_type, printerIds);
        }
示例#10
0
        /// <summary>
        /// 根据桌号和带菜品编号的菜品生成菜单
        /// </summary>
        /// <param name="deskId"></param>
        /// <param name="orderDetails"></param>
        /// <returns></returns>
        public DishOrder GenerateDishOrder(int deskId, List <DishOrderDetail> orderDetails)
        {
            // 补全DishOrderDetail中的Dish属性值
            CompleteDishDetailsWithTheirIds(orderDetails);
            // 根据补全后的DishOrderDetail获取餐品总价
            int sumPrice = GetSumPriceByDishOrderDetailList(orderDetails);

            DishOrder dishOrder = new DishOrder();

            dishOrder.DeskId      = deskId;
            dishOrder.DishDetails = orderDetails;
            dishOrder.SumPrice    = sumPrice;
            dishOrder.OrderTime   = DateTime.Now;

            return(dishOrder);
        }
示例#11
0
        public JsonResult Remark(DishStore store, int?orderId, string remark = null)
        {
            if (!orderId.HasValue)
            {
                return(ApiModel(message: "参数不能为空[orderId]"));
            }

            DishOrder         order     = DishOrderBLL.SingleModel.GetModel(orderId.Value);
            DishOrderAttrbute orderAttr = order.GetAttrbute();

            orderAttr.mark = remark;
            order.attrbute = JsonConvert.SerializeObject(orderAttr);

            bool success = DishOrderBLL.SingleModel.Update(order, "attrbute");

            return(ApiModel(isok: success, message: success ? "操作成功" : "操作失败"));
        }
示例#12
0
        public async Task <IActionResult> CartCheckout()
        {
            //this is a horrible implementation cause im doing same calculations twice
            // will need to get back to it later :^);

            var dishIds = HttpContext.Session.Get <List <int> >("cart");

            if (dishIds is null || dishIds.Count < 1)
            {
                return(Redirect("/"));
            }
            var cartItems = await CalculatePrice(dishIds);

            var data = cartItems.First();
            //creating the new order object
            Order order = new Order();

            order.State = Order.OrderState.Paid;
            var id = User.FindFirstValue(ClaimTypes.NameIdentifier);

            order.ClientId    = id;
            order.DeliveryFee = (double)data.DeliveryFee;
            Dish dish = await _context.Dish.FindAsync(data.Dish.Id);

            order.RestaurantId = dish.RestaurantId;
            _context.Order.Add(order);
            foreach (var item in cartItems)
            {
                DishOrder dishorder = new DishOrder();
                dishorder.Dish    = _context.Dish.Find(item.Dish.Id);
                dishorder.DishId  = item.Dish.Id;
                dishorder.order   = order;
                dishorder.OrderId = order.Id;
                dishorder.Amount  = item.ItemCount;
                _context.DishOrders.Add(dishorder);
            }
            await _context.SaveChangesAsync();

            _flashMessage.Confirmation("Food is on the way :^)");

            //flushing session cart data
            HttpContext.Session.Set <List <int> >("cart", new List <int>());

            return(Redirect("/"));
        }
示例#13
0
        public JsonResult UpdateItem(DishStore store, int?itemId, int count = 0)
        {
            if (!itemId.HasValue)
            {
                return(ApiModel(message: "参数不能为空[itemId]"));
            }

            DishShoppingCart item = DishShoppingCartBLL.SingleModel.GetModel(itemId.Value);

            if (item == null)
            {
                return(ApiModel(message: "订单商品不存在"));
            }

            DishOrder order = DishOrderBLL.SingleModel.GetModel(item.order_id);

            if (order.huodong_manjin_jiner > 0 && order.huodong_manjian_id == 0)
            {
                return(ApiModel(message: "2018-8-13前享受满减的订单,不能修改"));
            }

            List <DishShoppingCart> carts = DishShoppingCartBLL.SingleModel.GetShoppingCart(item.aId, item.storeId, item.user_id, order.id) ?? new List <DishShoppingCart>(); //购物车
            List <DishGood>         goods = DishGoodBLL.SingleModel.GetGoodsByIds(carts.Select(c => c.goods_id)?.ToArray());                                                  //购物车内商品详细资料

            if (goods == null || carts.Any(c => !goods.Any(g => c.goods_id == g.id)))
            {
                return(ApiModel(message: "菜品不存在"));
            }

            item.goods_number += count;
            if (item.goods_number < 0)
            {
                item.goods_number = 0;
            }

            if (item.goods_number <= 0 && carts.Count == 1)
            {
                return(ApiModel(message: "订单至少要有一个菜品"));
            }

            DishReturnMsg result      = new DishReturnMsg();
            bool          buildResult = DishOrderBLL.SingleModel.ReBuildOrder(order, store, item, carts, goods, result);

            return(ApiModel(isok: buildResult, message: buildResult ? "设置成功" : "设置失败"));
        }
示例#14
0
        public JsonResult Print(DishStore store, int?orderId, string printer = null)
        {
            if (!orderId.HasValue)
            {
                return(ApiModel(message: "参数不能为空[orderId]"));
            }

            DishOrder order = DishOrderBLL.SingleModel.GetModel(orderId.Value);

            try
            {
                PrinterHelper.DishPrintOrderByPrintType(order, 0, printer);
            }
            catch (Exception ex)
            {
                return(ApiModel(message: ex.Message));
            }

            return(ApiModel(isok: true, message: "操作成功"));
        }
示例#15
0
        private void buttonAddDishToOrder_Click(object sender, EventArgs e)
        {
            Dish           selectedDish    = _orderHelpers.GetDishById(dataGridViewMenu.SelectedRows[0].Cells["DishIdentifier"].Value.ToString());
            IList <Extras> availableExtras = _orderHelpers.GetAvailableExtrasForCategory(selectedDish.DishCategory);

            DishOrder dishOrder = new DishOrder
            {
                DishIdentifier = selectedDish.DishIdentifier,
                Quantity       = Convert.ToInt32(numericUpDownDishQuantity.Value)
            };


            if (availableExtras.Any())
            {
                using (ChooseExtrasDialog chooseExtrasDialogForm = new ChooseExtrasDialog(availableExtras))
                {
                    chooseExtrasDialogForm.ShowDialog();
                    dishOrder.Extras = new List <string>();
                    IList <Extras> selectedExtras = chooseExtrasDialogForm.SelectedExtras;
                    if (selectedExtras != null)
                    {
                        foreach (var selectedExtra in selectedExtras)
                        {
                            dishOrder.Extras.Add(selectedExtra.ExtrasIdentifier);
                        }
                    }

                    if (chooseExtrasDialogForm.DialogResult == DialogResult.OK)
                    {
                        _appState.DishesInOrder.Add(dishOrder);
                        numericUpDownDishQuantity.Value = 1;
                    }
                }
            }
            else
            {
                _appState.DishesInOrder.Add(dishOrder);
                numericUpDownDishQuantity.Value = 1;
            }
        }
        public string GenerateDishOrderID(DishOrder order)
        {
            string res = "DIOR";

            if (order.GetVipID() == "")
            {
                res += "R";
            }
            else
            {
                res += "V";
            }
            res += "N_";     // Hiện chưa có chức băng voucher
            res += order.DateCreated.Value.Date.ToString("ddMMyy") + "_";

            Table <DAL.OrderBasicInfo> orderTable = GetOrderBasicInfoTable();
            var matchedRes = (from o in orderTable
                              where o.orderID.Contains(res) == true
                              select o).ToList();

            res += (matchedRes.Count + 1).ToString();

            return(res);
        }
示例#17
0
        /// <summary>
        /// 智慧餐厅打单内容 - 总单
        /// </summary>
        /// <returns></returns>
        public static string GetPrintContent_Total(DishStore store, DishOrder order, List <DishShoppingCart> carts, DishPrint print)
        {
            string          printContent = string.Empty;
            List <DishGood> goods        = DishGoodBLL.SingleModel.GetList($" id in ({string.Join(",", carts.Select(c => c.goods_id))}) ");

            if (goods == null)
            {
                log4net.LogHelper.WriteInfo(typeof(PrinterHelper), $"参数为空导致无法打印:goods:{goods == null}");
                return(printContent);
            }

            List <DishShoppingCart> printShoppingCarts = carts;

            //得出此次要打印的购物车记录
            if (!string.IsNullOrWhiteSpace(print.print_tags))
            {
                int[] selTagsId = print.print_tags.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(t => Convert.ToInt32(t)).ToArray();
                printShoppingCarts = (from c in carts
                                      join g in goods on c.goods_id equals g.id
                                      where selTagsId.Contains(g.g_print_tag)
                                      select c)?.ToList();
            }
            if (printShoppingCarts == null || !printShoppingCarts.Any())
            {
                return(printContent);                                                         //当前打印机无要打印的内容
            }
            //处理商品字体
            Func <string, string> goodsFont = (info) =>
            {
                if (print.print_goods_ziti_type == 0)
                {
                    return($"{info}");
                }
                else
                {
                    return($"<FS2>{info}</FS2>");
                }
            };

            //处理其它资料字体
            Func <string, string> msgFont = (info) =>
            {
                if (print.print_ziti_type == 0)
                {
                    return($"{info}");
                }
                else
                {
                    return($"<FS>{info}</FS>");
                }
            };

            #region 订单打单内容拼接
            printContent  = string.Empty;
            printContent += $"<MC>0,00005,0</MC><MN>{print.print_dnum}</MN>";
            printContent += $"<center>{print.print_top_copy}</center>\r\n";
            printContent += $"<FS2>{store.dish_name}</FS2>\r\n";
            printContent += $"<FS2>{order.order_haoma}号</FS2>\r\n";
            printContent += $"<FS2>{order.order_type_txt}订单{(!string.IsNullOrWhiteSpace(order.order_table_id) ? $":{order.order_table_id}" : string.Empty)}</FS2>\r\n";
            printContent += "<table><tr><td>@@2................................</td></tr>";
            //printContent += $"<tr><td>{msgFont("名称")}   </td><td>{msgFont("单价")}  </td><td>{msgFont("数量")} </td><td>{msgFont("金额")}</td></tr>";
            printContent += $"<tr><td>{msgFont("名称")}   </td><td>{msgFont("数量")}  </td><td>{msgFont("金额")}  </td></tr>";
            printContent += $"<tr><td>┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄</td></tr>";
            foreach (DishShoppingCart item in printShoppingCarts)
            {
                if (!string.IsNullOrEmpty(item.goods_attr))
                {
                    //printContent += $"<tr><td>{goodsFont($"{item.goods_name}({item.goods_attr})")}</td><td>{msgFont(item.goods_price.ToString())}  </td><td>{msgFont(item.goods_number.ToString())}  </td><td>{msgFont((item.goods_price * item.goods_number).ToString())}  </td></tr>";
                    printContent += $"<tr><td>{goodsFont($"{item.goods_name}({item.goods_attr})")}</td><td>{msgFont(item.goods_number.ToString())}  </td><td>{msgFont((item.goods_price * item.goods_number).ToString())}  </td></tr>";
                }
                else
                {
                    //printContent += $"<tr><td>{goodsFont(item.goods_name)}</td><td>{msgFont(item.goods_price.ToString())}  </td><td>{msgFont(item.goods_number.ToString())}  </td><td>{msgFont((item.goods_price * item.goods_number).ToString())}  </td></tr>";
                    printContent += $"<tr><td>{goodsFont(item.goods_name)}</td><td>x{msgFont(item.goods_number.ToString())}  </td><td>{msgFont((item.goods_price * item.goods_number).ToString())}  </td></tr>";
                }
            }

            #region 优惠内容
            string youhuiContent = string.Empty;
            if (order.shipping_fee > 0.00d)
            {
                youhuiContent += $"<tr><td>{msgFont("配送费")}</td><td></td><td></td><td>{msgFont($"¥{order.shipping_fee}")}</td></tr>";
            }
            if (order.dabao_fee > 0.00d)
            {
                youhuiContent += $"<tr><td>{msgFont("餐盒费")}</td><td></td><td></td><td>{msgFont($"¥{order.dabao_fee}")}</td></tr>";
            }
            if (order.huodong_quan_jiner > 0.00d)
            {
                youhuiContent += $"<tr><td>{msgFont("优惠券")}</td><td></td><td></td><td>{msgFont($"¥{order.huodong_quan_jiner}")}</td></tr>";
            }
            if (order.huodong_shou_jiner > 0.00d)
            {
                youhuiContent += $"<tr><td>{msgFont("首单减")}</td><td></td><td></td><td>{msgFont($"¥{order.huodong_shou_jiner}")}</td></tr>";
            }
            if (order.huodong_manjin_jiner > 0.00d)
            {
                youhuiContent += $"<tr><td>{msgFont("满减")}</td><td></td><td></td><td>{msgFont($"¥{order.huodong_manjin_jiner}")}</td></tr>";
            }

            //优惠文案不为空时才添加到打印内容
            if (!string.IsNullOrWhiteSpace(youhuiContent))
            {
                printContent += $"<tr><td>┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄</td></tr>" + youhuiContent;
            }
            #endregion

            printContent += $"</table>";
            printContent += $"┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄\r\n";

            string payText = order.pay_name;
            if ((int)DishEnums.PayMode.微信支付 == order.pay_id)
            {
                payText = order.pay_status == (int)DishEnums.PayState.未付款 ? "微信未支付" :
                          order.pay_status == (int)DishEnums.PayState.已付款 ? "微信已支付" : payText;
            }
            printContent += $"{msgFont($"合计:¥{order.settlement_total_fee} {(order.pay_id > 0 ? $"({payText})" : "")}")}\r\n";
            printContent += $"{msgFont($"订单号:{order.order_sn}")}\r\n";
            printContent += $"{msgFont($"下单时间:{order.add_time_txt}")}\r\n";
            printContent += $"{msgFont($"订单备注:{order.post_info}")}\r\n";

            if (order.order_type == (int)DishEnums.OrderType.外卖)//外卖额外信息
            {
                printContent += $"┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄\r\n";
                printContent += $"<FW2><FH2>配送信息</FH2></FW2>\r\n";
                printContent += $"{msgFont($"收货人:{order.consignee}")}\r\n";
                printContent += $"{msgFont($"收货地址:{order.address}")}\r\n";
                printContent += $"{msgFont($"联系电话:{order.mobile}")}\r\n";
            }
            if (order.is_fapiao == 1)//如果要发票
            {
                printContent += $"{msgFont($"发票:【{order.fapiao_leixing_txt}】【{order.fapiao_text}】【{order.fapiao_no}】")}\r\n";
            }
            printContent += $"<center>{print.print_bottom_copy}</center>\r\n";
            #endregion

            return(printContent);
        }
示例#18
0
        public ActionResult ChangeDish(string act = "", int aId = 0, int storeId = 0, int orderId = 0, int cartId = 0, int count = 0)
        {
            #region 验证
            if (orderId <= 0)
            {
                _result.msg = "非法请求";
                return(Json(_result));
            }
            DishOrder order = DishOrderBLL.SingleModel.GetModel(orderId);
            DishStore store = DishStoreBLL.SingleModel.GetModel(storeId);
            if (store == null)
            {
                _result.msg = "门店不存在";
                return(Json(_result));
            }
            if (order == null)
            {
                _result.msg = "订单不存在";
                return(Json(_result));
            }
            if (order.pay_status != (int)DishEnums.PayState.未付款)
            {
                _result.msg = "只有未支付的订单才能修改";
                return(Json(_result));
            }
            #endregion
            DishShoppingCart cartModel = DishShoppingCartBLL.SingleModel.GetModel(cartId);
            if (cartModel == null)
            {
                _result.msg = "对象不存在或已删除";
                return(Json(_result));
            }
            if (order.huodong_manjin_jiner > 0 && order.huodong_manjian_id == 0)
            {
                _result.msg = "2018-8-13前享受满减的订单,不能修改";
                return(Json(_result));
            }


            List <DishShoppingCart> carts = DishShoppingCartBLL.SingleModel.GetShoppingCart(cartModel.aId, cartModel.storeId, cartModel.user_id, order.id) ?? new List <DishShoppingCart>(); //购物车
            List <DishGood>         goods = DishGoodBLL.SingleModel.GetGoodsByIds(carts.Select(c => c.goods_id)?.ToArray());                                                                 //购物车内商品详细资料
            if (goods == null || carts.Any(c => !goods.Any(g => c.goods_id == g.id)))
            {
                _result.msg = "菜品不存在";
                return(Json(_result));
            }
            cartModel.goods_number += count;
            if (cartModel.goods_number < 0)
            {
                cartModel.goods_number = 0;
            }

            if (cartModel.goods_number <= 0 && carts.Count == 1)
            {
                _result.msg = "订单至少要有一个菜品。";
                return(Json(_result));
            }

            bool buildResult = DishOrderBLL.SingleModel.ReBuildOrder(order, store, cartModel, carts, goods, _result);
            _result.code = buildResult ? 1 : 0;
            _result.msg  = buildResult ? "设置成功" : "设置失败";
            return(Json(_result));
        }
示例#19
0
 public static string GetDishOrder(int deskId, List <DishOrderDetail> orderDetails)
 {
     dishOrder = new DAL.DishService().GenerateDishOrder(deskId, orderDetails);
     return(JsonConvert.SerializeObject(dishOrder));
 }
示例#20
0
        private void bunifuTileButton_Execute_Click(object sender, EventArgs e)
        {
            string err = "";

            if (mode == "view")
            {
                this.Close();
                return;
            }
            if (mode == "delete")
            {
                ThreadManager.DisplayLoadingScreen();
                err = manager.DeleteOrder(bunifuCustomTextbox_BillCode.Text);
                ThreadManager.CloseLoadingScreen();
                ErrorManager.MessageDisplay(err, "Cancel order successfully", "Cancel order failed");
                return;
            }
            ThreadManager.DisplayLoadingScreen();
            if (mode == "update")
            {
                Order order = new Order();
                order.OrderID     = bunifuCustomTextbox_BillCode.Text;
                order.DateCreated = Convert.ToDateTime(bunifuCustomTextbox_CurentTime.Text);
                int temp = 0;
                int.TryParse(bunifuCustomTextbox_Priority.Text, out temp);
                order.PriorityNumber = temp;
                order.TotalPayment   = double.Parse(bunifuMetroTextbox_GrandTotal.Text);
                order.ChargedMoney   = double.Parse(bunifuMetroTextbox_ChangeGiven.Text);
                order.Status         = bunifuDropdown_Status.selectedValue;
                if (bunifuCheckbox_VIPChecker.Checked)
                {
                    order.SetVipID(bunifuCustomTextbox_VIP.Text);
                }
                else
                {
                    order.SetVipID("");
                }

                err = manager.AddOrUpdateOrderBasicInfo(order, order.OrderID);
                ThreadManager.CloseLoadingScreen();
                ErrorManager.MessageDisplay(err, "Update order successfully", "Update order failed");
                return;
            }
            if (bunifuImageButton_ChooseDish_Drink.Enabled == true)
            {
                DishOrder order = new DishOrder();
                try
                {
                    order.OrderID     = bunifuCustomTextbox_BillCode.Text;
                    order.DateCreated = Convert.ToDateTime(bunifuCustomTextbox_CurentTime.Text);
                    int temp = 0;
                    int.TryParse(bunifuCustomTextbox_Priority.Text, out temp);
                    order.PriorityNumber = temp;
                    order.TotalPayment   = double.Parse(bunifuMetroTextbox_GrandTotal.Text);
                    order.ChargedMoney   = double.Parse(bunifuMetroTextbox_ChangeGiven.Text);
                    order.Status         = bunifuDropdown_Status.selectedValue;
                    if (bunifuCheckbox_VIPChecker.Checked)
                    {
                        order.SetVipID(bunifuCustomTextbox_VIP.Text);
                    }
                    else
                    {
                        order.SetVipID("");
                    }
                    order.OrderItems = (List <Food>)bunifuCustomTextbox__list_selectedDishesDrinks.Tag;
                }
                catch (Exception ex)
                {
                    ThreadManager.CloseLoadingScreen();
                    ErrorManager.MessageDisplay(ex.Message, "", "Extract data falied");
                    return;
                }
                err = manager.AddOrUpdateDishOrder(order);
                ThreadManager.CloseLoadingScreen();
                ErrorManager.MessageDisplay(err, "Add dish order successfully", "Add dish order failed");
            }
            else if (bunifuImageButton_ChooseBook.Enabled == true)
            {
                BorrowBookOrder order = new BorrowBookOrder();
                try
                {
                    order.OrderID     = bunifuCustomTextbox_BillCode.Text;
                    order.DateCreated = Convert.ToDateTime(bunifuCustomTextbox_CurentTime.Text);
                    int temp = 0;
                    int.TryParse(bunifuCustomTextbox_Priority.Text, out temp);
                    order.PriorityNumber = temp;
                    order.TotalPayment   = double.Parse(bunifuMetroTextbox_GrandTotal.Text);
                    order.ChargedMoney   = double.Parse(bunifuMetroTextbox_ChangeGiven.Text);
                    order.Status         = bunifuDropdown_Status.selectedValue;
                    if (bunifuCheckbox_VIPChecker.Checked)
                    {
                        order.SetVipID(bunifuCustomTextbox_VIP.Text);
                    }
                    else
                    {
                        ThreadManager.CloseLoadingScreen();
                        ErrorManager.MessageDisplay("No VIP ID input", "", "This feature require a VIP ID to be used");
                        return;
                    }
                    order.Books = (List <Book>)bunifuCustomTextbox__list_selectedBooks.Tag;

                    err = manager.AddOrUpdateBorrowBookOrder(order);
                    ErrorManager.MessageDisplay(err, "Add book borrow order successfully", "Add book borrow order failed");
                }
                catch (Exception ex)
                {
                    ErrorManager.MessageDisplay(ex.Message, "", "Extract data falied");
                    ThreadManager.CloseLoadingScreen();
                    return;
                }
                ThreadManager.CloseLoadingScreen();
            }
            else if (bunifuCheckbox_BorrowedBookCode.Checked == true)
            {
                ReturnBookOrder order = (ReturnBookOrder)bunifuCustomTextbox_BorrowedBookInfo.Tag;
                try
                {
                    order.OrderID     = bunifuCustomTextbox_BillCode.Text;
                    order.DateCreated = Convert.ToDateTime(bunifuCustomTextbox_CurentTime.Text);
                    int temp = 0;
                    int.TryParse(bunifuCustomTextbox_Priority.Text, out temp);
                    order.PriorityNumber = temp;
                    order.TotalPayment   = double.Parse(bunifuMetroTextbox_GrandTotal.Text);
                    order.ChargedMoney   = double.Parse(bunifuMetroTextbox_ChangeGiven.Text);
                    order.Status         = bunifuDropdown_Status.selectedValue;
                    if (bunifuCheckbox_VIPChecker.Checked)
                    {
                        order.SetVipID(bunifuCustomTextbox_VIP.Text);
                    }

                    err = manager.AddOrUpdateReturnBookOrder(order);
                    ThreadManager.CloseLoadingScreen();
                    ErrorManager.MessageDisplay(err, "Add book return order successfully", "Add book return order failed");
                }
                catch (Exception ex)
                {
                    ThreadManager.CloseLoadingScreen();
                    ErrorManager.MessageDisplay(ex.Message, "", "Extract data falied");
                    return;
                }
            }
            if (err == "")
            {
                this.Close();
            }
        }
示例#21
0
        /// <summary>
        /// 物流平台对接
        /// </summary>
        /// <param name="rid">权限表ID</param>
        /// <param name="userId">用户ID</param>
        /// <param name="cityName">城市名(达达)</param>
        /// <param name="lat">纬度</param>
        /// <param name="lnt">经度</param>
        /// <param name="distributionType">2:达达,3:蜂鸟</param>
        /// <param name="order">订单</param>
        /// <param name="carsData">购物车</param>
        /// <param name="orderType">TmpType枚举</param>
        /// <returns></returns>
        public string AddDistributionOrder(int rid, int userId, string cityName, string latStr, string lntStr, int distributionType, object order, object carsData, int tempType, int storeId = 0, int fee = 0, int orderType = 0)
        {
            if (distributionType <= 1)
            {
                return("");
            }

            string dugmsg = "";
            DistributionApiModel model = new DistributionApiModel();

            model.aid       = rid;
            model.userid    = userId;
            model.temptype  = tempType;
            model.storeid   = storeId;
            model.fee       = fee;
            model.cityname  = cityName;
            model.ordertype = orderType;
            double lat = 0;

            if (!double.TryParse(latStr, out lat))
            {
                dugmsg = "纬度转换错误";
                return(dugmsg);
            }
            if (lat <= 0)
            {
                dugmsg = "纬度不能小于0";
                return(dugmsg);
            }
            double lnt = 0;

            if (!double.TryParse(lntStr, out lnt))
            {
                dugmsg = "经度转换错误";
                return(dugmsg);
            }
            if (lnt <= 0)
            {
                dugmsg = "经度不能小于0";
                return(dugmsg);
            }
            model.lat = lat;
            model.lnt = lnt;
            List <elegood> fngoods = new List <elegood>();

            try
            {
                //物流数据提取
                switch (tempType)
                {
                case (int)TmpType.小程序餐饮模板:
                    FoodGoodsOrder data = (FoodGoodsOrder)order;
                    model.orderid           = data.Id;
                    model.buyprice          = data.BuyPrice;
                    model.accepterName      = data.AccepterName;
                    model.accepterTelePhone = data.AccepterTelePhone;
                    model.address           = data.Address;
                    model.remark            = data.Message;
                    if (carsData != null)
                    {
                        List <FoodGoodsCart> goodsCar = (List <FoodGoodsCart>)carsData;
                        //商品信息
                        foreach (FoodGoodsCart good in goodsCar)
                        {
                            model.ordercontent += good.goodsMsg.GoodsName + $"({good.Count});";
                        }
                    }
                    dugmsg = "数据提取成功";
                    break;

                case (int)TmpType.智慧餐厅:
                    DishOrder disOrder = (DishOrder)order;
                    model.orderid           = disOrder.id;
                    model.buyprice          = Convert.ToInt32(disOrder.order_amount * 100);
                    model.accepterName      = disOrder.consignee;
                    model.accepterTelePhone = disOrder.mobile;
                    model.address           = disOrder.address;
                    model.remark            = disOrder.post_info;
                    List <DishShoppingCart> dishGoodsCartList = DishShoppingCartBLL.SingleModel.GetCartsByOrderId(disOrder.id);
                    if (dishGoodsCartList != null && dishGoodsCartList.Count > 0)
                    {
                        //商品信息
                        foreach (DishShoppingCart good in dishGoodsCartList)
                        {
                            model.ordercontent += good.goods_name + $"({good.goods_number});";
                        }
                    }

                    dugmsg = "数据提取成功";
                    break;
                }
                //添加物流订单
                switch (distributionType)
                {
                case (int)miniAppOrderGetWay.达达配送:    //生成达达物流订单
                    DadaOrderBLL dadaOrderBLL = new DadaOrderBLL();
                    dugmsg = dadaOrderBLL.AddDadaOrder(model);
                    if (!string.IsNullOrEmpty(dugmsg))
                    {
                        return($"达达订单生成失败:" + dugmsg);
                    }
                    break;

                case (int)miniAppOrderGetWay.蜂鸟配送:    //生成蜂鸟物流订单

                    dugmsg = FNOrderBLL.SingleModel.AddFNOrder(fngoods, model);
                    if (!string.IsNullOrEmpty(dugmsg))
                    {
                        return("蜂鸟订单生成失败:" + dugmsg);
                    }
                    break;

                case (int)miniAppOrderGetWay.快跑者配送:    //生成快跑者物流订单

                    dugmsg = KPZOrderBLL.SingleModel.AddKPZOrder(model);
                    if (!string.IsNullOrEmpty(dugmsg))
                    {
                        return("快跑者订单生成失败:" + dugmsg);
                    }
                    break;

                case (int)miniAppOrderGetWay.UU配送:    //生成uu物流订单

                    dugmsg = UUOrderBLL.SingleModel.AddUUOrder(model);
                    if (!string.IsNullOrEmpty(dugmsg))
                    {
                        return("UU订单生成失败:" + dugmsg);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                dugmsg += "物流数据转化失败:" + ex.Message;
                log4net.LogHelper.WriteInfo(this.GetType(), dugmsg);
                return(dugmsg);
            }

            return(dugmsg);
        }
        public IActionResult CreateOrderForManyTables(CreateOrderForManyTablesViewModel viewModel)
        {
            if (!viewModel.Tables.Any(x => x.IsSelected))
            {
                ModelState.AddModelError(string.Empty, "Wybierz conajmniej 1 stolik");
                return(View(viewModel));
            }
            if (!viewModel.Dishes.Any(x => x.IsSelected))
            {
                ModelState.AddModelError(string.Empty, "Wybierz co najmniej jedno danie");
                return(View(viewModel));
            }
            var selectedTables = viewModel.Tables.Where(x => x.IsSelected).ToList();
            var selectedDishes = viewModel.Dishes.Where(x => x.IsSelected).ToList();

            foreach (var table in selectedTables)
            {
                var order = new Order();
                if (orders.Any())
                {
                    order.Id = orders.LastOrDefault().Id + 1;
                }
                else
                {
                    order.Id = 1;
                }
                order.TableId = table.Id;
                order.Dishes  = new List <DishOrder>();
                foreach (var dish in selectedDishes)
                {
                    var dishOrder = new DishOrder();
                    if (!dishOrders.Any(x => x.OrderId == order.Id && x.DishId == dish.Id))
                    {
                        if (dishOrders.Any())
                        {
                            dishOrder.Id = dishOrders.LastOrDefault().Id + 1;
                        }
                        else
                        {
                            dishOrder.Id = 1;
                        }
                    }
                    else
                    {
                        dishOrders.Remove(dishOrders.FirstOrDefault(x => x.OrderId == order.Id && x.DishId == dish.Id));
                        if (dishOrders.Any())
                        {
                            dishOrder.Id = dishOrders.LastOrDefault().Id + 1;
                        }
                        else
                        {
                            dishOrder.Id = 1;
                        }
                    }
                    if (dish.Amount == null || dish.Amount <= 0)
                    {
                        ModelState.AddModelError(string.Empty, "Podaj prawidłowe ilości dla wszystkich wybranych dań");
                        return(View(viewModel));
                    }
                    dishOrder.DishId  = dish.Id;
                    dishOrder.Amount  = dish.Amount.Value;
                    dishOrder.OrderId = order.Id;
                    dishOrder.Dish    = dish;
                    dishOrders.Add(dishOrder);
                    order.Dishes.Add(dishOrder);
                }
                orders.Add(order);
            }
            SessionService.SetJson(HttpContext.Session, SessionKeys.OrdersKey, orders);
            TempData["SuccessMessage"] = "Pomyślnie utworzono zamówienia";
            return(RedirectToAction("Index"));
        }
 public IActionResult CreateNewOrder(NewOrderViewModel viewModel)
 {
     if (viewModel.Dishes.Any(x => x.IsSelected))
     {
         var selectedDishes = viewModel.Dishes.Where(x => x.IsSelected).ToList();
         if (viewModel.IsEditing)
         {
             var order     = orders.FirstOrDefault(x => x.Id == viewModel.Order.Id);
             var oldDishes = order.Dishes;
             order.Dishes = new List <DishOrder>();
             foreach (var dish in viewModel.Dishes)
             {
                 DishOrder newDishOrder = new DishOrder();
                 if (dish.IsSelected && oldDishes.Any(x => x.Id == dish.Id && x.OrderId == viewModel.Order.Id) && oldDishes.FirstOrDefault(x => x.Id == dish.Id && x.OrderId == viewModel.Order.Id).Dish.IsSelected)
                 {
                     if (dish.Amount == null || dish.Amount <= 0)
                     {
                         ModelState.AddModelError(string.Empty, "Podaj poprawne ilości wybranych dań");
                         return(View(viewModel));
                     }
                     dishOrders.Remove(dishOrders.FirstOrDefault(x => x.Id == dish.Id && x.OrderId == viewModel.Order.Id));
                     newDishOrder.OrderId = viewModel.Order.Id;
                     if (dishOrders.Count == 0)
                     {
                         newDishOrder.Id = 1;
                     }
                     else
                     {
                         newDishOrder.Id = dishOrders.LastOrDefault().Id + 1;
                     }
                     newDishOrder.Dish   = dish;
                     newDishOrder.DishId = dish.Id;
                     newDishOrder.Amount = dish.Amount.Value;
                     dishOrders.Add(newDishOrder);
                     order.Dishes.Add(newDishOrder);
                 }
                 else if (dish.IsSelected)
                 {
                     if (dish.Amount == null || dish.Amount <= 0)
                     {
                         ModelState.AddModelError(string.Empty, "Podaj poprawne ilości wybranych dań");
                         return(View(viewModel));
                     }
                     newDishOrder.OrderId = viewModel.Order.Id;
                     newDishOrder.Id      = dishOrders.LastOrDefault().Id + 1;
                     newDishOrder.DishId  = dish.Id;
                     newDishOrder.Dish    = dish;
                     newDishOrder.Amount  = dish.Amount.Value;
                     dishOrders.Add(newDishOrder);
                     order.Dishes.Add(newDishOrder);
                 }
             }
             SessionService.SetJson(HttpContext.Session, SessionKeys.OrdersKey, orders);
             TempData["SuccessMessage"] = "Pomyślnie edytowano zamówienie";
             return(RedirectToAction("Index"));
         }
         else
         {
             var order = new Order()
             {
                 TableId = viewModel.TableId
             };
             if (orders.Any())
             {
                 order.Id = orders.LastOrDefault().Id + 1;
             }
             else
             {
                 order.Id = 1;
             }
             order.Dishes = new List <DishOrder>();
             foreach (var dish in selectedDishes)
             {
                 if (dishOrders.Any(x => x.Dish.Name == dish.Name && x.OrderId == order.Id))
                 {
                     if (!dish.IsSelected)
                     {
                         dishOrders.Remove(dishOrders.FirstOrDefault(x => x.Dish.Name == dish.Name && x.OrderId == order.Id));
                     }
                     else
                     {
                         var existingDishOrder = dishOrders.FirstOrDefault(x => x.Dish.Name == dish.Name && x.OrderId == order.Id);
                         existingDishOrder.Amount = dish.Amount.Value;
                     }
                 }
                 else
                 {
                     if (dish.Amount == null || dish.Amount <= 0)
                     {
                         ModelState.AddModelError(string.Empty, "Podaj poprawne ilości wybranych dań");
                         return(View(viewModel));
                     }
                     var dishOrder = new DishOrder();
                     if (dishOrders.Any())
                     {
                         dishOrder.Id = dishOrders.LastOrDefault().Id + 1;
                     }
                     else
                     {
                         dishOrder.Id = 1;
                     }
                     dishOrder.Dish    = dish;
                     dishOrder.DishId  = dish.Id;
                     dishOrder.Amount  = dish.Amount.Value;
                     dishOrder.OrderId = order.Id;
                     dishOrders.Add(dishOrder);
                     order.Dishes.Add(dishOrder);
                 }
             }
             orders.Add(order);
             SessionService.SetJson(HttpContext.Session, SessionKeys.OrdersKey, orders);
             TempData["SuccessMessage"] = "Pomyślnie utworzono zamówienie";
             return(RedirectToAction("Index"));
         }
     }
     ModelState.AddModelError(string.Empty, "Nie wybrano dań do zapisania");
     return(View(viewModel));
 }
示例#24
0
        public JsonResult Detail(DishStore store, int?orderId)
        {
            if (!orderId.HasValue)
            {
                return(ApiModel(message: "店铺ID不能为空"));
            }
            DishOrder order = DishOrderBLL.SingleModel.GetModel(orderId.Value);

            if (order == null)
            {
                return(ApiModel(message: "无效订单,数据不存在"));
            }

            if (order.storeId != store.id)
            {
                return(ApiModel(message: "非法操作"));
            }

            //订单商品
            List <DishShoppingCart> orderItem = DishShoppingCartBLL.SingleModel.GetCartsByOrderId(order.id);
            //订单配送员
            List <DishTransporter> deliveryUnit = DishTransporterBLL.SingleModel.GetTransportersByparams(order.aId, order.storeId, true) ?? new List <DishTransporter>();

            object formatItem = orderItem?.Select(item => new
            {
                Id     = item.goods_id,
                Name   = item.goods_name,
                Img    = item.goods_img,
                Price  = item.goods_price,
                Spec   = item.goods_attr,
                Amount = item.goods_number,
            });

            object formatOrder = new
            {
                Id             = order.id,
                OrderNo        = order.order_sn,
                OrderDate      = order.ctime.ToString(),
                OrderStateEnum = order.order_status,
                OrderState     = order.order_status_txt,
                OrderTypeEnum  = order.order_type,
                OrderType      = order.order_type_txt,

                PayStateEnum    = order.pay_status,
                PayState        = order.pay_status_txt,
                PayDate         = order.pay_time.ToString(),
                PayAmount       = order.order_amount * 0.01,
                PackingFee      = order.dabao_fee * 0.01,
                NewUserDiscount = order.huodong_shou_jiner,
                Discount        = order.huodong_quan_jiner,
                FullDiscount    = order.huodong_manjin_jiner,

                UserName          = order.user_name,
                IsPickUp          = order.is_ziqu == 1,
                PickUpName        = order.ziqu_username,
                PickUpPhoneNo     = order.ziqu_userphone,
                ReceivingName     = order.consignee,
                ReceivingPhoneNo  = order.mobile,
                DeliveryName      = order.peisong_user_name,
                DeliveryPhoneNo   = order.peisong_user_phone,
                DeliveryFee       = order.shipping_fee * 0.01,
                DeliveryStateEnum = order.peisong_status,
                DeliveryState     = order.peisong_status_text,
                Address           = order.address,

                Table        = order.order_table_id == "0" ? null : order.order_table_id,
                Invoice      = order.is_fapiao,
                InvoiceTitle = order.fapiao_text,
                InvoiceNo    = order.fapiao_no,
                InvoiceType  = order.fapiao_leixing_txt,
                UserRemark   = order.post_info,
                StoreRemark  = order.GetAttrbute().mark ?? "",
            };

            return(ApiModel(isok: true, message: "获取成功", data: new { Order = formatOrder, Item = formatItem }));
        }
示例#25
0
文件: UUOrderBLL.cs 项目: soon14/vzan
        /// <summary>
        /// 处理智慧餐厅UU配送回调
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public bool UUToMutilFoodReturn(UUOrder order)
        {
            bool      isSuccess = false;
            string    updatesql = "State";
            DishOrder dishOrder = DishOrderBLL.SingleModel.GetModel(order.OrderId);

            if (dishOrder == null)
            {
                LogHelper.WriteInfo(this.GetType(), "UU配送:找不到智慧餐厅订单");
                return(isSuccess);
            }

            string msg = string.Empty;

            switch (order.State)
            {
            case (int)UUOrderEnum.订单取消:
                isSuccess = base.Update(order, updatesql);
                if (!isSuccess)
                {
                    LogHelper.WriteInfo(this.GetType(), "UU配送:修改UU订单状态出错," + JsonConvert.SerializeObject(order));
                    return(isSuccess);
                }

                //退款接口 abel
                //判断是否是取消订单,取消订单则要执行退款
                if (dishOrder.pay_status == (int)DishEnums.PayState.已付款)
                {
                    DishReturnMsg result = new DishReturnMsg();
                    DishOrderBLL.SingleModel.RefundOrderById(order.OrderId, result);
                    isSuccess = result.code == 1;
                    if (isSuccess)
                    {
                        LogHelper.WriteInfo(this.GetType(), result.msg);
                    }
                }

                return(isSuccess);

            case (int)UUOrderEnum.跑男抢单:
            case (int)UUOrderEnum.已到达:
                updatesql += ",driver_name,driver_mobile,driver_jobnum";
                dishOrder.peisong_status     = (int)DishEnums.DeliveryState.待取货;
                dishOrder.peisong_open       = 1;
                dishOrder.peisong_user_name  = order.driver_name;
                dishOrder.peisong_user_phone = order.driver_mobile;
                #region 发送餐饮订单配送通知 模板消息

                #endregion
                break;

            case (int)UUOrderEnum.已取件:
            case (int)UUOrderEnum.到达目的地:
                dishOrder.peisong_status = (int)DishEnums.DeliveryState.配送中;
                break;

            case (int)UUOrderEnum.收件人已收货:
                dishOrder.peisong_status = (int)DishEnums.DeliveryState.已完成;
                break;
            }
            isSuccess = base.Update(order, updatesql);
            if (!isSuccess)
            {
                LogHelper.WriteInfo(this.GetType(), "UU配送:修改智慧餐厅订单状态出错:" + JsonConvert.SerializeObject(order));
                return(isSuccess);
            }
            isSuccess = DishOrderBLL.SingleModel.Update(dishOrder, "peisong_status,peisong_open,peisong_user_name,peisong_user_phone");

            return(isSuccess);
        }
示例#26
0
        /// <summary>
        /// 智慧餐厅打单内容 - 分单
        /// </summary>
        /// <returns></returns>
        public static List <string> GetPrintContent_Part(DishStore store, DishOrder order, List <DishShoppingCart> carts, DishPrint print)
        {
            List <string>   printContents = new List <string>();
            string          printContent  = string.Empty;
            List <DishGood> goods         = DishGoodBLL.SingleModel.GetList($" id in ({string.Join(",", carts.Select(c => c.goods_id))}) ");

            if (goods == null)
            {
                log4net.LogHelper.WriteInfo(typeof(PrinterHelper), $"参数为空导致无法打印:goods:{goods == null}");
                return(printContents);
            }

            //得出此次要打印的购物车记录
            List <DishShoppingCart> printShoppingCarts = carts;

            if (!string.IsNullOrWhiteSpace(print.print_tags))
            {
                int[] selTagsId = print.print_tags.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(t => Convert.ToInt32(t)).ToArray();
                printShoppingCarts = (from c in carts
                                      join g in goods on c.goods_id equals g.id
                                      where selTagsId.Contains(g.g_print_tag)
                                      select c)?.ToList();
            }
            if (printShoppingCarts == null || !printShoppingCarts.Any())
            {
                return(printContents);                                                         //当前打印机无要打印的内容
            }
            //处理商品字体
            Func <string, string> goodsFont = (info) =>
            {
                if (print.print_goods_ziti_type == 0)
                {
                    return($"{info}");
                }
                else
                {
                    return($"<FS2>{info}</FS2>");
                }
            };

            //处理其它资料字体
            Func <string, string> msgFont = (info) =>
            {
                if (print.print_ziti_type == 0)
                {
                    return($"{info}");
                }
                else
                {
                    return($"<FS>{info}</FS>");
                }
            };

            #region 分单打单
            foreach (DishShoppingCart item in printShoppingCarts)
            {
                printContent  = string.Empty;
                printContent += $"<MC>0,00005,0</MC><MN>{print.print_dnum}</MN>";
                printContent += $"<FS2>{store.dish_name}</FS2>\r\n";
                printContent += $"<FS2>{order.order_haoma}号</FS2>\r\n";
                printContent += $"<FS2>{order.order_type_txt}订单{(!string.IsNullOrWhiteSpace(order.order_table_id) ? $":{order.order_table_id}" : string.Empty)}</FS2>\r\n";
                printContent += "<table><tr><td>@@2................................</td></tr>";
                //printContent += $"<tr><td>{msgFont("菜品")}       </td><td>{msgFont("单价")} </td><td>{msgFont("数量")} </td><td>{msgFont("金额")} </td></tr>";
                printContent += $"<tr><td>{msgFont("菜品")}       </td><td>{msgFont("数量")} </td><td>{msgFont("金额")} </td></tr>";
                printContent += $"<tr><td>┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄</td></tr>";
                if (!string.IsNullOrEmpty(item.goods_attr))
                {
                    //printContent += $"<tr><td>{goodsFont($"{item.goods_name}({item.goods_attr})")}</td><td>{msgFont(item.goods_price.ToString())}  </td><td>{msgFont(item.goods_number.ToString())}  </td><td>{msgFont((item.goods_price * item.goods_number).ToString())}  </td></tr>";
                    printContent += $"<tr><td>{goodsFont($"{item.goods_name}({item.goods_attr})")}</td><td>{msgFont(item.goods_number.ToString())}  </td><td>{msgFont((item.goods_price * item.goods_number).ToString())}  </td></tr>";
                }
                else
                {
                    //printContent += $"<tr><td>{goodsFont(item.goods_name)}</td><td>{msgFont(item.goods_price.ToString())}  </td><td>{msgFont(item.goods_number.ToString())}  </td><td>{msgFont((item.goods_price * item.goods_number).ToString())}  </td></tr>";
                    printContent += $"<tr><td>{goodsFont(item.goods_name)}</td><td>x{msgFont(item.goods_number.ToString())}  </td><td>{msgFont((item.goods_price * item.goods_number).ToString())}  </td></tr>";
                }
                printContent += $"</table>";
                printContent += $"┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄\r\n";
                printContent += $"{msgFont($"订单号:{order.order_sn}")}\r\n";
                printContent += $"{msgFont($"下单时间:{order.add_time_txt}")}\r\n";
                printContent += $"{msgFont($"订单备注:{order.post_info}")}\r\n";

                printContents.Add(printContent);//添加入分单内容集合
            }
            #endregion
            return(printContents);
        }
示例#27
0
        public JsonResult Update(DishStore store, string doWhat, int?orderId, int?tableId, int?deliveryUnit)
        {
            if (!orderId.HasValue)
            {
                return(ApiModel(message: "参数不能为空[orderId]"));
            }

            DishOrder order = DishOrderBLL.SingleModel.GetModel(orderId.Value);

            if (order?.storeId != store.id)
            {
                return(ApiModel(message: "无效订单"));
            }

            bool success = false;

            switch (doWhat)
            {
            case "Table":
                if (!tableId.HasValue)
                {
                    return(ApiModel(message: "未找到相关桌台"));
                }
                DishTable table = DishTableBLL.SingleModel.GetModel(tableId.Value);
                if (table == null || table.storeId != store.id)
                {
                    return(ApiModel(message: "未找到相关桌台"));
                }
                order.order_table_id_zhen = table.id;
                order.order_table_id      = table.table_name;
                success = DishOrderBLL.SingleModel.Update(order, "order_table_id,order_table_id_zhen");
                break;

            case "PickUp":
                order.peisong_status = (int)DishEnums.DeliveryState.待取货;
                success = DishOrderBLL.SingleModel.Update(order, "peisong_status");
                break;

            case "Cancel":
                order.peisong_status = (int)DishEnums.DeliveryState.已取消;
                success = DishOrderBLL.SingleModel.Update(order, "peisong_status");
                break;

            case "Complete":
                order.peisong_status = (int)DishEnums.DeliveryState.已完成;
                success = DishOrderBLL.SingleModel.Update(order, "peisong_status");
                break;

            case "Delivery":
                if (!deliveryUnit.HasValue)
                {
                    return(ApiModel(message: "参数不能为空[deliveryUnit]"));
                }
                DishTransporter transporter = DishTransporterBLL.SingleModel.GetModel(deliveryUnit.Value);
                if (transporter == null)
                {
                    return(ApiModel(message: "未找到配送员资料"));
                }
                order.peisong_open       = 1;
                order.peisong_status     = (int)DishEnums.DeliveryState.配送中;
                order.peisong_user_name  = transporter.dm_name;
                order.peisong_user_phone = transporter.dm_mobile;
                success = DishOrderBLL.SingleModel.Update(order, "peisong_open,peisong_status,peisong_user_name,peisong_user_phone");
                break;
            }

            return(ApiModel(isok: success, message: success ? "操作成功" : "操作失败"));
        }
示例#28
0
        /// <summary>
        /// 订单资料
        /// </summary>
        /// <param name="order"></param>
        /// <param name="act"></param>
        /// <returns></returns>
        public ActionResult Info(DishOrder order, string act = "", int psy_id = 0, string printer = null, string orderMark = null)
        {
            if (order.id <= 0)
            {
                _result.code = 0;
                _result.msg  = "未找到有效的订单标识";
                return(Json(_result, JsonRequestBehavior.AllowGet));
            }


            if (string.IsNullOrWhiteSpace(act))
            {
                EditModel <DishOrder> model = new EditModel <DishOrder>();

                model.DataModel = DishOrderBLL.SingleModel.GetModel(order.id) ?? new DishOrder();
                if (model.DataModel.id > 0)
                {
                    model.DataModel.carts = DishShoppingCartBLL.SingleModel.GetCartsByOrderId(model.DataModel.id) ?? new List <DishShoppingCart>();
                }
                model.aId     = model.appId = order.aId;
                model.storeId = order.storeId;

                ViewBag.dishTransporters = DishTransporterBLL.SingleModel.GetTransportersByparams(model.aId, model.storeId, true) ?? new List <DishTransporter>();
                return(View(model));
            }
            else
            {
                bool      isSuccess = false;
                DishOrder dbOrder   = DishOrderBLL.SingleModel.GetModel(order.id);
                if (dbOrder == null)
                {
                    _result.code = 0;
                    _result.msg  = "未找到相关订单";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }

                if (act == "changeTable")
                {
                    DishTable table = DishTableBLL.SingleModel.GetModel(order.order_table_id_zhen);
                    if (table == null)
                    {
                        _result.code = 0;
                        _result.msg  = "未找到相关桌台";
                        return(Json(_result, JsonRequestBehavior.AllowGet));
                    }

                    dbOrder.order_table_id_zhen = table.id;
                    dbOrder.order_table_id      = table.table_name;

                    isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "order_table_id,order_table_id_zhen");

                    _result.code = isSuccess ? 1 : 0;
                    _result.msg  = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "queren")
                {
                    dbOrder.peisong_status = (int)DishEnums.DeliveryState.待取货;
                    isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_status");

                    _result.code = isSuccess ? 1 : 0;
                    _result.msg  = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "quxiao")
                {
                    dbOrder.peisong_status = (int)DishEnums.DeliveryState.已取消;
                    isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_status");

                    _result.code = isSuccess ? 1 : 0;
                    _result.msg  = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "wancheng")
                {
                    dbOrder.peisong_status = (int)DishEnums.DeliveryState.已完成;
                    isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_status");

                    _result.code = isSuccess ? 1 : 0;
                    _result.msg  = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "peisong")
                {
                    if (psy_id <= 0)
                    {
                        _result.code = 0;
                        _result.msg  = "配送员标识错误";
                        return(Json(_result, JsonRequestBehavior.AllowGet));
                    }
                    DishTransporter transporter = DishTransporterBLL.SingleModel.GetModel(psy_id);
                    if (transporter == null)
                    {
                        _result.code = 0;
                        _result.msg  = "未找到配送员资料";
                        return(Json(_result, JsonRequestBehavior.AllowGet));
                    }
                    dbOrder.peisong_open       = 1;
                    dbOrder.peisong_status     = (int)DishEnums.DeliveryState.配送中;
                    dbOrder.peisong_user_name  = transporter.dm_name;
                    dbOrder.peisong_user_phone = transporter.dm_mobile;

                    isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_open,peisong_status,peisong_user_name,peisong_user_phone");

                    _result.code = isSuccess ? 1 : 0;
                    _result.msg  = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "print") //打印
                {
                    PrinterHelper.DishPrintOrderByPrintType(dbOrder, 0, printer);
                    _result.code = 1;
                    _result.msg  = "操作成功";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "mark")
                {
                    DishOrderAttrbute orderAttr = dbOrder.GetAttrbute();
                    orderAttr.mark   = orderMark;
                    dbOrder.attrbute = JsonConvert.SerializeObject(orderAttr);
                    isSuccess        = DishOrderBLL.SingleModel.Update(dbOrder, "attrbute");
                    _result.code     = isSuccess ? 1 : 0;
                    _result.msg      = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(_result, JsonRequestBehavior.AllowGet));
        }
示例#29
0
        /// <summary>
        /// 处理智慧餐厅达达配送回调
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public bool DadaToMutilFoodReturn(int orderid, DadaOrder order, string appid)
        {
            bool      isSuccess = false;
            string    updatesql = "state,update_time";
            DishOrder dishOrder = DishOrderBLL.SingleModel.GetModel(orderid);// and  OrderType ={(int)miniAppFoodOrderType.店内点餐 } ");

            if (dishOrder == null)
            {
                LogHelper.WriteInfo(this.GetType(), "智慧餐厅达达配送:找不到订单");
                return(isSuccess);
            }

            string msg = string.Empty;

            switch (order.state)
            {
            case (int)DadaOrderEnum.已取消:
                if (order.state == (int)DadaOrderEnum.已取消)
                {
                    updatesql += ",cancel_from,cancel_reason";
                }

                isSuccess = base.Update(order, updatesql);
                if (!isSuccess)
                {
                    LogHelper.WriteInfo(this.GetType(), "智慧餐厅达达配送回调修改系统订单状态出错:" + JsonConvert.SerializeObject(order));
                    return(isSuccess);
                }

                //退款接口 abel
                //判断是否是取消订单,取消订单则要执行退款
                if (dishOrder.pay_status == (int)DishEnums.PayState.已付款)
                {
                    DishReturnMsg result = new DishReturnMsg();
                    DishOrderBLL.SingleModel.RefundOrderById(orderid, result);
                    isSuccess = result.code == 1;
                    if (isSuccess)
                    {
                        LogHelper.WriteInfo(this.GetType(), result.msg);
                    }
                }

                return(isSuccess);

            case (int)DadaOrderEnum.待接单:
                dishOrder.peisong_status = (int)DishEnums.DeliveryState.待商家确认;
                break;

            case (int)DadaOrderEnum.待取货:
                updatesql += ",dm_id,dm_name,dm_mobile";
                dishOrder.peisong_status     = (int)DishEnums.DeliveryState.待取货;
                dishOrder.peisong_open       = 1;
                dishOrder.peisong_user_name  = order.dm_name;
                dishOrder.peisong_user_phone = order.dm_mobile;
                #region 发送餐饮订单配送通知 模板消息

                //C_UserInfo userinfo = _userInfoBLL.GetModel(dishOrder.user_id) ?? new C_UserInfo();
                //TemplateMsg_UserParam tmgup = _templateMsg_UserParamBLL.getParamByAppIdOpenId(appid, userinfo.OpenId) ?? new TemplateMsg_UserParam();
                //TemplateMsg_User tmgu = _templateMsg_UserBLL.getModelByAppIdTypeId(tmgup.AppId, (int)TmpType.小程序餐饮模板, (int)SendTemplateMessageTypeEnum.餐饮订单配送通知) ?? new Entity.MiniApp.Conf.TemplateMsg_User();
                //if (tmgu.State == 1)
                //{
                //    object postData = _foodGoodsOrderBLL.getTemplateMessageData(dishOrder.id, SendTemplateMessageTypeEnum.餐饮订单配送通知);
                //    _msnModelHelper.sendMyMsn(userinfo.appId, userinfo.OpenId, tmgu.TemplateId, tmgu.PageUrl, tmgup.Form_Id, postData, string.Empty, string.Empty, ref msg);
                //    //参数使用次数增加(默认是1)
                //    _templateMsg_UserParamBLL.addUsingCount(tmgup);
                //}
                #endregion
                break;

            case (int)DadaOrderEnum.配送中:
                dishOrder.peisong_status = (int)DishEnums.DeliveryState.配送中;
                break;

            case (int)DadaOrderEnum.已完成:
                dishOrder.peisong_status = (int)DishEnums.DeliveryState.已完成;
                break;

            case (int)DadaOrderEnum.已过期:
            case (int)DadaOrderEnum.系统故障订单发布失败:
            case (int)DadaOrderEnum.妥投异常之物品返回完成:
                dishOrder.peisong_status = (int)DishEnums.DeliveryState.已取消;
                updatesql += ",cancel_from,cancel_reason";
                break;
            }
            isSuccess = base.Update(order, updatesql);
            if (!isSuccess)
            {
                LogHelper.WriteInfo(this.GetType(), "达达配送回调修改系统订单状态出错:" + JsonConvert.SerializeObject(order));
                return(isSuccess);
            }
            isSuccess = DishOrderBLL.SingleModel.Update(dishOrder, "peisong_status,peisong_open,peisong_user_name,peisong_user_phone");

            return(isSuccess);
        }
示例#30
0
        public IActionResult Create()//FromRedirectToPayment - newOrder
        {
            string cart     = HttpContext.Session.GetString("Cart");
            var    dishes   = new List <Dish>();
            Order  newOrder = new Order();

            if (cart != null)
            {
                string[] dishIds = cart.Split(",", StringSplitOptions.RemoveEmptyEntries);
                //Get the all info of the dishes from DB
                dishes = _context.Dish.Where(x => dishIds.Contains(x.Id.ToString())).ToList();

                Dictionary <string, int> dict = new Dictionary <string, int>();

                double total = 0;
                //Create dictionary
                foreach (var id in dishIds)
                {
                    if (dict.ContainsKey(id))
                    {
                        dict[id]++;
                    }
                    else
                    {
                        dict.Add(id, 1);
                    }
                }

                int  i = 0;
                Dish currentDish;

                foreach (var dish in dict)
                {
                    DishOrder d = new DishOrder();

                    d.DishId   = int.Parse(dish.Key);
                    d.Quantity = dish.Value;

                    //Update total order
                    foreach (var tmp in dishes)
                    {
                        //Find the price of the dish in the dict
                        if (tmp.Id == Convert.ToInt32(dish.Key))
                        {
                            currentDish = tmp;
                            total      += (currentDish.Price * dish.Value);
                            break;
                        }
                    }

                    if (newOrder.Dishes == null)
                    {
                        newOrder.Dishes = new List <DishOrder>();
                    }
                    newOrder.Dishes.Add(d);
                }
                newOrder.Total = Convert.ToInt32(total);
            }

            //For using in create post
            globalOrder = newOrder;

            return(View(newOrder));
        }