/// <summary> /// 获取可用的抽奖次数 /// </summary> /// <returns></returns> public int GetCanUseTimes() { M_login M_uid = (M_login)DataCache.GetCache(CacheRemove._loginCachePrefix + Utils.GetUserIDCookieslocahost().ToString()); if (M_uid == null) { return(0); } //获取登录用户编号 int userID = Utils.checkloginsession(); //可抽奖次数 int CanUseTimes = 1; B_member_table bllMember = new B_member_table(); //获取会员信息 PartialMemberModel member = bllMember.GetPartialModel(userID); //验证用户是否为今天新注册并认证的用户 if (member.registration_time >= DateTime.Now.Date && member.registration_time < DateTime.Now.AddDays(1).Date&& member.isrealname == 1) { CanUseTimes += 1; } //获取用户的抽奖记录(当天的) B_LuckDraw bllLuckDraw = new B_LuckDraw(); int recordsCount = bllLuckDraw.GetRecordsCount(userID, DateTime.Now.Date, DateTime.Now.AddDays(1).Date); CanUseTimes = CanUseTimes >= recordsCount ? CanUseTimes - recordsCount : 0; return(CanUseTimes); }
public static ClaimsIdentity CreateIdentity(M_login user, string authenticationType) { ClaimsIdentity _identity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie); _identity.AddClaim(new Claim(ClaimTypes.Name, user.username)); _identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.userid.ToString())); _identity.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity")); _identity.AddClaim(new Claim("DisplayName", user.username)); return(_identity); }
public int[] SEARCH(Vo_login login) { if (m_login == null) { m_login = new M_login(); return(m_login.SEARCH(login)); } else { return(m_login.SEARCH(login)); } }
/// <summary> /// 发放现金奖励 /// </summary> /// <param name="luckDrawID"></param> /// <returns></returns> public ActionResult CheckCashAward(string luckDrawID) { JavaScriptSerializer jss = new JavaScriptSerializer(); int online_adminuserid = 0; M_login M_uid = (M_login)DataCache.GetCache(CacheRemove._loginCachePrefix + Utils.GetUserIDCookieslocahost().ToString()); if (M_uid == null) { return(Content(jss.Serialize(new { code = -1, data = "请登录后在进行该操作!" }))); } B_LuckDraw bllLuckDraw = new B_LuckDraw(); M_LuckDrawRecord record = bllLuckDraw.GetModel(luckDrawID); if (record.Ldre_AwardType != (int)EnumHelp.LuckDrawEnum.E_AwardType.type0) { return(Content(jss.Serialize(new { code = -1, data = "只有未发放的现金奖励才能进行该操作!" }))); } B_member_table bllUser = new B_member_table(); M_member_table user = bllUser.GetModel(record.Ldre_UserID); decimal orderID = decimal.Parse(Utils.Createcode()); string errMsg = ""; if (string.IsNullOrWhiteSpace(user.UsrCustId)) { return(Content(jss.Serialize(new { code = -1, data = "会员未开通汇付账号,无法完成转账操作" }))); } record.Ldre_AwardType = (int)EnumHelp.LuckDrawEnum.E_AwardType.type4; record.Ldre_OrderID = orderID.ToString(); if (!bllLuckDraw.UpdateModel(record)) { LogInfo.WriteLog("九月抽奖活动,后台列表审核,更新抽奖记录状态失败:" + string.Format(" operater:{0};operateTime:{1};", online_adminuserid, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); return(Content(jss.Serialize(new { code = -1, data = "更新抽奖记录失败" }))); } //hx_Activity_schedule 活动表中 50元红包的ID 为 53,对应于LuckDrawRecord中的awardID 为 -2 的数据均替换为 53 //if (!LuckDrawSendCash(orderID, 50, user.UsrCustId, 53, user.registerid, record.Ldre_AwardName, ref errMsg)) if (SendCash(record.Ldre_AwardID, user.registerid)) { LogInfo.WriteLog("九月抽奖活动,后台列表审核,现金奖励发放失败:" + string.Format(" operater:{0};operateTime:{1};errMsg:{2}", online_adminuserid, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), errMsg)); return(Content(jss.Serialize(new { code = -1, data = errMsg }))); } LogInfo.WriteLog("九月抽奖活动,后台列表审核,现金发放成功:" + string.Format(" operater:{0};operateTime:{1};", online_adminuserid, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); return(Content(jss.Serialize(new { code = 0, data = "现金发放成功" }))); }
/// <summary> /// 抽奖方法 /// </summary> /// <returns></returns> public ActionResult LuckDrawAward() { JavaScriptSerializer jss = new JavaScriptSerializer(); AjaxResponseData arData = new AjaxResponseData(); M_login M_uid = (M_login)DataCache.GetCache(CacheRemove._loginCachePrefix + Utils.GetUserIDCookieslocahost().ToString()); if (M_uid == null) { arData = new AjaxResponseData { code = "1", data = "您还没有登录" }; return(Content(jss.Serialize(arData))); } int userID = Utils.checkloginsession();//获取登录用户编号 string returnStr = TActivity_Luck.LuckDrawAward(userID, startTime, endTime, amount); string[] spl = returnStr.Split(';'); arData = new AjaxResponseData { code = spl[0], data = spl[1] }; return(Content(jss.Serialize(arData))); }
int amount = 1000; //规则金额 #endregion /// <summary> /// 中奖榜单初始化 /// </summary> private void FillDrawPersons() { string msg = ""; int state = TActivity_Luck.CheckActivityTime(startTime, endTime, ref msg); if (state != 0) { ViewBag.ltrCanUseTimes = "0"; ViewBag.ltrLuckCount = "0"; //Response.Write("<script>alert('" + msg + "');</script>"); return; } int luckCount = 0; B_LuckDraw bllLuckDraw = new B_LuckDraw(); List <M_LuckMan> lucks = bllLuckDraw.GetLuckDrawRecordList(30, "双12抽奖", out luckCount); lucks.ForEach(c => { c.Mobile = c.Mobile.Substring(0, 3) + "****" + c.Mobile.Substring(c.Mobile.Length - 4, 4); //c.UserName = c.UserName.Substring(0, 1) + "*******" + c.UserName.Substring(c.UserName.Length - 1, 1); c.AwardName = c.AwardName.Replace("双12抽奖送", ""); //c.AwardName.Length > 6 ? c.AwardName.Substring(c.AwardName.Length - 6, 6) : c.AwardName; }); StringBuilder builder = new StringBuilder(); builder.Append("<ul id='xstCont'>"); foreach (M_LuckMan luck in lucks) { builder.Append(" <li>"); builder.AppendFormat("<span>恭喜{0}用户</span><span>获得{1}</span>", luck.Mobile, luck.AwardName); builder.Append("</li>"); } builder.Append("</ul>"); ViewBag.ltrLuckMan = builder.ToString(); ViewBag.ltrLuckCount = luckCount.ToString(); M_login M_uid = (M_login)DataCache.GetCache(CacheRemove._loginCachePrefix + Utils.GetUserIDCookieslocahost().ToString()); if (M_uid == null) { ViewBag.ltrCanUseTimes = 0; } else { int userID = M_uid.userid;//PC获取登录用户编号 if (!TActivity_Luck.CheckChannel(userID)) { string channelType = ""; if (TActivity_Luck.CheckIsChannel(userID, ref channelType)) { if (channelType == "cps1") { Response.Write("<script>alert('抱歉,您是渠道用户,不可以参加本次活动,再投一笔即可抽奖!');</script>"); } else { Response.Write("<script>alert('抱歉,您是渠道用户,不可以参加本次活动!');</script>"); } } } ViewBag.ltrCanUseTimes = TActivity_Luck.GetCanUseTimes(userID, startTime, endTime, amount).ToString(); } }
public string Register(string Validatecode, string userpassword1, string mobile1, string username1, bool realMobileUser = false) { Utils.SetSYSDateTimeFormat(); string json = ""; //注册奖励 M_Activity_schedule ma = new M_Activity_schedule(); B_Activity_schedule ba = new B_Activity_schedule(); B_member_table o = new B_member_table(); M_member_table p = new M_member_table(); B_bonus_account bb = new B_bonus_account(); M_bonus_account mb = new M_bonus_account(); M_bonus_account_water mbaw = new M_bonus_account_water(); B_bonus_account_water bbaw = new B_bonus_account_water(); string email1 = ""; string strvcode = realMobileUser ? "y" : ck.GetVcode(Validatecode, mobile1); string tid = "";//富爸爸参数uid //Utils.GetCookie("Cooperation", "tid");//渠道来源ID string invcode = Utils.GetInvCode(); // 用户邀请用户关系存在的时候,不走 新渠道机制(channel) #region 道 //渠道的cookie var cc_keyValue = Utils.GetInvCookie("channel"); string cInvitedcode = string.Empty; if (string.IsNullOrEmpty(invcode) && cc_keyValue.Count != 0) { cInvitedcode = cc_keyValue["Invitedcode"]; var channelInvitedCode = ef.hx_Channel.Where(c => c.ChannelName == "fubaba").Select(c => c.Invitedcode).FirstOrDefault(); if (cInvitedcode.Trim() == channelInvitedCode) { tid = cc_keyValue["uid"]; } } #endregion int ch = 0; if (Utils.GetCookie("Cooperation", "ch") != "") { try { ch = int.Parse(Utils.GetCookie("Cooperation", "ch"));//渠道来源 } catch { ch = 0; } } if (ch == 0) { if (invcode != "") { ch = 1; } } if (strvcode != null) { if (strvcode == "y") { string checkMob = ck.checkmobile(mobile1, 0); if (checkMob != "y") { json = @" {""rs"" : ""n"", ""error"" : ""手机号已被注册!""}"; return(json); } p.username = username1; p.password = DESEncrypt.Encrypt(userpassword1, ConfigurationManager.AppSettings["webp"].ToString()); p.mobile = mobile1; p.email = email1; p.usertypes = 0; p.invitedcode = Calculator.Getinvitedcode(); p.ismobile = 1; p.Channelsource = ch; p.Tid = tid; p.channel_invitedcode = cInvitedcode; LogInfo.WriteLog("用户注册内容:" + FastJSON.toJOSN(p) + " IP:" + Utils.GetRealIP()); int uid = o.Add(p); if (uid > 0) { CheckXiCai(p.mobile, cInvitedcode); //if (tid != "") //{ // Utils.GetCoopAPI(tid, uid.ToString(), 1); //} string keys = DESEncrypt.Encrypt(uid.ToString(), ConfigurationManager.AppSettings["webp"].ToString()); string keys1 = DESEncrypt.Encrypt(username1, ConfigurationManager.AppSettings["webp"].ToString()); M_td_SMS_record pm = new M_td_SMS_record(); B_td_SMS_record om = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.注册成功.ToString()); string smscontxt = Utils.GetMSMEmailContext(18, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(smscontxt); string mobile = mobile1; sbsms = sbsms.Replace("#USERANEM#", p.username.ToString()); pm.phone_number = mobile; pm.sendtime = DateTime.Now; pm.senduserid = uid; pm.smstype = smstype; pm.smscontext = sbsms.ToString(); pm.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); pm.vcode = ""; om.Add(pm); M_login mlogin = new M_login(); mlogin.userid = uid; mlogin.username = p.username; mlogin.codeno = Utils.SetSessioncode(); int remember = 0; if (Utils.LoginWriteSession(mlogin, remember) > 0) { string sql = "update hx_member_table set lastlogintime='" + DateTime.Now + "',lastloginIP='" + Utils.GetRealIP() + "' where registerid=" + uid.ToString(); LogInfo.WriteLog(sql); DbHelperSQL.ExecuteSql(sql); } #region MyRegion //记录邀请关系 LogInfo.WriteLog("注册:邀请码:" + invcode); if (invcode != "") { string codesql = "SELECT invcode from hx_td_Userinvitation where invpersonid=" + uid.ToString();//查询本人是否已经被邀请注册过 invcode='" + invcode + "' and LogInfo.WriteLog("codesql2:" + codesql); DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql); if (dtcode.Rows.Count == 0) { M_td_Userinvitation myao = new M_td_Userinvitation(); B_td_Userinvitation dyao = new B_td_Userinvitation(); int yaouids = Utils.GetCodeUid(); myao.invcode = invcode; myao.invtime = DateTime.Now; myao.invpersonid = uid; myao.Invpeopleid = yaouids; myao.InvitesStates = 0; myao.Invitereward = 0; int myaoint = dyao.Add(myao); } } #endregion MyRegion //记录邀请关系 json = @" {""rs"" : ""y"", ""url"" : ""/""}"; string temstr = "/opening_account/Index/" + uid.ToString(); json = json.Replace("/", temstr); return(json); } else { json = @" {""rs"" : ""n"", ""error"" : ""注册失败!""}"; return(json); } } else { json = @" {""rs"" : ""n"", ""error"" : ""验证码不对!""}"; return(json); } } else { json = @" {""rs"" : ""n"", ""error"" : ""验证码不存在或过期!""}"; } return(json); }
public string LoginIN(string username, string userpassword, string Validatecode, int remember, bool realMobileUser = false) { string ip = Utils.GetRealIP(); string json = ""; B_member_table o = new B_member_table(); string strIdentify = "LoginValidateCode"; //随机字串存储键值,以便存储到Session中 var ts = true; if (Settings.Instance.SiteDomain.IndexOf(PublicURL.NewPCUrl) >= 0) { ts = false; } if (realMobileUser || Session[strIdentify] != null) { if (realMobileUser && ts == false) { if (Session[strIdentify].ToString() != Validatecode) { json = @" {""rs"" : ""n"", ""error"" : ""验证码不对!""}"; return(json); } } if (realMobileUser || Session[strIdentify].ToString() == Validatecode) { int userid = o.CheckLogin(username, userpassword); if (userid > 0) { M_login mlogin = new M_login(); mlogin.userid = userid; mlogin.username = username; mlogin.codeno = Utils.SetSessioncode(); Utils.AddLoginCache(username, mlogin); string sql = "update hx_member_table set lastlogintime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',lastloginIP='" + Utils.GetRealIP() + "' where registerid=" + userid.ToString(); LogInfo.WriteLog("登录信息更新" + sql); DbHelperSQL.ExecuteSql(sql); #region 登录成功 try { hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo(); usrmode.logintime = DateTime.Now; usrmode.Loginusrname = username; usrmode.loginusrpass = "******"; usrmode.registerid = userid; usrmode.loginIP = ip; usrmode.logincity = GetIpToCity.GetAddressByIp(ip); usrmode.loginsource = 1; usrmode.loginstate = 0; ef.hx_td_usrlogininfo.Add(usrmode); int ie = ef.SaveChanges(); //登录发送1580奖励(活动时间:2017.1.9-1.24) using (ChuanglitouP2P.BLL.EF.ActFacade actFacade = new ChuanglitouP2P.BLL.EF.ActFacade()) { actFacade.LoginSendDKQ(userid); } } catch (Exception tx) { throw (tx); } #endregion var jmpUrl = DNTRequest.GetString("jmpUrl"); if (!string.IsNullOrEmpty(jmpUrl)) { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "y", url = jmpUrl })); } return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "y", url = "/" })); } else if (userid == -100) { #region 登录失败 try { hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo(); usrmode.logintime = DateTime.Now; usrmode.Loginusrname = username; usrmode.loginusrpass = "******"; usrmode.registerid = userid; usrmode.loginIP = ip; usrmode.logincity = GetIpToCity.GetAddressByIp(ip); usrmode.loginsource = 1; usrmode.loginstate = 2; ef.hx_td_usrlogininfo.Add(usrmode); int ie = ef.SaveChanges(); } catch { } #endregion return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "n", error = "禁止登录!" })); } else { #region 登录失败 try { hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo(); usrmode.logintime = DateTime.Now; usrmode.Loginusrname = username; usrmode.loginusrpass = "******"; usrmode.registerid = userid; usrmode.loginIP = ip; usrmode.logincity = GetIpToCity.GetAddressByIp(ip); usrmode.loginsource = 1; usrmode.loginstate = 1; ef.hx_td_usrlogininfo.Add(usrmode); int ie = ef.SaveChanges(); } catch { } #endregion return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "n", error = "用户名或密码错误!" })); } } return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "n", error = "验证码不对!" })); } return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "n", error = "验证码过期!" })); }
public string Register(string Validatecode, string userpassword1, string mobile1, string username1, bool realMobileUser = false) { Utils.SetSYSDateTimeFormat(); string json = ""; //注册奖历 M_Activity_schedule ma = new M_Activity_schedule(); B_Activity_schedule ba = new B_Activity_schedule(); B_member_table o = new B_member_table(); M_member_table p = new M_member_table(); B_bonus_account bb = new B_bonus_account(); M_bonus_account mb = new M_bonus_account(); M_bonus_account_water mbaw = new M_bonus_account_water(); B_bonus_account_water bbaw = new B_bonus_account_water(); string email1 = ""; string strvcode = realMobileUser ? "y" : ck.GetVcode(Validatecode, mobile1); //string strvcode = "y"; if ((Settings.Instance.SiteDomain.IndexOf(PublicURL.NewWXUrl) >= 0)) { strvcode = ck.GetVcodeWX(Validatecode, mobile1); } string tid = Utils.GetCookie("Cooperation", "tid"); int ch = 0; string invcode = Utils.GetInvCode(); #region 道 //渠道的cookie var cc_keyValue = Utils.GetInvCookie("channel"); string cInvitedcode = string.Empty; if (string.IsNullOrEmpty(invcode) && cc_keyValue.Count != 0) { cInvitedcode = cc_keyValue["Invitedcode"]; } #endregion if (Utils.GetCookie("Cooperation", "ch") != "") { try { ch = int.Parse(Utils.GetCookie("Cooperation", "ch")); } catch { ch = 0; } } if (ch == 0) { if (invcode != "") { ch = 3; } else { ch = 2; } } if (realMobileUser || strvcode != null) { if (realMobileUser || strvcode == "y") { string checkMob = ck.checkmobile(mobile1, 0); if (checkMob != "y") { json = @" {""rs"" : ""n"", ""error"" : ""手机号已被注册!""}"; return(json); } p.username = username1; p.password = DESEncrypt.Encrypt(userpassword1, ConfigurationManager.AppSettings["webp"].ToString()); p.mobile = mobile1; p.email = email1; p.usertypes = 0; p.invitedcode = Calculator.Getinvitedcode(); p.ismobile = 1; p.Channelsource = ch; p.Tid = tid; p.channel_invitedcode = cInvitedcode; LogInfo.WriteLog("用户注册内容:" + FastJSON.toJOSN(p) + " IP:" + Utils.GetRealIP()); int uid = o.Add(p);//注册成功返回会员ID if (uid > 0) { //记录用户信息到活动流量发放表里 2016.10.21-31日 //string CookCode = Utils.GetCookie("CookCode"); //if (!string.IsNullOrWhiteSpace(CookCode)) //{ // if (CookCode== "liumi") // { // AddReceiveInfo(uid); // } //} if (tid != "") { // Utils.GetCoopAPI(tid, uid.ToString(), 1); } string keys = DESEncrypt.Encrypt(uid.ToString(), ConfigurationManager.AppSettings["webp"].ToString()); string keys1 = DESEncrypt.Encrypt(username1, ConfigurationManager.AppSettings["webp"].ToString()); M_td_SMS_record pm = new M_td_SMS_record(); B_td_SMS_record om = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.注册成功.ToString()); string smscontxt = Utils.GetMSMEmailContext(18, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(smscontxt); string mobile = mobile1; sbsms = sbsms.Replace("#USERANEM#", p.username.ToString()); pm.phone_number = mobile; pm.sendtime = DateTime.Now; pm.senduserid = uid; pm.smstype = smstype; pm.smscontext = sbsms.ToString(); pm.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); pm.vcode = ""; om.Add(pm); M_login mlogin = new M_login(); mlogin.userid = uid; mlogin.username = p.username; mlogin.codeno = Utils.SetSessioncode(); int remember = 0; FormsAuthentication.SignOut(); Utils.AddLoginCache(p.username, mlogin); string sql = "update hx_member_table set lastlogintime='" + DateTime.Now + "',lastloginIP='" + Utils.GetRealIP() + "' where registerid=" + uid.ToString(); DbHelperSQL.ExecuteSql(sql); #region MyRegion //记录邀请关系 LogInfo.WriteLog("注册:邀请码:" + invcode); if (invcode != "") { string codesql = "SELECT invcode from hx_td_Userinvitation where invpersonid=" + uid.ToString();//查询本人是否已经被邀请注册过 invcode='" + invcode + "' and LogInfo.WriteLog("codesql2:" + codesql); DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql); if (dtcode.Rows.Count == 0) { M_td_Userinvitation myao = new M_td_Userinvitation(); B_td_Userinvitation dyao = new B_td_Userinvitation(); int yaouids = Utils.GetCodeUid(); myao.invcode = invcode; myao.invtime = DateTime.Now; myao.invpersonid = uid; myao.Invpeopleid = yaouids; myao.InvitesStates = 0; myao.Invitereward = 0; int myaoint = dyao.Add(myao); } } #endregion MyRegion //记录邀请关系 json = @" {""rs"" : ""y"", ""url"" : ""/index.html"",""uid"":" + uid + "}"; string temstr = "/opening_account/Index/" + uid.ToString(); json = json.Replace("/index.html", temstr); return(json); } else { json = @" {""rs"" : ""n"", ""error"" : ""注册失败!""}"; return(json); } } else { json = @" {""rs"" : ""n"", ""error"" : ""验证码不对!""}"; return(json); } } else { json = @" {""rs"" : ""n"", ""error"" : ""验证码不存在或过期!""}"; } return(json); }
/// <summary> /// 抽奖方法 /// </summary> /// <returns></returns> public ActionResult LuckDrawAward() { JavaScriptSerializer jss = new JavaScriptSerializer(); AjaxResponseData arData = new AjaxResponseData(); try { string msg = ""; int state = CheckActivityTime(ref msg); if (state != 0) { arData = new AjaxResponseData { code = "4", data = msg }; return(Content(jss.Serialize(arData))); } M_login M_uid = (M_login)DataCache.GetCache(CacheRemove._loginCachePrefix + Utils.GetUserIDCookieslocahost().ToString()); if (M_uid == null) { arData = new AjaxResponseData { code = "1", data = "请登录后重试" }; return(Content(jss.Serialize(arData))); } if (M_uid.codeno != Utils.getSessioncode()) { arData = new AjaxResponseData { code = "1", data = "请登录后重试" }; return(Content(jss.Serialize(arData))); } //获取登录用户编号 int userID = M_uid.userid; //可抽奖次数 int CanUseTimes = 1; B_member_table bllMember = new B_member_table(); //获取会员信息 PartialMemberModel member = bllMember.GetPartialModel(userID); //验证用户是否为今天新注册的用户 if (member.registration_time >= DateTime.Now.Date && member.registration_time < DateTime.Now.AddDays(1).Date&& member.isrealname == 1) { CanUseTimes += 1; } B_LuckDraw bllLuckDraw = new B_LuckDraw(); //获取用户的抽奖记录数量(当天的) int recordsCount = bllLuckDraw.GetRecordsCount(userID, DateTime.Now.Date, DateTime.Now.AddDays(1).Date); CanUseTimes -= recordsCount; if (CanUseTimes <= 0) { arData = new AjaxResponseData { code = "2", data = "抽奖机会已用完,请明天再来" }; return(Content(jss.Serialize(arData))); } #region 规则及数据 // 现金50元 50 0.17 %(60次抽满后,每天限中2次,概率填充入50元代金券) //1 -17 //50元代金券 2450 23.33 % //18-2350 //20元代金卷 2100 20.00 % //2351-4350 //10元代金卷 2100 20.00 % //4351-6350 //1 % 加息券 1750 16.67 % //6351-8017 //2 % 加息券 1400 13.33 % //8018-9350 //谢谢参与 682.5 6.50 % //9351-10000 //47 9月注册送500元奖励 //48 9月注册送200元奖励 //49 9月注册送50元奖励 //50 9月注册送20元奖励 //51 [9月注册送10元奖励] //52 [9月注册送8元奖励] //1 3 % 加息券 //2 1 % 加息券 //3 2 % 加息券 //4 加息券 #endregion //现金50元已抽中的个数 int cash50Count = bllLuckDraw.GetCash50RecordsCount(-2, DateTime.Now.Date, DateTime.Now.AddDays(1).Date); //B_Activity_schedule bllASchedule = new B_Activity_schedule(); ActFacade act = new ActFacade(); //B_Activity bllActivity = new B_Activity(); //admin.users.AddBonusForUser adfu = new admin.users.AddBonusForUser(); //奖品编号 int awardID = 0; //奖品标题 string title = ""; //奖品类型 int awardType = -1; //轮盘区块编号 int awardBlockID = 0; Random random = new Random(); //随机数 int randomRate = random.Next(1, 10001); //randomRate = 9350; //switch (randomRate) //{ if (randomRate <= 8) { //每天限中2次,概率填充入50元代金券 if (cash50Count < 2) { awardID = ConfigHelper.GetConfigInt("AwardCash50"); awardType = 0; title = "现金50元"; awardBlockID = 3; } else { awardID = ConfigHelper.GetConfigInt("AwardBonus50"); awardType = 1; awardBlockID = 7; } } //现金50元 else if (randomRate <= 17) { //每天限中2次,概率填充入50元代金券 if (cash50Count < 2) { awardID = ConfigHelper.GetConfigInt("AwardCash50"); awardType = 0; title = "现金50元"; awardBlockID = 5; } else { awardID = ConfigHelper.GetConfigInt("AwardBonus50"); awardType = 1; awardBlockID = 7; } } //50元代金券 else if (randomRate <= 2350) { awardID = ConfigHelper.GetConfigInt("AwardBonus50"); awardType = 1; awardBlockID = 7; } //20元代金卷 else if (randomRate <= 4350) { awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; awardBlockID = 4; } //10元代金卷 else if (randomRate <= 6350) { awardID = ConfigHelper.GetConfigInt("AwardBonus10"); awardType = 1; awardBlockID = 6; } //1 % 加息券 else if (randomRate <= 8017) { awardID = ConfigHelper.GetConfigInt("AwardRate1"); awardType = 2; awardBlockID = 0; } //2 % 加息券 else if (randomRate <= 9350) { awardID = ConfigHelper.GetConfigInt("AwardRate2"); awardType = 2; awardBlockID = 2; } //谢谢参与 else if (randomRate <= 10000) { awardID = ConfigHelper.GetConfigInt("AwardThankYou"); awardType = 3; title = "谢谢参与"; awardBlockID = 1; } //谢谢参与 if (awardType == -1) { awardID = ConfigHelper.GetConfigInt("AwardThankYou"); awardType = 3; title = "谢谢参与"; awardBlockID = 1; } //} //发放代金券 if (awardType == 1 || awardType == 2) { var sourceData = act.GetActivityModel(awardID); //bllASchedule.GetModel(awardID); title = sourceData.ActName; //sourceData.activity_schedule_name.Replace("活动", "抽奖"); if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord { Ldre_AwardID = awardID, Ldre_AwardName = sourceData.ActName, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID })) { DrawBonus(sourceData, userID); arData = new AjaxResponseData { code = "0", data = awardBlockID.ToString() }; return(Content(jss.Serialize(arData))); } else { arData = new AjaxResponseData { code = "3", data = "碰到点小问题,刷新一下试试^v^" }; return(Content(jss.Serialize(arData))); } } ////发放加息券 //if (awardType == 2) //{ // var sourceData = bllActivity.GetModel(awardID); // title = "9月抽奖" + sourceData.ActivityName; // if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord { Ldre_AwardID = awardID, Ldre_AwardName = sourceData.ActivityName, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID })) // { // thisObj.SubmitRate(awardID, 1, userID, DateTime.Now, sourceData.EndDate, title); // arData = new AjaxResponseData { code = "0", data = awardBlockID.ToString() }; // return jss.Serialize(arData); // } //} //增加现金和“谢谢参与”的抽奖记录 if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord { Ldre_AwardID = awardID, Ldre_AwardName = title, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID })) { arData = new AjaxResponseData { code = "0", data = awardBlockID.ToString() }; return(Content(jss.Serialize(arData))); } //没有增加任何抽奖记录时的异常状态 arData = new AjaxResponseData { code = "3", data = "碰到点小问题,刷新一下试试" }; return(Content(jss.Serialize(arData))); } catch (Exception ex) { LogInfo.WriteLog("9月抽奖活动异常日志:" + "msg:" + ex.Message + " StackTrace" + ex.StackTrace); //没有增加任何抽奖记录时的异常状态 arData = new AjaxResponseData { code = "3", data = ex.Message }; return(Content(jss.Serialize(arData))); } }
public string loginIn(string username, string userpassword, string Validatecode, int remember, bool realMobileUser = false) { string json = string.Empty; B_member_table o = new B_member_table(); string strIdentify = "LoginValidateCode"; //随机字串存储键值,以便存储到Session中 string ip = Utils.GetRealIP(); if (realMobileUser || Session[strIdentify] != null) { if (!realMobileUser) { var ts = true; if (Settings.Instance.SiteDomain.IndexOf(PublicURL.NewPCUrl) >= 0) { ts = false; } if (ts == false) { if (Session[strIdentify].ToString() != Validatecode) { json = @" {""rs"" : ""n"", ""error"" : ""验证码过期!""}"; return(json); } } } int userid = 0; // int userid = o.CheckLogin(username, userpassword); M_member_table mtb = o.CheckUsrLogin(username); if (mtb == null) { json = @" {""rs"" : ""n"", ""error"" : ""该手机号未注册用户!""}"; return(json); } if (mtb.password != userpassword) { #region 登录失败 try { hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo(); usrmode.logintime = DateTime.Now; usrmode.Loginusrname = mtb.username; usrmode.loginusrpass = "******"; usrmode.registerid = mtb.registerid; usrmode.loginIP = ip; usrmode.logincity = GetIpToCity.GetAddressByIp(ip); usrmode.loginsource = 0; usrmode.loginstate = 1; ef.hx_td_usrlogininfo.Add(usrmode); int ie = ef.SaveChanges(); } catch { } #endregion json = @" {""rs"" : ""n"", ""error"" : ""用户名或密码错误!""}"; return(json); } userid = mtb.registerid; if (userid > 0) { M_login mlogin = new M_login(); mlogin.userid = userid; mlogin.username = username; mlogin.codeno = Utils.SetSessioncode(); mlogin.UsrName = mtb.realname; if (Utils.LoginWriteSession(mlogin, remember) > 0) { string sql = "update hx_member_table set LoginNum=LoginNum+1,lastlogintime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',lastloginIP='" + ip + "' where registerid=" + userid.ToString(); LogInfo.WriteLog("登录信息更新" + sql); DbHelperSQL.ExecuteSql(sql); #region 登录成功 try { hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo(); usrmode.logintime = DateTime.Now; usrmode.Loginusrname = mtb.username; usrmode.loginusrpass = "******"; usrmode.registerid = mtb.registerid; usrmode.loginIP = ip; usrmode.logincity = GetIpToCity.GetAddressByIp(ip); usrmode.loginsource = 0; usrmode.loginstate = 0; ef.hx_td_usrlogininfo.Add(usrmode); int ie = ef.SaveChanges(); //登录发送1580奖励(活动时间:2017.1.9-1.24) ActFacade actFacade = new ActFacade(); { actFacade.LoginSendDKQ(userid); } } catch (Exception tx) { throw (tx); } #endregion if (realMobileUser) { json = @"{""rs"" : ""y"", ""url"" : ""/""}"; return(json); } if (Session["returnpage"] != null) { json = @"{""rs"" : ""y"", ""url"" : ""/""}"; json = json.Replace("/", Session["returnpage"].ToString()); Session["returnpage"] = null; } else { json = @" {""rs"" : ""y"", ""url"" : ""/""}"; } return(json); } } else if (userid == -100) { #region 登录失败 try { hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo(); usrmode.logintime = DateTime.Now; usrmode.Loginusrname = mtb.username; usrmode.loginusrpass = "******"; usrmode.registerid = mtb.registerid; usrmode.loginIP = ip; usrmode.logincity = GetIpToCity.GetAddressByIp(ip); usrmode.loginsource = 1; usrmode.loginstate = 2; ef.hx_td_usrlogininfo.Add(usrmode); int ie = ef.SaveChanges(); } catch { } #endregion json = @" {""rs"" : ""n"", ""error"" : ""禁止登录!""}"; return(json); } else { #region 登录失败 try { hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo(); usrmode.logintime = DateTime.Now; usrmode.Loginusrname = mtb.username; usrmode.loginusrpass = "******"; usrmode.registerid = mtb.registerid; usrmode.loginIP = ip; usrmode.logincity = GetIpToCity.GetAddressByIp(ip); usrmode.loginsource = 0; usrmode.loginstate = 1; ef.hx_td_usrlogininfo.Add(usrmode); int ie = ef.SaveChanges(); } catch { } #endregion json = @" {""rs"" : ""n"", ""error"" : ""用户名或密码错误!""}"; return(json); } } else { json = @" {""rs"" : ""y"", ""error"" : ""验证码过期!""}"; } return(json); }