Exemplo n.º 1
0
        protected void RefundButton_Click(object sender, EventArgs e)
        {
            int orderRefundId     = RequestHelper.GetQueryString <int>("Id");
            var submitOrderRefund = OrderRefundBLL.Read(orderRefundId);

            //更改状态为退款中...
            if (submitOrderRefund.Status == (int)OrderRefundStatus.Approve)
            {
                submitOrderRefund.Status = (int)OrderRefundStatus.Returning;
                submitOrderRefund.Remark = "正在处理退款";

                OrderRefundBLL.Update(submitOrderRefund);

                //退款操作记录
                AddOrderRefundAction(submitOrderRefund, (int)BoolType.True);
            }

            //退款到账户余额及各支付渠道
            if (submitOrderRefund.Status == (int)OrderRefundStatus.Returning)
            {
                JWRefund.RefundToAnyPay(submitOrderRefund);
            }
            else
            {
                ScriptHelper.Alert("无效的操作", RequestHelper.RawUrl);
            }
        }
Exemplo n.º 2
0
        private void Approve(int approveStatus)
        {
            int    orderRefundId     = RequestHelper.GetQueryString <int>("Id");
            var    submitOrderRefund = OrderRefundBLL.Read(orderRefundId);
            string remark            = Remark.Text.Trim();

            switch (submitOrderRefund.Status)
            {
            case (int)OrderRefundStatus.Submit:
                CheckAdminPower("OrderRefundApprove", PowerCheckType.Single);
                //如果是团购单,且拼团正在进行中,暂不能申请退款
                var order = OrderBLL.Read(submitOrderRefund.OrderId);
                if (order.IsActivity == (int)OrderKind.GroupBuy && order.FavorableActivityId > 0)
                {
                    var groupBuy = GroupBuyBLL.Read(order.FavorableActivityId);
                    if (groupBuy.StartTime <= DateTime.Now && groupBuy.EndTime >= DateTime.Now && groupBuy.Quantity > groupBuy.SignCount)
                    {
                        ScriptHelper.Alert("拼团正在进行,暂不能退款", RequestHelper.RawUrl);
                    }
                }
                if (approveStatus == (int)BoolType.True)
                {
                    submitOrderRefund.Status = (int)OrderRefundStatus.Approve;
                    submitOrderRefund.Remark = "系统审核通过,等待处理退款: " + remark;
                }
                else
                {
                    submitOrderRefund.Status = (int)OrderRefundStatus.Reject;
                    submitOrderRefund.Remark = "系统审核不通过: " + remark;
                }
                break;

            case (int)OrderRefundStatus.Returning:
                ScriptHelper.Alert("正在处理退款,请不要重复退款", RequestHelper.RawUrl);
                break;

            case (int)OrderRefundStatus.HasReturn:
                ScriptHelper.Alert("退款已完成,请不要重复退款", RequestHelper.RawUrl);
                break;

            case (int)OrderRefundStatus.Reject:
                ScriptHelper.Alert("退款已被拒绝,请不要重复退款", RequestHelper.RawUrl);
                break;

            default:
                ScriptHelper.Alert("无效的操作", RequestHelper.RawUrl);
                break;
            }

            OrderRefundBLL.Update(submitOrderRefund);

            //退款操作记录
            AddOrderRefundAction(submitOrderRefund, approveStatus);

            AdminLogBLL.Add(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("OrderRefund"), submitOrderRefund.Id);
            ScriptHelper.Alert("操作成功", RequestHelper.RawUrl);
        }
Exemplo n.º 3
0
        protected override void PageLoad()
        {
            base.PageLoad();
            int id = RequestHelper.GetQueryString <int>("id");

            orderRefund           = OrderRefundBLL.Read(id);
            order                 = OrderBLL.Read(orderRefund.OrderId);
            order.OrderDetailList = OrderDetailBLL.ReadList(orderRefund.OrderId);

            topNav = 0;
        }
Exemplo n.º 4
0
        protected void CancelButton_Click(object sender, EventArgs e)
        {
            int orderRefundId     = RequestHelper.GetQueryString <int>("Id");
            var submitOrderRefund = OrderRefundBLL.Read(orderRefundId);

            //更改状态为已取消...
            submitOrderRefund.Status = (int)OrderRefundStatus.Cancel;
            submitOrderRefund.Remark = "系统取消了退款";
            OrderRefundBLL.Update(submitOrderRefund);

            //退款操作记录
            AddOrderRefundAction(submitOrderRefund, (int)BoolType.False);
            ScriptHelper.Alert("操作成功", RequestHelper.RawUrl);
        }
