public JsonResult DoAdd(string channelName, string invitedcode, int status, string adminUserName, string adminUserPassword, string trueName, string channelType = "cps1") { var result = new { state = 1, msg = "渠道 " + channelName + " 增加成功!" }; if (string.IsNullOrEmpty(channelName) || string.IsNullOrEmpty(invitedcode) || string.IsNullOrEmpty(adminUserName) || string.IsNullOrEmpty(adminUserPassword)) { result = new { state = 0, msg = "缺少增加的参数!" }; return(Json(result)); } var ckChannelNameList = ef.hx_Channel.Any(p => p.ChannelName == channelName); if (ckChannelNameList) { result = new { state = 0, msg = "渠道名称已经存在!" }; return(Json(result)); } var ckAdminNameList = ef.hx_Channel_AdminUser.Any(p => p.AdminUserName == adminUserName); if (ckAdminNameList) { result = new { state = 0, msg = "渠道使用者名称已存在!" }; return(Json(result)); } //写入 Channel 与 Channel_AdminUser 表 hx_Channel channelEnitty = new hx_Channel(); channelEnitty.ChannelName = channelName; channelEnitty.Invitedcode = invitedcode; channelEnitty.Status = (byte)status; channelEnitty.Creator = Utils.GetAdmUserID().ToString(); channelEnitty.CreateTime = DateTime.Now; channelEnitty.type = channelType;//渠道类型 channelEnitty.UpdateTime = channelEnitty.CreateTime; hx_Channel_AdminUser cAdminUserEntity = new hx_Channel_AdminUser(); cAdminUserEntity.CreateTime = channelEnitty.CreateTime; cAdminUserEntity.AdminUserName = adminUserName; cAdminUserEntity.AdminUserPassword = Utils.MD5(adminUserPassword); cAdminUserEntity.Status = (byte)1; if (string.IsNullOrEmpty(trueName)) { cAdminUserEntity.TrueName = adminUserName; } else { cAdminUserEntity.TrueName = trueName; } List <hx_Channel_AdminUser> cauList = new List <hx_Channel_AdminUser>(); cauList.Add(cAdminUserEntity); channelEnitty.hx_Channel_AdminUser = cauList; ef.hx_Channel.Add(channelEnitty); ef.SaveChanges(); return(Json(result)); }
/// <summary> /// 判断用户是否为渠道用户 /// </summary> /// <param name="userID"></param> /// <param name="channelType">渠道类型</param> /// <returns></returns> public static bool CheckIsChannel(int userID, ref string channelType) { //chuangtouEntities ef = new chuangtouEntities(); bool t = true; B_member_table b_member_table = new B_member_table(); M_member_table investor = new M_member_table(); investor = b_member_table.GetModel(userID); if (investor == null) { return(false); } string codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from hx_td_Userinvitation where invpersonid=" + investor.registerid + " ";//查询本人是否已经被邀请注册过 DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql); //if (dtcode.Rows.Count > 0 || (investor != null && !string.IsNullOrWhiteSpace(investor.channel_invitedcode))) //{ int uuid = dtcode.Rows.Count > 0 ? int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()) : 0; //邀请用户id //用户等级为渠道 不参与活动 if (investor != null && investor.useridentity == 4) { return(t); } int investCount = B_usercenter.GetInvestCountByUserid(investor.registerid); //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动 if (uuid != 0) { M_member_table py = new M_member_table(); B_member_table oy = new B_member_table(); py = oy.GetModel(uuid);//推荐人 if ((py != null && py.useridentity == 4)) { return(t); } } if (string.IsNullOrWhiteSpace(investor.channel_invitedcode)) { return(false); } string cacheName = "hx_Channel_" + investor.channel_invitedcode; hx_Channel channelEnitty = (hx_Channel)Utils.GetThirdCacheObject(cacheName); if (channelEnitty == null) { channelEnitty = ef.hx_Channel.AsNoTracking().Where(p => p.Invitedcode == investor.channel_invitedcode).FirstOrDefault(); } if (channelEnitty != null) { channelType = channelEnitty.type; Utils.SetThirdCacheName(cacheName, channelEnitty, 5); } return(channelEnitty != null); }
public ActionResult Editor(int channelId = 0) { hx_Channel channel = ef.hx_Channel.Where(p => p.ChannelID == channelId).ToList().FirstOrDefault(); if (channelId == 0 || channel == null) { Response.End(); } ViewBag.Channel = channel; return(View()); }
public JsonResult DoEditor(string channelName, int status, string adminUserName, string adminUserPassword, string trueName, int channelId = 0, string channelType = "cps1") { var result = new { state = 1, msg = "渠道 " + channelName + " 编辑完成!" }; if (string.IsNullOrEmpty(channelName) || channelId == 0 || string.IsNullOrEmpty(adminUserName) || string.IsNullOrEmpty(adminUserPassword)) { result = new { state = 0, msg = "缺少编辑的参数!" }; return(Json(result)); } hx_Channel channelEnitty = ef.hx_Channel.Where(p => p.ChannelID == channelId).ToList().FirstOrDefault(); var ckChannelNameList = ef.hx_Channel.Where(p => p.ChannelName == channelName && p.ChannelID != channelId).ToList(); if (ckChannelNameList.Count() > 0) { result = new { state = 0, msg = "渠道名称已经存在!" }; return(Json(result)); } var cAdminuserId = channelEnitty.hx_Channel_AdminUser.FirstOrDefault().AdminUserID; var ckAdminNameList = ef.hx_Channel_AdminUser.Where(p => p.AdminUserName == adminUserName && p.AdminUserID != cAdminuserId).ToList(); if (ckAdminNameList.Count() > 0) { result = new { state = 0, msg = "渠道使用者名称已存在!" }; return(Json(result)); } //编辑 Channel 与 Channel_AdminUser 表 channelEnitty.ChannelName = channelName; channelEnitty.Status = (byte)status; channelEnitty.type = channelType; channelEnitty.UpdateTime = DateTime.Now; hx_Channel_AdminUser cAdminUserEntity = channelEnitty.hx_Channel_AdminUser.ToList().FirstOrDefault(); cAdminUserEntity.AdminUserName = adminUserName; if (cAdminUserEntity.AdminUserPassword != adminUserPassword) { cAdminUserEntity.AdminUserPassword = Utils.MD5(adminUserPassword); } cAdminUserEntity.TrueName = trueName == "" || string.IsNullOrEmpty(trueName) ? cAdminUserEntity.TrueName : trueName; ef.SaveChanges(); Utils.RemoveCache("hx_Channel_" + channelEnitty.Invitedcode); return(Json(result)); }
/// <summary> /// 新渠道机制下区分 渠道类型,不同渠道类型可参加活动不一样 /// </summary> /// <param name="channelInviteCode">渠道邀请码</param> /// <param name="investNum">被邀请投资次数</param> /// <returns>true 参加活动</returns> public bool IsParticipateActivity(string channelInviteCode, int investNum = 0) { if (string.IsNullOrWhiteSpace(channelInviteCode)) { return(true); } string cacheName = "hx_Channel_" + channelInviteCode; hx_Channel channelEnitty = (hx_Channel)Utils.GetThirdCacheObject(cacheName); if (channelEnitty == null) { channelEnitty = ef.hx_Channel.AsNoTracking().Where(p => p.Invitedcode == channelInviteCode).FirstOrDefault(); Utils.SetThirdCacheName(cacheName, channelEnitty, 5); } if (channelEnitty == null) { return(false); } else { if (channelEnitty.type == "cps1")//渠道cps只结算首投,复投可参与所有活动 { if (investNum <= 1) { return(false); } else { return(true); } } else if (channelEnitty.type == "cps2") //渠道cps2结算首投及复投,所有投资不参加活动 { return(false); } else if (channelEnitty.type == "cpc")//cpc渠道结算与投资无关,参与所有活动 { return(true); } } return(false); }
public JsonResult DoLogin() { var result = new { state = 1, msg = "登录成功!" }; string username = Utils.CheckSQLHtml(Request.Form["txtUserName"].ToString()); string password = Utils.CheckSQLHtml(Request.Form["txtPassword"].ToString()); string code = Utils.CheckSQLHtml(Request.Form["txtCheckCode"].ToString()); if (string.IsNullOrEmpty(username)) { result = new { state = 0, msg = "渠道用户名不能为空!" }; return(Json(result)); } if (string.IsNullOrEmpty(password)) { result = new { state = 0, msg = "密码不能为空!" }; return(Json(result)); } if (string.IsNullOrEmpty(username)) { result = new { state = 0, msg = "验证码不能为空!" }; return(Json(result)); } password = Utils.MD5(password); if (Session["CheckCode"] != null) { string serverCode = Session["CheckCode"].ToString(); if (code != serverCode) { result = new { state = 0, msg = "验证码错误!" }; return(Json(result)); } } else { result = new { state = 0, msg = "验证码过期!" }; return(Json(result)); } //渠道用户 hx_Channel_AdminUser adminUser = ef.hx_Channel_AdminUser.Where(p => p.AdminUserName == username).FirstOrDefault(); hx_Channel channel = null; if (adminUser == null) { result = new { state = 0, msg = "此渠道用户不存在!" }; return(Json(result)); } else { channel = adminUser.hx_Channel.Where(p => p.Status == 1).FirstOrDefault(); } if (channel == null) { result = new { state = 0, msg = "渠道用户已禁用!" }; return(Json(result)); } else if (adminUser.AdminUserPassword != password) { result = new { state = 0, msg = "密码错误!" }; return(Json(result)); } else { Session["Channel_AdminUser"] = adminUser; Session["adminuserid"] = adminUser.AdminUserID + 10000;//防止和后台管理帐号冲突,加1w偏移 } return(Json(result)); }