public bool ModifyForOrder(ModifiedPaidOrder modifiedPaidOrder) { string json = JsonConvert.SerializeObject(modifiedPaidOrder); 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_MODIFY_PAIDORDER), 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 ModifyForOrder(ModifiedPaidOrder modifiedOrder) { bool returnValue = false; _daoManager.BeginTransaction(); try { if (modifiedOrder != null) { //日结 string dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo(); //更新Order if (_orderDao.UpdatePaidOrderPrice(modifiedOrder.order)) { //更新OrderDetails foreach (OrderDetails item in modifiedOrder.orderDetailsList) { _orderDetailsDao.UpdateOrderDetailsDiscount(item); } if (modifiedOrder.orderDiscountList != null && modifiedOrder.orderDiscountList.Count > 0) { foreach (OrderDiscount item in modifiedOrder.orderDiscountList) { //删除OrderDiscount _orderDiscountDao.DeleteOrderSingleDiscount(item.OrderDetailsID); //插入OrderDiscount item.DailyStatementNo = dailyStatementNo; _orderDiscountDao.CreateOrderDiscount(item); } } _orderPayoffDao.DeleteOrderPayoff(modifiedOrder.order.OrderID); //插入OrderPayoff foreach (OrderPayoff item in modifiedOrder.orderPayoffList) { item.DailyStatementNo = dailyStatementNo; _orderPayoffDao.CreateOrderPayoff(item); } returnValue = true; } } _daoManager.CommitTransaction(); } catch(Exception exception) { LogHelper.GetInstance().Error(string.Format("[ModifyForOrder]参数:modifiedOrder_{0}", JsonConvert.SerializeObject(modifiedOrder)), exception); _daoManager.RollBackTransaction(); returnValue = false; } return returnValue; }
private bool ModifyForOrder(List<OrderPayoff> orderPayoffList, decimal paymentMoney, decimal needChangePay) { //填充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.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; //填充OrderDetails\OrderDiscount List<OrderDetails> orderDetailsList = new List<OrderDetails>(); List<OrderDiscount> orderDiscountList = new List<OrderDiscount>(); for (int i = 0; i < dgvGoodsOrder.RowCount; i++) { Discount itemDiscount = dgvGoodsOrder.Rows[i].Cells["GoodsDiscount"].Tag as Discount; if (itemDiscount != null) { decimal itemDiscountPrice = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsDiscount"].Value); OrderDetails orderDetails = CopyExtension.Clone<OrderDetails>(m_SalesOrder.orderDetailsList[i]); orderDetails.TotalDiscount = itemDiscountPrice; 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(itemDiscountPrice); orderDiscount.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; orderDiscountList.Add(orderDiscount); } } ModifiedPaidOrder modifiedPaidOrder = new ModifiedPaidOrder(); modifiedPaidOrder.order = order; modifiedPaidOrder.orderDetailsList = orderDetailsList; modifiedPaidOrder.orderDiscountList = orderDiscountList; modifiedPaidOrder.orderPayoffList = orderPayoffList; return ModifyOrderService.GetInstance().ModifyForOrder(modifiedPaidOrder); }