Exemplo n.º 5
0
        protected override void PageLoad()
        {
            base.PageLoad();

            string action = RequestHelper.GetQueryString <string>("Action");

            if (action == "CancelRefund")
            {
                this.CancelRefund();
            }

            int id = RequestHelper.GetQueryString <int>("id");

            orderRefund           = OrderRefundBLL.Read(id);
            orderRefundActionList = OrderRefundActionBLL.ReadList(id);

            order = OrderBLL.Read(orderRefund.OrderId);

            Title = "退款记录";
        }
Exemplo n.º 6
0
        private void CancelRefund()
        {
            int id = RequestHelper.GetQueryString <int>("id");
            var submitOrderRefund = OrderRefundBLL.Read(id);

            if (submitOrderRefund.OwnerId != base.UserId)
            {
                ResponseHelper.Write("error|无效的请求");
                ResponseHelper.End();
            }

            if (OrderRefundBLL.CanToReturn(submitOrderRefund.Status))
            {
                submitOrderRefund.Status = (int)OrderRefundStatus.Cancel;
                submitOrderRefund.Remark = "用户取消了退款";
                OrderRefundBLL.Update(submitOrderRefund);

                OrderRefundActionInfo submitOrderRefundAction = new OrderRefundActionInfo
                {
                    OrderRefundId = submitOrderRefund.Id,
                    Status        = (int)BoolType.False,
                    Remark        = submitOrderRefund.Remark,
                    Tm            = DateTime.Now,
                    UserType      = 1,
                    UserId        = base.UserId,
                    UserName      = base.UserName
                };

                OrderRefundActionBLL.Add(submitOrderRefundAction);

                ResponseHelper.Write("ok|");
                ResponseHelper.End();
            }
            else
            {
                ResponseHelper.Write("error|无效的请求");
                ResponseHelper.End();
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CheckAdminPower("OrderRefundApprove", PowerCheckType.Single);

                int orderRefundId = RequestHelper.GetQueryString <int>("Id");
                orderRefund = OrderRefundBLL.Read(orderRefundId);
                if (orderRefund.Id > 0)
                {
                    order = OrderBLL.Read(orderRefund.OrderId);
                    if (orderRefund.OrderDetailId > 0)
                    {
                        orderDetailList.Add(OrderDetailBLL.Read(orderRefund.OrderDetailId));
                    }
                    else
                    {
                        orderDetailList = OrderDetailBLL.ReadList(orderRefund.OrderId);
                    }

                    orderRefundActionList = OrderRefundActionBLL.ReadList(orderRefund.Id);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 退款操作:通过、拒绝、退款、取消
        /// </summary>
        protected override void PostBack()
        {
            string param     = RequestHelper.GetForm <string>("param").ToLower();
            int    id        = RequestHelper.GetForm <int>("id");
            string returnUrl = "/mobileadmin/orderrefunddetail.html?id=" + id;

            if (id <= 0)
            {
                ScriptHelper.AlertFront("请求参数错误", returnUrl);
            }
            OrderRefundInfo orderRefund = OrderRefundBLL.Read(id);

            switch (param)
            {
            case "approve":
                Approve((int)BoolType.True, orderRefund);
                break;

            case "reject":
                Approve((int)BoolType.False, orderRefund);
                break;

            case "finish":
                //更改状态为退款中...
                if (orderRefund.Status == (int)OrderRefundStatus.Approve)
                {
                    orderRefund.Status = (int)OrderRefundStatus.Returning;
                    orderRefund.Remark = "正在处理退款";

                    OrderRefundBLL.Update(orderRefund);

                    //退款操作记录
                    AddOrderRefundAction(orderRefund, (int)BoolType.True);
                }

                //退款到账户余额及各支付渠道
                if (orderRefund.Status == (int)OrderRefundStatus.Returning)
                {
                    //退款操作完成后跳转回本页面
                    JWRefund.RefundRedirectUrl = returnUrl;
                    JWRefund.RefundToAnyPay(orderRefund);
                }
                else
                {
                    ScriptHelper.AlertFront("无效的操作", returnUrl);
                }
                break;

            case "cancel":
                if (orderRefund.Status == (int)OrderRefundStatus.Approve || orderRefund.Status == (int)OrderRefundStatus.Returning)
                {
                    //更改状态为已取消...
                    orderRefund.Status = (int)OrderRefundStatus.Cancel;
                    orderRefund.Remark = "系统取消了退款";
                    OrderRefundBLL.Update(orderRefund);

                    //退款操作记录
                    AddOrderRefundAction(orderRefund, (int)BoolType.False);
                    ScriptHelper.AlertFront("操作成功", returnUrl);
                }
                else
                {
                    ScriptHelper.AlertFront("无效的操作", returnUrl);
                }
                break;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAdminPower("OrderRefundConfirm", PowerCheckType.Single);

            int id = RequestHelper.GetQueryString <int>("order_refund_id");

            var orderRefund = OrderRefundBLL.Read(id);

            if (orderRefund.Status != (int)OrderRefundStatus.Returning)
            {
                message = "无效的退款状态";
                return;
            }

            if (orderRefund.RefundBalance <= 0)
            {
                message = "退款金额必须大于0";
                return;
            }

            //需退款到第三方支付平台的退款单,一律在第三方支付退款成功后的回调页面操作
            if (orderRefund.RefundMoney > 0)
            {
                message = "请通过第三方平台进行退款";
                return;
            }

            var user = UserBLL.Read(orderRefund.OwnerId);

            if (user.Id < 0)
            {
                message = "无效的退款用户";
                return;
            }

            var order = OrderBLL.Read(orderRefund.OrderId);

            if (order.Id < 0)
            {
                message = "无效的退款订单";
                return;
            }


            //***********业务逻辑***************************************//

            /*************************************************************
            *  if (isSuccess)
            *  {
            *   msg = "退款完成";
            *
            *   //更新状态
            *   orderRefund.Status = (int)OrderRefundStatus.HasReturn;
            *   orderRefund.TmRefund = DateTime.Now;
            *   OrderRefundBLL.Update(orderRefund);
            *  }
            *  else
            *  {
            *   message = msg;
            *  }
            *
            *  OrderRefundActionBLL.Add(new OrderRefundActionInfo
            *  {
            *   OrderRefundId = orderRefund.Id,
            *   Status = isSuccess ? (int)BoolType.True : (int)BoolType.False,
            *   Tm = DateTime.Now,
            *   UserType = 2,
            *   UserId = base.AdminID,
            *   UserName = Cookies.Admin.GetAdminName(false),
            *   Remark = msg
            *  });
            *************************************************************/
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Log.Info(this.GetType().ToString(), "page load");

            if (Page.IsPostBack)
            {
                return;
            }

            /*******************请求参数验证 start*****************************************************************/
            int orderRefundId = RequestHelper.GetQueryString <int>("order_refund_id");
            var orderRefund   = OrderRefundBLL.Read(orderRefundId);

            if (orderRefund.Id < 1)
            {
                Response.Write("<p style=\"margin-left:130px\">无效的退款服务工单</p>");
                Response.End();
            }

            decimal refundMoney = orderRefund.RefundMoney;

            if (refundMoney <= 0)
            {
                Response.Write("<p style=\"margin-left:130px\">无效的退款金额,退款金额必须大于0</p>");
                Response.End();
            }

            if (orderRefund.Status == (int)OrderRefundStatus.HasReturn)
            {
                Response.Write("<p style=\"margin-left:130px\">无效的退款请求,该服务工单已处理退款</p>");
                Response.End();
            }
            if (orderRefund.Status != (int)OrderRefundStatus.Returning)
            {
                Response.Write("<p style=\"margin-left:130px\">无效的退款请求,请等待管理员审核</p>");
                Response.End();
            }

            var order = OrderBLL.Read(orderRefund.OrderId);

            if (order.Id < 1)
            {
                Response.Write("<p style=\"margin-left:130px\">无效的订单</p>");
                Response.End();
            }

            string tradeNo = order.WxPayTradeNo;

            if (string.IsNullOrEmpty(tradeNo))
            {
                Response.Write("<p style=\"margin-left:130px\">无效的微信支付交易号</p>");
                Response.End();
            }

            decimal totalMoney = order.ProductMoney - order.FavorableMoney + order.ShippingMoney + order.OtherMoney - order.Balance - order.CouponMoney - order.PointMoney;

            if (refundMoney > totalMoney)
            {
                Response.Write("<p style=\"margin-left:130px\">退款金额不能超过订单金额</p>");
                Response.End();
            }

            //商户退款单号
            //商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔
            string batch_no = orderRefund.BatchNo;

            if (string.IsNullOrEmpty(batch_no))
            {
                batch_no = DateTime.Now.ToString("yyyyMMddhhmmssfff");

                //记录退款批次号存入订单退款表
                OrderRefundBLL.UpdateBatchNo(orderRefundId, batch_no);
            }

            /*******************请求参数验证 end*****************************************************************/


            //订单总金额
            string total_fee = Convert.ToInt32(totalMoney * 100).ToString();
            //退款金额
            string refund_fee = Convert.ToInt32(refundMoney * 100).ToString();

            //申请退款

            /***
             * 申请退款完整业务流程逻辑
             * @param transaction_id 微信订单号(优先使用)
             * @param out_trade_no 商户订单号
             * @param out_refund_no 商户退款单号
             * @param total_fee 订单总金额
             * @param refund_fee 退款金额
             * @return 退款结果(xml格式)
             */
            string result = "";

            try
            {
                result = RefundBusiness.Run(tradeNo, "", batch_no, total_fee, refund_fee);

                //退款成功
                bool   isSuccess = true;
                string msg       = "";
                //退款到余额
                if (orderRefund.RefundBalance > 0)
                {
                    //在这里写自己的逻辑
                }

                if (isSuccess)
                {
                    orderRefund.Remark = "退款完成";
                    #region 发送订单退款成功通知
                    int       isSendNotice  = ShopConfig.ReadConfigInfo().RefundOrder;
                    int       isSendEmail   = ShopConfig.ReadConfigInfo().RefundOrderEmail;
                    int       isSendMessage = ShopConfig.ReadConfigInfo().RefundOrderMsg;
                    string    key           = "RefundOrder";
                    OrderInfo order         = OrderBLL.Read(orderRefund.OrderId);
                    if (isSendNotice == (int)BoolType.True && key != string.Empty)
                    {
                        if (isSendEmail == (int)BoolType.True)
                        {//发邮件
                            try
                            {
                                EmailContentInfo    emailContent    = EmailContentHelper.ReadSystemEmailContent(key);
                                EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo();
                                emailSendRecord.Title     = emailContent.EmailTitle;
                                emailSendRecord.Content   = emailContent.EmailContent.Replace("$UserName$", order.UserName).Replace("$OrderNumber$", order.OrderNumber).Replace("$PayName$", order.PayName).Replace("$ShippingName$", ShippingBLL.Read(order.ShippingId).Name).Replace("$ShippingNumber$", order.ShippingNumber).Replace("$ShippingDate$", order.ShippingDate.ToString("yyyy-MM-dd"));
                                emailSendRecord.IsSystem  = (int)BoolType.True;
                                emailSendRecord.EmailList = order.Email;
                                emailSendRecord.IsStatisticsOpendEmail = (int)BoolType.False;
                                emailSendRecord.SendStatus             = (int)SendStatus.No;
                                emailSendRecord.AddDate  = RequestHelper.DateNow;
                                emailSendRecord.SendDate = RequestHelper.DateNow;
                                emailSendRecord.ID       = EmailSendRecordBLL.AddEmailSendRecord(emailSendRecord);
                                EmailSendRecordBLL.SendEmail(emailSendRecord);
                                //result = "通知邮件已发送。";
                            }
                            catch
                            {
                                //result = "未发送通知邮件。";
                            }
                        }
                        if (isSendMessage == (int)BoolType.True)
                        {//发短信
                         //result += "未发送通知短信。";
                        }
                    }
                    #endregion
                }
                else
                {
                    orderRefund.Remark = orderRefund.RefundPayKey + " 已退款完成,余额退款失败,失败信息:" + msg + ",请线下处理。";
                }

                orderRefund.Status   = (int)OrderRefundStatus.HasReturn;
                orderRefund.TmRefund = DateTime.Now;
                OrderRefundBLL.Update(orderRefund);

                OrderRefundActionBLL.Add(new OrderRefundActionInfo
                {
                    OrderRefundId = orderRefund.Id,
                    Status        = isSuccess ? 1 : 0,
                    Tm            = DateTime.Now,
                    UserType      = 2,
                    UserId        = 0,
                    UserName      = "******",
                    Remark        = orderRefund.Remark
                });

                Response.Redirect("/Admin/OrderRefundAdd.aspx?Id=" + orderRefundId);
            }
            catch
            {
                Response.Write("<p style=\"margin-left:130px\">退款遇到问题</p>");
            }

            //Response.Write(result);
        }