Esempio n. 1
0
 /// <summary>
 /// 计算已付款
 /// </summary>
 /// <param name="orderId"></param>
 /// <returns></returns>
 protected string GetPayed(string orderId)
 {
     string totle = string.Empty;
     decimal remPrice = 0;
     decimal payPrice = 0;
     decimal prePrice = 0;
     //银行支付
     ShowShop.BLL.Order.RemittanceInfo remBll = new ShowShop.BLL.Order.RemittanceInfo();
     List<ShowShop.Model.Order.RemittanceInfo> remdate = remBll.GetAll("orderid='" + orderId + "'");
     if (remdate.Count > 0)
     {
         foreach (ShowShop.Model.Order.RemittanceInfo da in remdate)
         {
             remPrice += Convert.ToDecimal(da.RemittanceMoney.ToString());
         }
     }
     //现金支付
     ShowShop.BLL.Order.PaymentMoney payBll = new ShowShop.BLL.Order.PaymentMoney();
     List<ShowShop.Model.Order.PaymentMoney> paydata = payBll.GetAll("orderid='" + orderId + "'");
     if (paydata.Count > 0)
     {
         foreach (ShowShop.Model.Order.PaymentMoney da in paydata)
         {
             payPrice += Convert.ToDecimal(da.GatheringMoney.ToString());
         }
     }
     //预付款
     ShowShop.BLL.Order.PrepayMoney preBll = new ShowShop.BLL.Order.PrepayMoney();
     List<ShowShop.Model.Order.PrepayMoney> predata = preBll.GetAll("orderid='" + orderId + "'");
     if (predata.Count > 0)
     {
         foreach (ShowShop.Model.Order.PrepayMoney da in predata)
         {
             prePrice += Convert.ToDecimal(da.PayoutMoney);
         }
     }
     totle = (remPrice + payPrice + prePrice).ToString();
     return totle;
 }
        /// <summary>
        /// 列表
        /// </summary>
        /// <returns></returns>
        protected string GetMoneyList(string orderId)
        {
            ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table();
            //银行资金
            ShowShop.BLL.Order.RemittanceInfo remBll = new ShowShop.BLL.Order.RemittanceInfo();
            ChangeHope.DataBase.DataByPage remData = remBll.GetList(" 1=1 and orderid='" + orderId + "'");
            //预付款
            ShowShop.BLL.Order.PrepayMoney preBll = new ShowShop.BLL.Order.PrepayMoney();
            ChangeHope.DataBase.DataByPage preData = preBll.GetList(" 1=1 and orderid='" + orderId + "'");
            //现金付款
            ShowShop.BLL.Order.PaymentMoney payBll = new ShowShop.BLL.Order.PaymentMoney();
            ChangeHope.DataBase.DataByPage payData = payBll.GetList(" 1=1 and orderid='" + orderId + "'");

            //第一步先添加表头
            table.AddHeadCol("", "客户名称");
            table.AddHeadCol("", "交易时间");
            table.AddHeadCol("", "交易方式");
            table.AddHeadCol("", "交易金额");
            table.AddHeadCol("", "备注/说明");
            table.AddHeadCol("", "赠送点卷");
            table.AddRow();
            //添加银行付款的内容
            if (remData.DataReader != null)
            {
                while (remData.DataReader.Read())
                {
                    table.AddCol(remData.DataReader["username"].ToString());
                    table.AddCol(remData.DataReader["remittancedate"].ToString());
                    table.AddCol("银行支付");
                    if (remData.DataReader["remittancemoney"].ToString() == "0")
                    {
                        table.AddCol("");
                    }
                    else
                    {
                        table.AddCol(remData.DataReader["remittancemoney"].ToString());
                    }
                    table.AddCol(remData.DataReader["remark"].ToString());
                    table.AddCol(remData.DataReader["presentticket"].ToString());
                    table.AddRow();
                }
            }
            //添加预付款的内容
            if (preData.DataReader != null)
            {
                while (preData.DataReader.Read())
                {
                    table.AddCol(preData.DataReader["username"].ToString());
                    table.AddCol(preData.DataReader["notedate"].ToString());
                    table.AddCol("预付款支付");
                    table.AddCol(preData.DataReader["payoutmoney"].ToString());
                    table.AddCol(preData.DataReader["remark"].ToString());
                    table.AddCol("0");
                    table.AddRow();
                }
            }
            //添加现金付款的内容
            if (payData.DataReader != null)
            {
                while (payData.DataReader.Read())
                {
                    table.AddCol(payData.DataReader["username"].ToString());
                    table.AddCol(payData.DataReader["gatheringdate"].ToString());
                    table.AddCol("现金付款");
                    table.AddCol(payData.DataReader["gatheringmoney"].ToString());
                    table.AddCol(payData.DataReader["remark"].ToString());
                    table.AddCol(payData.DataReader["presentticket"].ToString());
                    table.AddRow();
                }
            }
            string view = table.GetTable();
            remData.Dispose();
            remData = null;
            preData.Dispose();
            preData = null;
            payData.Dispose();
            payData = null;
            return view;
        }
        protected void lbtnSave_Click(object sender, EventArgs e)
        {
            ShowShop.Model.Admin.AdminInfo adminInfo = (ShowShop.Model.Admin.AdminInfo)ShowShop.Common.AdministrorManager.Get();
            if (Convert.ToDecimal(this.txtRefundmentMoney.Text.Trim()) + Convert.ToDecimal(this.txtPoundAge.Text.Trim()) > Convert.ToDecimal(GetPayed(this.lblOrderId.Text)))
            {
                this.ltlMsg.Text = "退款的金额不能大于已付的金额!";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionErr";
                return;
            }
            //银行支付
            ShowShop.BLL.Order.RemittanceInfo remBll = new ShowShop.BLL.Order.RemittanceInfo();
            ShowShop.Model.Order.RemittanceInfo remModel = remBll.GetModelByOrderId(this.lblOrderId.Text);
            //现金支付
            ShowShop.BLL.Order.PaymentMoney payBll = new ShowShop.BLL.Order.PaymentMoney();
            ShowShop.Model.Order.PaymentMoney payModel = payBll.GetModelByOrderId(this.lblOrderId.Text);
            //预付款
            ShowShop.BLL.Order.PrepayMoney preBll = new ShowShop.BLL.Order.PrepayMoney();
            ShowShop.Model.Order.PrepayMoney preModel = preBll.GetModelByOrderId(this.lblOrderId.Text);
            //订单信息
            ShowShop.BLL.Order.Orders orderBll = new ShowShop.BLL.Order.Orders();
            ShowShop.Model.Order.Orders orderModel = orderBll.GetModel(this.lblOrderId.Text);

            #region 退款信息
            ShowShop.BLL.Order.RefundMent refBll = new ShowShop.BLL.Order.RefundMent();
            ShowShop.Model.Order.RefundMent refModel = new ShowShop.Model.Order.RefundMent();
            refModel.OrderId = this.lblOrderId.Text;
            refModel.UserName = this.lblUserId.Text;
            refModel.PaymentDate = Convert.ToDateTime(this.txtPaymentDate.Text);
            refModel.PoundAge = Convert.ToDecimal(this.txtPoundAge.Text.Trim());
            refModel.RefundMentMoney = Convert.ToDecimal(this.txtRefundmentMoney.Text.Trim());
            refModel.RefundMentMode = this.rabRefundmentMode.SelectedItem.Text;
            refModel.Remark = this.txtRemark.Text;
            refModel.InformMode = GetInforMode(cbxInformMode)["txt"]; //通知方式
            refModel.NoteDate = DateTime.Now;
            refModel.NoteName = adminInfo.AdminName;
            #endregion

            #region 用户交易明细
            ShowShop.Model.Member.UserinAndExp userModel = new ShowShop.Model.Member.UserinAndExp();
            ShowShop.BLL.Member.UserinAndExp userBll = new ShowShop.BLL.Member.UserinAndExp();

            //银行资金的明细
            userModel.UID = this.GetUidByUserId(this.lblUserId.Text);
            userModel.AdsumMoneyDate = Convert.ToDateTime(this.txtPaymentDate.Text);
            userModel.AdsumMoney = Convert.ToDecimal(this.txtRefundmentMoney.Text);
            userModel.PresentCoupons = 0;
            userModel.RemitMode = 1;
            userModel.RemitBank = string.Empty;
            userModel.Remark = this.txtRemark.Text;
            userModel.FormMode = GetInforMode(cbxInformMode)["txt"]; //通知方式
            userModel.BosomNote = this.txtBosomNote.Text;
            userModel.NoteDate = DateTime.Now;
            userModel.NoteName = adminInfo.AdminName;
            userModel.InComeandExpState = 0;
            userModel.State = 0;
            userModel.UserId = this.lblUserId.Text;
            #endregion

            try
            {
                if (refModel.RefundMentMoney == orderModel.FactPrice)//如果退款和订单价 匹配
                {
                    remBll.Delete(remModel.ID.ToString());
                    payBll.Delete(payModel.ID.ToString());
                    preBll.Delete(preModel.ID.ToString());
                }
                else
                {
                    if (remModel.RemittanceMoney > 0) //银行汇款
                    {
                        if (remModel.RemittanceMoney <= refModel.RefundMentMoney)
                        {
                            remBll.Delete(remModel.ID.ToString());
                        }
                        else
                        {
                            remModel.RemittanceMoney = remModel.RemittanceMoney - refModel.RefundMentMoney;
                            remBll.Amend(remModel);
                        }
                    }
                    if (preModel.PayoutMoney > 0) //预付款
                    {
                        if (preModel.PayoutMoney <= refModel.RefundMentMoney)
                        {
                            preBll.Delete(preModel.ID.ToString());
                        }
                        else
                        {
                            preModel.PayoutMoney = (preModel.PayoutMoney + remModel.RemittanceMoney) - refModel.RefundMentMoney;
                            preBll.Amend(preModel);
                        }
                    }
                    if (payModel.GatheringMoney > 0) //现金支付
                    {
                        if (payModel.GatheringMoney == (refModel.RefundMentMoney - remModel.RemittanceMoney - preModel.PayoutMoney))
                        {
                            payBll.Delete(payModel.ID.ToString());
                        }
                        else
                        {
                            payModel.GatheringMoney = (remModel.RemittanceMoney + preModel.PayoutMoney + payModel.GatheringMoney) - refModel.RefundMentMoney;
                            payBll.Amend(payModel);
                        }
                    }
                }

                refBll.Add(refModel); //退款信息
                userBll.Add(userModel); //明细记录

                //已付款
                decimal payTotail = Convert.ToDecimal(this.GetPayed(this.lblOrderId.Text));
                if ((payTotail - (Convert.ToDecimal(this.txtRefundmentMoney.Text.Trim()))) < 0)
                {
                    orderModel.PaymentStatus = ShowShop.Common.OrdersStatusEnum.PaymentStatu.等待汇款.GetHashCode();
                }
                else
                {
                    orderModel.PaymentStatus = ShowShop.Common.OrdersStatusEnum.PaymentStatu.已收定金.GetHashCode();

                }
                orderModel.OrderStatus = ShowShop.Common.OrdersStatusEnum.OrderStatu.已经确认.GetHashCode();
                orderBll.Update(orderModel);
                ChangeHope.WebPage.BasePage.PageRight("已保存该信息.", "order_bank_pay.aspx?OrderId=" + orderModel.Id, "<li><a href='order_order_info.aspx?OrderId=" + orderModel.Id.ToString() + "'>返回信息页</a></li>");

            }
            catch
            {
                this.ltlMsg.Text = "操作失败!";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionErr";
            }
            finally
            {
                adminInfo = null;
                remModel = null;
                remBll = null;
                userModel = null;
                userBll = null;
                payBll = null;
                payModel = null;
                preBll = null;
                preModel = null;
                orderBll = null;
                orderModel = null;
                GC.Collect();
            }
        }