protected override DeleteMenuRD ProcessRequest(DTO.Base.APIRequest <DeleteMenuRP> pRequest) { var rd = new DeleteMenuRD(); var menuId = pRequest.Parameters.MenuId; var bll = new WMenuBLL(CurrentUserInfo); var entity = bll.QueryByEntity(new WMenuEntity() { ID = menuId }, null); var level = entity[0].Level; if (level == "1") { throw new APIException("一级菜单不能删除") { ErrorCode = ErrorFirstLevelNotDelete }; } if (entity.Length > 0) { bll.Delete(entity); } else { throw new APIException("MenuId无效") { ErrorCode = ErrorMenuIdInavial }; } return(rd); }
/// <summary> /// 获取子节点数据 /// </summary> /// <param name="pParentNodeID">父节点ID</param> /// <returns></returns> protected override TreeNodes GetNodes(string pParentNodeID) { TreeNodes nodes = new TreeNodes(); var service = new WMenuBLL(new SessionManager().CurrentUserLoginInfo); IList <WMenuEntity> data = new List <WMenuEntity>(); string content = string.Empty; string key = string.Empty; if (Request("node") != null && Request("node") != string.Empty) { key = Request("node").ToString().Trim(); } if (key == "root") { key = ""; } //if (key.Length == 2) //{ // data = service.GetCityListByProvince(key); //} //else if (key.Length == 4) //{ // data = service.GetAreaListByCity(key); //} //else if (key.Length == 0) //{ // data = service.GetProvinceList(); //} var queryEntity = new WMenuEntity(); queryEntity.ParentId = key; queryEntity.ApplicationId = Request("ApplicationId"); data = service.GetWebWMenu(queryEntity, 0, 1000); var jsonData = new JsonData(); jsonData.totalCount = data.Count.ToString(); jsonData.data = data; var parentCode = string.Empty; foreach (var item in data) { nodes.Add(item.ID, item.Name, item.ParentId, item.Level == "3" ? true : false); } // //var root = new TreeNodes(); //root.Add(new TreeNode() { ID = "1", IsLeaf = false, Text = "1" }); //root.Add(new TreeNode() { ID = "1_1", ParentID = "1", IsLeaf = false, Text = "1_1" }); //root.Add(new TreeNode() { ID = "1_1_1", ParentID = "1_1", IsLeaf = false, Text = "1_1_1`" }); return(nodes); }
/// <summary> /// 取消授权 /// </summary> /// <param name="appid"></param> /// <param name="clientid"></param> /// <returns></returns> public static bool UnauthWechatApp(string appid) { var clientId = "eb17cc2569c74ab7888b1f403972d37d";//测试用 var loggingSessionInfo = Default.GetBSLoggingSession(clientId, "open"); var waiBll = new WApplicationInterfaceBLL(loggingSessionInfo); var wmenuBll = new WMenuBLL(loggingSessionInfo); var userInfo = loggingSessionInfo; userInfo.CurrentLoggingManager.Connection_String = WebConfigurationManager.AppSettings["APConn"]; var customerWxMappingBll = new TCustomerWeiXinMappingBLL(userInfo); var customerId = customerWxMappingBll.GetCustomerIdByAppId(appid); var waiEntitys = new WApplicationInterfaceEntity[] { }; var waiEntity = new WApplicationInterfaceEntity(); var component_Appid = WebConfigurationManager.AppSettings["Component_Appid"]; waiEntitys = waiBll.QueryByEntity(new WApplicationInterfaceEntity { AppID = appid, OpenOAuthAppid = component_Appid, CustomerId = customerId, IsDelete = 0 }, null); if (waiEntitys != null && waiEntitys.Length > 0) { waiEntity = waiEntitys.FirstOrDefault(); //waiEntity.OpenOAuthAppid = null;//置空 //waiBll.Update(waiEntity); waiBll.Delete(waiEntity); //查询参数 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; complexCondition.Add(new EqualsCondition() { FieldName = "WeiXinID", Value = waiEntity.WeiXinID }); var tempList = wmenuBll.PagedQuery(complexCondition.ToArray(), null, 10, 1); if (tempList.Entities.Length > 0) { foreach (var item in tempList.Entities) { wmenuBll.Delete(item); } } //var wmenuEntitys = wmenuBll.QueryByEntity(new WMenuEntity { WeiXinID = waiEntity.WeiXinID }, null); //if (wmenuEntitys != null && wmenuEntitys.Length > 0) //{ // foreach (var item in wmenuEntitys) // { // wmenuBll.Delete(item); // } //} } return(true); }
protected override GetMenuDetailRD ProcessRequest(DTO.Base.APIRequest <GetMenuDetailRP> pRequest) { var rd = new GetMenuDetailRD(); string menuId = pRequest.Parameters.MenuId; var bll = new WMenuBLL(this.CurrentUserInfo); var ds = bll.GetMenuDetail(menuId); var textDs = bll.GetMenuTextIdListByMenuId(CurrentUserInfo.ClientID, menuId); var temp = ds.Tables[0].AsEnumerable().Select(t => new MenuDetailInfo() { MenuId = t["ID"].ToString(), PageUrlJson = t["PageUrlJson"].ToString(), WeiXinId = t["WeiXinID"].ToString(), Name = t["Name"].ToString(), DisplayColumn = Convert.ToInt32(t["DisplayColumn"]), Text = t["Text"].ToString(), MenuUrl = t["MenuUrl"].ToString(), Level = Convert.ToInt32(t["Level"]), MessageType = t["materialTypeId"].ToString(), PageId = string.IsNullOrEmpty(t["PageId"].ToString()) == true ? "" : t["PageId"].ToString(), ImageUrl = t["imageUrl"].ToString(), PageParamJson = t["PageParamJson"].ToString(), ParentId = t["ParentId"].ToString(), Status = Convert.ToInt32(t["Status"]), UnionTypeId = Convert.ToInt32(t["BeLinkedType"]), ImageId = t["ImageId"].ToString(), MaterialTextIds = textDs.Tables[0].AsEnumerable() .Where(tt => tt["MenuId"].ToString() == t["ID"].ToString()) .OrderBy(tt => tt["DisplayIndex"].ToString()) .Select(tt => new MaterialTextIdInfo { TestId = string.IsNullOrEmpty(tt["TextId"].ToString()) ? "" : tt["TextId"].ToString(), DisplayIndex = string.IsNullOrEmpty(tt["DisplayIndex"].ToString()) ? 0 : Convert.ToInt32(tt["DisplayIndex"]), ImageUrl = string.IsNullOrEmpty(tt["CoverImageUrl"].ToString()) ? "" : tt["CoverImageUrl"].ToString(), Title = string.IsNullOrEmpty(tt["Title"].ToString()) ? "" : tt["Title"].ToString(), Author = string.IsNullOrEmpty(tt["Author"].ToString()) ? "" : tt["Author"].ToString(), Text = string.IsNullOrEmpty(tt["Text"].ToString()) ? "" : tt["Text"].ToString(), OriginalUrl = string.IsNullOrEmpty(tt["OriginalUrl"].ToString()) ? "" : tt["OriginalUrl"].ToString() }).DefaultIfEmpty().ToArray() }); rd.MenuList = temp.ToArray(); return(rd); }
/// <summary> /// 超级分销 App 登录 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> protected override GetLoginInfoRD ProcessRequest(DTO.Base.APIRequest <GetLoginInfoRP> pRequest) { string customerCode = pRequest.Parameters.SuperRetailTraderCode; string phone = pRequest.Parameters.AccountName; string password = pRequest.Parameters.PassWord; if (string.IsNullOrEmpty(customerCode)) { throw new APIException("客户代码不能为空") { ErrorCode = Error_CustomerCode_NotNull }; } WMenuBLL menuServer = new WMenuBLL(Default.GetAPLoggingSession("")); string customerId = menuServer.GetCustomerIDByCustomerCode(customerCode); if (string.IsNullOrEmpty(customerId)) { throw new APIException("客户代码对应的客户不存在") { ErrorCode = Error_CustomerCode_NotExist }; } var currentUserInfo = Default.GetBSLoggingSession(customerId, "1"); #region 判断分销商是否存在 T_SuperRetailTraderBLL bll = new T_SuperRetailTraderBLL(currentUserInfo); List <T_SuperRetailTraderEntity> _model = bll.QueryByEntity(new T_SuperRetailTraderEntity() { SuperRetailTraderLogin = pRequest.Parameters.AccountName, SuperRetailTraderPass = pRequest.Parameters.PassWord, CustomerId = currentUserInfo.ClientID }, null).ToList(); if (_model == null || _model.Count == 0) { throw new APIException("账号或密码不正确!") { ErrorCode = 135 }; } var result = _model[0]; #endregion #region 获取分销商信息 var rd = new GetLoginInfoRD(); rd.JoinTime = result.JoinTime; rd.SuperRetailTraderAddress = result.SuperRetailTraderAddress; rd.SuperRetailTraderFrom = result.SuperRetailTraderFrom; rd.SuperRetailTraderMan = result.SuperRetailTraderMan; rd.SuperRetailTraderName = result.SuperRetailTraderName; rd.SuperRetailTraderPhone = result.SuperRetailTraderPhone; rd.CustomerId = currentUserInfo.ClientID; rd.UserId = result.SuperRetailTraderID.ToString(); if (result.Status == "00") //未统一协议 { rd.Status = 0; } else if (result.Status == "10") { rd.Status = 1; } #endregion return(rd); }
/// <summary> /// 客户登录 /// </summary> public string SetSignIn() { string content = string.Empty; var respData = new SetSignInRespData(); try { string reqContent = Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <SetSignInReqData>(); Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetSignIn: {0}", reqContent) }); #region 判断参数是否传递 if (string.IsNullOrEmpty(reqObj.special.customerCode)) { respData.code = "103"; respData.description = "customerCode不能为空"; return(respData.ToJSON()); } if (string.IsNullOrEmpty(reqObj.special.phone)) { respData.code = "103"; respData.description = "phone不能为空"; return(respData.ToJSON()); } if (string.IsNullOrEmpty(reqObj.special.password)) { respData.code = "103"; respData.description = "password不能为空"; return(respData.ToJSON()); } #endregion WMenuBLL menuServer = new WMenuBLL(Default.GetAPLoggingSession("")); customerId = menuServer.GetCustomerIDByCustomerCode(reqObj.special.customerCode); if (string.IsNullOrEmpty(customerId)) { respData.code = "103"; respData.description = "customerCode对应的客户不存在"; return(respData.ToJSON()); } var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); var ds = new VipBLL(loggingSessionInfo).SetSignIn(reqObj.special.phone, reqObj.special.password, customerId); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { respData.content = new SetSignInRespContentData(); respData.content.customerId = customerId; respData.content.userId = ds.Tables[0].Rows[0]["user_id"].ToString(); } else { respData.code = "103"; respData.description = "用户名或密码错误"; return(respData.ToJSON()); } } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
protected override SetSignInRD ProcessRequest(DTO.Base.APIRequest <SetSignInRP> pRequest) { SetSignInRD rd = new SetSignInRD(); string customerCode = pRequest.Parameters.CustomerCode; string phone = pRequest.Parameters.LoginName; string password = pRequest.Parameters.Password; if (string.IsNullOrEmpty(customerCode)) { throw new APIException("客户代码不能为空") { ErrorCode = Error_CustomerCode_NotNull }; } WMenuBLL menuServer = new WMenuBLL(Default.GetAPLoggingSession("")); string customerId = menuServer.GetCustomerIDByCustomerCode(customerCode); if (string.IsNullOrEmpty(customerId)) { throw new APIException("客户代码对应的客户不存在") { ErrorCode = Error_CustomerCode_NotExist }; } var currentUserInfo = Default.GetBSLoggingSession(customerId, "1"); VipBLL vipBll = new VipBLL(currentUserInfo); #region 判断用户是否存在 if (!vipBll.JudgeUserExist(phone, customerId)) { throw new APIException("用户名无效") { ErrorCode = Error_UserName_InValid }; } #endregion #region 判断密码是否正确 if (!vipBll.JudgeUserPasswordExist(phone, customerId, password)) { throw new APIException("登录密码错误") { ErrorCode = Error_Password_InValid }; } #endregion #region 判断是否有登录连锁掌柜App权限 var userRolesDs = vipBll.GetUserRoles(phone, customerId, password); bool flag = false; foreach (DataRow row in userRolesDs.Tables[0].Rows) { if (row["Def_App_Code"].ToString().ToUpper() == "APP") { flag = true; break; } } if (!flag) { throw new APIException("该账号无权登录本系统") { ErrorCode = Error_Password_InValid }; } #endregion #region 判断该客服人员是否有客服或操作订单的权限 //if (!vipBll.JudgeUserRoleExist(phone, customerId, password)) //{ // throw new APIException("该账号无权登录本系统") { ErrorCode = Error_Password_InValid }; //} #endregion #region 获取UserId var ds = vipBll.GetUserIdByUserNameAndPassword(phone, customerId, password); rd.UserId = ds.Tables[0].Rows[0]["user_id"].ToString(); rd.UserName = ds.Tables[0].Rows[0]["user_name"].ToString(); rd.Status = int.Parse(ds.Tables[0].Rows[0]["user_status"].ToString()); rd.CustomerId = customerId; var T_SuperRetailTraderbll = new T_SuperRetailTraderBLL(currentUserInfo); var T_SuperRetailTraderInfo = T_SuperRetailTraderbll.QueryByEntity(new T_SuperRetailTraderEntity() { CustomerId = customerId, SuperRetailTraderFromId = rd.UserId, SuperRetailTraderFrom = "User" }, new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }).FirstOrDefault(); if (T_SuperRetailTraderInfo != null) { rd.SuperRetailTraderID = T_SuperRetailTraderInfo.SuperRetailTraderID.ToString(); } #endregion //如果状态不等于1,就说明已经停用, if (rd.Status != 1) { throw new APIException("该员工已经被停用,请联系管理员") { ErrorCode = Error_Password_InValid }; } #region 获取角色列表 var roleCodeDs = vipBll.GetRoleCodeByUserId(rd.UserId, customerId); var tmp = roleCodeDs.Tables[0].AsEnumerable().Select(t => new RoleCodeInfo() { RoleCode = t["role_code"].ToString() }); #endregion rd.UnitId = vipBll.GetUnitByUserId(rd.UserId);//获取会集店 TUnitBLL tUnitBLL = new TUnitBLL(currentUserInfo); if (!string.IsNullOrEmpty(rd.UnitId)) { rd.UnitName = tUnitBLL.GetByID(rd.UnitId).UnitName; } else { rd.UnitName = ""; } //app登陆用户权限 add by henry 2015-3-26 var roleCodeList = vipBll.GetAppMenuByUserId(rd.UserId); //app登陆用户权限 add by henry 2015-3-26 List <string> lst = new List <string>(); if (roleCodeDs.Tables[0] != null && roleCodeDs.Tables[0].Rows.Count > 0) { foreach (DataRow item in roleCodeDs.Tables[0].Rows) { var menuList = new JIT.CPOS.BS.DataAccess.AppSysService(currentUserInfo).GetRoleMenus(currentUserInfo.ClientID, item["role_id"] + ""); if (menuList != null) { lst.AddRange(menuList.Select(m => m.Menu_Code).Distinct().ToList()); } } } rd.MenuCodeList = new List <Menu>(); foreach (var item in lst.Distinct().ToList()) { rd.MenuCodeList.Add(new Menu() { MenuCode = item }); } //if (roleCodeList != null) //{ // rd.MenuCodeList = DataTableToObject.ConvertToList<Menu>(roleCodeList.Tables[0]); //} rd.RoleCodeList = tmp.ToArray(); rd.CustomerName = currentUserInfo.ClientName; //销售员头像 ObjectImagesBLL _ObjectImagesBLL = new ObjectImagesBLL(currentUserInfo); ObjectImagesEntity en = new ObjectImagesEntity(); en.ObjectId = rd.UserId;//根据获取的用户ID List <ObjectImagesEntity> ImgList = _ObjectImagesBLL.QueryByEntity(en, null).OrderByDescending(p => p.CreateTime).ToList(); if (ImgList != null && ImgList.Count != 0) { // string fileDNS = customerBasicSettingBll.GetSettingValueByCode("FileDNS"); ;//http://182.254.156.57:811 rd.HeadImg = ImgList[0].ImageURL; } #region 获取appLogo //基础数据初始化 CustomerBasicSettingBLL customerBasicSettingBLL = new CustomerBasicSettingBLL(currentUserInfo); List <CustomerBasicCodeInfo> customerBasicCodeList = new List <CustomerBasicCodeInfo>(); //查询条件 CustomerBasicSettingEntity customerBasicSettingEntity = new CustomerBasicSettingEntity() { CustomerID = currentUserInfo.ClientID, SettingCode = "WebLogo" }; //执行查询 List <CustomerBasicSettingEntity> customerBasicSettingEntityList = customerBasicSettingBLL.QueryByEntity(customerBasicSettingEntity, null).ToList(); foreach (var a in customerBasicSettingEntityList) { CustomerBasicCodeInfo customerBasicCodeInfo = new CustomerBasicCodeInfo(); if (a.SettingCode.Equals("WebLogo")) { customerBasicCodeInfo.WebLogo = a.SettingValue.ToString(); } customerBasicCodeList.Add(customerBasicCodeInfo); } rd.CustomerBasicCodeList = customerBasicCodeList; #endregion 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); }
protected override GetMenuListRD ProcessRequest(DTO.Base.APIRequest <GetMenuListRP> pRequest) { var rd = new GetMenuListRD(); string applicationId = pRequest.Parameters.ApplicationId; string customerId = this.CurrentUserInfo.ClientID; var bll = new WMenuBLL(this.CurrentUserInfo); var wappBll = new WApplicationInterfaceBLL(CurrentUserInfo); var wappEntity = wappBll.QueryByEntity(new WApplicationInterfaceEntity() { ApplicationId = applicationId }, null); if (wappEntity.Length == 0 || wappEntity.Any() == false) { throw new APIException("该微信公众号无效") { ErrorCode = 120 }; } var weixinId = wappEntity[0].WeiXinID; var ds = bll.GetMenuList(customerId, applicationId); if (ds.Tables[0].Rows.Count == 0) { rd.MenuList = null; } else { string menuList = ds.Tables[0].AsEnumerable().Aggregate("", (x, j) => { x += string.Format("'{0}',", j["ID"].ToString()); return(x); }).Trim(','); #region 根据菜单ID从图文映射表里面关联到图文表里面数据 // var textDs = bll.GetMenuTextIdList(customerId, weixinId, menuList); #endregion var temp = ds.Tables[0].AsEnumerable() .Where(t => t["level"].ToString() == "1") //先取第一层 .OrderBy(t => t["Status"].ToString()) .OrderBy(t => Convert.ToInt32(t["DisplayColumn"])) .Select(t => new MenuInfo { MenuId = t["ID"].ToString(), WeiXinId = t["WeiXinID"].ToString(), ApplicationId = applicationId, Name = t["Name"].ToString(), DisplayColumn = Convert.ToInt32(t["DisplayColumn"]), Level = Convert.ToInt32(t["Level"]), ParentId = t["ParentId"].ToString(), Status = Convert.ToInt32(t["Status"]), SubMenus = ds.Tables[0].AsEnumerable() .Where( tt => tt["ParentId"].ToString() == t["ID"].ToString() && tt["level"].ToString() == "2") //子菜单里取第二层 .OrderBy(tt => tt["Status"].ToString()) .OrderBy(tt => Convert.ToInt32(tt["DisplayColumn"])) .Select(tt => new MenuChildInfo { MenuId = tt["ID"].ToString(), WeiXinId = tt["WeiXinID"].ToString(), ApplicationId = applicationId, Name = tt["Name"].ToString(), DisplayColumn = Convert.ToInt32(tt["DisplayColumn"]), Level = Convert.ToInt32(tt["Level"]), ParentId = tt["ParentId"].ToString(), Status = Convert.ToInt32(tt["Status"]), }).ToArray() }); rd.MenuList = temp.ToArray(); } return(rd); }
protected override BeSuperRetailTraderRD ProcessRequest(DTO.Base.APIRequest <BeSuperRetailTraderRP> pRequest) { var rd = new BeSuperRetailTraderRD(); var para = pRequest.Parameters; LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID); var vipBll = new VipBLL(loggingSessionInfo); var userBll = new T_UserBLL(loggingSessionInfo); var T_SuperRetailTraderEntityBll = new T_SuperRetailTraderBLL(loggingSessionInfo); var InnerGroupNewsbll = new InnerGroupNewsBLL(loggingSessionInfo);//目前还没有针对单对单通知的站内信 WMenuBLL menuServer = new WMenuBLL(Default.GetAPLoggingSession("")); string customerCode = menuServer.GetCustomerCodeByCustomerID(loggingSessionInfo.CurrentUser.customer_id); if (!string.IsNullOrEmpty(para.BeRYType)) { VipEntity VipInfo = null; //会员实体 T_UserEntity T_UserInfo = null; //员工实体 T_SuperRetailTraderEntity T_SuperRetailTraderInfo = null; //超级分销商实体 T_SuperRetailTraderInfo = T_SuperRetailTraderEntityBll.QueryByEntity(new T_SuperRetailTraderEntity() { CustomerId = loggingSessionInfo.CurrentUser.customer_id, SuperRetailTraderFromId = para.SuperRetailTraderFromId }, null).FirstOrDefault(); //判断是否已成为分销商 if (T_SuperRetailTraderInfo == null) { var SuperRetailTraderEntity = new T_SuperRetailTraderEntity(); //不是分销商 就判断分销商来源类型 if (para.BeRYType == "Vip") { //查询会员信息 VipInfo = vipBll.QueryByEntity(new VipEntity() { ClientID = loggingSessionInfo.CurrentUser.customer_id, VIPID = para.SuperRetailTraderFromId }, null).FirstOrDefault(); if (VipInfo != null) { try { SuperRetailTraderEntity.SuperRetailTraderID = Guid.NewGuid(); SuperRetailTraderEntity.SuperRetailTraderCode = VipInfo.VipCode; SuperRetailTraderEntity.SuperRetailTraderName = VipInfo.VipRealName == null ? VipInfo.VipName : VipInfo.VipRealName; SuperRetailTraderEntity.SuperRetailTraderLogin = VipInfo.Phone; string strSuperPwd = StringUtil.GetRandomStr(6);//生成6位随机数,为超级分销商密码生成使用 SuperRetailTraderEntity.SuperRetailTraderPass = EncryptManager.Hash(strSuperPwd, HashProviderType.MD5); SuperRetailTraderEntity.SuperRetailTraderPassData = strSuperPwd; SuperRetailTraderEntity.SuperRetailTraderMan = VipInfo.VipRealName == null ? VipInfo.VipName : VipInfo.VipRealName; SuperRetailTraderEntity.SuperRetailTraderPhone = VipInfo.Phone; SuperRetailTraderEntity.SuperRetailTraderAddress = "";//目前因为没有填写详细地址的地方,给空值 SuperRetailTraderEntity.SuperRetailTraderFrom = para.BeRYType; SuperRetailTraderEntity.SuperRetailTraderFromId = VipInfo.VIPID; if (!string.IsNullOrEmpty(para.HigheSuperRetailTraderID)) { SuperRetailTraderEntity.HigheSuperRetailTraderID = new Guid(para.HigheSuperRetailTraderID); } if (!string.IsNullOrEmpty(VipInfo.Col20)) { SuperRetailTraderEntity.HigheSuperRetailTraderID = new Guid(VipInfo.Col20); } SuperRetailTraderEntity.JoinTime = System.DateTime.Now; SuperRetailTraderEntity.CreateTime = System.DateTime.Now; SuperRetailTraderEntity.CreateBy = VipInfo.VIPID; SuperRetailTraderEntity.LastUpdateBy = VipInfo.VIPID; SuperRetailTraderEntity.LastUpdateTime = System.DateTime.Now; SuperRetailTraderEntity.IsDelete = 0; SuperRetailTraderEntity.CustomerId = loggingSessionInfo.CurrentUser.customer_id; SuperRetailTraderEntity.Status = "00"; T_SuperRetailTraderEntityBll.Create(SuperRetailTraderEntity); rd.IsSuperRetailTrader = 1; rd.SuperRetailTraderLogin = VipInfo.Phone; rd.SuperRetailTraderPass = strSuperPwd; VipInfo.Col26 = SuperRetailTraderEntity.SuperRetailTraderID.ToString(); vipBll.Update(VipInfo, false); } catch { rd.IsSuperRetailTrader = 0; } } } //不是分销商 就判断分销商来源类型 if (para.BeRYType == "User") { //查询员工信息 T_UserInfo = userBll.QueryByEntity(new T_UserEntity() { customer_id = loggingSessionInfo.CurrentUser.customer_id, user_id = para.SuperRetailTraderFromId }, null).FirstOrDefault(); if (T_UserInfo != null) { try { SuperRetailTraderEntity.SuperRetailTraderID = Guid.NewGuid(); SuperRetailTraderEntity.SuperRetailTraderCode = T_UserInfo.user_code; SuperRetailTraderEntity.SuperRetailTraderName = T_UserInfo.user_name; SuperRetailTraderEntity.SuperRetailTraderLogin = T_UserInfo.user_code; SuperRetailTraderEntity.SuperRetailTraderPass = T_UserInfo.user_password; SuperRetailTraderEntity.SuperRetailTraderMan = T_UserInfo.user_name; SuperRetailTraderEntity.SuperRetailTraderPhone = T_UserInfo.user_telephone != null ? T_UserInfo.user_telephone : T_UserInfo.user_cellphone; SuperRetailTraderEntity.SuperRetailTraderAddress = T_UserInfo.user_address; SuperRetailTraderEntity.SuperRetailTraderFrom = para.BeRYType; SuperRetailTraderEntity.SuperRetailTraderFromId = T_UserInfo.user_id; if (!string.IsNullOrEmpty(para.HigheSuperRetailTraderID)) { SuperRetailTraderEntity.HigheSuperRetailTraderID = new Guid(para.HigheSuperRetailTraderID); } SuperRetailTraderEntity.JoinTime = System.DateTime.Now; SuperRetailTraderEntity.CreateTime = System.DateTime.Now; SuperRetailTraderEntity.CreateBy = T_UserInfo.user_id; SuperRetailTraderEntity.LastUpdateBy = T_UserInfo.user_id; SuperRetailTraderEntity.LastUpdateTime = System.DateTime.Now; SuperRetailTraderEntity.IsDelete = 0; SuperRetailTraderEntity.CustomerId = loggingSessionInfo.CurrentUser.customer_id; SuperRetailTraderEntity.Status = "00"; T_SuperRetailTraderEntityBll.Create(SuperRetailTraderEntity); rd.IsSuperRetailTrader = 1;//成功成为分销商 } catch { rd.IsSuperRetailTrader = 0;//成为分销商失败 } } } //如果成为分销商 则需要增加站内信通知 if (rd.IsSuperRetailTrader == 1) { } } else { rd.IsSuperRetailTrader = 2;//已成为分销商 rd.SuperRetailTraderLogin = T_SuperRetailTraderInfo.SuperRetailTraderLogin; rd.SuperRetailTraderPass = T_SuperRetailTraderInfo.SuperRetailTraderPassData; } } if (!string.IsNullOrEmpty(customerCode)) { rd.CustomerCode = customerCode; } return(rd); }