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; } }
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 }
protected override SaveDefaultKeyWordRD ProcessRequest(DTO.Base.APIRequest <SaveDefaultKeyWordRP> pRequest) { var rd = new SaveDefaultKeyWordRD(); var keywordList = pRequest.Parameters.KeyWordList; if (string.IsNullOrEmpty(keywordList.ApplicationId)) { throw new APIException("微信公众号不能为空") { ErrorCode = 124 }; } if (keywordList.BeLinkedType == 0) { throw new APIException("关联类型不能为空") { ErrorCode = 125 }; } if (keywordList.ReplyType == 0) { throw new APIException("回复类型不能为空") { ErrorCode = 126 }; } var bll = new WKeywordReplyBLL(CurrentUserInfo); var entity = new WKeywordReplyEntity//实体对象数据,含有文本信息 { ApplicationId = keywordList.ApplicationId, Keyword = keywordList.KeyWord, ReplyType = keywordList.ReplyType, Text = keywordList.Text }; if (keywordList.ReplyType == 1) { if (string.IsNullOrEmpty(keywordList.Text) || keywordList.Text == "") { //内容为空相当于关闭自动回复 - bob 2014-08-11**** //throw new APIException("文本不能为空") { ErrorCode = 120 }; entity.ReplyId = keywordList.ReplyId; bll.Delete(entity); } if (Encoding.Default.GetBytes(keywordList.Text).Length > 2048) { throw new APIException("文本超过了最大限制(2M)") { ErrorCode = 121 }; } } if (keywordList.ReplyType == 3) { if (keywordList.MaterialTextIds == null || keywordList.MaterialTextIds.Any() == false) { throw new APIException("图文消息不能为空") { ErrorCode = 124 }; } if (keywordList.MaterialTextIds.Any() == true && keywordList.MaterialTextIds.Length > 10) { throw new APIException("图文消息最大不能超过10条数据") { ErrorCode = 125 }; } } if (string.IsNullOrEmpty(keywordList.ReplyId)) { //var keywordEntity = bll.QueryByEntity(new WKeywordReplyEntity() //{ // ApplicationId = keywordList.ApplicationId //}, null); //if (keywordEntity != null && keywordEntity.Length > 0) //{ // bll.Delete(keywordEntity); //} var replyId = Utils.NewGuid();//新建 entity.ReplyId = replyId; bll.Create(entity); rd.ReplyId = replyId; } else { entity.ReplyId = keywordList.ReplyId;//修改 bll.Update(entity); rd.ReplyId = keywordList.ReplyId; } bll.UpdateWkeywordReplyByReplyId(rd.ReplyId, keywordList.BeLinkedType, keywordList.KeywordType, -1); if (keywordList.ReplyType == 3) { var mappingBll = new WMenuMTextMappingBLL(CurrentUserInfo); var mappingEntity = mappingBll.QueryByEntity(new WMenuMTextMappingEntity() { MenuId = rd.ReplyId }, null); if (mappingEntity.Length > 0) { mappingBll.Delete(mappingEntity);//每一次都先删除,然后再添加 } var textMappingEntity = new WMenuMTextMappingEntity(); foreach (var materialTextIdInfo in keywordList.MaterialTextIds) { textMappingEntity.MappingId = Guid.NewGuid(); textMappingEntity.MenuId = rd.ReplyId; textMappingEntity.DisplayIndex = materialTextIdInfo.DisplayIndex; textMappingEntity.TextId = materialTextIdInfo.TestId; textMappingEntity.CustomerId = CurrentUserInfo.ClientID; mappingBll.Create(textMappingEntity); } } return(rd); }
/// <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 SetKeyWordRD ProcessRequest(DTO.Base.APIRequest <SetKeyWordRP> pRequest) { var rd = new SetKeyWordRD(); var keywordList = pRequest.Parameters.KeyWordList; if (keywordList.DisplayIndex == 0) { throw new APIException("序号不能为空或为零") { ErrorCode = 122 }; } if (string.IsNullOrEmpty(keywordList.KeyWord)) { throw new APIException("关键字不能为空") { ErrorCode = 123 }; } if (string.IsNullOrEmpty(keywordList.ApplicationId)) { throw new APIException("微信公众号不能为空") { ErrorCode = 124 }; } if (keywordList.BeLinkedType == 0) { throw new APIException("关联类型不能为空") { ErrorCode = 125 }; } if (keywordList.ReplyType == 0) { throw new APIException("回复类型不能为空") { ErrorCode = 126 }; } var bll = new WKeywordReplyBLL(CurrentUserInfo); #region 关键字不能重复 WKeywordReplyEntity wKeywordReplyEntity = new WKeywordReplyEntity() { Keyword = keywordList.KeyWord, ApplicationId = keywordList.ApplicationId }; var queryByEntityArray = bll.QueryByEntity(wKeywordReplyEntity, null); if (string.IsNullOrEmpty(keywordList.ReplyId)) { if (queryByEntityArray.Length != 0) { throw new APIException("关键字不能重复") { ErrorCode = 127 }; } } else { if (queryByEntityArray.Length != 0 && queryByEntityArray[0].ReplyId != keywordList.ReplyId) { throw new APIException("关键字不能重复") { ErrorCode = 127 }; } } #endregion var entity = new WKeywordReplyEntity { ApplicationId = keywordList.ApplicationId, Keyword = keywordList.KeyWord, ReplyType = keywordList.ReplyType, Text = keywordList.Text }; if (keywordList.ReplyType == 1) { if (string.IsNullOrEmpty(keywordList.Text) || keywordList.Text == "") { throw new APIException("文本不能为空") { ErrorCode = 120 }; } if (Encoding.Default.GetBytes(keywordList.Text).Length > 2048) { throw new APIException("文本超过了最大限制(2M)") { ErrorCode = 121 }; } } if (keywordList.ReplyType == 3) { if (keywordList.MaterialTextIds == null || keywordList.MaterialTextIds.Any() == false) { throw new APIException("图文消息不能为空") { ErrorCode = 124 }; } if (keywordList.MaterialTextIds.Any() == true && keywordList.MaterialTextIds.Length > 10) { throw new APIException("图文消息最大不能超过10条数据") { ErrorCode = 125 }; } } if (string.IsNullOrEmpty(keywordList.ReplyId)) { var replyId = Utils.NewGuid(); entity.ReplyId = replyId; bll.Create(entity); rd.ReplyId = replyId; } else { entity.ReplyId = keywordList.ReplyId; bll.Update(entity); rd.ReplyId = keywordList.ReplyId; } bll.UpdateWkeywordReplyByReplyId(rd.ReplyId, keywordList.BeLinkedType, keywordList.KeywordType, keywordList.DisplayIndex); if (keywordList.ReplyType == 3) { var mappingBll = new WMenuMTextMappingBLL(CurrentUserInfo); var mappingEntity = mappingBll.QueryByEntity(new WMenuMTextMappingEntity() { MenuId = rd.ReplyId }, null); if (mappingEntity.Length > 0) { mappingBll.Delete(mappingEntity); } var textMappingEntity = new WMenuMTextMappingEntity(); foreach (var materialTextIdInfo in keywordList.MaterialTextIds) { textMappingEntity.MappingId = Guid.NewGuid(); textMappingEntity.MenuId = rd.ReplyId; textMappingEntity.DisplayIndex = materialTextIdInfo.DisplayIndex; textMappingEntity.TextId = materialTextIdInfo.TestId; textMappingEntity.CustomerId = CurrentUserInfo.ClientID; mappingBll.Create(textMappingEntity); } } return(rd); }
protected override SetMenuRD ProcessRequest(DTO.Base.APIRequest <SetMenuRP> pRequest) { var rd = new SetMenuRD(); string menuId = pRequest.Parameters.MenuId; string name = pRequest.Parameters.Name; string parentId = pRequest.Parameters.ParentId; string displayIndex = pRequest.Parameters.DisplayColumn; int status = pRequest.Parameters.Status; string applicationId = pRequest.Parameters.ApplicationId;//某个公众号在数据库里的标识 string text = pRequest.Parameters.Text; string menuUrl = pRequest.Parameters.MenuUrl; string imageUrl = pRequest.Parameters.ImageUrl; string messageType = pRequest.Parameters.MessageType; int unionTypeId = pRequest.Parameters.UnionTypeId; Guid? pageId = pRequest.Parameters.PageId; string pageParamJson = pRequest.Parameters.PageParamJson; var materialTextIds = pRequest.Parameters.MaterialTextIds; string pageUrlJson = pRequest.Parameters.PageUrlJson; int level = pRequest.Parameters.Level; string type = ""; var bll = new WMenuBLL(this.CurrentUserInfo); #region 一级节点 节点名称长度不能超过3个汉字,二级节点 不能超过7个汉字 #endregion #region type = view时,菜单链接MenuUrl不能为空 #endregion #region 图文消息只能增加10条 if (unionTypeId == 1 || unionTypeId == 3) { type = "view"; if (unionTypeId == 1 && (string.IsNullOrEmpty(menuUrl) || menuUrl == "")) { throw new APIException("菜单链接不能为空") { ErrorCode = 123 }; } if (unionTypeId == 1 && (menuUrl.Length > 500)) { throw new APIException("菜单链接地址超长,请重新填写") { ErrorCode = 140 }; } } else if (unionTypeId == 2) { type = "click"; if (messageType == "3") { if (materialTextIds == null || materialTextIds.Any() == false) { throw new APIException("图文消息不能为空") { ErrorCode = 124 }; } if (materialTextIds.Any() == true && materialTextIds.Length > 10) { throw new APIException("图文消息最大不能超过10条数据") { ErrorCode = 125 }; } } if (messageType == "1") { if (text == "" || string.IsNullOrEmpty(text)) { throw new APIException("文本不能为空") { ErrorCode = 126 }; } if (Encoding.Default.GetBytes(text).Length > 2048) { throw new APIException("文本超过了最大限制(2M)") { ErrorCode = 127 }; } } if (messageType == "2") { if (imageUrl == "" || string.IsNullOrEmpty(imageUrl)) { throw new APIException("图片不能为空") { ErrorCode = 128 }; } } } #endregion #region 确保每个一级节点下面不能超过五个状态已启用的二级菜单 if (level == 2) { int count = bll.GetLevel2CountByMenuId(parentId, applicationId, this.CurrentUserInfo.ClientID); if (count >= 5 && status == 1 && (menuId == "" || string.IsNullOrEmpty(menuId))) { throw new APIException("二级节点的数量最大为5条启用的菜单") { ErrorCode = 120 }; } if (!string.IsNullOrEmpty(menuId) && count >= 5) { var ds = bll.GetMenuDetail(menuId); if (ds.Tables[0].Rows.Count > 0) { var oldStatus = Convert.ToInt32(ds.Tables[0].Rows[0]["Status"]); if (oldStatus == 0 && status == 1) //如果已经目前已经有五个已经启用了,这个之前是没启用的,现在启用了 { throw new APIException("二级节点的数量最大为5条启用的菜单") { ErrorCode = 130 }; } } } //取没被删除的,id int countDisplayCoulumn = bll.GetLevel2CountByDisplayColumn(parentId, menuId, int.Parse(displayIndex), applicationId, this.CurrentUserInfo.ClientID); if (countDisplayCoulumn > 0) { throw new APIException("同一个一级菜单下的二级菜单,序号不能相同") { ErrorCode = 130 }; } if (Encoding.Default.GetBytes(name).Length > 16) { throw new APIException("二级节点的名称最多不能超过8个汉字") { ErrorCode = 121 }; } //判断一级菜单的类型 如果一级菜单的类型为View改为Click var menuEntity = bll.QueryByEntity(new WMenuEntity() { ID = parentId }, null).FirstOrDefault(); if (menuEntity != null) { if (menuEntity.Type == "view") { menuEntity.Type = "click"; bll.Update(menuEntity); } } } else if (level == 1) { //判断是否有二级菜单 var b = bll.CheckExistLevel2Menu(menuId); //有,type=Click if (b) { type = "click"; } //没有根据当前选择的点击关联到来判断Click或View else { if (unionTypeId == 1 || unionTypeId == 3) { type = "view"; } else if (unionTypeId == 2) { type = "click"; } } if (Encoding.Default.GetBytes(name).Length > 12) { throw new APIException("一级节点的名称最多不能超过6个汉字") { ErrorCode = 122 }; } } else { throw new APIException("菜单级别参数错误【Level】") { ErrorCode = 131 }; } #endregion var wappBll = new WApplicationInterfaceBLL(CurrentUserInfo); string weixinId = ""; var wappEntity = wappBll.QueryByEntity(new WApplicationInterfaceEntity() { CustomerId = CurrentUserInfo.ClientID, ApplicationId = applicationId }, null); if (wappEntity.Length > 0) { weixinId = wappEntity[0].WeiXinID; } if (unionTypeId == 3) { var sysPageBll = new SysPageBLL(CurrentUserInfo); var pages = sysPageBll.GetPageByID(pageId); if (pages.Length > 0) { var page = pages.FirstOrDefault(); if (page != null) { //获取生成的URL menuUrl = page.GetUrl(pageParamJson, CurrentUserInfo.ClientID, applicationId, weixinId); } else { throw new APIException("缺少页面参数配置") { ErrorCode = 141 }; } } } //上传图文素材 //获取access_token/ /** * var commonService = new CommonBLL(); * var appService = new WApplicationInterfaceBLL(CurrentUserInfo); * var appEntity = appService.GetByID(applicationId);// * //var accessToken = commonService.GetAccessTokenByCache(appEntity.AppID, appEntity.AppSecret, CurrentUserInfo); * //UploadMediaEntity media = commonService.UploadMediaFileFOREVER(accessToken.access_token, imageUrl, MediaType.Image); * string filePath = commonService.DownloadFile(imageUrl); ***/ var wMaterialImageBll = new WMaterialImageBLL(CurrentUserInfo); var wMaterialImageEntity = new WMaterialImageEntity(); var imageId = Utils.NewGuid(); wMaterialImageEntity.ApplicationId = applicationId; wMaterialImageEntity.ImageUrl = imageUrl; wMaterialImageEntity.ImageId = imageId; // wMaterialImageEntity.ImageName = filePath;//存物理路径,用于在微信端发送图片 wMaterialImageBll.Create(wMaterialImageEntity); var entity = new WMenuEntity(); WMenuEntity[] wMenuEntityArrayByName; if (level == 1) { var wMenuEntityArraybyIndex = bll.QueryByEntity(new WMenuEntity() { DisplayColumn = displayIndex, WeiXinID = weixinId, Level = "1" }, null); if (wMenuEntityArraybyIndex.Length != 0 && wMenuEntityArraybyIndex[0].ID != menuId) { throw new APIException("一级菜单序号不可重复") { ErrorCode = 143 }; } wMenuEntityArrayByName = bll.QueryByEntity(new WMenuEntity() { Name = name, WeiXinID = weixinId, Level = "1" }, null); if (string.IsNullOrEmpty(menuId) || menuId == "") { if (wMenuEntityArrayByName.Length != 0) { throw new APIException("菜单名称不可重复") { ErrorCode = 142 }; } } else if (wMenuEntityArrayByName.Length != 0 && wMenuEntityArrayByName[0].ID != menuId) { throw new APIException("菜单名称不可重复") { ErrorCode = 142 }; } } if (level == 2) { wMenuEntityArrayByName = bll.QueryByEntity(new WMenuEntity() { Name = name, WeiXinID = weixinId, Level = "2" }, null); if (string.IsNullOrEmpty(menuId) || menuId == "") { if (wMenuEntityArrayByName.Length != 0) { throw new APIException("菜单名称不可重复") { ErrorCode = 142 }; } } else if (wMenuEntityArrayByName.Length != 0 && wMenuEntityArrayByName[0].ID != menuId) { throw new APIException("菜单名称不可重复") { ErrorCode = 142 }; } } if (string.IsNullOrEmpty(menuId) || menuId == "") { var newMenuId = Utils.NewGuid().ToString(); entity.ID = newMenuId; entity.Name = name; entity.ParentId = parentId; entity.DisplayColumn = displayIndex; entity.ImageId = imageId; //和图片做了关联 entity.Status = status; entity.Level = level.ToString(); entity.MenuURL = menuUrl; entity.Key = Utils.NewGuid().Substring(0, 7); entity.WeiXinID = weixinId; entity.Type = type; entity.PageId = pageId; entity.BeLinkedType = unionTypeId; entity.MaterialTypeId = messageType; entity.Text = text; bll.Create(entity); rd.MenuId = newMenuId; } else { if (unionTypeId == 2) { menuUrl = null; } entity.ID = menuId; entity.Name = name; entity.ParentId = parentId; entity.DisplayColumn = displayIndex; entity.ImageId = imageId; entity.Status = status; entity.MaterialTypeId = messageType; entity.MenuURL = menuUrl; entity.Key = Utils.NewGuid().Substring(0, 7); entity.Level = level.ToString(); entity.WeiXinID = weixinId; entity.Type = type; entity.PageId = pageId; entity.Text = text; entity.BeLinkedType = unionTypeId; bll.Update(entity); rd.MenuId = menuId; } bll.UpdateMenuData(rd.MenuId, status, pageId, pageParamJson, pageUrlJson, unionTypeId); #region unionTypeId 为回复消息的时候,素材类型必须有值,MenuUrl必须为空,反之 清空表中的所有素材类型,MuneUrl必须有值 var mappingBll = new WMenuMTextMappingBLL(CurrentUserInfo); var mappingEntity = mappingBll.QueryByEntity(new WMenuMTextMappingEntity() { MenuId = rd.MenuId }, null); if (mappingEntity.Length > 0) { mappingBll.Delete(mappingEntity); } if (unionTypeId == 2) { if (messageType == "3") { var textMappingEntity = new WMenuMTextMappingEntity(); foreach (var materialTextIdInfo in materialTextIds) { textMappingEntity.MappingId = Guid.NewGuid(); textMappingEntity.MenuId = rd.MenuId; textMappingEntity.DisplayIndex = materialTextIdInfo.DisplayIndex; textMappingEntity.TextId = materialTextIdInfo.TestId; textMappingEntity.CustomerId = CurrentUserInfo.ClientID; mappingBll.Create(textMappingEntity); } } } #endregion return(rd); }
/// <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); }