public JsonResult RefundApply(OrderRefundInfo info) { if (info.ReasonDetail != null && info.ReasonDetail.Length > 1000) { throw new Himall.Core.HimallException("退款原因不能超过1000字符"); } var order = _iOrderService.GetOrder(info.OrderId, CurrentUser.Id); if (order == null) { throw new Himall.Core.HimallException("该预约单已删除或不属于该用户"); } if ((int)order.OrderStatus < 2) { throw new Himall.Core.HimallException("错误的售后申请,预约单状态有误"); } //售后时间限制 if (_iOrderService.IsRefundTimeOut(info.OrderId)) { throw new Himall.Core.HimallException("预约单已超过售后期"); } if (order.OrderStatus == OrderInfo.OrderOperateStatus.WaitDelivery || order.OrderStatus == OrderInfo.OrderOperateStatus.WaitSelfPickUp) { info.RefundMode = OrderRefundInfo.OrderRefundMode.OrderRefund; info.ReturnQuantity = 0; } if (info.RefundType == 1) { info.ReturnQuantity = 0; info.IsReturn = false; } if (info.ReturnQuantity == null || info.ReturnQuantity < 0) { throw new Himall.Core.HimallException("错误的退货数量"); } var orderitem = order.OrderItemInfo.FirstOrDefault(a => a.Id == info.OrderItemId); if (orderitem == null && info.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund) { throw new Himall.Core.HimallException("该预约单条目已删除或不属于该用户"); } if (info.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund) { if (order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitSelfPickUp) { throw new Himall.Core.HimallException("错误的预约单退款申请,预约单状态有误"); } info.IsReturn = false; info.ReturnQuantity = 0; if (info.Amount > order.OrderEnabledRefundAmount) { throw new Himall.Core.HimallException("退款金额不能超过预约单的实际支付金额"); } } else { if (info.Amount > (orderitem.EnabledRefundAmount - orderitem.RefundPrice)) { throw new Himall.Core.HimallException("退款金额不能超过预约单的可退金额"); } if (info.ReturnQuantity > (orderitem.Quantity - orderitem.ReturnQuantity)) { throw new Himall.Core.HimallException("退货数量不可以超出可退数量"); } } 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 Himall.Core.HimallException("错误的退货数量"); } if (info.Amount <= 0) { throw new Himall.Core.HimallException("错误的退款金额"); } 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("\"", "”")); 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); //info.RefundAccount = HTMLEncode(info.RefundAccount.Replace("'", "‘").Replace("\"", "”")); if (info.Id > 0) { _iRefundService.ActiveRefund(info); } else { _iRefundService.AddOrderRefund(info); } return(Json(new { success = true, msg = "提交成功", id = info.Id })); }
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)); }
/// <summary> /// 激活售后 /// </summary> /// <param name="info"></param> public static void ActiveRefund(OrderRefundInfo info) { _iRefundService.ActiveRefund(info); }
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)); }
public JsonResult RefundApply(OrderRefundInfo info) { if (info.RefundType == 1) { info.ReturnQuantity = 0; info.IsReturn = false; } 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 Himall.Core.HimallException("错误的退货数量"); } if (info.Amount <= 0) { throw new Himall.Core.HimallException("错误的退款金额"); } if (info.ReasonDetail != null && info.ReasonDetail.Length > 1000) { throw new Himall.Core.HimallException("退款原因不能超过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); //info.RefundAccount = HTMLEncode(info.RefundAccount.Replace("'", "‘").Replace("\"", "”")); Result result = new Result() { success = true, Data = info.Id, msg = "提交成功" }; 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); } //取退款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; } } } return(Json(result)); }