/// <summary> /// 发送Email,保存发送状态,发送时间 /// </summary> /// <param name="emailSendRecord"></param> public static EmailSendRecordInfo SendEmail(EmailSendRecordInfo emailSendRecord) { //发送 foreach (string temp in emailSendRecord.EmailList.Split(',')) { if (temp != string.Empty) { MailInfo mail = new MailInfo(); mail.ToEmail = temp; mail.Title = emailSendRecord.Title; mail.Content = emailSendRecord.Content; if (emailSendRecord.IsStatisticsOpendEmail == (int)BoolType.True) { mail.Content += "<img style=\"display:none\" src=\"http://" + HttpContext.Current.Request.ServerVariables["Http_Host"] + "/Admin/EmailCheckOpen.aspx?Email=" + temp + "&ID=" + emailSendRecord.ID + "\" >"; } mail.UserName = ShopConfig.ReadConfigInfo().EmailUserName; mail.Password = ShopConfig.ReadConfigInfo().EmailPassword; mail.Server = ShopConfig.ReadConfigInfo().EmailServer; mail.ServerPort = ShopConfig.ReadConfigInfo().EmailServerPort; try { MailClass.SendEmail(mail); } catch (Exception ex) { ExceptionHelper.ProcessException(ex, true); } } } //保存状态 emailSendRecord.SendDate = RequestHelper.DateNow; emailSendRecord.SendStatus = (int)SendStatus.Finished; EmailSendRecordBLL.SaveEmailSendRecordStatus(emailSendRecord); return(emailSendRecord); }
/// <summary> /// 退款到账户余额及各支付渠道 /// </summary> /// <param name="orderRefund"></param> public static void RefundToAnyPay(OrderRefundInfo orderRefund) { if (orderRefund.Status != (int)OrderRefundStatus.Returning) { return; } if (RefundOnline) { if (PayPlugins.ReadPayPlugins(orderRefund.RefundPayKey).IsOnline == 1 && (OrderBLL.Read(orderRefund.OrderId).AliPayTradeNo.Trim() != string.Empty || OrderBLL.Read(orderRefund.OrderId).WxPayTradeNo.Trim() != string.Empty))//只有在线付款才走线上流程,并且存在支付交易号(支付宝微信任意一个) { //退款到各支付渠道 //如需退余额,将在第三方支付退款成功后操作 //这样做的好处在于保障了余额能够被准确退还。不会出现退了余额,但支付宝或微信因为人为或意外的原因没退成功的情况。 if (orderRefund.RefundMoney > 0) { //HttpContext.Current.Response.Redirect(string.Format("/Plugins/Pay/{0}/Refund.aspx?order_refund_id={1}", orderRefund.RefundPayKey, orderRefund.Id)); HttpContext.Current.Response.Redirect(string.Format("/Plugins/Pay/{0}/Refund.aspx?order_refund_id={1}&returnurl={2}", orderRefund.RefundPayKey, orderRefund.Id, RefundRedirectUrl)); } else { //只需退款到余额 //在这里写自己的逻辑 if (orderRefund.RefundBalance > 0) { //HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundToBalance.aspx?order_refund_id={0}", orderRefund.Id)); HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundToBalance.aspx?order_refund_id={0}&returnurl={1}", orderRefund.Id, RefundRedirectUrl)); } } } else//线下退款则直接更改状态,所以线下退款只能管理员自己审核。 { orderRefund.Remark = "退款完成"; orderRefund.Status = (int)OrderRefundStatus.HasReturn; orderRefund.TmRefund = DateTime.Now; OrderRefundBLL.Update(orderRefund); OrderRefundActionBLL.Add(new OrderRefundActionInfo { OrderRefundId = orderRefund.Id, Status = 1, Tm = DateTime.Now, UserType = 2, UserId = Cookies.Admin.GetAdminID(false), UserName = Cookies.Admin.GetAdminName(false), Remark = orderRefund.Remark }); #region 发送订单退款成功通知 int isSendNotice = ShopConfig.ReadConfigInfo().RefundOrder; int isSendEmail = ShopConfig.ReadConfigInfo().RefundOrderEmail; int isSendMessage = ShopConfig.ReadConfigInfo().RefundOrderMsg; string key = "RefundOrder"; OrderInfo order = OrderBLL.Read(orderRefund.OrderId); if (isSendNotice == (int)BoolType.True && key != string.Empty) { if (isSendEmail == (int)BoolType.True) {//发邮件 try { EmailContentInfo emailContent = EmailContentHelper.ReadSystemEmailContent(key); EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo(); emailSendRecord.Title = emailContent.EmailTitle; emailSendRecord.Content = emailContent.EmailContent.Replace("$UserName$", order.UserName).Replace("$OrderNumber$", order.OrderNumber).Replace("$PayName$", order.PayName).Replace("$ShippingName$", ShippingBLL.Read(order.ShippingId).Name).Replace("$ShippingNumber$", order.ShippingNumber).Replace("$ShippingDate$", order.ShippingDate.ToString("yyyy-MM-dd")); emailSendRecord.IsSystem = (int)BoolType.True; emailSendRecord.EmailList = order.Email; emailSendRecord.IsStatisticsOpendEmail = (int)BoolType.False; emailSendRecord.SendStatus = (int)SendStatus.No; emailSendRecord.AddDate = RequestHelper.DateNow; emailSendRecord.SendDate = RequestHelper.DateNow; emailSendRecord.ID = EmailSendRecordBLL.AddEmailSendRecord(emailSendRecord); EmailSendRecordBLL.SendEmail(emailSendRecord); //result = "通知邮件已发送。"; } catch { //result = "未发送通知邮件。"; } } if (isSendMessage == (int)BoolType.True) {//发短信 //result += "未发送通知短信。"; } } #endregion if (string.IsNullOrEmpty(RefundRedirectUrl)) { HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundAdd.aspx?id={0}", orderRefund.Id)); } else { HttpContext.Current.Response.Redirect(RefundRedirectUrl); } } } else { //处理订单、商品的退款状态,线下退款 //在这里写自己的逻辑 HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundToBalance.aspx?order_refund_id={0}&returnurl={1}", orderRefund.Id, RefundRedirectUrl)); } }