public string Delete(HttpContext pContext) { try { WMaterialTextBLL bll = new WMaterialTextBLL(CurrentUserInfo); string textID = pContext.Request["textID"]; var server = new WMenuMTextMappingBLL(CurrentUserInfo); var entity = server.QueryByEntity(new WMenuMTextMappingEntity { TextId = textID, IsDelete = 0 }, null).FirstOrDefault(); if (entity != null) { return(string.Format("{{\"success\":'false',\"msg\":\"图文信息已被引用,不能删除\"}}")); } object[] obi = new object[] { textID }; bll.Delete(obi); return(string.Format("{{\"success\":'true'}}")); } catch (Exception) { return(string.Format("{{\"success\":'false',\"msg\":\"操作异常,删除失败\"}}")); throw; } }
protected override GetMaterialTextDetailRD ProcessRequest(DTO.Base.APIRequest <GetMaterialTextDetailRP> pRequest) { var rd = new GetMaterialTextDetailRD(); var customerId = pRequest.Parameters.CustomerId; var textId = pRequest.Parameters.TextId; if (string.IsNullOrEmpty(textId) || textId == "") { throw new APIException("图文标识不能为空") { ErrorCode = 120 }; } var currentUserInfo = Default.GetBSLoggingSession(customerId, "1"); var bll = new WMaterialTextBLL(currentUserInfo); var ds = bll.GetMaterialTextTitleList(textId, customerId); var temp = ds.Tables[0].AsEnumerable().Select(t => new MaterialTextTitleInfo() { Text = t["Text"].ToString(), Title = t["Title"].ToString(), TextId = textId }).FirstOrDefault(); rd.MaterialTextTitleList = temp; return(rd); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["id"])) { var id = Request.QueryString["id"].Replace("'", ""); if (!string.IsNullOrEmpty(Request.QueryString["customerId"])) { customerId = Request.QueryString["customerId"].Replace("'", ""); } //Response.Write(newsID); var condition = new List <IWhereCondition> { new EqualsCondition() { FieldName = "TextId", Value = id } }; LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); WMaterialTextBLL server = new WMaterialTextBLL(loggingSessionInfo); var data = server.Query(condition.ToArray(), null).ToList(); if (data != null && data.Count > 0) { var newsEntity = data.FirstOrDefault(); this.newsTitle.Text = newsEntity.Title; title = newsEntity.Title; imageUrl = newsEntity.CoverImageUrl; if (string.IsNullOrEmpty(imageUrl)) { this.Panel1.Visible = false; } this.newsPublishTime.Text = newsEntity.CreateTime.Value.ToString("yyyy-MM-dd"); this.newsContent.Text = newsEntity.Text; newsPublishTime.Visible = false; string result = System.Text.RegularExpressions.Regex.Replace(newsEntity.Text, @"<[^>]*>", "").Replace("\r\n", "").Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", ""); if (result.Length > 100) { description = HttpUtility.UrlEncode(result.Substring(0, 100)); } else { description = HttpUtility.UrlEncode(result.Substring(0, result.Length)); } //记录访问日志 log4net.ILog logger = log4net.LogManager.GetLogger("Logger"); var log = new JIT.CPOS.Web.Module.Log.InterfaceWebLog.LogContent("TextImageWap", Request.QueryString["id"], "System", Request.QueryString["customerId"], "System", "System", "", "", "", newsEntity.Title); //JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo() { Message = "记录访问日志" }); logger.Info(log); } } } }
/// <summary> /// 获取所有图文素材类别 /// </summary> /// <returns></returns> public string GetMaterialTextType() { try { DataSet ds = new WMaterialTextBLL(CurrentUserInfo).GetWmType(); return(ds.Tables[0].ToJSON()); } catch (Exception) { return(""); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["id"])) { var id = Request.QueryString["id"].Replace("'", ""); if (!string.IsNullOrEmpty(Request.QueryString["customerId"])) { customerId = Request.QueryString["customerId"].Replace("'", ""); } //Response.Write(newsID); var condition = new List <IWhereCondition> { new EqualsCondition() { FieldName = "TextId", Value = id } }; LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); WMaterialTextBLL server = new WMaterialTextBLL(loggingSessionInfo); var data = server.Query(condition.ToArray(), null).ToList(); if (data != null && data.Count > 0) { var newsEntity = data.FirstOrDefault(); this.newsTitle.Text = newsEntity.Title; title = newsEntity.Title; imageUrl = newsEntity.CoverImageUrl; this.newsPublishTime.Text = newsEntity.CreateTime.Value.ToString("yyyy-MM-dd"); this.newsContent.Text = newsEntity.Text; newsPublishTime.Visible = false; string result = System.Text.RegularExpressions.Regex.Replace(newsEntity.Text, @"<[^>]*>", "").Replace("\r\n", "").Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", ""); if (result.Length > 100) { description = HttpUtility.UrlEncode(result.Substring(0, 100)); } else { description = HttpUtility.UrlEncode(result.Substring(0, result.Length)); } } } } }
protected override GetNewsListRD ProcessRequest(APIRequest <EmptyRequestParameter> pRequest) { var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; if (loggingSessionInfo == null) { throw new APIException("用户未登录") { ErrorCode = ERROR_CODES.INVALID_RESPONSE }; } WMaterialTextBLL bll = new WMaterialTextBLL(loggingSessionInfo); var r = bll.GetAllByCustomId(); GetNewsListRD result = TransModel(r); return(result); }
public string GetList(HttpContext pContext) { try { WMaterialTextEntity entity = pContext.Request["form"].DeserializeJSONTo <WMaterialTextEntity>(); int pageSize = pContext.Request["limit"].ToInt(); int pageIndex = pContext.Request["page"].ToInt(); DataSet ds = new WMaterialTextBLL(CurrentUserInfo).GetWMaterialTextPage(entity.Title, entity.ModelId, pageSize, pageIndex - 1); //return string.Format("{{\"totalCount\":'{0}',\"topics\":{1}}}", // ds.Tables[1].Rows[0][0], ds.Tables[0].ToJSON()); return(string.Format("{{\"totalCount\":{1},\"topics\":{0}}}", ds.Tables[0].ToJSON(), ds.Tables[1].Rows[0][0])); } catch (Exception) { return(string.Format("{{\"totalCount\":'',\"topics\":''}}")); } }
protected override GetMaterialTextListRD ProcessRequest(DTO.Base.APIRequest <GetMaterialTextListRP> pRequest) { var rd = new GetMaterialTextListRD(); string materialTextId = pRequest.Parameters.MaterialTextId; string name = pRequest.Parameters.Name; string typeId = pRequest.Parameters.TypeId; int?pageSize = pRequest.Parameters.PageSize; int?pageIndex = pRequest.Parameters.PageIndex; var bll = new WMaterialTextBLL(CurrentUserInfo); var entitys = bll.GetWMaterialTextList(this.CurrentUserInfo.ClientID, name, materialTextId, typeId, pageSize, pageIndex); var list = entitys.Select(t => new MaterialTextListInfo { TestId = t.TextId, ApplicationId = t.ApplicationId, Abstract = t.Author,//摘要使用原来的字段 DisplayIndex = Convert.ToInt32(t.DisplayIndex), ImageUrl = t.CoverImageUrl, OriginalUrl = t.OriginalUrl, PageId = t.PageId.ToString(), PageParamJson = t.PageParamJson, Text = t.Text, Title = t.Title, TypeId = t.ModelId, UnionTypeId = t.TypeId, IsTitlePageImage = t.IsTitlePageImage }); rd.MaterialTextList = list.ToArray(); int totalCount = bll.GetWMaterialTextListCount(CurrentUserInfo.ClientID, name, materialTextId, typeId); rd.TotalPages = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(totalCount * 1.00 / (pageSize ?? 15) * 1.00))); return(rd); }
public void CreateH5QRCode(SetCTWEventRP para, WApplicationInterfaceEntity wapentity, out string strQRCode, out string QRCodeUrl, out string RedirectUrl) { #region 图文,二维码 #region 生成图文素材 #region 获取Page信息 var pageBll = new SysPageBLL(loggingSessionInfo); var textBll = new WMaterialTextBLL(loggingSessionInfo); //组织图文实体 var entity = new WMaterialTextEntity() { ApplicationId = wapentity.ApplicationId, //用自己取出来的 CoverImageUrl = para.MaterialText.ImageUrl, //图片地址 PageId = Guid.NewGuid(), //页面模块的标识 PageParamJson = para.MaterialText.PageParamJson, //这个比较重要 Text = para.MaterialText.Text, TextId = "", //为空时在后面保存时生成 Title = para.MaterialText.Title, TypeId = para.MaterialText.TypeId }; #endregion #region 生成URL var Domain = ConfigurationManager.AppSettings["interfacehost"].Replace("http://", ""); var Domain1 = ConfigurationManager.AppSettings["interfacehost1"].Replace("http://", ""); string URL = string.Empty; bool IsAuth = false; URL = ConfigurationManager.AppSettings["LinKinUrl"] + "id=" + para.EventThemeInfo.WorksId; entity.IsAuth = Convert.ToInt32(IsAuth); entity.PageParamJson = para.MaterialText.PageParamJson; #endregion #endregion entity.OriginalUrl = URL;//图文素材要跳转到的页面 RedirectUrl = URL; #endregion #region 保存 var unionMappingBll = new WModelTextMappingBLL(loggingSessionInfo); entity.TextId = Guid.NewGuid().ToString("N"); textBll.Create(entity);//创建图文素材 #endregion string strQRCodeObjectId = Guid.NewGuid().ToString(); //活动的二维码自己查找QRCodeId var wqrCodeManagerEntity = new WQRCodeManagerBLL(loggingSessionInfo).QueryByEntity(new WQRCodeManagerEntity() { ObjectId = strQRCodeObjectId }, null).FirstOrDefault(); Guid QRCodeId; if (wqrCodeManagerEntity == null) { #region 生成二维码 var wqrentity = new WQRCodeTypeBLL(loggingSessionInfo).QueryByEntity( new WQRCodeTypeEntity { TypeCode = "CreativeCode" } , null).FirstOrDefault(); var wxCode = CretaeWxCode(); var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo); QRCodeId = Guid.NewGuid(); if (!string.IsNullOrEmpty(wxCode.ImageUrl)) { wqrCodeManagerEntity = new WQRCodeManagerEntity() { QRCodeId = QRCodeId, QRCode = wxCode.MaxWQRCod.ToString(), QRCodeTypeId = wqrentity.QRCodeTypeId, IsUse = 1, ObjectId = strQRCodeObjectId, CreateBy = loggingSessionInfo.UserID, ApplicationId = wapentity.ApplicationId, IsDelete = 0, ImageUrl = wxCode.ImageUrl, CustomerId = loggingSessionInfo.ClientID }; WQRCodeManagerbll.Create(wqrCodeManagerEntity); } else { throw new APIException(wxCode.msg) { ErrorCode = 342 }; } #endregion //throw new APIException("活动没有生成二维码!") { ErrorCode = 342 }; } QRCodeId = (Guid)wqrCodeManagerEntity.QRCodeId;//活动二维码的标识 ////根据二维码标识查找是否有他的关键字回复 var WKeywordReplyentity = new WKeywordReplyBLL(loggingSessionInfo).QueryByEntity(new WKeywordReplyEntity() { Keyword = QRCodeId.ToString() //二维码的标识 }, null).FirstOrDefault(); var ReplyBLL = new WKeywordReplyBLL(loggingSessionInfo); var ReplyId = Guid.NewGuid().ToString();//创建临时 if (WKeywordReplyentity == null) { ReplyBLL.Create(new WKeywordReplyEntity() { ReplyId = ReplyId, Keyword = QRCodeId.ToString(), ReplyType = 3, //用图文素材 KeywordType = 4, //标识 IsDelete = 0, CreateBy = loggingSessionInfo.UserID, ApplicationId = wapentity.ApplicationId, }); } else { ReplyId = WKeywordReplyentity.ReplyId; //用取出来的数据查看 WKeywordReplyentity.Text = ""; WKeywordReplyentity.ReplyType = 3; //图文素材 ReplyBLL.Update(WKeywordReplyentity); } #region 添加图文消息 WMenuMTextMappingBLL MenuMTextMappingServer = new WMenuMTextMappingBLL(loggingSessionInfo); WMenuMTextMappingEntity MappingEntity = new WMenuMTextMappingEntity(); MappingEntity.MenuId = ReplyId; MappingEntity.TextId = entity.TextId; // 用图文素材标识****** MappingEntity.DisplayIndex = 1; //排列顺序 MappingEntity.CustomerId = loggingSessionInfo.ClientID; MappingEntity.MappingId = Guid.NewGuid(); MenuMTextMappingServer.Create(MappingEntity); strQRCode = QRCodeId.ToString(); QRCodeUrl = wqrCodeManagerEntity.ImageUrl; #endregion }
/// <summary> /// 获取商品信息 /// </summary> public string GetItemInfoById() { var itemService = new ItemService(CurrentUserInfo); ItemInfo data = new ItemInfo(); string content = string.Empty; string key = string.Empty; if (Request("item_id") != null && Request("item_id") != string.Empty) { key = Request("item_id").ToString().Trim(); } data = itemService.GetItemInfoById(CurrentUserInfo, key); WQRCodeManagerBLL wQRCodeManagerBLL = new WQRCodeManagerBLL(CurrentUserInfo); var entity = wQRCodeManagerBLL.QueryByEntity(new WQRCodeManagerEntity { ObjectId = key , IsDelete = 0 }, null).FirstOrDefault(); #region 图文|二维码 if (entity != null) { data.imageUrl = entity.ImageUrl; var WKeywordReplyentity = new WKeywordReplyBLL(this.CurrentUserInfo).QueryByEntity(new WKeywordReplyEntity() { Keyword = entity.QRCodeId.ToString() }, null).FirstOrDefault(); if (WKeywordReplyentity != null) { if (WKeywordReplyentity.ReplyType == 1) { data.ReplyType = "1"; data.Text = WKeywordReplyentity.Text; } else if (WKeywordReplyentity.ReplyType == 3) { data.ReplyType = "3"; WMenuMTextMappingBLL bll = new WMenuMTextMappingBLL(this.CurrentUserInfo); WMaterialTextBLL wmbll = new WMaterialTextBLL(this.CurrentUserInfo); OrderBy[] pOrderBys = new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Asc } }; var textMapping = bll.QueryByEntity(new WMenuMTextMappingEntity { MenuId = WKeywordReplyentity.ReplyId, IsDelete = 0 }, pOrderBys); if (textMapping != null && textMapping.Length > 0) { List <WMaterialTextEntity> list = new List <WMaterialTextEntity>(); foreach (var item in textMapping) { WMaterialTextEntity WMaterialTextentity = wmbll.QueryByEntity(new WMaterialTextEntity { TextId = item.TextId, IsDelete = 0 }, null)[0]; list.Add(WMaterialTextentity); } data.listMenutext = list; } } } } #endregion var jsonData = new JsonData(); jsonData.totalCount = data == null ? "0" : "1"; jsonData.data = data; content = jsonData.ToJSON(); return(content); }
protected override GetSetoffToolsRD ProcessRequest(APIRequest <GetSetoffToolsRP> pRequest) { SetoffToolsBLL setOffToolsBLL = new SetoffToolsBLL(CurrentUserInfo); IincentiveRuleBLL incentiveRuleBLL = new IincentiveRuleBLL(CurrentUserInfo); var para = pRequest.Parameters; var setoffToolsEntity = new SetoffToolsEntity(); if (para.ToolsType != null) { setoffToolsEntity.ToolType = para.ToolsType.ToString(); } GetSetoffToolsRD setoffToolsRD = new GetSetoffToolsRD(); var setoffEventBLL = new SetoffEventBLL(CurrentUserInfo); //获取集客活动信息 string NoticePlatType = string.Empty; if (string.IsNullOrEmpty(para.ApplicationType)) { para.ApplicationType = "0"; } else { switch (para.ApplicationType) { case "1": NoticePlatType = "1"; break; case "2": NoticePlatType = "2"; break; case "3": NoticePlatType = "2"; //传3需要进行平台类型处理 等于3时获取员工集客行动平台 break; case "4": NoticePlatType = "3"; //传4需要进行平台类型处理 等于4时获取超级分销商推广行动平台 break; } } var setOffEventInfo = setoffEventBLL.QueryByEntity(new SetoffEventEntity() { Status = "10", IsDelete = 0, SetoffType = Convert.ToInt32(NoticePlatType), CustomerId = CurrentUserInfo.CurrentUser.customer_id }, null); int SetoffToolsTotalCount = 0; DataSet SetoffToolsList = null; if (setOffEventInfo.Length != 0) { //获取集客活动工具数量 SetoffToolsTotalCount = setOffToolsBLL.GeSetoffToolsListCount(setoffToolsEntity, para.ApplicationType, para.BeShareVipID, setOffEventInfo[0].SetoffEventID.ToString()); //获取集客活动工具列表 SetoffToolsList = setOffToolsBLL.GetSetoffToolsList(setoffToolsEntity, para.ApplicationType, para.BeShareVipID, para.PageIndex, para.PageSize, setOffEventInfo[0].SetoffEventID.ToString()); } //获取集客奖励信息 var IncentiveRule = incentiveRuleBLL.GetIncentiveRule(para.ApplicationType); setoffToolsRD.TotalCount = SetoffToolsTotalCount; int remainder = 0; if (para.PageSize == 0) { para.PageSize = 10; } setoffToolsRD.TotalPageCount = Math.DivRem(SetoffToolsTotalCount, para.PageSize, out remainder); if (remainder > 0) { setoffToolsRD.TotalPageCount++; } string strHost = ConfigurationManager.AppSettings["website_url"].Trim(); if (SetoffToolsList != null && SetoffToolsList.Tables[0].Rows.Count > 0) { //为优惠券和海报添加图片路径 SetoffToolsList.Tables[0].Columns.Add("ImageUrl", typeof(string)); var CustomerBasicSettingBLL = new CustomerBasicSettingBLL(CurrentUserInfo); var CustomerBasicInfo = CustomerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity() { CustomerID = CurrentUserInfo.CurrentUser.customer_id, SettingCode = "SetoffPosterWeChatDefaultPhoto" }, null).FirstOrDefault(); var setOffPosterBLL = new SetoffPosterBLL(CurrentUserInfo); var ObjectImagesBLL = new ObjectImagesBLL(CurrentUserInfo); var T_CTW_LEventBLL = new T_CTW_LEventBLL(CurrentUserInfo); var wMaterialTextBLL = new WMaterialTextBLL(CurrentUserInfo); string SourceId = string.Empty; if (!string.IsNullOrEmpty(para.ApplicationType)) { switch (para.ApplicationType) { case "1": SourceId = "3"; //会员集客 break; case "2": SourceId = "1"; //APP会员服务; break; case "3": SourceId = "3"; //APP会员服务; break; case "4": SourceId = "4"; //超级分销商; break; } } string goUrl = string.Empty; string goCouponUrl = strHost + "/HtmlApps/html/common/GatheringClient/Coupon.html?customerId="; //拼优惠券详细页面 string goPosterUrl = strHost + "/HtmlApps/html/common/GatheringClient/poster.html?customerId="; //拼海报详细页面 string strOAuthUrl = strHost + "/WXOAuth/AuthUniversal.aspx?scope=snsapi_userinfo&SourceId=" + SourceId + "&customerId="; //拼OAuth认证 foreach (DataRow dr in SetoffToolsList.Tables[0].Rows) { if (dr["ToolType"].ToString() == "Coupon") { if (CustomerBasicInfo != null) { dr["ImageUrl"] = CustomerBasicInfo.SettingValue; } if (para.ApplicationType == "4") { goUrl = goCouponUrl + CurrentUserInfo.CurrentUser.customer_id + "&pushType=IsSuperRetail&ShareVipId=" + CurrentUserInfo.UserID + "&couponId=" + dr["ObjectId"] + "&version="; dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=Coupon&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl); } else { //Oauth认证加商品详情页 goUrl = goCouponUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipId=" + CurrentUserInfo.UserID + "&couponId=" + dr["ObjectId"] + "&version="; dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl); } } if (dr["ToolType"].ToString() == "SetoffPoster") { var setOffPosterInfo = setOffPosterBLL.QueryByEntity(new SetoffPosterEntity() { SetoffPosterID = new Guid(dr["ObjectId"].ToString()) }, null).FirstOrDefault(); if (setOffPosterInfo != null) { var ObjectImgsInfo = ObjectImagesBLL.QueryByEntity(new ObjectImagesEntity() { ImageId = setOffPosterInfo.ImageId }, null).FirstOrDefault(); if (ObjectImgsInfo != null) { dr["ImageUrl"] = ObjectImgsInfo.ImageURL; } } if (para.ApplicationType == "4") { goUrl = goPosterUrl + CurrentUserInfo.CurrentUser.customer_id + "&pushType=IsSuperRetail&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version="; dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=SetoffPoster&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl); } else { //Oauth认证加海报详情页 goUrl = goPosterUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version="; dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl); } } if (dr["ToolType"].ToString() == "CTW") { var T_CTW_LEventInfo = T_CTW_LEventBLL.QueryByEntity(new T_CTW_LEventEntity() { CTWEventId = new Guid(dr["ObjectId"].ToString()) }, null).FirstOrDefault(); if (T_CTW_LEventInfo != null) { dr["ImageUrl"] = T_CTW_LEventInfo.ImageURL; } if (para.ApplicationType == "4") { goUrl = dr["URL"].ToString() + "&pushType=IsSuperRetail&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version="; dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=CTW&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl); } else { goUrl = dr["URL"].ToString() + "&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version="; dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl); } } if (dr["ToolType"].ToString() == "Material")//如果是图文素材 { var wMaterialTextInfo = wMaterialTextBLL.QueryByEntity(new WMaterialTextEntity() { TextId = dr["ObjectId"].ToString() }, null).FirstOrDefault(); if (wMaterialTextInfo != null) { dr["ImageUrl"] = wMaterialTextInfo.CoverImageUrl; } goUrl = dr["URL"].ToString(); dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=Material&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl); } } setoffToolsRD.SetOffToolsList = DataTableToObject.ConvertToList <SetOffToolsInfo>(SetoffToolsList.Tables[0]); } if (IncentiveRule != null && IncentiveRule.Tables[0].Rows.Count > 0) { setoffToolsRD.SetoffRegAwardType = Convert.ToInt32(IncentiveRule.Tables[0].Rows[0]["SetoffRegAwardType"].ToString()); //激励类型 setoffToolsRD.SetoffRegPrize = IncentiveRule.Tables[0].Rows[0]["SetoffRegPrize"].ToString(); //激励值 setoffToolsRD.SetoffOrderPer = Convert.ToDecimal(IncentiveRule.Tables[0].Rows[0]["SetoffOrderPer"].ToString()); //订单成交提成比例 } return(setoffToolsRD); }
/// <summary> /// 获取商品信息 /// </summary> public string GetItemInfoById() { var itemService = new ItemService(CurrentUserInfo); ItemInfo data = new ItemInfo(); string content = string.Empty; string key = string.Empty; if (Request("item_id") != null && Request("item_id") != string.Empty) { key = Request("item_id").ToString().Trim(); } data = itemService.GetItemInfoById(CurrentUserInfo, key); if (data.ifservice == 0) { data.ItemDeliverySettings = new T_Item_Delivery_MappingBLL(CurrentUserInfo).QueryByEntity(new T_Item_Delivery_MappingEntity() { Item_Id = data.Item_Id }, null); } else if (data.ifservice == 1) { data.VirtualItems = new T_VirtualItemTypeSettingBLL(CurrentUserInfo).QueryByEntity(new T_VirtualItemTypeSettingEntity() { ItemId = data.Item_Id }, null); } //图片信息 //根据实体条件查询实体 var imageService = new ObjectImagesBLL(CurrentUserInfo); var itemObj = imageService.QueryByEntity(new ObjectImagesEntity() { ObjectId = key }, null); if (itemObj != null && itemObj.Length > 0) { //itemObj竟然是个数组,把自动生成的产品二维码给过滤掉,不显示出来 itemObj = itemObj.Where <ObjectImagesEntity>(t => t.Description != "自动生成的产品二维码").ToArray <ObjectImagesEntity>(); data.ItemImageList = itemObj.OrderBy(item => item.DisplayIndex).ToList(); } WQRCodeManagerBLL wQRCodeManagerBLL = new WQRCodeManagerBLL(CurrentUserInfo); var entity = wQRCodeManagerBLL.QueryByEntity(new WQRCodeManagerEntity { ObjectId = key , IsDelete = 0 }, null).FirstOrDefault(); #region 图文|二维码 if (entity != null) { data.imageUrl = entity.ImageUrl; var WKeywordReplyentity = new WKeywordReplyBLL(this.CurrentUserInfo).QueryByEntity(new WKeywordReplyEntity() { Keyword = entity.QRCodeId.ToString() }, null).FirstOrDefault(); if (WKeywordReplyentity != null) { if (WKeywordReplyentity.ReplyType == 1) { data.ReplyType = "1"; data.Text = WKeywordReplyentity.Text; } else if (WKeywordReplyentity.ReplyType == 3) { data.ReplyType = "3"; WMenuMTextMappingBLL bll = new WMenuMTextMappingBLL(this.CurrentUserInfo); WMaterialTextBLL wmbll = new WMaterialTextBLL(this.CurrentUserInfo); OrderBy[] pOrderBys = new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Asc } }; var textMapping = bll.QueryByEntity(new WMenuMTextMappingEntity { MenuId = WKeywordReplyentity.ReplyId, IsDelete = 0 }, pOrderBys); if (textMapping != null && textMapping.Length > 0) { List <WMaterialTextEntity> list = new List <WMaterialTextEntity>(); foreach (var item in textMapping) { WMaterialTextEntity WMaterialTextentity = wmbll.QueryByEntity(new WMaterialTextEntity { TextId = item.TextId, IsDelete = 0 }, null)[0]; list.Add(WMaterialTextentity); } data.listMenutext = list; } } } } #endregion var jsonData = new JsonData(); jsonData.totalCount = data == null ? "0" : "1"; jsonData.data = data; content = jsonData.ToJSON(); return(content); }
protected override SetMaterialTextRD ProcessRequest(APIRequest <SetMaterialTextRP> pRequest) { SetMaterialTextRD rd = new SetMaterialTextRD(); var para = pRequest.Parameters; #region 获取Page信息 var pageBll = new SysPageBLL(CurrentUserInfo); var textBll = new WMaterialTextBLL(CurrentUserInfo); //组织图文实体 var entity = new WMaterialTextEntity() { ApplicationId = para.MaterialText.ApplicationId, CoverImageUrl = para.MaterialText.ImageUrl, PageId = para.MaterialText.PageID, PageParamJson = para.MaterialText.PageParamJson, Text = para.MaterialText.Text, TextId = para.MaterialText.TextId, Title = para.MaterialText.Title, TypeId = para.MaterialText.TypeId, Author = para.MaterialText.Abstract,//摘要使用原来的字段 IsTitlePageImage = para.MaterialText.IsTitlePageImage }; #endregion #region 生成URL var Domain = ConfigurationManager.AppSettings["interfacehost"].Replace("http://", ""); var Domain1 = ConfigurationManager.AppSettings["interfacehost1"].Replace("http://", ""); string URL = string.Empty; switch (para.MaterialText.UnionTypeId) { case "1": //链接 #region 链接 URL = para.MaterialText.OriginalUrl; #endregion break; case "2": //详情 #region 详情 URL = string.Format("http://{0}/Module/WeiXin/MaterialTextDetail.aspx?news_id=#TextId#&customerId=#cutomerId#&interfacehost={1}", Domain1.Trim('/'), ConfigurationManager.AppSettings["interfacehost1"]); #endregion break; case "3": //系统模块 #region 系统模块 var pages = pageBll.GetPageByID(para.MaterialText.PageID); //通过pageid查找syspage信息 if (pages.Length == 0) { throw new APIException("未找到Page:" + para.MaterialText.PageID) { ErrorCode = 341 } } ; SysPageEntity CurrentPage; string path = string.Empty; //要替换的路径 string urlTemplate = pages[0].URLTemplate; //模板URL string json = pages[0].JsonValue; // JSON体 var jsonDic = json.DeserializeJSONTo <Dictionary <string, object> >(); //转换后的字典 var htmls = jsonDic["htmls"].ToJSON().DeserializeJSONTo <Dictionary <string, object>[]>().ToList(); //所有的Html模板 Dictionary <string, object> html = null; //选择的html信息 var defaultHtmlId = jsonDic["defaultHtml"].ToString(); html = htmls.Find(t => t["id"].ToString() == defaultHtmlId); //默认的htmlid***** if (html != null) { path = html["path"].ToString(); } //判断高级oauth认证 var scope = "snsapi_base"; if (jsonDic.ContainsKey("scope")) { scope = (jsonDic["scope"] == null || jsonDic["scope"] == "") ? "snsapi_base" : "snsapi_userinfo"; } //判断是否有定制,没有则取JSON体中的默认 //找出订制内容 var customerPages = pages.ToList().FindAll(t => t.CustomerID == CurrentUserInfo.ClientID); if (customerPages.Count > 0) { //看是否有htmls的定制(Node值=2) CurrentPage = customerPages.Find(t => t.Node == "2"); if (CurrentPage != null) { var nodeValue = CurrentPage.NodeValue; //在Json解析后的集合中找到path html = htmls.Find(t => t["id"].ToString() == nodeValue); if (html != null) { path = html["path"].ToString(); } } else { CurrentPage = pages[0]; } } else { CurrentPage = pages[0]; } //读取配置信息域名,检查不用http://开头,如果有则去除 var IsAuth = false; //TODO:判断页面是否需要Auth认证,如果页面需要证则再判断这个客户有没有Auth认证,Type=3 if (CurrentPage.IsAuth == 1) { //判断这个客户是否是认证客户,type=3 var applicationBll = new WApplicationInterfaceBLL(CurrentUserInfo); var application = applicationBll.GetByID(para.MaterialText.ApplicationId); if (application.WeiXinTypeId == "3") { IsAuth = true; } } //替换URL模板 #region 替换URL模板 urlTemplate = urlTemplate.Replace("_pageName_", path); var paraDic = para.MaterialText.PageParamJson.DeserializeJSONTo <Dictionary <string, object>[]>(); foreach (var item in paraDic) //这里key和value对于活动来说,其实就是活动的eventId,和eventId的值 { if (item.ContainsKey("key") && item.ContainsKey("value")) { urlTemplate = urlTemplate.Replace("{" + item["key"] + "}", item["value"].ToString()); } } #endregion //根据规则组织URL #region 组织URL //读取配置文件中的域名 if (string.IsNullOrEmpty(Domain)) { throw new APIException("微信管理:未配置域名,请在web.config中添加<add key='host' value=''/>") { ErrorCode = 342 } } ; if (IsAuth) { //需要认证,并加上scope类型 URL = string.Format("http://{0}/WXOAuth/AuthUniversal.aspx?customerId={1}&applicationId={2}&goUrl={3}&scope={4}", Domain.Trim('/'), CurrentUserInfo.ClientID, para.MaterialText.ApplicationId, HttpUtility.UrlEncode(string.Format("{0}{1}", Domain.Trim('/'), urlTemplate)), scope); } else { //不需要认证 URL = string.Format("http://{0}/WXOAuth/NoAuthGoto.aspx?customerId={1}&goUrl={2}", Domain.Trim('/'), CurrentUserInfo.ClientID, HttpUtility.UrlEncode(string.Format("{0}{1}", Domain.Trim('/'), urlTemplate.Trim('/')))); } entity.IsAuth = Convert.ToInt32(IsAuth); entity.PageParamJson = para.MaterialText.PageParamJson; #endregion #endregion break; default: break; } entity.OriginalUrl = URL;//图文素材 #endregion #region 保存 var unionMappingBll = new WModelTextMappingBLL(CurrentUserInfo); //检查图文素材是否重复 if (textBll.CheckName(entity.ApplicationId, entity.Title, entity.TextId)) { throw new APIException("标题重复,请重新输入.") { ErrorCode = ERROR_CODES.INVALID_REQUEST }; } if (string.IsNullOrEmpty(entity.TextId)) { entity.TextId = Guid.NewGuid().ToString("N"); #region 图文详情要对占位符#TextId#和#customerId#进行替换 entity.OriginalUrl = entity.OriginalUrl.Replace("#TextId#", entity.TextId).Replace("#cutomerId#", CurrentUserInfo.ClientID); #endregion textBll.Create(entity); var mapping = new WModelTextMappingEntity() { MappingId = Guid.NewGuid().ToString("N"), ModelId = entity.TypeId, TextId = entity.TextId, }; unionMappingBll.Create(mapping); } else { #region 图文详情要对占位符#textId和#customerId进行替换 entity.OriginalUrl = entity.OriginalUrl.Replace("#TextId#", entity.TextId).Replace("#cutomerId#", CurrentUserInfo.ClientID); #endregion textBll.Update(entity); } #region 图文分类和图文Mapping关系,先删除再增加 var modelMappingBll = new WModelTextMappingBLL(CurrentUserInfo); modelMappingBll.DeleteByTextId(entity.TextId); var modelMapping = new WModelTextMappingEntity() { MappingId = Guid.NewGuid().ToString("N"), ModelId = entity.TypeId, //模板的标识竟然是和图文类型的标识 TextId = entity.TextId }; modelMappingBll.Create(modelMapping); #endregion #endregion rd.MaterialTextId = entity.TextId; return(rd); }