Exemplo n.º 1
0
        private void btn_ReturnGoods_Click(object sender, EventArgs e)
        {
            ReturnGoods returnGoods = new ReturnGoods(this);

            returnGoods.MdiParent = this;
            SetMdiForm(returnGoods.Text, typeof(ReturnGoods));
        }
Exemplo n.º 2
0
 public ItemInput(ReturnGoods obj, ILog log)
 {
     InitializeComponent();
     this.returnGoods = obj;
     this.log         = log;
     this.count       = ParentWindow.ReturnGoods.ToString();
 }
Exemplo n.º 3
0
        private void returnGoodsButton_Click(object sender, EventArgs e)
        {
            ReturnGoods returnGoods = new ReturnGoods();

            returnGoods.Show();//扫码退货
            this.Hide();
        }
Exemplo n.º 4
0
 public void Add(ReturnGoods returnGoods)
 {
     if (_returnGoodsRepository.Exists(p => p.WayBillNumber == returnGoods.WayBillNumber))
     {
         return;
     }
     _returnGoodsRepository.Add(returnGoods);
     _returnGoodsRepository.UnitOfWork.Commit();
 }
Exemplo n.º 5
0
 public QueryGoods(ReturnGoods obj, string bar, string num)
 {
     this.returnGoods = obj;
     this.bar         = bar;
     this.num         = num;
     this.count       = ParentWindow.ReturnGoods.ToString();
     if (num.Equals(""))
     {
         this.num = "1";
     }
 }
Exemplo n.º 6
0
 public ScanGood(ReturnGoods obj, string bar, string num)
 {
     InitializeComponent();
     this.returnGoods = obj;
     this.bar         = bar;
     this.num         = num;
     this.count       = ParentWindow.ReturnGoods.ToString();
     if (num.Equals(""))
     {
         this.num = "1";
     }
 }
Exemplo n.º 7
0
        public void BatchAddReturnGoods(List <ReturnGoodsExt> list)
        {
            var returnList = list.FindAll(p => p.IsDirectReturnGoods).Where(returnGoods =>
                                                                            !_returnGoodsRepository.Exists(p => p.WayBillNumber == returnGoods.WayBillNumber)).ToList();

            if (returnList.Any())
            {
                //直接退货操作
                foreach (var returnGoods in returnList)
                {
                    #region 修改订单、运单状态

                    var wayBillInfo = _wayBillInfoRepository.Get(returnGoods.WayBillNumber);
                    if (wayBillInfo != null)
                    {
                        if (wayBillInfo.Status != (int)WayBill.StatusEnum.Send && wayBillInfo.Status != (int)WayBill.StatusEnum.WaitOrder)
                        {
                            throw new Exception(string.Format("运单{0}的状态不是已发货或待转单", returnGoods.WayBillNumber));
                        }

                        wayBillInfo.Status                   = WayBill.StatusToValue(WayBill.StatusEnum.ReGoodsInStorage);
                        wayBillInfo.LastUpdatedOn            = DateTime.Now;
                        wayBillInfo.LastUpdatedBy            = returnGoods.UserName;
                        wayBillInfo.CustomerOrderInfo.Status =
                            CustomerOrder.StatusToValue(CustomerOrder.StatusEnum.ReGoodsInStorage);
                        wayBillInfo.CustomerOrderInfo.LastUpdatedBy = returnGoods.UserName;
                        wayBillInfo.CustomerOrderInfo.LastUpdatedOn = DateTime.Now;
                        _wayBillInfoRepository.Modify(wayBillInfo);
                    }
                    #endregion

                    #region 录入内部信息

                    if (wayBillInfo != null)
                    {
                        //Add By zxq
                        //Time:2014-09-15
                        var wayBillEventLog = new WayBillEventLog()
                        {
                            WayBillNumber = wayBillInfo.WayBillNumber,
                            EventCode     = (int)WayBillEvent.EventCodeEnum.OutStorage,
                            Description   = WayBillEvent.GetEventCodeDescription((int)WayBillEvent.EventCodeEnum.OutStorage),
                            EventDate     = DateTime.Now,
                            LastUpdatedOn = DateTime.Now,
                            Operator      = returnGoods.UserName,
                        };

                        _wayBillEventLogRepository.Add(wayBillEventLog);
                    }

                    #endregion

                    //退货详细
                    if (wayBillInfo != null)
                    {
                        ReceivingExpensesEditExt receivingExpensesEditExt = new ReceivingExpensesEditExt();
                        receivingExpensesEditExt =
                            _financialService.GetReceivingExpensesEditExt(wayBillInfo.WayBillNumber);
                        ReturnGoods rgGoods = new ReturnGoods()
                        {
                            WayBillNumber    = returnGoods.WayBillNumber,
                            Weight           = returnGoods.Weight != 0 ? returnGoods.Weight : wayBillInfo.Weight.Value,
                            CreatedBy        = returnGoods.UserName,
                            CreatedOn        = DateTime.Now,
                            IsReturnShipping = returnGoods.IsReturnShipping,
                            LastUpdatedBy    = returnGoods.UserName,
                            LastUpdatedOn    = DateTime.Now,
                            Reason           = returnGoods.Reason,
                            ReasonRemark     = returnGoods.ReasonRemark,
                            ReGoodsId        = SequenceNumberService.GetSequenceNumber(PrefixCode.ReturnGoodsID),
                            Type             = returnGoods.Type,
                            Status           = (int)ReturnGood.ReturnStatusEnum.UnAudited,
                            ReturnSource     = (int)ReturnGood.ReturnSourceStatusEnum.CSReturn
                        };


                        //是否退运费
                        if (returnGoods.IsReturnShipping)
                        {
                            if (receivingExpensesEditExt != null)
                            {
                                if (receivingExpensesEditExt.TotalFeeFinal.HasValue)
                                {
                                    rgGoods.ShippingFee = receivingExpensesEditExt.TotalFeeFinal ?? 0;
                                }
                                else if (receivingExpensesEditExt.TotalFeeOriginal.HasValue)
                                {
                                    rgGoods.ShippingFee = receivingExpensesEditExt.TotalFeeOriginal ?? 0;
                                }
                            }
                            else
                            {
                                rgGoods.ShippingFee = 0;
                            }
                        }
                        else
                        {
                            rgGoods.ShippingFee = 0;
                        }
                        _returnGoodsRepository.Add(rgGoods);
                    }
                    using (var transaction = new TransactionScope())
                    {
                        _returnGoodsRepository.UnitOfWork.Commit();
                        _wayBillInfoRepository.UnitOfWork.Commit();
                        _wayBillEventLogRepository.UnitOfWork.Commit();
                        _receivingExpensRepository.UnitOfWork.Commit();
                        transaction.Complete();
                    }
                }
            }
        }
