Example #1
0
        public bool DeletePaidSingleOrder(DeletedPaidOrder deletedPaidOrder)
        {
            string json = JsonConvert.SerializeObject(deletedPaidOrder);

            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_DELETE_PAIDSINGLEORDER), 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);
        }
Example #2
0
        public bool DeletePaidSingleOrder(DeletedPaidOrder deletedPaidOrder)
        {
            bool returnValue = false;

            _daoManager.BeginTransaction();
            try
            {
                if (deletedPaidOrder != null)
                {
                    if (_orderDao.UpdatePaidOrderPrice(deletedPaidOrder.order))
                    {
                        foreach (DeletedOrderDetails item in deletedPaidOrder.deletedOrderDetailsList)
                        {
                            _orderDetailsDao.DeleteSingleOrderDetails(item);
                        }
                        _orderPayoffDao.DeleteOrderPayoff(deletedPaidOrder.order.OrderID);
                        //日结号
                        string dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo();
                        //插入OrderPayoff
                        foreach (OrderPayoff item in deletedPaidOrder.orderPayoffList)
                        {
                            item.DailyStatementNo = dailyStatementNo;
                            _orderPayoffDao.CreateOrderPayoff(item);
                        }
                        returnValue = true;
                    }
                }
                _daoManager.CommitTransaction();
            }
            catch (Exception exception)
            {
                _daoManager.RollBackTransaction();
                returnValue = false;
                LogHelper.GetInstance().Error(string.Format("[DeletePaidSingleOrder]参数:deletedPaidOrder_{0}", JsonConvert.SerializeObject(deletedPaidOrder)), exception);
            }
            return(returnValue);
        }
Example #3
0
        public static byte[] DeletePaidSingleOrder(byte[] itemBuffer)
        {
            byte[]           objRet           = null;
            string           strReceive       = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD, itemBuffer.Length - ParamFieldLength.PACKAGE_HEAD).Trim('\0');
            DeletedPaidOrder deletedPaidOrder = JsonConvert.DeserializeObject <DeletedPaidOrder>(strReceive);

            bool result = DeletedOrderService.GetInstance().DeletePaidSingleOrder(deletedPaidOrder);

            if (result)
            {
                //单品删除订单成功
                objRet = new byte[ParamFieldLength.PACKAGE_HEAD];
                Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32);
                Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
            }
            else
            {
                //单品删除订单失败
                objRet = new byte[ParamFieldLength.PACKAGE_HEAD];
                Array.Copy(BitConverter.GetBytes((int)RET_VALUE.ERROR_DB), 0, objRet, 0, BasicTypeLength.INT32);
                Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
            }
            return(objRet);
        }
