/// <summary> /// 咨询回复发送邮件 /// </summary> /// <param name="info"></param> public static void SendMailConsultReply(ProductConsultReplyInfo info, int productSysNo, string productName) { AsyncEmail email = new AsyncEmail(); email.MailAddress = info.CustomerInfo.Email; email.CustomerID = info.CustomerInfo.CustomerID; email.Status = (int)EmailStatus.NotSend; email.ImgBaseUrl = ConfigurationManager.AppSettings["CDNWebDomain"].ToString(); string subject = string.Empty; email.MailBody = MailHelper.GetMailTemplateBody("ConsultReply", out subject); string productdetail = ConstValue.WebDomain + "/Product/Detail/" + productSysNo.ToString(); ConsultationInfo consultInfo = ConsultationDA.GetProductConsult(info.ConsultSysNo); email.MailSubject = subject; email.MailBody = email.MailBody.Replace("[ProducDetail]", productdetail) .Replace("[ProductName]", productName) .Replace("[ImgBaseUrl]", email.ImgBaseUrl) .Replace("[WebBaseUrl]", ConstValue.WebDomain) .Replace("[CurrentDateTime]", DateTime.Now.ToString("yyyy-MM-dd")) .Replace("[Content]", StringUtility.RemoveHtmlTag(consultInfo.Content)) .Replace("[ReplyContent]", StringUtility.RemoveHtmlTag(info.Content)); EmailDA.SendEmail(email); }
/// <summary> /// 发表咨询 /// </summary> /// <returns></returns> public JsonResult CreateConsult() { ConsultationInfo info = new ConsultationInfo(); info.ProductSysNo = int.Parse(Request["ProductSysNo"].ToString()); info.CustomerSysNo = this.CurrUser.UserSysNo; info.Content = Request["Content"].ToString(); info.Type = Request["Type"].ToString(); bool IsSuccess = ConsultationFacade.CreateProductConsult(info); if (IsSuccess) { return(new JsonResult() { Data = 1 }); } else { return(new JsonResult() { Data = 0 }); } }
/// <summary> /// 发表咨询 /// </summary> /// <param name="info"></param> /// <returns></returns> public static bool CreateProductConsult(ConsultationInfo info) { DataCommand cmd = DataCommandManager.GetDataCommand("CreateProductConsult"); cmd.SetParameterValue("@ProductSysNo", info.ProductSysNo); cmd.SetParameterValue("@CustomerSysNo", info.CustomerSysNo); cmd.SetParameterValue("@Content", info.Content); cmd.SetParameterValue("@Type", info.Type); cmd.SetParameterValue("@Status", info.Status); SetCommandDefaultParameters(cmd); return(cmd.ExecuteNonQuery() > 0); }
/// <summary> /// 获取咨询 /// </summary> /// <param name="queryInfo"></param> /// <returns></returns> public static ConsultationInfo GetConsultListBySysNo(ConsultQueryInfo queryInfo) { ConsultationInfo consultationInfo = ConsultationDA.GetConsultListBySysNo(queryInfo); if (consultationInfo != null) { consultationInfo.Content = CommonFacade.SetCannotOnlineWordsMask(consultationInfo.Content); if (consultationInfo.PagedReplyList != null) { foreach (var reply in consultationInfo.PagedReplyList) { reply.Content = CommonFacade.SetCannotOnlineWordsMask(reply.Content); } } } return(consultationInfo); }
/// <summary> /// 发表咨询 /// </summary> /// <param name="info"></param> /// <returns></returns> public static bool CreateProductConsult(ConsultationInfo info) { string cacheKey = CommonFacade.GenerateKey("CreateProductConsult", info.CustomerSysNo.ToString(), info.ProductSysNo.ToString()); DateTime now = DateTime.Now; int nowTimePoint = now.Hour * 3600 + now.Minute * 60 + now.Second; if (HttpRuntime.Cache[cacheKey] != null) { int preTimePoint = (int)HttpRuntime.Cache[cacheKey]; if (nowTimePoint - preTimePoint < 60) { throw new BusinessException("很抱歉,您发表咨询的频率过快,请稍后再试。"); } } else { HttpRuntime.Cache.Insert(cacheKey, 0, null, DateTime.Now.AddSeconds(CacheTime.Shortest), Cache.NoSlidingExpiration); } bool result = false; if (ConstValue.ProductConsultSwitch) { info.Status = "A"; } else { info.Status = "O"; } result = ConsultationDA.CreateProductConsult(info); if (result) { now = DateTime.Now; nowTimePoint = now.Hour * 3600 + now.Minute * 60 + now.Second; HttpRuntime.Cache[cacheKey] = nowTimePoint; } return(result); }
/// <summary> /// 根据商品唯一系统ID获取咨询 /// </summary> /// <param name="queryInfo"></param> /// <returns>咨询</returns> public static ConsultationInfo GetConsultListBySysNo(ConsultQueryInfo queryInfo) { DataCommand dataCommand = DataCommandManager.GetDataCommand("GetProductConsultInfoBySysNo"); dataCommand.SetParameterValue("@SysNo", queryInfo.ConsultSysNo); dataCommand.SetParameterValue("@PageSize", queryInfo.PagingInfo.PageSize); dataCommand.SetParameterValue("@PageIndex", queryInfo.PagingInfo.PageIndex); dataCommand.SetParameterValue("@LanguageCode", ConstValue.LanguageCode); dataCommand.SetParameterValue("@CompanyCode", ConstValue.CompanyCode); dataCommand.SetParameterValue("@StoreCompanyCode", ConstValue.StoreCompanyCode); DataSet result = dataCommand.ExecuteDataSet(); DataTable masterTable = result.Tables[0]; ConsultationInfo consultInfo = new ConsultationInfo(); if (masterTable.Rows.Count > 0) { consultInfo = DataMapper.GetEntity <ConsultationInfo>(masterTable.Rows[0]);// EntityBuilder.BuildEntity<ConsultationInfo>(masterTable.Rows[0]); if (consultInfo == null) { return(null); } DataTable itemTable = result.Tables[1]; List <ProductConsultReplyInfo> replyList = DataMapper.GetEntityList <ProductConsultReplyInfo, List <ProductConsultReplyInfo> >(itemTable.Rows);// EntityBuilder.BuildEntityList<ProductConsultReplyInfo>(itemTable); if (itemTable.Rows.Count > 0) { if (replyList.Count > 0) { //新蛋回复 List <ProductConsultReplyInfo> neweggReplyList = replyList.FindAll( replyInfo => replyInfo.ReplyType == FeedbackReplyType.Newegg); if (neweggReplyList.Count > 0) { neweggReplyList.Sort((a, b) => b.InDate.CompareTo(a.InDate)); consultInfo.NeweggReply = neweggReplyList[0]; } //厂商回复 List <ProductConsultReplyInfo> manuReplyList = replyList.FindAll( replyInfo => replyInfo.ReplyType == FeedbackReplyType.Manufacturer); if (manuReplyList.Count > 0) { manuReplyList.Sort((a, b) => b.InDate.CompareTo(a.InDate)); consultInfo.ManufactureReply = manuReplyList[0]; } //如果网友回复被置顶则作为厂商回复 List <ProductConsultReplyInfo> topReplyList = replyList.FindAll( replyInfo => replyInfo.ReplyType == FeedbackReplyType.Web && replyInfo.IsTop.ToUpper() == "Y"); if (topReplyList.Count > 0) { topReplyList.Sort((a, b) => b.EditDate.CompareTo(a.EditDate)); consultInfo.ManufactureReply = topReplyList[0]; //网友回复列表(除去用来替换厂商回复的一条数据) replyList.RemoveAll(replyInfo => replyInfo.SysNo == topReplyList[0].SysNo); } List <ProductConsultReplyInfo> userList = replyList.FindAll( replyInfo => replyInfo.ReplyType == FeedbackReplyType.Web); int totalCount = Convert.ToInt32(dataCommand.GetParameterValue("@TotalCount")); int pageIndex = queryInfo.PagingInfo.PageIndex; if ((pageIndex * queryInfo.PagingInfo.PageSize) > totalCount) { if (totalCount != 0 && (totalCount % queryInfo.PagingInfo.PageSize) == 0) { pageIndex = totalCount / queryInfo.PagingInfo.PageSize; } else { pageIndex = totalCount / queryInfo.PagingInfo.PageSize + 1; } } consultInfo.PagedReplyList = new PagedResult <ProductConsultReplyInfo>(totalCount, queryInfo.PagingInfo.PageSize, pageIndex, userList); } } } return(consultInfo); }