Exemplo n.º 8
0
 public GoodsChoose(ReturnGoods obj)
 {
     InitializeComponent();
     this.returnGoods = obj;
     this.count       = ParentWindow.ReturnGoods.ToString();
 }
Exemplo n.º 9
0
        private void btnReturnGoods_Click(object sender, EventArgs e)
        {
            if (!IsShopManager)
            {
                ShowMessage("当前用户无退货权限!", ico: MessageBoxIcon.Warning);
                return;
            }
            DataTable dataSource = this.gridControlReturnGoods.DataSource as DataTable;

            if (null != dataSource)
            {
                var rows = dataSource.Select("ReturnCount>0"); //过滤数据
                if (null != rows && rows.Length > 0)
                {
                    if (XtraMessageBox.Show("确定要执行退货操作吗?一张小票只能执行一次退货操作!", "系统提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        ReturnGoods returnGoods = new ReturnGoods();
                        returnGoods.ID               = new Guid(rows[0]["PosID"].ToString());
                        returnGoods.Cashier          = UserInfo.Instance.RealName;
                        returnGoods.CashierID        = UserInfo.Instance.ID;
                        returnGoods.Description      = txtDescription.Text;
                        returnGoods.Details          = new List <ReturnGoodsDetail>();
                        returnGoods.Guider           = txtGuider.Text;
                        returnGoods.GuiderID         = new Guid(labelGuider.Tag.ToString());
                        returnGoods.PayType          = int.Parse(labelPaytype.Tag.ToString());
                        returnGoods.RecordSerial     = PosBLL.instance.GetBatchNumber("LS");
                        returnGoods.RefundAmount     = double.Parse(labelReturnAmount.Text);
                        returnGoods.RefundTime       = DateTime.Now;
                        returnGoods.ReturnGoodsCount = int.Parse(labelReturnCount.Text);
                        returnGoods.TicketCode       = labelLS.Tag.ToString();

                        for (int i = 0; i < rows.Length; i++)
                        {
                            ReturnGoodsDetail detail = new ReturnGoodsDetail();
                            detail.ID           = new Guid(rows[i]["ID"].ToString());
                            detail.PosID        = returnGoods.ID;
                            detail.ReturnAmount = double.Parse(rows[i]["ReturnAmount"].ToString());
                            detail.ReturnCount  = int.Parse(rows[i]["ReturnCount"].ToString());
                            returnGoods.Details.Add(detail);
                        }
                        var    returnAmount  = returnGoods.Details.Sum(item => item.ReturnAmount).ToString();
                        bool   hasError      = false;
                        string msg           = null;
                        int    payTypeCode   = int.Parse(PosRow["PayType"].ToString());
                        var    refoundAmount = returnGoods.Details.Sum(item => item.ReturnAmount).ToString();
                        //if (payTypeCode == (int)PayMentType.Alipay)
                        //{
                        //    IAlipayTradeService services = AlipayServices.CreateServiceClient();
                        //    AlipayF2FQueryResult queryResult = services.tradeQuery(PosRow["TicketCode"].ToString());
                        //    AlipayTradeQueryResponse response = queryResult.response;
                        //    if (response.TradeStatus.ToUpper() == "TRADE_CLOSED")
                        //    {
                        //        ShowMessage($"支付宝订单为关闭状态,无法退款,请走人工方式!");
                        //        return;
                        //    }
                        //    if (response.TradeStatus.ToUpper() == "TRADE_SUCCESS")
                        //    {
                        //        var refoundContent = new AlipayTradeRefundContentBuilder();
                        //        refoundContent.refund_reason = txtDescription.Text.Trim();
                        //        refoundContent.out_trade_no = PosRow["TicketCode"].ToString();
                        //        refoundContent.refund_amount = refoundAmount;
                        //        refoundContent.out_request_no = PosRow["PayOrderNo"].ToString();
                        //        AlipayF2FRefundResult refoundResult = services.tradeRefund(refoundContent);
                        //        switch (refoundResult.Status)
                        //        {
                        //            case Com.Alipay.Model.ResultEnum.SUCCESS:
                        //                msg = $"支付宝退款成功,退款金额:{refoundResult.response.RefundFee}";
                        //                break;
                        //            case Com.Alipay.Model.ResultEnum.FAILED:
                        //            case Com.Alipay.Model.ResultEnum.UNKNOWN:
                        //                msg = $"支付宝退款失败,失败原因:{refoundResult.response.SubMsg}";
                        //                hasError = true;
                        //                break;
                        //            default:
                        //                break;
                        //        }
                        //    }
                        //}
                        //else if (payTypeCode == (int)PayMentType.WeChat)
                        //{
                        //    int successCode = 0;
                        //    var res = MicroPay.Query(PosRow["TicketCode"].ToString(), out successCode);
                        //    decimal _goodsAmount = decimal.Parse(PosRow["GoodsAmount"].ToString()) * 100;
                        //    decimal _refoundAmount = decimal.Parse(refoundAmount) * 100;
                        //    string refoundResult = Refund.Run(PosRow["PayOrderNo"].ToString(), PosRow["TicketCode"].ToString(), 1.ToString(), 1.ToString());
                        //    //string refoundResult=Refund.Run(PosRow["PayOrderNo"].ToString(), PosRow["TicketCode"].ToString(), _goodsAmount.ToString(), _refoundAmount.ToString());

                        //}
                        if (!hasError)
                        {
                            var result = PosBLL.instance.SubmitRetunGoods(returnGoods);
                            if (result)
                            {
                                List <ReturnGoodsDetail> returnGoodsDetails = returnGoods.Details;

                                ShowMessage(msg ?? $"退款成功,退款金额:{returnAmount}");
                                Clear();
                            }
                        }
                    }
                }
                else
                {
                    ShowMessage("请修改列表中需退货商品的数量", "系统提示");
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 退货
        /// </summary>
        /// <param name="returnGoods">退货信息</param>
        /// <returns></returns>
        public static bool SubmitRetunGoods(ReturnGoods returnGoods)
        {
            if (null == returnGoods)
            {
                return(false);
            }

            if (null == returnGoods.Details || returnGoods.Details.Count == 0)
            {
                return(false);
            }

            string returnDetailInsertCommand = "INSERT INTO [ReturnPosDetail]([ID],[PosID],[BarID],[StoreID],[RetailPrice],[GoodsCount],[GoodsAmount],[DiscountRate],[DiscountPrice],[DiscountAmount],[BuyingPrice],[GoodsProfit],[GoodsName],[GoodsID],[GoodsCategoryID],[GoodsCategory],[CashierID],[SaleDate]) SELECT [ID],[PosID],[BarID],[StoreID],[RetailPrice],@GoodsCount,@GoodsAmount,[DiscountRate],[DiscountPrice],[DiscountAmount],[BuyingPrice],[GoodsProfit],[GoodsName],[GoodsID],[GoodsCategoryID],[GoodsCategory],[CashierID],[SaleDate] FROM [PosDetail] WHERE ID=@ID";
            string returnGoodsInsertCommand  = "INSERT INTO [ReturnGoods]([ID],[RecordSerial],[TicketCode],[PayType],[RefundAmount],[ReturnGoodsCount],[RefundTime],[CashierID],[Cashier],[GuiderID],[Guider],[Description]) VALUES(@ID,@RecordSerial,@TicketCode,@PayType,@RefundAmount,@ReturnGoodsCount,@RefundTime,@CashierID,@Cashier,@GuiderID,@Guider,@Description)";

            string posDetailUpdateCommand = "UPDATE [PosDetail] SET [ReturnCount]=@GoodsCount WHERE  [ID]=@ID";
            string posUpdateCommand       = "UPDATE [Pos] SET [RecordStatus]=-1 WHERE  [ID]=@ID";

            string goodsCommand = "UPDATE dbo.Goods SET SaleQuantity=SaleQuantity-@ReturnCount,SaleAmount=SaleAmount-@ReturnAmount,StockQuantity=StockQuantity+ @ReturnCount WHERE BarID IN (SELECT [BarID] FROM [PosDetail] WHERE ID=@ID) AND [StoreID] IN (SELECT [StoreID] FROM [PosDetail] WHERE ID=@ID)";

            var trans = utity.BeginTransaction();

            try
            {
                foreach (var item in returnGoods.Details)
                {
                    List <DbParameter> parms = new List <DbParameter>();
                    parms.Add(new SqlParameter("@GoodsCount", item.ReturnCount));
                    parms.Add(new SqlParameter("@ID", item.ID));
                    utity.ExecuteNonQuery(trans, CommandType.Text, posDetailUpdateCommand, parms.ToArray());    //更新销售明细表
                    parms.Add(new SqlParameter("@GoodsAmount", item.ReturnAmount));
                    utity.ExecuteNonQuery(trans, CommandType.Text, returnDetailInsertCommand, parms.ToArray()); //增加退货记录

                    var goodsPara = new List <DbParameter>();
                    goodsPara.Add(new SqlParameter("@ReturnCount", item.ReturnCount));
                    goodsPara.Add(new SqlParameter("@ReturnAmount", item.ReturnAmount));
                    goodsPara.Add(new SqlParameter("@ID", item.ID));
                    utity.ExecuteNonQuery(trans, CommandType.Text, goodsCommand, goodsPara.ToArray());
                }

                List <DbParameter> return_parms = new List <DbParameter>();
                return_parms.Add(new SqlParameter("@ID", returnGoods.ID));

                utity.ExecuteNonQuery(trans, CommandType.Text, posUpdateCommand, return_parms.ToArray()); //修改销售记录状态
                return_parms.Add(new SqlParameter("@RecordSerial", returnGoods.RecordSerial));
                return_parms.Add(new SqlParameter("@TicketCode", returnGoods.TicketCode));
                return_parms.Add(new SqlParameter("@PayType", returnGoods.PayType));
                return_parms.Add(new SqlParameter("@RefundAmount", returnGoods.RefundAmount));
                return_parms.Add(new SqlParameter("@ReturnGoodsCount", returnGoods.ReturnGoodsCount));
                return_parms.Add(new SqlParameter("@RefundTime", returnGoods.RefundTime));
                return_parms.Add(new SqlParameter("@CashierID", returnGoods.CashierID));
                return_parms.Add(new SqlParameter("@Cashier", returnGoods.Cashier));
                return_parms.Add(new SqlParameter("@GuiderID", returnGoods.GuiderID));
                return_parms.Add(new SqlParameter("@Guider", returnGoods.Guider));
                return_parms.Add(new SqlParameter("@Description", returnGoods.Description));
                utity.ExecuteNonQuery(trans, CommandType.Text, returnGoodsInsertCommand, return_parms.ToArray()); //增加退货记录

                trans.Commit();

                return(true);
            }
            catch (Exception exc)
            {
                string error = exc.Message;
                trans.Rollback();
                return(false);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// 提交退货信息
 /// </summary>
 /// <param name="returnGoods">退货信息</param>
 /// <returns></returns>
 public bool SubmitRetunGoods(ReturnGoods returnGoods)
 {
     return(PosDAL.SubmitRetunGoods(returnGoods));
 }