Example #4
0
        private void btnCheckOut_Click(object sender, EventArgs e)
        {
            decimal refundAmount     = decimal.Parse(txtRefundAmount.Text);
            decimal realReturnAmount = 0;

            if (!string.IsNullOrEmpty(txtRealReturnAmount.Text))
            {
                realReturnAmount = decimal.Parse(txtRealReturnAmount.Text);
            }
            if (refundAmount == realReturnAmount)
            {
                //判断支付方式是否正确
                bool IsPayoffWayRight = true;
                IList <OrderPayoff> _orderPayoffList = new List <OrderPayoff>();
                foreach (KeyValuePair <string, OrderPayoff> item in dic)
                {
                    if (item.Value.Quantity > 0)
                    {
                        _orderPayoffList.Add(item.Value);
                    }
                }
                foreach (OrderPayoff orderPayoff in _orderPayoffList)
                {
                    bool        IsContains = false;
                    OrderPayoff temp       = null;
                    foreach (OrderPayoff item in m_SalesOrder.orderPayoffList)
                    {
                        if (item.PayoffID.Equals(orderPayoff.PayoffID))
                        {
                            IsContains = true;
                            temp       = item;
                            break;
                        }
                    }
                    if (IsContains)
                    {
                        decimal tempAmount = temp.AsPay * temp.Quantity - temp.NeedChangePay;
                        decimal payAmount  = orderPayoff.AsPay * orderPayoff.Quantity - orderPayoff.NeedChangePay;
                        if (tempAmount < payAmount)
                        {
                            IsPayoffWayRight = false;
                            break;
                        }
                    }
                    else
                    {
                        IsPayoffWayRight = false;
                        break;
                    }
                }
                if (IsPayoffWayRight)
                {
                    IList <OrderPayoff> orderPayoffList = new List <OrderPayoff>();
                    foreach (OrderPayoff item in m_SalesOrder.orderPayoffList)
                    {
                        bool IsContains = false;
                        foreach (OrderPayoff orderPayoff in _orderPayoffList)
                        {
                            if (item.PayoffID.Equals(orderPayoff.PayoffID))
                            {
                                decimal remainQty = ((item.AsPay * item.Quantity - item.NeedChangePay) - (orderPayoff.AsPay * orderPayoff.Quantity - orderPayoff.NeedChangePay)) / orderPayoff.AsPay;
                                if (remainQty > 0)
                                {
                                    OrderPayoff temp = new OrderPayoff();
                                    temp.OrderPayoffID = Guid.NewGuid();
                                    temp.OrderID       = m_SalesOrder.order.OrderID;
                                    temp.PayoffID      = item.PayoffID;
                                    temp.PayoffName    = item.PayoffName;
                                    temp.PayoffType    = item.PayoffType;
                                    temp.AsPay         = item.AsPay;
                                    temp.Quantity      = remainQty;
                                    temp.NeedChangePay = 0;
                                    temp.CardNo        = item.CardNo;
                                    temp.EmployeeID    = ConstantValuePool.CurrentEmployee.EmployeeID;
                                    orderPayoffList.Add(temp);
                                }
                                IsContains = true;
                                break;
                            }
                        }
                        if (!IsContains)
                        {
                            OrderPayoff temp = CopyExtension.Clone <OrderPayoff>(item);
                            temp.OrderID       = m_SalesOrder.order.OrderID;
                            temp.OrderPayoffID = Guid.NewGuid();
                            temp.EmployeeID    = ConstantValuePool.CurrentEmployee.EmployeeID;
                            orderPayoffList.Add(temp);
                        }
                    }
                    List <DeletedOrderDetails> deletedOrderDetailsList = new List <DeletedOrderDetails>();
                    for (int i = 0; i < dgvGoodsOrder.RowCount; i++)
                    {
                        OrderDetails tempOrderDetails  = dgvGoodsOrder.Rows[i].Cells["OrderDetailsID"].Tag as OrderDetails;
                        decimal      tempGoodsNum      = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsNum"].Value);
                        decimal      tempGoodsDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsDiscount"].Value);
                        decimal      tempDeletedNum    = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["DelFlag"].Value);
                        if (Math.Abs(tempDeletedNum) > 0)
                        {
                            decimal             remainQty    = tempGoodsNum - Math.Abs(tempDeletedNum);
                            DeletedOrderDetails orderDetails = new DeletedOrderDetails();
                            orderDetails.OrderDetailsID    = tempOrderDetails.OrderDetailsID;
                            orderDetails.DeletedQuantity   = tempDeletedNum;
                            orderDetails.RemainQuantity    = remainQty;
                            orderDetails.OffPay            = Math.Round(-tempGoodsDiscount / tempGoodsNum * remainQty, 4);
                            orderDetails.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID;
                            orderDetails.CancelEmployeeNo  = ConstantValuePool.CurrentEmployee.EmployeeNo;
                            orderDetails.CancelReasonName  = dgvGoodsOrder.Rows[i].Cells["DelReasonName"].Value.ToString();;
                            deletedOrderDetailsList.Add(orderDetails);
                        }
                    }
                    //构造DeletedPaidOrder对象
                    decimal paymentMoney = 0;
                    foreach (OrderPayoff item in orderPayoffList)
                    {
                        paymentMoney += item.AsPay * item.Quantity;
                    }
                    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   = 0;
                    order.EmployeeID      = ConstantValuePool.CurrentEmployee.EmployeeID;
                    DeletedPaidOrder deletedPaidOrder = new DeletedPaidOrder();
                    deletedPaidOrder.order = order;
                    deletedPaidOrder.deletedOrderDetailsList = deletedOrderDetailsList;
                    deletedPaidOrder.orderPayoffList         = orderPayoffList;
                    if (DeletedOrderService.GetInstance().DeletePaidSingleOrder(deletedPaidOrder))
                    {
                        m_IsChanged = true;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("单品删除失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("退款支付方式不属于原结账支付方式,请重新支付!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("应退金额与实退金额不一致,请重新支付!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }