Beispiel #1
0
        private void btnAcceptReturn_Click(object sender, EventArgs e)
        {
            int        num            = this.Page.Request["ReturnId"].ToInt(0);
            string     text           = Globals.StripAllTags(this.txtAdminShipAddress.Text);
            string     adminShipTo    = Globals.StripAllTags(this.txtAdminShipTo.Text);
            string     adminCellPhone = Globals.StripAllTags(this.txtAdminCellPhone.Text);
            ReturnInfo returnInfo     = TradeHelper.GetReturnInfo(num);
            string     adminRemark    = Globals.StripAllTags(this.txtAdminRemark.Text);
            string     text2          = "退货";

            if (returnInfo == null)
            {
                this.ShowMsg("售后信息错误!", false);
            }
            else
            {
                bool flag = false;
                if (returnInfo.AfterSaleType == AfterSaleTypes.OnlyRefund)
                {
                    text2 = "退款";
                    flag  = true;
                }
                string    skuId     = returnInfo.SkuId;
                OrderInfo orderInfo = TradeHelper.GetOrderInfo(returnInfo.OrderId);
                if (orderInfo == null)
                {
                    this.ShowMsg("订单不存在!", false);
                }
                else if (!orderInfo.LineItems.ContainsKey(skuId))
                {
                    this.ShowMsg("订单中不存在要退货的商品!", false);
                }
                else
                {
                    LineItemInfo lineItemInfo = orderInfo.LineItems[skuId];
                    decimal      num2         = default(decimal);
                    if (lineItemInfo.Status != LineItemStatus.ReturnApplied)
                    {
                        this.ShowMsg(text2 + "状态不正确.", false);
                    }
                    else if (!decimal.TryParse(this.txtRefundMoney.Text, out num2))
                    {
                        this.ShowMsg("退款金额需为数字格式!", false);
                    }
                    else if (num2 < decimal.Zero)
                    {
                        this.ShowMsg("退款金额必须大于等于0", false);
                    }
                    else
                    {
                        if (this.UserStoreId != returnInfo.StoreId && returnInfo.StoreId >= 0)
                        {
                            if (flag)
                            {
                                if (orderInfo.IsStoreCollect && this.UserStoreId == 0)
                                {
                                    this.ShowMsg("门店收的款,只能由门店进行退款确认处理!", false);
                                    return;
                                }
                            }
                            else if (this.UserStoreId > 0)
                            {
                                this.ShowMsg("同意" + text2 + "只能由发货的店铺或者平台进行处理!", false);
                                return;
                            }
                        }
                        if (!flag && string.IsNullOrEmpty(text))
                        {
                            this.ShowMsg("请输入平台收货地址,告之用户发货的地址和联系方式", false);
                        }
                        else
                        {
                            GroupBuyInfo groupbuy = null;
                            if (orderInfo.GroupBuyId > 0)
                            {
                                groupbuy = ProductBrowser.GetGroupBuy(orderInfo.GroupBuyId);
                            }
                            decimal canRefundAmount = orderInfo.GetCanRefundAmount(skuId, groupbuy, 0);
                            if (num2 > canRefundAmount)
                            {
                                this.ShowMsg("退款金额不能大于退货订单或者商品的金额!", false);
                            }
                            else if (flag)
                            {
                                RefundTypes refundType = returnInfo.RefundType;
                                string      userRemark = returnInfo.UserRemark;
                                MemberInfo  user       = Users.GetUser(orderInfo.UserId);
                                string      text3      = "";
                                if (RefundHelper.IsBackReturn(orderInfo.Gateway) && returnInfo.RefundType == RefundTypes.BackReturn)
                                {
                                    text3 = RefundHelper.SendRefundRequest(orderInfo, num2, returnInfo.RefundOrderId, false);
                                    if (text3 == "")
                                    {
                                        if (OrderHelper.AgreedReturns(num, num2, adminRemark, orderInfo, returnInfo.SkuId, text, adminShipTo, adminCellPhone, flag, false))
                                        {
                                            if (flag)
                                            {
                                                VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, returnInfo.SkuId, EnumPushOrderAction.OrderReturnConfirm);
                                            }
                                            else
                                            {
                                                VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, returnInfo.SkuId, EnumPushOrderAction.OrderRefund);
                                            }
                                            Messenger.OrderRefund(user, orderInfo, returnInfo.SkuId);
                                            this.ShowMsg("成功的完成退款并且已成功原路退回退款金额!", true, HttpContext.Current.Request.Url.ToString());
                                        }
                                    }
                                    else
                                    {
                                        TradeHelper.SaveRefundErr(num, text3, false);
                                        this.ShowMsg("退款原路返回错误,错误信息" + text3 + ",请重新尝试!", false);
                                    }
                                }
                                else if (OrderHelper.AgreedReturns(num, num2, adminRemark, orderInfo, returnInfo.SkuId, text, adminShipTo, adminCellPhone, flag, returnInfo.RefundType == RefundTypes.InBalance))
                                {
                                    if (flag)
                                    {
                                        VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, returnInfo.SkuId, EnumPushOrderAction.OrderReturnConfirm);
                                    }
                                    else
                                    {
                                        VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, returnInfo.SkuId, EnumPushOrderAction.OrderRefund);
                                    }
                                    Messenger.OrderRefund(user, orderInfo, returnInfo.SkuId);
                                    if (returnInfo.RefundType == RefundTypes.InBalance)
                                    {
                                        this.ShowMsg("成功确定了退款,退款金额已退回用户预付款帐号!", true, HttpContext.Current.Request.Url.ToString());
                                    }
                                    else
                                    {
                                        this.ShowMsg("成功的完成了退款,请即时给用户退款", true, HttpContext.Current.Request.Url.ToString());
                                    }
                                }
                            }
                            else if (OrderHelper.AgreedReturns(num, num2, adminRemark, orderInfo, returnInfo.SkuId, text, adminShipTo, adminCellPhone, flag, false))
                            {
                                VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, returnInfo.SkuId, EnumPushOrderAction.OrderReturnConfirm);
                                this.ShowMsg("成功的确认了售后", true, HttpContext.Current.Request.Url.ToString());
                            }
                            else
                            {
                                this.ShowMsg("确认售后失败!", false);
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void BatchDealException(HttpContext context)
        {
            string idList = context.Request["ReturnIds"].ToNullString();

            idList = Globals.GetSafeIDList(idList, ',', true);
            if (string.IsNullOrEmpty(idList))
            {
                throw new HidistroAshxException("请选择要退款/退货的ID");
            }
            IList <ReturnInfo> list = OrderHelper.GetReturnListOfReturnIds(idList);

            if (list != null && list.Count > 0)
            {
                string Operator = HiContext.Current.Manager.UserName;
                Task.Factory.StartNew(delegate
                {
                    int num = 0;
                    foreach (ReturnInfo item in list)
                    {
                        OrderInfo orderInfo = OrderHelper.GetOrderInfo(item.OrderId);
                        if (orderInfo != null && RefundHelper.IsBackReturn(orderInfo.Gateway) && item.RefundType == RefundTypes.BackReturn && !TradeHelper.AlipayCanRefundGateway.Contains(orderInfo.Gateway))
                        {
                            if (item.AfterSaleType == AfterSaleTypes.OnlyRefund)
                            {
                                if (item.HandleStatus == ReturnStatus.Applied)
                                {
                                    goto IL_00cc;
                                }
                            }
                            else if (item.HandleStatus == ReturnStatus.GetGoods || item.HandleStatus == ReturnStatus.Deliverying)
                            {
                                goto IL_00cc;
                            }
                        }
                        continue;
                        IL_00cc:
                        MemberInfo user = Users.GetUser(orderInfo.UserId);
                        string text     = RefundHelper.SendRefundRequest(orderInfo, item.RefundAmount, item.RefundOrderId, true);
                        if (text == "")
                        {
                            if (item.AfterSaleType == AfterSaleTypes.ReturnAndRefund)
                            {
                                if (OrderHelper.CheckReturn(item, orderInfo, Operator, item.RefundAmount, item.AdminRemark, true, false))
                                {
                                    Messenger.OrderRefund(user, orderInfo, item.SkuId);
                                }
                            }
                            else if (OrderHelper.AgreedReturns(item.ReturnId, item.RefundAmount, item.AdminRemark, orderInfo, item.SkuId, item.AdminShipAddress, item.AdminShipTo, item.AdminShipAddress, true, false))
                            {
                                VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, item.SkuId, EnumPushOrderAction.OrderReturnConfirm);
                                Messenger.OrderRefund(user, orderInfo, item.SkuId);
                            }
                            num++;
                        }
                        else
                        {
                            TradeHelper.SaveRefundErr(item.ReturnId, text, false);
                        }
                        Thread.Sleep(5000);
                    }
                    base.ReturnSuccessResult(context, "退款自动处理提交成功,请稍后刷新页面", 0, true);
                });
                return;
            }
            throw new HidistroAshxException("未找到退款记录");
        }