private void btnRefuseRefund_Click(object sender, EventArgs e) { string username = HiContext.Current.User.Username; OrderHelper.CheckRefund(OrderHelper.GetOrderInfo(this.hidOrderId.Value), username, this.hidAdminRemark.Value, int.Parse(this.hidRefundType.Value), false); this.BindOrders(); this.ShowMsg("成功的拒绝了订单退款", true); }
private void btnRefuseRefund_Click(object sender, System.EventArgs e) { ManagerHelper.CheckPrivilege(Privilege.OrderRefundApplyRefuse); string username = HiContext.Current.User.Username; OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.hidOrderId.Value); OrderHelper.CheckRefund(orderInfo, username, this.hidAdminRemark.Value, int.Parse(this.hidRefundType.Value), 0, false, false); this.BindRefund(); this.ShowMsg("成功的拒绝了订单退款", true); }
public void BatchDealException(HttpContext context) { string idList = context.Request["RefundIds"].ToNullString(); idList = Globals.GetSafeIDList(idList, ',', true); if (string.IsNullOrEmpty(idList)) { throw new HidistroAshxException("请选择要退款的ID"); } IList <RefundInfo> list = OrderHelper.GetRefundListOfRefundIds(idList); if (list != null && list.Count > 0) { string Operator = HiContext.Current.Manager.UserName; Task.Factory.StartNew(delegate { int num = 0; foreach (RefundInfo 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) && item.HandleStatus == RefundStatus.Applied) { MemberInfo user = Users.GetUser(orderInfo.UserId); string text = RefundHelper.SendRefundRequest(orderInfo, item.RefundAmount, item.RefundOrderId, true); if (text == "") { if (OrderHelper.CheckRefund(orderInfo, item, item.RefundAmount, Operator, item.AdminRemark, true, false)) { VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, "", EnumPushOrderAction.OrderRefund); Messenger.OrderRefund(user, orderInfo, ""); } num++; } else { TradeHelper.SaveRefundErr(item.RefundId, text, true); } Thread.Sleep(5000); } } base.ReturnSuccessResult(context, "退款自动处理提交成功,请稍后刷新页面", 0, true); }); return; } throw new HidistroAshxException("未找到退款记录"); }
protected void btnAcceptRefund_Click(object sender, EventArgs e) { string username = HiContext.Current.User.Username; OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.hidOrderId.Value); if (OrderHelper.CheckRefund(orderInfo, username, this.hidAdminRemark.Value, int.Parse(this.hidRefundType.Value), true)) { this.BindOrders(); decimal total = orderInfo.GetTotal(); if ((orderInfo.GroupBuyId > 0) && (orderInfo.GroupBuyStatus != GroupBuyStatus.Failed)) { total = orderInfo.GetTotal() - orderInfo.NeedPrice; } Member user = Users.GetUser(orderInfo.UserId) as Member; Messenger.OrderRefund(user, orderInfo.OrderId, total); this.ShowMsg("成功的确认了订单退款", true); } }
private void btnRefuseRefund_Click(object sender, EventArgs e) { int refundId = this.Page.Request.QueryString["RefundId"].ToInt(0); string text = Globals.StripAllTags(this.txtAdminRemark.Text); RefundInfo refundInfo = TradeHelper.GetRefundInfo(refundId); if (refundInfo == null) { this.ShowMsg("退款信息错误!", false); } else { OrderInfo orderInfo = OrderHelper.GetOrderInfo(refundInfo.OrderId); if (orderInfo == null) { this.ShowMsg("错误的订单信息", false); } else if (string.IsNullOrEmpty(text)) { this.ShowMsg("请填写拒绝退款的原因", false); } else { refundInfo.AdminRemark = text; decimal num = refundInfo.RefundAmount; if (num == decimal.Zero) { num = orderInfo.GetTotal(false); } string userName = HiContext.Current.Manager.UserName; OrderHelper.CheckRefund(orderInfo, refundInfo, num, userName, text, false, false); MemberInfo user = Users.GetUser(orderInfo.UserId); Messenger.OrderRefundRefused(user, orderInfo, refundInfo); this.ShowMsg("成功的拒绝了订单退款", true, HttpContext.Current.Request.Url.ToString()); } } }
protected void btnAcceptRefund_Click(object sender, EventArgs e) { bool flag = true; string userName = HiContext.Current.Manager.UserName; string adminRemark = Globals.StripAllTags(this.txtAdminRemark.Text); int refundId = this.Page.Request.QueryString["RefundId"].ToInt(0); RefundInfo refundInfo = TradeHelper.GetRefundInfo(refundId); if (refundInfo == null) { this.ShowMsg("错误的退款申请信息", false); } else { OrderInfo orderInfo = OrderHelper.GetOrderInfo(refundInfo.OrderId); if (orderInfo == null) { this.ShowMsg("错误的订单信息", false); } else { decimal num = this.txtRefundMoney.Text.ToDecimal(0); if (num < decimal.Zero) { this.ShowMsg("退款金额必须大于等于0", false); } else { if (!refundInfo.IsServiceProduct) { GroupBuyInfo groupbuy = null; if (orderInfo.GroupBuyId > 0) { groupbuy = ProductBrowser.GetGroupBuy(orderInfo.GroupBuyId); } if (num > orderInfo.GetCanRefundAmount("", groupbuy, 0)) { this.ShowMsg("退款金额不能大于订单/商品最大金额", false); return; } } else if (num > refundInfo.RefundAmount) { this.ShowMsg("退款金额不能大于可退款总额", false); return; } if (refundInfo.HandleStatus != 0) { this.ShowMsg("退款状态不正确", false); } else if (refundInfo.IsServiceProduct || (!refundInfo.IsServiceProduct && OrderHelper.CanFinishRefund(orderInfo, refundInfo, num, false))) { RefundTypes refundType = refundInfo.RefundType; string userRemark = refundInfo.UserRemark; MemberInfo user = Users.GetUser(orderInfo.UserId); string text = ""; if (RefundHelper.IsBackReturn(orderInfo.Gateway) && refundInfo.RefundType == RefundTypes.BackReturn) { text = RefundHelper.SendRefundRequest(orderInfo, num, refundInfo.RefundOrderId, true); if (text == "") { if (OrderHelper.CheckRefund(orderInfo, refundInfo, num, userName, adminRemark, true, false)) { VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, "", EnumPushOrderAction.OrderRefund); Messenger.OrderRefund(user, orderInfo, ""); this.ShowMsg("成功的完成退款并且已成功原路退回退款金额!", true, HttpContext.Current.Request.Url.ToString()); } } else { TradeHelper.SaveRefundErr(refundInfo.RefundId, text, true); this.ShowMsg("退款原路返回错误,错误信息" + text + ",请重新尝试!", false); } } else if (OrderHelper.CheckRefund(orderInfo, refundInfo, num, userName, adminRemark, true, false)) { Messenger.OrderRefund(user, orderInfo, ""); VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, "", EnumPushOrderAction.OrderRefund); if (refundInfo.RefundType == RefundTypes.InBalance) { this.ShowMsg("成功确定了退款,退款金额已退回用户预付款帐号!", true, HttpContext.Current.Request.Url.ToString()); } else { this.ShowMsg("成功的完成了退款,请即时给用户退款", true, HttpContext.Current.Request.Url.ToString()); } } } } } } }
protected void btnAcceptRefund_Click(object sender, System.EventArgs e) { ManagerHelper.CheckPrivilege(Privilege.OrderRefundApplyAccept); decimal refundTotal = 0m; if (string.IsNullOrEmpty(this.hidRefundTotal.Value)) { this.ShowMsg("退款金额不能为空", false); return; } if (!decimal.TryParse(this.hidRefundTotal.Value, out refundTotal)) { this.ShowMsg("退款金额只能为数字", false); return; } string username = HiContext.Current.User.Username; OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.hidOrderId.Value); if (refundTotal > orderInfo.GetTotal()) { this.ShowMsg("退款金额不能大于订单金额", false); return; } bool isReturn = false; if (this.radBtnList.SelectedValue == "1") { isReturn = true; } if (OrderHelper.CheckRefund(orderInfo, username, this.hidAdminRemark.Value, int.Parse(this.hidRefundType.Value), refundTotal, true, isReturn)) { this.BindRefund(); decimal amount = orderInfo.GetTotal(); if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Failed) { amount = orderInfo.GetTotal() - orderInfo.NeedPrice; } //调用微信接口退款 bool isAutoRefund = this.hidIsAutoRefund.Value == "1"; if (1 == 2) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PackageInfo packageInfo = new PackageInfo(); PayClient payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey); RefundInfo refundinfo = OrderHelper.GetRefundByOrderId(orderInfo.OrderId); packageInfo.TransactionId = orderInfo.GatewayOrderId; packageInfo.OutTradeNo = orderInfo.OrderId; packageInfo.OutRefundNo = refundinfo.RefundId.ToString(); packageInfo.RefundFee = (int)refundTotal * 100m; packageInfo.TotalFee = (int)orderInfo.GetTotal() * 100m; string ret = string.Empty; try { ret = payClient.RequestRefund(packageInfo); } catch (Exception ex) { ErrorLog.Write("申请退款失败:" + ex.ToString()); } ErrorLog.Write(ret); } Member user = Users.GetUser(orderInfo.UserId) as Member; //是否退券 radBtnList Messenger.OrderRefund(user, orderInfo, amount); this.ShowMsg("成功的确认了订单退款", true); } }
public void ProcessorOrderVerificationItemsExpire() { StringBuilder stringBuilder = new StringBuilder(); try { Database obj = this.database; ProductSaleStatus productSaleStatus = ProductSaleStatus.UnSale; object arg = productSaleStatus.GetHashCode(); object arg2 = DateTime.Now; productSaleStatus = ProductSaleStatus.OnSale; obj.ExecuteNonQuery(CommandType.Text, string.Format("UPDATE Hishop_StoreProducts SET SaleStatus = {0} WHERE SaleStatus = {2} AND ProductId IN(SELECT ProductId FROM Hishop_Products WHERE ProductType = 1 AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{1}')", arg, arg2, productSaleStatus.GetHashCode())); StringBuilder stringBuilder2 = stringBuilder; productSaleStatus = ProductSaleStatus.UnSale; object arg3 = productSaleStatus.GetHashCode(); object arg4 = DateTime.Now; productSaleStatus = ProductSaleStatus.OnSale; stringBuilder2.AppendLine(string.Format("UPDATE Hishop_StoreProducts SET SaleStatus = {0} WHERE SaleStatus = {2} AND ProductId IN(SELECT ProductId FROM Hishop_Products WHERE ProductType = 1 AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{1}')", arg3, arg4, productSaleStatus.GetHashCode())); this.database.ExecuteNonQuery(CommandType.Text, $"DELETE FROM Hishop_StoreSKUs WHERE ProductId IN(SELECT ProductId FROM Hishop_Products WHERE ProductType = 1 AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{DateTime.Now}')"); stringBuilder.AppendLine($"DELETE FROM Hishop_StoreSKUs WHERE ProductId IN(SELECT ProductId FROM Hishop_Products WHERE ProductType = 1 AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{DateTime.Now}')"); Database obj2 = this.database; productSaleStatus = ProductSaleStatus.UnSale; object arg5 = productSaleStatus.GetHashCode(); object arg6 = DateTime.Now; productSaleStatus = ProductSaleStatus.OnSale; obj2.ExecuteNonQuery(CommandType.Text, string.Format("UPDATE Hishop_Products SET SaleStatus = {0} WHERE ProductType = 1 AND SaleStatus = {2} AND IsValid = 0 AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{1}'", arg5, arg6, productSaleStatus.GetHashCode())); StringBuilder stringBuilder3 = stringBuilder; productSaleStatus = ProductSaleStatus.UnSale; stringBuilder3.AppendLine($"UPDATE Hishop_Products SET SaleStatus = {productSaleStatus.GetHashCode()} WHERE ProductType = 1 AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{DateTime.Now}'"); DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_OrderVerificationItems SET VerificationStatus = " + 3 + " WHERE OrderId IN(SELECT OrderId FROM Hishop_OrderItems WHERE(IsValid = 0 OR IsValid IS NULL) AND ValidEndDate IS NOT NULL AND ValidEndDate < @Now) AND VerificationStatus = " + 0); this.database.AddInParameter(sqlStringCommand, "Now", DbType.DateTime, DateTime.Now); this.database.ExecuteNonQuery(sqlStringCommand); stringBuilder.AppendLine(string.Format("UPDATE Hishop_OrderVerificationItems SET VerificationStatus = " + 3 + " WHERE OrderId IN(SELECT OrderId FROM Hishop_OrderItems WHERE(IsValid = 0 OR IsValid IS NULL) AND ValidEndDate IS NOT NULL AND ValidEndDate < '@Now') AND VerificationStatus = " + 0).Replace("@Now", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); StringBuilder stringBuilder4 = new StringBuilder(); StringBuilder stringBuilder5 = stringBuilder4; object[] obj3 = new object[4]; OrderStatus orderStatus = OrderStatus.Finished; obj3[0] = orderStatus.GetHashCode(); OrderType orderType = OrderType.ServiceOrder; obj3[1] = orderType.GetHashCode(); VerificationStatus verificationStatus = VerificationStatus.Expired; obj3[2] = verificationStatus.GetHashCode(); orderStatus = OrderStatus.BuyerAlreadyPaid; obj3[3] = orderStatus.GetHashCode(); stringBuilder5.Append(string.Format("UPDATE Hishop_Orders SET OrderStatus = {0} WHERE OrderStatus = {3} AND OrderType = {1} AND OrderId IN(SELECT OrderId FROM Hishop_OrderItems oi WHERE oi.Quantity = (SELECT COUNT(Id) FROM Hishop_OrderVerificationItems WHERE VerificationStatus = {2} AND OrderId = oi.OrderId))", obj3)); StringBuilder stringBuilder6 = stringBuilder4; object[] obj4 = new object[4]; orderStatus = OrderStatus.Closed; obj4[0] = orderStatus.GetHashCode(); orderType = OrderType.ServiceOrder; obj4[1] = orderType.GetHashCode(); verificationStatus = VerificationStatus.Expired; obj4[2] = verificationStatus.GetHashCode(); orderStatus = OrderStatus.BuyerAlreadyPaid; obj4[3] = orderStatus.GetHashCode(); stringBuilder6.Append(string.Format("UPDATE Hishop_Orders SET OrderStatus = {0} WHERE OrderStatus = {3} AND OrderType = {1} AND OrderId IN(SELECT OrderId FROM Hishop_OrderItems oi WHERE oi.Quantity = (SELECT COUNT(Id) FROM Hishop_OrderVerificationItems WHERE (VerificationStatus = {2}) AND OrderId = oi.OrderId AND oi.IsOverRefund = 0))", obj4)); StringBuilder stringBuilder7 = stringBuilder4; object[] obj5 = new object[6]; orderStatus = OrderStatus.Finished; obj5[0] = orderStatus.GetHashCode(); orderType = OrderType.ServiceOrder; obj5[1] = orderType.GetHashCode(); verificationStatus = VerificationStatus.Expired; obj5[2] = verificationStatus.GetHashCode(); verificationStatus = VerificationStatus.Finished; obj5[3] = verificationStatus.GetHashCode(); orderStatus = OrderStatus.BuyerAlreadyPaid; obj5[4] = orderStatus.GetHashCode(); verificationStatus = VerificationStatus.Refunded; obj5[5] = verificationStatus.GetHashCode(); stringBuilder7.Append(string.Format("UPDATE Hishop_Orders SET OrderStatus = {0} WHERE OrderStatus = {4} AND OrderType = {1} AND OrderId IN(SELECT OrderId FROM Hishop_OrderItems oi WHERE oi.Quantity = (SELECT COUNT(Id) FROM Hishop_OrderVerificationItems WHERE (VerificationStatus = {2} OR VerificationStatus = {3} OR VerificationStatus = {5}) AND OrderId = oi.OrderId))", obj5)); stringBuilder.AppendLine(stringBuilder4.ToString()); this.database.ExecuteNonQuery(CommandType.Text, stringBuilder4.ToString()); DbCommand sqlStringCommand2 = this.database.GetSqlStringCommand("SELECT oi.Quantity, oi.OrderId,oi.ProductId,StoreId,VerificationStatus,UserName,VerificationPassword FROM [Hishop_OrderItems] oi INNER JOIN Hishop_OrderVerificationItems ov ON ov.OrderId = oi.OrderId WHERE (IsValid = 0 OR IsValid IS NULL) AND IsOverRefund = 1 AND VerificationStatus =" + 3 + ";"); stringBuilder.AppendLine("SELECT oi.Quantity, oi.OrderId,oi.ProductId,StoreId,VerificationStatus,UserName FROM [Hishop_OrderItems] oi INNER JOIN Hishop_OrderVerificationItems ov ON ov.OrderId = oi.OrderId WHERE (IsValid = 0 OR IsValid IS NULL) AND IsOverRefund = 1 AND VerificationStatus =" + 3 + ";"); using (IDataReader objReader = this.database.ExecuteReader(sqlStringCommand2)) { IList <VerificationItemsExipreInfo> list = DataHelper.ReaderToList <VerificationItemsExipreInfo>(objReader); if (list != null && list.Count > 0) { List <string> list2 = (from o in list select o.OrderId).Distinct().ToList(); foreach (string item in list2) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(item); if (orderInfo != null) { MemberInfo user = Users.GetUser(orderInfo.UserId); if (user != null) { IList <VerificationItemsExipreInfo> list3 = (from v in list where v.OrderId == item select v).ToList(); decimal num = ((decimal)list3.Count * (orderInfo.GetTotal(false) / (decimal)orderInfo.GetBuyQuantity() * 1.0m) * 1.0m).F2ToString("f2").ToDecimal(0); string generateId = Globals.GetGenerateId(); RefundInfo refund = new RefundInfo { UserRemark = "", RefundReason = "核销码过期自动退款", RefundType = ((orderInfo.Gateway.ToNullString().ToLower() == EnumDescription.GetEnumDescription((Enum)(object)EnumPaymentType.AdvancePay, 1) || orderInfo.BalanceAmount > decimal.Zero) ? RefundTypes.InBalance : RefundTypes.BackReturn), RefundGateWay = orderInfo.Gateway, RefundOrderId = generateId, RefundAmount = num, StoreId = orderInfo.StoreId, ApplyForTime = DateTime.Now, BankName = "", BankAccountName = "", BankAccountNo = "", OrderId = item, HandleStatus = RefundStatus.Applied, ValidCodes = string.Join(",", from ii in list3 select ii.VerificationPassword), IsServiceProduct = true, Quantity = list3.Count }; try { int num2 = TradeHelper.ServiceOrderApplyForRefund(refund); if (num2 > 0) { refund = TradeHelper.GetRefundInfo(num2); if (refund.Quantity == orderInfo.GetAllQuantity(true)) { OrderHelper.UpdateOrderStatus(orderInfo, OrderStatus.ApplyForRefund); } SiteSettings masterSettings = SettingsManager.GetMasterSettings(); if (masterSettings.IsAutoDealRefund) { if (orderInfo.GetTotal(false) == decimal.Zero) { if (OrderHelper.CheckRefund(orderInfo, refund, decimal.Zero, "", "自动退款", true, true)) { VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, "", EnumPushOrderAction.OrderRefund); Messenger.OrderRefund(user, orderInfo, ""); } else { TradeHelper.SetOrderVerificationItemStatus(item, refund.ValidCodes, VerificationStatus.ApplyRefund); } } else if (refund.RefundType == RefundTypes.InBalance) { if (OrderHelper.CheckRefund(orderInfo, refund, num, "", "自动退款", true, true)) { VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, "", EnumPushOrderAction.OrderRefund); Messenger.OrderRefund(user, orderInfo, ""); } else { TradeHelper.SetOrderVerificationItemStatus(item, refund.ValidCodes, VerificationStatus.ApplyRefund); } } else { string text = TradeHelper.SendWxRefundRequest(orderInfo, num, refund.RefundOrderId); if (text == "") { if (OrderHelper.CheckRefund(orderInfo, refund, num, "", "自动退款", true, true)) { VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, "", EnumPushOrderAction.OrderRefund); Messenger.OrderRefund(user, orderInfo, ""); } else { TradeHelper.SetOrderVerificationItemStatus(item, refund.ValidCodes, VerificationStatus.ApplyRefund); } } else { TradeHelper.SaveRefundErr(num2, text, true); TradeHelper.SetOrderVerificationItemStatus(item, refund.ValidCodes, VerificationStatus.ApplyRefund); } } } else { TradeHelper.SetOrderVerificationItemStatus(orderInfo.OrderId, refund.ValidCodes, VerificationStatus.ApplyRefund); } if (orderInfo.StoreId > 0) { VShopHelper.AppPsuhRecordForStore(orderInfo.StoreId, orderInfo.OrderId, "", EnumPushStoreAction.StoreOrderRefundApply); } } } catch (Exception ex) { Globals.WriteExceptionLog_Page(ex, null, "O2OAutoRefundError"); } } } } } } } catch (Exception ex2) { IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("Sql", stringBuilder.ToString()); Globals.WriteExceptionLog(ex2, dictionary, "ProcessorOrderVerificationItemsExpire"); } }