⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 refundment.aspx.cs

📁 易想商城系统
💻 CS
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Shop.Web.UI;
using System.Collections.Generic;

namespace YXShop.Web.Membercenter.Dynamic
{
    public partial class Refundment : System.Web.UI.Page
    {
        public static string orderId = "";
        public static int userID = 0;
        private static decimal orderPrice = 0;

        private static decimal remiPrice = 0;
        private static decimal paymPrice = 0;
        private static decimal prepPrice = 0;
        YXShop.BLL.Orders bll = new YXShop.BLL.Orders();
        YXShop.BLL.BankAccount bankBll = new YXShop.BLL.BankAccount();
        YXShop.BLL.MemberInfo membBll = new YXShop.BLL.MemberInfo();
        YXShop.BLL.UserInAndExp UIAEBll = new YXShop.BLL.UserInAndExp();
        YXShop.BLL.Refundment refunBll = new YXShop.BLL.Refundment();
        BasePage bp = new BasePage();
        YXShop.BLL.RemittanceInfo Remibll = new YXShop.BLL.RemittanceInfo();//银行支付
        YXShop.BLL.PaymentMoney paymbll = new YXShop.BLL.PaymentMoney();//现金支付
        YXShop.BLL.PrepayMoney prepbll = new YXShop.BLL.PrepayMoney();//预付款支付
        protected void Page_Load(object sender, EventArgs e)
        {
            YXShop.DBUtility.ExitMemberCenter.ExitDynamic();
            saveInfo.Attributes.Add("onclick", "confirm('你确定保存退款信息吗?')");
            if ((!IsPostBack) || ((Request["Event"] != null) && (Request["Event"] != "")))
            {
                //初始化信息(订单信息,银行信息,支付信息)
                if (!string.IsNullOrEmpty(Request.QueryString["OrderID"]))
                {
                    //bindOrderInfo(YXShop.Common.WebUtility.replaceStr(Request.QueryString["OrderID"]));
                    orderId = YXShop.Common.WebUtility.replaceStr(Request.QueryString["OrderID"]);
                    bindOrderInfo(orderId);
                    foreach (ListItem li in RadioButtonList1.Items)
                    {
                        li.Attributes.Add("onclick", "changeTxt(this)");
                    }
                }
                else
                {
                    Response.Redirect("orderList.aspx");
                }
            }
        }
        /// <summary>
        /// 绑定订单数据及其它
        /// </summary>
        /// <param name="orderID"></param>
        private void bindOrderInfo(string orderID)
        {
            List<YXShop.Model.Orders> li = bll.GetListByColumn("OrderID", orderID);
            YXShop.Model.RemittanceInfo bankModel = Remibll.GetModel(orderId);
            YXShop.Model.PaymentMoney paymModel = paymbll.GetModel(orderId);
            YXShop.Model.PrepayMoney prepModel = prepbll.GetModel(orderId);
            if (li.Count == 1)
            {
                orderPrice = Convert.ToDecimal(li[0].FactPrice);
                remiPrice = Convert.ToDecimal(bankModel != null ? bankModel.RemittanceMoney : 0);
                paymPrice = Convert.ToDecimal(paymModel != null ? paymModel.GatheringMoney : 0);
                prepPrice = Convert.ToDecimal(prepModel != null ? prepModel.PayoutMoney : 0);

                userID = int.Parse(li[0].UserId);
                Label1.Text = UserReal(userID);
                myuser.Text = UserName(userID);
                Label3.Text = li[0].OrderId;
                Label4.Text = orderPrice.ToString();
                Label5.Text = (remiPrice + paymPrice + prepPrice).ToString();//已经支付
                TextBox6.Text = "0";
                TextBox2.Text = "订单退款金额,订单号:" + orderId;
                if (orderPrice <= (remiPrice + paymPrice + prepPrice))
                {
                    TextBox4.Text = orderPrice.ToString();
                }
                else
                {
                    TextBox4.Text = (remiPrice + paymPrice + prepPrice).ToString();
                }
            }
        }
        #region 客户信息查询
        protected string UserName(int UserID)
        {
            string str = "";
            YXShop.BLL.UserCommon ucBll = new YXShop.BLL.UserCommon();
            List<YXShop.Model.UserCommon> ucList = ucBll.GetListByColumn("UID", UserID);
            if (ucList.Count > 0)
            {
                str = ucList[0].UserName;
            }
            return str;
        }
        protected string UserReal(int UserID)
        {
            string str = "";
            YXShop.BLL.MemberInfo data = new YXShop.BLL.MemberInfo();
            List<YXShop.Model.MemberInfo> dataStr = data.GetListByColumn("UID", UserID);
            if (dataStr.Count > 0)
            {
                str = dataStr[0].cTrueName;
            }
            return str;
        }
        #endregion
        protected void saveInfo_Click(object sender, EventArgs e)
        {

            YXShop.Model.UserInAndExp uiaeModel = null;
            YXShop.Model.Refundment refunModel = new YXShop.Model.Refundment();

            YXShop.Model.RemittanceInfo bankModel = Remibll.GetModel(orderId);
            YXShop.Model.PaymentMoney paymModel = paymbll.GetModel(orderId);
            YXShop.Model.PrepayMoney prepModel = prepbll.GetModel(orderId);

            decimal reimbursement = Convert.ToDecimal(TextBox4.Text.Trim());

            if (reimbursement > (remiPrice + paymPrice + prepPrice))//已经支付 
            {
                YXShop.Common.alert.ShowAndRedirectgo(this, "退订订单金额不能大于已付款金额!", "refundment.aspx?OrderID=" + orderId);
                return;
            }

            //int userID = membBll.getUserIDByName(myuser.Text);//通过用户名找寻用户编号

            #region 退款信息
            refunModel.OrderID = Label3.Text;
            refunModel.UserName = myuser.Text;
            refunModel.PaymentDate = getMoneyDate.Date;
            refunModel.Poundage = Convert.ToDecimal(YXShop.Common.WebUtility.replaceStr(TextBox6.Text));
            refunModel.RefundmentMoney = reimbursement;//退款金额
            refunModel.RefundmentMode = RadioButtonList1.SelectedItem.Text;
            refunModel.Remark = YXShop.Common.WebUtility.replaceStr(TextBox2.Text);
            refunModel.InformMode = GetInforMode(CheckBoxList1)["txt"];//通知方式
            refunModel.NoteDate = DateTime.Now;
            refunModel.NoteName = Session["MemberName"].ToString();
            #endregion

            #region 用户交易明细
            uiaeModel = new YXShop.Model.UserInAndExp();
            uiaeModel.UserID = userID;
            uiaeModel.AdsumMoneyDate = getMoneyDate.Date;
            uiaeModel.AdsumMoney = Convert.ToDecimal(TextBox4.Text);
            uiaeModel.PresentTicket = 0;
            uiaeModel.RemitJoinMode = YXShop.Common.StatuEnum.RemitJoinMode.虚拟货币.GetHashCode();//支付方式:虚拟货币
            uiaeModel.RemitJoinBank = "";
            uiaeModel.Remark = YXShop.Common.WebUtility.replaceStr(TextBox2.Text.Trim()) == string.Empty ? "退付订单费用。订单号:" + orderId + "" : YXShop.Common.WebUtility.replaceStr(TextBox2.Text.Trim());//备注
            uiaeModel.InformMode = GetInforMode(CheckBoxList1)["txt"];//通知方式
            uiaeModel.BosomNote = YXShop.Common.WebUtility.replaceStr(TextBox5.Text);//内部信息
            uiaeModel.NoteDate = DateTime.Now;
            uiaeModel.NoteName = Session["MemberName"].ToString();
            uiaeModel.incomeAndExpStatus = 0;//用户收支状态,目前为收
            uiaeModel.Status = 0;//确认
            #endregion

            try
            {
                #region 删除入帐信息
                if (reimbursement == orderPrice)
                {//删除所有入账信息
                    Remibll.Delete(orderId);
                    prepbll.Delete(orderId);
                    paymbll.Delete(orderId);
                }
                else
                {//reimbursement退款数据
                    if (remiPrice > 0)
                    {
                        if (remiPrice <= reimbursement)
                        {//删除银行汇款信息
                            Remibll.Delete(orderId);
                        }
                        else
                        {
                            bankModel.RemittanceMoney = (remiPrice - reimbursement);
                            Remibll.UpdateMoney(bankModel);
                        }
                    }
                    if (prepPrice > 0)
                    {
                        if (prepPrice <= (reimbursement - remiPrice))
                        {//删除预付款信息
                            prepbll.Delete(orderId);
                        }
                        else
                        {
                            prepModel.PayoutMoney = (prepPrice + remiPrice - reimbursement);
                            prepbll.UpdateMoney(prepModel);
                        }
                    }
                    if (paymPrice > 0)
                    {
                        if (paymPrice == (reimbursement - remiPrice - prepPrice))
                        {//删除现金支付信息
                            paymbll.Delete(orderId);
                        }
                        else
                        {
                            paymModel.GatheringMoney = (prepPrice + remiPrice + paymPrice - reimbursement);
                            paymbll.UpdateMoney(paymModel);
                        }
                    }

                }
                #endregion

                refunBll.Add(refunModel);
                UIAEBll.Add(uiaeModel);


                if ((remiPrice + paymPrice + prepPrice) - reimbursement <= 0)
                {
                    bll.UpdateOrders("PaymentStatus", YXShop.Common.StatuEnum.PaymentStatu.等待汇款.GetHashCode(), orderId);
                }
                else
                {
                    bll.UpdateOrders("PaymentStatus", YXShop.Common.StatuEnum.PaymentStatu.已收定金.GetHashCode(), orderId);
                }
                bll.UpdateOrders("OrderStatus", YXShop.Common.StatuEnum.OrderStatu.已经确认.GetHashCode(), orderId);

            }
            catch (Exception ex)
            {
                bp.PageError(ex.Message, "Refundment.aspx");
            }
            finally
            {
                bp.PageRight("退款成功!", "OrdersInfo.aspx?OrderId=" + orderId + "");
            }
        }
        private Dictionary<string, string> GetInforMode(CheckBoxList CbList)
        {
            string val = string.Empty;
            string txt = string.Empty;
            foreach (ListItem lItem in CbList.Items)
            {
                if (lItem.Selected)
                {
                    val += lItem.Value + ",";
                    txt += lItem.Text + ",";
                }
            }
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("val", val.TrimEnd(','));
            dic.Add("txt", val.TrimEnd(','));
            return dic;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -