private void btnReplace_Click(object sender, System.EventArgs e) { if (!TradeHelper.CanReplace(this.hdorderId.Value)) { this.ShowMessage("已有待确认的申请!", false); return; } if (TradeHelper.ApplyForReplace(this.hdorderId.Value, this.txtReplaceRemark.Text)) { this.BindOrders(); this.ShowMessage("成功的申请了换货", true); return; } this.ShowMessage("申请换货失败", false); }
private void btnReturns_Click(object sender, EventArgs e) { string text = this.Page.Request.QueryString["returnUrl"].ToNullString(); if (string.IsNullOrEmpty(text)) { text = this.Page.Request.UrlReferrer.ToNullString(); if (text == this.Page.Request.Url.ToString()) { text = "/User/UserOrders"; } } int num = 3; string text2 = ""; string text3 = ""; string text4 = ""; this.iRefundType = this.hidRefundType.Value.ToInt(0); num = this.hidAfterSaleType.Value.ToInt(0); if (string.IsNullOrEmpty(this.SkuId) || !this.order.LineItems.ContainsKey(this.SkuId)) { this.ShowMessage("请选择要进行售后的商品", false, "", 1); } if (!TradeHelper.CanReturn(this.order, this.SkuId)) { this.ShowMessage("该商品正在售后中!", false, "", 1); } else if (num != 2 && !Enum.IsDefined(typeof(RefundTypes), this.iRefundType)) { this.ShowMessage("错误的退款方式", false, "", 1); } else { string enumDescription = EnumDescription.GetEnumDescription((Enum)(object)EnumPaymentType.AdvancePay, 1); if ((this.order.Gateway.ToLower() == enumDescription || this.order.DepositGatewayOrderId.ToNullString().ToLower() == enumDescription) && this.iRefundType != 1) { this.ShowMessage("预付款支付的订单只能退回到预付款帐号", false, "", 1); } else if (!Enum.IsDefined(typeof(AfterSaleTypes), num)) { this.ShowMessage("错误的售后类型", false, "", 1); } else { string userRemark = Globals.StripAllTags(this.txtRemark.Text.Trim()); if (!this.CanRefundBalance()) { this.ShowMessage("请先开通预付款账户", false, "", 1); } else { text2 = Globals.StripAllTags(this.txtBankName.Value); text3 = Globals.StripAllTags(this.txtBankAccountName.Value); text4 = Globals.StripAllTags(this.txtBankAccountNo.Value); string text5 = ""; string text6 = this.hidePicture.Value.Trim(); string imageServerUrl = Globals.GetImageServerUrl(); if (text6.Length > 0) { string[] array = text6.Split(','); for (int i = 0; i < array.Length; i++) { text5 += (string.IsNullOrEmpty(imageServerUrl) ? (Globals.SaveFile("user\\Credentials", array[i], "/Storage/master/", true, false, "") + "|") : (array[i] + "|")); } } text5 = text5.TrimEnd('|'); string selectedValue = this.DropReturnsReason.SelectedValue; if (string.IsNullOrEmpty(selectedValue)) { this.ShowMessage("请选择售后原因", false, "", 1); } string refundGateWay = string.IsNullOrEmpty(this.order.Gateway) ? "" : this.order.Gateway.ToLower().Replace(".payment.", ".refund."); int num2 = this.ReturnsItem.ShipmentQuantity; if (num != 3) { int.TryParse(this.txtQuantity.Value, out num2); if (num2 == 0) { num2 = TradeHelper.GetMaxQuantity(this.order, this.SkuId); } else if (this.ReturnsItem != null) { if (num2 > this.ReturnsItem.ShipmentQuantity) { this.ShowMessage("数量不能大于购买商品的数量", false, "", 1); return; } } else if (num2 > this.order.GetAllQuantity(true)) { this.ShowMessage("数量不能大于订单中商品的数量", false, "", 1); return; } } decimal num3 = default(decimal); decimal.TryParse(this.txtRefundAmount.Text, out num3); decimal canRefundAmount = this.order.GetCanRefundAmount(this.SkuId, this.groupBuy, 1); if (num == 3 && canRefundAmount <= decimal.Zero) { this.ShowMessage("订单支付金额为0时不能进行仅退款操作。", false, "", 1); } else { decimal num4 = this.litMaxAmount.Text.ToDecimal(0); if (num2 < this.litMaxQuantity.Text.ToInt(0)) { num4 = canRefundAmount * (decimal)num2; } if (num3 < decimal.Zero && num != 2) { this.ShowMessage("退款金额必须大于0", false, "", 1); } else if (num3 > num4) { this.ShowMessage(string.Format("退款金额不能大于最大可退款金额({0})", num4.F2ToString("f2")), true, "", 1); } else { string text7 = (num == 3) ? "退款" : "退货"; if (num == 3 || num == 1) { string generateId = Globals.GetGenerateId(); ReturnInfo returnInfo = new ReturnInfo { UserRemark = userRemark, ReturnReason = selectedValue, RefundType = (RefundTypes)this.iRefundType, RefundGateWay = refundGateWay, RefundOrderId = generateId, RefundAmount = num3, StoreId = this.order.StoreId, ApplyForTime = DateTime.Now, BankName = text2, BankAccountName = text3, BankAccountNo = text4, HandleStatus = ReturnStatus.Applied, OrderId = this.order.OrderId, SkuId = this.SkuId, Quantity = num2, UserCredentials = text5, AfterSaleType = (AfterSaleTypes)num }; if (TradeHelper.ApplyForReturn(returnInfo)) { if (this.order.StoreId > 0) { VShopHelper.AppPsuhRecordForStore(this.order.StoreId, this.OrderId, this.SkuId, EnumPushStoreAction.StoreOrderReturnApply); } this.ShowMessage("成功的申请了退货", true, text, 2); } else { this.ShowMessage("申请退货失败", false, text, 2); } } else { ReplaceInfo replace = new ReplaceInfo { ApplyForTime = DateTime.Now, HandleStatus = ReplaceStatus.Applied, OrderId = this.order.OrderId, Quantity = num2, ReplaceReason = selectedValue, SkuId = this.SkuId, StoreId = this.order.StoreId, UserCredentials = text5, UserRemark = userRemark }; if (TradeHelper.ApplyForReplace(replace)) { if (this.order.StoreId > 0) { VShopHelper.AppPsuhRecordForStore(this.order.StoreId, this.OrderId, this.SkuId, EnumPushStoreAction.StoreOrderReplaceApply); } this.ShowMessage("成功的申请了换货", true, text, 2); } else { this.ShowMessage("申请换货失败", false, "", 1); } } } } } } } }