public bool PayForOrder(PayingOrder payingOrder) { string json = JsonConvert.SerializeObject(payingOrder); byte[] jsonByte = Encoding.UTF8.GetBytes(json); int cByte = ParamFieldLength.PACKAGE_HEAD + jsonByte.Length; byte[] sendByte = new byte[cByte]; int byteOffset = 0; Array.Copy(BitConverter.GetBytes((int)Command.ID_PAYFORORDER), sendByte, BasicTypeLength.INT32); byteOffset = BasicTypeLength.INT32; Array.Copy(BitConverter.GetBytes(cByte), 0, sendByte, byteOffset, BasicTypeLength.INT32); byteOffset += BasicTypeLength.INT32; Array.Copy(jsonByte, 0, sendByte, byteOffset, jsonByte.Length); byteOffset += jsonByte.Length; bool result = false; using (SocketClient socket = new SocketClient(ConstantValuePool.BizSettingConfig.IPAddress, ConstantValuePool.BizSettingConfig.Port)) { Byte[] receiveData = null; Int32 operCode = socket.SendReceive(sendByte, out receiveData); if (operCode == (int)RET_VALUE.SUCCEEDED) { result = true; } socket.Close(); } return result; }
public bool CreatePrePayOrder(PayingOrder payingOrder) { bool returnValue = false; _daoManager.BeginTransaction(); try { if (payingOrder != null) { //日结 string dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo(); //更新Order if (_orderDao.UpdatePrePayOrder(payingOrder.order)) { //更新OrderDetails foreach (OrderDetails item in payingOrder.orderDetailsList) { _orderDetailsDao.UpdateOrderDetailsDiscount(item); } //插入OrderDiscount if (payingOrder.orderDiscountList != null && payingOrder.orderDiscountList.Count > 0) { foreach (OrderDiscount item in payingOrder.orderDiscountList) { item.DailyStatementNo = dailyStatementNo; _orderDiscountDao.CreateOrderDiscount(item); } } returnValue = true; } } _daoManager.CommitTransaction(); } catch(Exception exception) { LogHelper.GetInstance().Error(string.Format("[CreatePrePayOrder]参数:payingOrder_{0}", JsonConvert.SerializeObject(payingOrder)), exception); _daoManager.RollBackTransaction(); returnValue = false; } return returnValue; }
private bool PayForOrder(List<OrderPayoff> orderPayoffList, decimal paymentMoney, decimal needChangePay, string tradePayNo) { //填充Order Order order = new Order(); order.OrderID = m_SalesOrder.order.OrderID; order.TotalSellPrice = m_TotalPrice; order.ActualSellPrice = m_ActualPayMoney; order.DiscountPrice = m_Discount; order.CutOffPrice = m_CutOff; order.ServiceFee = 0; order.PaymentMoney = paymentMoney; order.NeedChangePay = needChangePay; order.MembershipCard = string.Empty; order.MemberDiscount = 0; order.PayEmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; order.PayEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo; order.CheckoutDeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo; order.TradePayNo = tradePayNo; PayingOrder payingOrder = new PayingOrder(); payingOrder.order = order; payingOrder.orderPayoffList = orderPayoffList; return PayingOrderService.GetInstance().PayForOrder(payingOrder); }
private void btnPreCheck_Click(object sender, EventArgs e) { CrystalButton btn = sender as CrystalButton; Order order = m_SalesOrder.order; if (order.Status == 0) { //存在整单折扣则先提交 //填充Order Order submitOrder = new Order(); submitOrder.OrderID = order.OrderID; submitOrder.TotalSellPrice = m_TotalPrice; submitOrder.ActualSellPrice = m_ActualPayMoney; submitOrder.DiscountPrice = m_Discount; submitOrder.CutOffPrice = m_CutOff; submitOrder.ServiceFee = m_ServiceFee; submitOrder.MembershipCard = m_MembershipCard; submitOrder.MemberDiscount = m_MemberDiscountRate; //填充OrderDetails\OrderDiscount List<OrderDetails> orderDetailsList = new List<OrderDetails>(); List<OrderDiscount> newOrderDiscountList = new List<OrderDiscount>(); foreach (DataGridViewRow dr in dgvGoodsOrder.Rows) { OrderDetails orderDetails = dr.Cells["OrderDetailsID"].Tag as OrderDetails; if (orderDetails != null) { Discount itemDiscount = dr.Cells["GoodsDiscount"].Tag as Discount; decimal itemDiscountPrice = Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value); if (orderDetails.CanDiscount && itemDiscount != null && Math.Abs(itemDiscountPrice) > 0) { orderDetailsList.Add(orderDetails); //OrderDiscount OrderDiscount orderDiscount = new OrderDiscount(); orderDiscount.OrderDiscountID = Guid.NewGuid(); orderDiscount.OrderID = order.OrderID; orderDiscount.OrderDetailsID = orderDetails.OrderDetailsID; orderDiscount.DiscountID = itemDiscount.DiscountID; orderDiscount.DiscountName = itemDiscount.DiscountName; orderDiscount.DiscountType = itemDiscount.DiscountType; orderDiscount.DiscountRate = itemDiscount.DiscountRate; orderDiscount.OffFixPay = itemDiscount.OffFixPay; orderDiscount.OffPay = Math.Abs(Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value)); orderDiscount.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; newOrderDiscountList.Add(orderDiscount); } } } if (orderDetailsList.Count > 0 && newOrderDiscountList.Count > 0) { PayingOrder payingOrder = new PayingOrder(); payingOrder.order = submitOrder; payingOrder.orderDetailsList = orderDetailsList; payingOrder.orderDiscountList = newOrderDiscountList; bool result = PayingOrderService.GetInstance().CreatePrePayOrder(payingOrder); if (result) { btn.Text = "解锁"; order.Status = 3; //预结 m_IsPreCheckOut = true; } else { MessageBox.Show("预结账单失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { int status = 3; //预结 if (OrderService.GetInstance().UpdateOrderStatus(order.OrderID, status)) { btn.Text = "解锁"; order.Status = status; m_IsPreCheckOut = true; } else { MessageBox.Show("预结账单失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } //打印预结小票 PrintData printData = new PrintData(); printData.ShopName = ConstantValuePool.CurrentShop.ShopName; printData.DeskName = m_CurrentDeskName; printData.PersonNum = m_SalesOrder.order.PeopleNum.ToString(); printData.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); printData.EmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo; printData.TranSequence = m_SalesOrder.order.TranSequence.ToString(); printData.ShopAddress = ConstantValuePool.CurrentShop.RunAddress; printData.Telephone = ConstantValuePool.CurrentShop.Telephone; printData.ReceivableMoney = this.lbReceMoney.Text; printData.ServiceFee = m_ServiceFee.ToString("f2"); printData.TotalAmount = (m_ActualPayMoney + m_ServiceFee).ToString("f2"); printData.GoodsOrderList = new List<GoodsOrder>(); foreach (OrderDetails item in m_SalesOrder.orderDetailsList) { string strLevelFlag = string.Empty; int levelCount = item.ItemLevel * 2; for (int i = 0; i < levelCount; i++) { strLevelFlag += "-"; } GoodsOrder goodsOrder = new GoodsOrder(); goodsOrder.GoodsName = strLevelFlag + item.GoodsName; goodsOrder.GoodsNum = item.ItemQty.ToString("f1"); goodsOrder.SellPrice = item.SellPrice.ToString("f2"); goodsOrder.TotalSellPrice = item.TotalSellPrice.ToString("f2"); goodsOrder.TotalDiscount = item.TotalDiscount.ToString("f2"); goodsOrder.Unit = item.Unit; printData.GoodsOrderList.Add(goodsOrder); } string paperWidth = ConstantValuePool.BizSettingConfig.printConfig.PaperWidth; if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.DRIVER) { string printerName = ConstantValuePool.BizSettingConfig.printConfig.Name; string paperName = ConstantValuePool.BizSettingConfig.printConfig.PaperName; DriverOrderPrint printer = DriverOrderPrint.GetInstance(printerName, paperName, paperWidth); printer.DoPrintPrePayOrder(printData); } if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.COM) { string port = ConstantValuePool.BizSettingConfig.printConfig.Name; if (port.Length > 3) { if (port.Substring(0, 3).ToUpper() == "COM") { string portName = port.Substring(0, 4).ToUpper(); InstructionOrderPrint printer = new InstructionOrderPrint(portName, 9600, Parity.None, 8, StopBits.One, paperWidth); printer.DoPrintPrePayOrder(printData); } } } if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.ETHERNET) { string ipAddress = ConstantValuePool.BizSettingConfig.printConfig.Name; InstructionOrderPrint printer = new InstructionOrderPrint(ipAddress, 9100, paperWidth); printer.DoPrintPrePayOrder(printData); } if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.USB) { string vid = ConstantValuePool.BizSettingConfig.printConfig.VID; string pid = ConstantValuePool.BizSettingConfig.printConfig.PID; string endpointId = ConstantValuePool.BizSettingConfig.printConfig.EndpointID; InstructionOrderPrint printer = new InstructionOrderPrint(vid, pid, endpointId, paperWidth); printer.DoPrintPrePayOrder(printData); } } else if (order.Status == 3) { //权限验证 bool hasRights = false; if (RightsItemCode.FindRights(RightsItemCode.PRECHECKOUT)) { hasRights = true; } else { FormRightsCode form = new FormRightsCode(); form.ShowDialog(); if (form.ReturnValue) { IList<string> rightsCodeList = form.RightsCodeList; if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.PRECHECKOUT)) { hasRights = true; } } } if (!hasRights) { return; } int status = 0; if (OrderService.GetInstance().UpdateOrderStatus(order.OrderID, status)) { btn.Text = "预结"; order.Status = status; m_IsPreCheckOut = false; } else { MessageBox.Show("预结状态解锁失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
private bool PayForOrder(List<OrderPayoff> orderPayoffList, decimal paymentMoney, decimal needChangePay, string tradePayNo) { //填充Order Order order = new Order(); order.OrderID = m_SalesOrder.order.OrderID; order.TotalSellPrice = m_TotalPrice; order.ActualSellPrice = m_ActualPayMoney; order.DiscountPrice = m_Discount; order.CutOffPrice = m_CutOff; order.ServiceFee = m_ServiceFee; order.PaymentMoney = paymentMoney; order.NeedChangePay = needChangePay; order.MembershipCard = m_MembershipCard; order.MemberDiscount = m_MemberDiscountRate; order.PayEmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; order.PayEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo; order.CheckoutDeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo; order.TradePayNo = tradePayNo; //填充OrderDetails\OrderDiscount List<OrderDetails> orderDetailsList = new List<OrderDetails>(); List<OrderDiscount> newOrderDiscountList = new List<OrderDiscount>(); foreach (DataGridViewRow dr in dgvGoodsOrder.Rows) { OrderDetails orderDetails = dr.Cells["OrderDetailsID"].Tag as OrderDetails; if (orderDetails != null) { Discount itemDiscount = dr.Cells["GoodsDiscount"].Tag as Discount; decimal itemDiscountPrice = Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value); if (orderDetails.CanDiscount && itemDiscount != null && Math.Abs(itemDiscountPrice) > 0) { orderDetailsList.Add(orderDetails); //OrderDiscount OrderDiscount orderDiscount = new OrderDiscount(); orderDiscount.OrderDiscountID = Guid.NewGuid(); orderDiscount.OrderID = m_SalesOrder.order.OrderID; orderDiscount.OrderDetailsID = orderDetails.OrderDetailsID; orderDiscount.DiscountID = itemDiscount.DiscountID; orderDiscount.DiscountName = itemDiscount.DiscountName; orderDiscount.DiscountType = itemDiscount.DiscountType; orderDiscount.DiscountRate = itemDiscount.DiscountRate; orderDiscount.OffFixPay = itemDiscount.OffFixPay; orderDiscount.OffPay = Math.Abs(Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value)); orderDiscount.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; newOrderDiscountList.Add(orderDiscount); } } } PayingOrder payingOrder = new PayingOrder(); payingOrder.order = order; payingOrder.orderDetailsList = orderDetailsList; payingOrder.orderDiscountList = newOrderDiscountList; payingOrder.orderPayoffList = orderPayoffList; return PayingOrderService.GetInstance().PayForOrder(payingOrder); }