コード例 #1
0
        public JsonResult ConfirmRefund(long refundId, string managerRemark)
        {
            Result         result        = new Result();
            IRefundService refundService = ServiceHelper.Create <IRefundService>();

            refundService.ConfirmRefund(refundId, managerRemark, base.CurrentManager.UserName);
            result.success = true;
            return(Json(result));
        }
コード例 #2
0
        public JsonResult ConfirmRefund(long refundId, string managerRemark)
        {
            Result result    = new Result();
            string notifyurl = "";

            string webRoot = CurrentUrlHelper.CurrentUrlNoPort();

            //获取异步通知地址
            notifyurl = webRoot + "/Pay/RefundNotify/{0}";

            string refundurl = _iRefundService.ConfirmRefund(refundId, managerRemark, CurrentManager.UserName, notifyurl);

            result.success = true;
            if (!string.IsNullOrWhiteSpace(refundurl))
            {
                result.msg    = refundurl;
                result.status = 2;   //表示需要继续异步请求
            }

            return(Json(result));
        }
コード例 #3
0
        public JsonResult ConfirmRefund(long refundId, string managerRemark)
        {
            Result result    = new Result();
            string notifyurl = "";

            string webRoot = Request.Url.Scheme + "://" + HttpContext.Request.Url.Host + (HttpContext.Request.Url.Port == 80 ? "" : (":" + HttpContext.Request.Url.Port.ToString()));

            //获取异步通知地址
            notifyurl = webRoot + "/Pay/RefundNotify/{0}";

            string refundurl = _iRefundService.ConfirmRefund(refundId, managerRemark, CurrentManager.UserName, notifyurl);

            result.success = true;
            if (!string.IsNullOrWhiteSpace(refundurl))
            {
                result.msg    = refundurl;
                result.status = 2;   //表示需要继续异步请求
            }

            return(Json(result));
        }
コード例 #4
0
        public JsonResult RefundApply(OrderRefundInfo info)
        {
            var order = _iOrderService.GetOrder(info.OrderId, CurrentUser.Id);

            if (order == null)
            {
                throw new Mall.Core.MallException("该订单已删除或不属于该用户");
            }
            if (info.RefundType == 1)
            {
                info.ReturnQuantity = 0;
                info.IsReturn       = false;
            }
            if (order.OrderType != OrderInfo.OrderTypes.Virtual)
            {
                info.IsReturn = false;
                if (info.ReturnQuantity > 0)
                {
                    info.IsReturn = true;
                }
                if (info.RefundType == 2)
                {
                    info.IsReturn = true;
                }
                if (info.IsReturn == true && info.ReturnQuantity < 1)
                {
                    throw new Mall.Core.MallException("错误的退货数量");
                }
            }
            if (info.Amount <= 0)
            {
                throw new Mall.Core.MallException("错误的退款金额");
            }
            if (info.ReasonDetail != null && info.ReasonDetail.Length > 1000)
            {
                throw new Mall.Core.MallException("退款说明不能超过1000字符");
            }
            // info.ReasonDetail=
            info.UserId       = CurrentUser.Id;
            info.Applicant    = CurrentUser.UserName;
            info.ApplyDate    = DateTime.Now;
            info.ReasonDetail = HttpUtility.HtmlEncode(info.ReasonDetail);
            info.Reason       = HTMLEncode(info.Reason.Replace("'", "‘").Replace("\"", "”"));
            info.CertPic1     = MoveImages(info.CertPic1, CurrentUser.Id, info.OrderItemId);
            info.CertPic2     = MoveImages(info.CertPic2, CurrentUser.Id, info.OrderItemId);
            info.CertPic3     = MoveImages(info.CertPic3, CurrentUser.Id, info.OrderItemId);

            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                if (string.IsNullOrWhiteSpace(info.VerificationCodeIds))
                {
                    throw new Mall.Core.MallException("虚拟订单退款核销码不能为空");
                }

                //检测核销码都为正确的
                var codeList = info.VerificationCodeIds.Split(',').ToList();
                var codes    = OrderApplication.GetOrderVerificationCodeInfoByCodes(codeList);
                if (codes.Count != codeList.Count)
                {
                    throw new Mall.Core.MallException("包含无效的核销码");
                }
                foreach (var item in codes)
                {
                    if (item.Status != OrderInfo.VerificationCodeStatus.WaitVerification)
                    {
                        throw new Mall.Core.MallException("包含已申请售后的核销码");
                    }
                }
                info.ReturnQuantity = codes.Count;
            }

            //info.RefundAccount = HTMLEncode(info.RefundAccount.Replace("'", "‘").Replace("\"", "”"));
            Result result = new Result()
            {
                success = true, data = info.Id, msg = "提交成功"
            };

            if (order.OrderType != OrderInfo.OrderTypes.Virtual)
            {
                if (info.Id > 0)
                {
                    _iRefundService.ActiveRefund(info);
                }
                else
                {
                    var status = RefundApplication.CanApplyRefund(info.OrderId, info.OrderItemId, info.OrderItemId == 0 ? true : false);
                    if (!status)
                    {
                        result.success = false;
                        result.status  = 2;
                        result.msg     = "您已申请过售后,不可重复申请";
                    }
                    else
                    {
                        RefundApplication.AddOrderRefund(info);
                    }
                    //TODO:FG 查询逻辑
                    //取退款ID
                    var refundInfos = RefundApplication.GetOrderRefunds(new RefundQuery()
                    {
                        OrderId = info.OrderId, PageNo = 1, PageSize = int.MaxValue
                    }).Models;
                    if (refundInfos.Count > 0)
                    {
                        if (info.OrderItemId != 0)
                        {
                            var refund = refundInfos.FirstOrDefault(e => e.OrderItemId == info.OrderItemId);
                            result.data = refund.Id;
                        }
                        else
                        {
                            var refund = refundInfos.FirstOrDefault();
                            result.data = refund.Id;
                        }
                    }
                }
            }
            else
            {
                RefundApplication.AddOrderRefund(info);
                //取退款ID
                result.data = info.Id;
                #region 处理退款
                //虚拟订单自动退款,异常不提示用户,进入平台待审核
                try
                {
                    //获取异步通知地址
                    string notifyurl    = CurrentUrlHelper.CurrentUrlNoPort() + "/Pay/RefundNotify/{0}";
                    var    refundResult = _iRefundService.ConfirmRefund(info.Id, "虚拟订单申请售后自动退款", "", notifyurl);
                }
                catch (MallException ex)
                {
                    Log.Error("虚拟商品自动退异常", ex);
                }
                #endregion
            }
            return(Json(result));
        }
