public JsonResult Checkout(WholeOrPartialCheckoutDto req) { try { var currentUser = OperatorProvider.Provider.GetCurrent(); var user = _userService.GetUserInfo(new VerifyUserDTO() { UserId = currentUser.UserId }); var discount = user.MinDiscountValue; req.OrderTableStatus = OrderTableStatus.未结; req.CompanyId = currentUser.CompanyId.ToInt(); req.OperateUser = currentUser.UserId; req.CurrentMarketId = currentUser.LoginMarketId; req.AuthPermissionDiscount = discount; req.OperateUserCode = currentUser.UserCode; if (_checkOutService.CheckoutVaild(req.ListOrderPayRecordDTO, currentUser.DepartmentId.ToInt())) { CheckOutResultDTO resultDto = _checkOutService.WholeOrPartialCheckout(req); return(Json(new { Result = true, Info = "操作成功", Data = resultDto })); } else { return(Json(new { Result = false, Info = "可挂账限额不足" })); } } catch (Exception e) { return(Json(new { Result = false, Info = "结账操作失败 - " + e.Message })); } }
/// <summary> /// 订单反结结账 /// </summary> /// <returns>JSON</returns> public JsonResult ReCheckout(WholeOrPartialCheckoutDto req) { try { var currentUser = OperatorProvider.Provider.GetCurrent(); var user = _userService.GetUserInfo(new VerifyUserDTO() { UserId = currentUser.UserId }); var discount = user.MinDiscountValue; req.OrderTableStatus = OrderTableStatus.已结; req.CompanyId = currentUser.CompanyId.ToInt(); req.OperateUser = currentUser.UserId; req.CurrentMarketId = currentUser.LoginMarketId; req.AuthPermissionDiscount = discount; req.OperateUserCode = currentUser.UserCode; _checkOutService.ReCheckout(req); return(Json(new { Result = true, Info = "操作成功 " })); } catch (Exception e) { return(Json(new { Result = false, Info = "结账操作失败 - " + e.Message })); } }
public async System.Threading.Tasks.Task <JsonResult> CheckOutOrder(WholeOrPartialCheckoutDto req, OperatorModel member) { var res = new Response() { Data = false, Successed = false }; if (ModelState.IsValid) { try { var orderInfo = _orderRepository.GetOrderDTO(req.OrderId); var user = new VerifyUserDTO() { UserId = member.UserId }; //var discount = user.MinDiscountValue; req.OrderTableStatus = OrderTableStatus.未结; req.CompanyId = orderInfo.R_Restaurant_Id; req.OperateUser = member.UserId; req.CurrentMarketId = orderInfo.R_Market_Id; req.AuthPermissionDiscount = 0; req.OperateUserCode = member.UserCode; CheckOutResultDTO resultDto = _checkOutService.WholeOrPartialCheckout(req, CyddCzjlUserType.会员); if (resultDto != null) { res.Successed = true; res.Data = true; var hub = GlobalHost.ConnectionManager.GetHubContext <MyHub>(); await hub.Clients.All.callResServiceRefersh(true); } else { res.Message = "结账失败,请联系管理员"; } } catch (Exception e) { res.Message = e.Message; } } else { res.Message = string.Join(",", ModelState.SelectMany(ms => ms.Value.Errors).Select(e => e.ErrorMessage)); } return(Json(res)); }
public JsonResult BeforeCheckout(CheckOutBillDTO billDto, WholeOrPartialCheckoutDto req) { Response res = new Response(); if (ModelState.IsValid) { try { var currentUser = OperatorProvider.Provider.GetCurrent(); var user = _userService.GetUserInfo(new VerifyUserDTO() { UserId = currentUser.UserId }); var discount = user.MinDiscountValue; req.OrderTableStatus = OrderTableStatus.未结; req.CompanyId = currentUser.CompanyId.ToInt(); req.OperateUser = currentUser.UserId; req.CurrentMarketId = currentUser.LoginMarketId; req.AuthPermissionDiscount = discount; req.OperateUserCode = currentUser.UserCode; res.Data = _checkOutService.BeforeWholeOrPartialCheckout(req); _printService.CheckedOutBill(billDto); } catch (Exception ex) { res.Data = false; res.Message = ex.Message; } } else { res.Data = false; res.Message = string.Join(",", ModelState .SelectMany(ms => ms.Value.Errors) .Select(e => e.ErrorMessage)); } return(Json(res)); }
public bool CheckedOut(WholeOrPartialCheckoutDto req, bool isLocked) { bool result = true; #region 验证数据 //_checkOutService.VerifyOrderInfo(req); //var checkOutOrderDTO = _checkOutService.GetCheckOutOrderDTO(req.OrderId, req.TableIds); //_checkOutService.VerifyAndCalcDetailInfo(req, checkOutOrderDTO); #endregion var userInfo = OperatorProvider.Provider.GetCurrent(); var tableList = _tableRepository.GetlistByIds(req.TableIds); //获取台号列表 var model = new CheckOutPrint() { OrderType = isLocked ? "结账单" : "预结单", RestaurantName = req.RestaurantName ?? string.Empty, CheckOutUser = userInfo.UserName, OpenUser = req.OperUserName ?? string.Empty, ReserveUser = string.Empty, PrintDate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), BillDate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), Market = string.Empty, PersonNum = "0", OrderNo = "", TableName = string.Join(",", tableList.Select(p => p.Name).ToArray()), ListOrderDetailDTO = req.ListOrderDetailDTO, ConAmount = req.ConAmount.ToString(), GiveAmount = req.GiveAmount.ToString(), DiscountRateNow = req.DiscountRateNow.ToString(), DiscountAmount = req.DiscountAmount.ToString(), OriginalAmount = req.OriginalAmount.ToString(), ContactPerson = req.ContactPerson }; Type type = typeof(CheckOutPrint); Type typeDetail = typeof(OrderDetailDTO); #region 打印内容 PrintInvoice print = new PrintInvoice(); var tcpClient = print.GetMyPrint(); var stream = print.BuildStream(); var inputStream = print.GetStream(tcpClient, stream); string txt = string.Empty; int left = 0; string key = string.Empty; foreach (var item in print.root.Element("Page").Elements()) { if (item.Name == "Text") { txt = item.Value; left = Convert.ToInt32(item.Attribute("Left").Value); if (txt.Contains("{{") && txt.Contains("}}")) { key = ReplaceTemplate(txt); txt = txt.Replace("{{" + key + "}}", type.GetProperty(key).GetValue(model).ToString()); } print.PrintText(inputStream, txt, left); } else if (item.Name == "Loop") { string lopValues = item.Attribute("Values").Value; if (lopValues == "Detials") { if (model.ListOrderDetailDTO.Any()) { foreach (var detail in model.ListOrderDetailDTO) { foreach (var loopItem in item.Elements("Text")) { txt = loopItem.Value; left = Convert.ToInt32(item.Attribute("Left")); if (txt.Contains("{{") && txt.Contains("}}")) { key = ReplaceTemplate(txt); txt = txt.Replace("{{" + key + "}}", typeDetail.GetProperty(key).GetValue(detail).ToString()); } print.PrintText(inputStream, txt, left); } } } } } } //inputStream.Close(); print.PrintText(inputStream, print.root.ToString(), 0); print.QieZhi(inputStream); print.DiposeStreamClient(tcpClient, inputStream); #endregion return(result); }