コード例 #5
0
        public JsonResult RefundApply(OrderRefundInfo info)
        {
            if (info.ReasonDetail != null && info.ReasonDetail.Length > 1000)
            {
                throw new Mall.Core.MallException("退款说明不能超过1000字符");
            }
            var order = _iOrderService.GetOrder(info.OrderId, CurrentUser.Id);

            if (order == null)
            {
                throw new Mall.Core.MallException("该订单已删除或不属于该用户");
            }
            if (order.OrderType != OrderInfo.OrderTypes.Virtual && (int)order.OrderStatus < 2)
            {
                throw new Mall.Core.MallException("错误的售后申请,订单状态有误");
            }
            //售后时间限制
            if (order.OrderType != OrderInfo.OrderTypes.Virtual && _iOrderService.IsRefundTimeOut(info.OrderId))
            {
                throw new Mall.Core.MallException("订单已超过售后期");
            }
            if (order.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitDelivery || order.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp)
            {
                info.RefundMode     = OrderRefundInfo.OrderRefundMode.OrderRefund;
                info.ReturnQuantity = 0;
            }
            if (info.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund && info.Id == 0)
            {
                var _refobj = OrderApplication.GetOrderRefunds(new long[] { info.OrderItemId }).FirstOrDefault(d => d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund);
                if (_refobj != null)
                {
                    info.Id = _refobj.Id;
                }
            }
            if (info.RefundType == 1)
            {
                info.ReturnQuantity = 0;
                info.IsReturn       = false;
            }
            if (order.OrderType != OrderInfo.OrderTypes.Virtual && info.ReturnQuantity < 0)
            {
                throw new MallException("错误的退货数量");
            }
            var orderitem = _iOrderService.GetOrderItem(info.OrderItemId);

            if (orderitem == null && info.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund)
            {
                throw new Mall.Core.MallException("该订单条目已删除或不属于该用户");
            }

            if (order.OrderType != OrderInfo.OrderTypes.Virtual)
            {
                if (info.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund)
                {
                    if (order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp)
                    {
                        throw new Mall.Core.MallException("错误的订单退款申请,订单状态有误");
                    }
                    info.IsReturn       = false;
                    info.ReturnQuantity = 0;
                    if (info.Amount > order.OrderEnabledRefundAmount)
                    {
                        throw new Mall.Core.MallException("退款金额不能超过订单的实际支付金额");
                    }
                }
                else
                {
                    if (info.Amount > (orderitem.EnabledRefundAmount - orderitem.RefundPrice))
                    {
                        throw new Mall.Core.MallException("退款金额不能超过订单的可退金额");
                    }
                    if (info.ReturnQuantity > (orderitem.Quantity - orderitem.ReturnQuantity))
                    {
                        throw new Mall.Core.MallException("退货数量不可以超出可退数量");
                    }
                }
            }
            info.IsReturn = false;
            if (info.ReturnQuantity > 0)
            {
                info.IsReturn = true;
            }
            if (info.RefundType == 2)
            {
                info.IsReturn = true;
            }
            if (order.OrderType != OrderInfo.OrderTypes.Virtual && info.IsReturn == true && info.ReturnQuantity < 1)
            {
                throw new Mall.Core.MallException("错误的退货数量");
            }
            if (info.Amount <= 0)
            {
                throw new Mall.Core.MallException("错误的退款金额");
            }
            info.ShopId       = order.ShopId;
            info.ShopName     = order.ShopName;
            info.UserId       = CurrentUser.Id;
            info.Applicant    = CurrentUser.UserName;
            info.ApplyDate    = DateTime.Now;
            info.ReasonDetail = HttpUtility.HtmlEncode(info.ReasonDetail);
            info.Reason       = HTMLEncode(info.Reason.Replace("'", "‘").Replace("\"", "”"));
            if (!info.IsWxUpload)
            {
                info.CertPic1 = MoveImages(info.CertPic1, CurrentUser.Id, info.OrderItemId);
                info.CertPic2 = MoveImages(info.CertPic2, CurrentUser.Id, info.OrderItemId);
                info.CertPic3 = MoveImages(info.CertPic3, CurrentUser.Id, info.OrderItemId);
            }
            else
            {
                info.CertPic1 = DownloadWxImage(info.CertPic1, CurrentUser.Id, info.OrderItemId);
                info.CertPic2 = DownloadWxImage(info.CertPic2, CurrentUser.Id, info.OrderItemId);
                info.CertPic3 = DownloadWxImage(info.CertPic3, CurrentUser.Id, info.OrderItemId);
            }
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                if (string.IsNullOrWhiteSpace(info.VerificationCodeIds))
                {
                    throw new Mall.Core.MallException("虚拟订单退款核销码不能为空");
                }

                //检测核销码都为正确的
                var codeList = info.VerificationCodeIds.Split(',').ToList();
                var codes    = OrderApplication.GetOrderVerificationCodeInfoByCodes(codeList);
                if (codes.Count != codeList.Count)
                {
                    throw new Mall.Core.MallException("包含无效的核销码");
                }
                foreach (var item in codes)
                {
                    if (item.Status != OrderInfo.VerificationCodeStatus.WaitVerification)
                    {
                        throw new Mall.Core.MallException("包含已申请售后的核销码");
                    }
                }
                info.ReturnQuantity = codes.Count;
            }
            //info.RefundAccount = HTMLEncode(info.RefundAccount.Replace("'", "‘").Replace("\"", "”"));
            if (order.OrderType != OrderInfo.OrderTypes.Virtual)
            {
                if (info.Id > 0)
                {
                    _iRefundService.ActiveRefund(info);
                }
                else
                {
                    _iRefundService.AddOrderRefund(info);
                }
            }
            else
            {
                _iRefundService.AddOrderRefund(info);
                #region 处理退款
                try
                {
                    //虚拟订单自动退款,异常不提示用户,进入平台待审核
                    //获取异步通知地址
                    string notifyurl = CurrentUrlHelper.CurrentUrlNoPort() + "/Pay/RefundNotify/{0}";
                    var    result    = _iRefundService.ConfirmRefund(info.Id, "虚拟订单申请售后自动退款", "", notifyurl);
                }
                catch (MallException ex)
                {
                    Log.Error("虚拟商品自动退异常", ex);
                }
                #endregion
            }
            return(SuccessResult <dynamic>(msg: "提交成功", data: info.Id));
        }
コード例 #6
0
 /// <summary>
 /// 管理员确认退款/退货
 /// </summary>
 /// <param name="id"></param>
 /// <param name="managerRemark"></param>
 /// <param name="managerName"></param>
 /// <param name="notifyurl">导步通知地址</param>
 public static string ConfirmRefund(long id, string managerRemark, string managerName, string notifyurl)
 {
     return(_iRefundService.ConfirmRefund(id, managerRemark, managerName, notifyurl));
 }