public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["Mobile"] == null || res["Mobile"].ToString().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "手机号码为空")); } else { string mobie = res["Mobile"].ToString().Trim(); SmsInfoManager sim = new SmsInfoManager(); UserInfoManager uim = new UserInfoManager(); //判断用户是否禁用状态 DataTable user = uim.GetUserInfoByBindPhone(mobie); if (user != null) { if (user.Rows.Count > 0) { Hashtable hashuser = DataTableHelper.DataRowToHashTable(user.Rows[0]); if (SiteHelper.GetHashTableValueByKey(hashuser, "UserState").Trim() == UserState.Disable.GetHashCode().ToString()) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "用户被禁用,无法收取验证码")); } } } ICache Cache = CacheFactory.GetCache(); string keyid = "sms_send_times@" + mobie; int sms_send_times = 0; if (string.IsNullOrEmpty(Cache.Get <string>(keyid))) { DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); Cache.Set(keyid, sms_send_times, dt - DateTime.Now); } if (sms_send_times >= MaxSendTimes) { Cache.Dispose(); return(SiteHelper.GetJsonFromHashTable(null, "faild", "短信发送失败,短信发送已超过当天最大次数")); } bool sendResult = sim.SendVerificationCode(mobie); if (sendResult) { sms_send_times += 1; DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); Cache.Set(keyid, sms_send_times, dt - DateTime.Now); Cache.Dispose(); return(SiteHelper.GetJsonFromHashTable(null, "success", "短信发送成功")); } else { Cache.Dispose(); return(SiteHelper.GetJsonFromHashTable(null, "faild", "短信发送失败")); } } }
public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["Mobile"] == null || res["Mobile"].ToString().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "手机号码为空")); } else { string mobile = res["Mobile"].ToString().Trim(); SmsInfoManager sim = new SmsInfoManager(); OPUserManager userManager = new OPUserManager(); DataTable user = userManager.GetUserInfoByMobile(mobile); //判断用户是否在系统中进行过注册 if (user == null || user.Rows.Count == 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "用户未在系统注册,无法收取验证码")); } if (user != null) { if (user.Rows.Count > 0) { Hashtable hashuser = DataTableHelper.DataRowToHashTable(user.Rows[0]); //判断用户是否禁用状态 if (SiteHelper.GetHashTableValueByKey(hashuser, "UserState").Trim() == UserState.Disable.GetHashCode().ToString()) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "用户被禁用,无法收取验证码")); } } } bool sendResult = sim.SendVerificationCode(mobile); if (sendResult) { return(SiteHelper.GetJsonFromHashTable(null, "success", "短信发送成功")); } else { return(SiteHelper.GetJsonFromHashTable(null, "faild", "短信发送失败")); } } }
public void ProcessRequest(HttpContext context) { context.Response.CacheControl = "no-cache"; context.Response.AddHeader("Pragma", "no-cache"); context.Response.ContentType = "text/plain"; string Action = context.Request["action"]; switch (Action) { case "GetDistrict": ServiceAreaManager areaManager = new ServiceAreaManager(); DataTable dtArea = areaManager.GetAreaList(int.Parse(context.Request["levelType"]), int.Parse(context.Request["parentId"])); context.Response.Write(JsonHelper.DataTableToJson("success", "获取数据成功", dtArea, "ServiceArea")); context.Response.End(); break; case "GetServiceAreaByID": ServiceAreaManager manager = new ServiceAreaManager(); DataTable dt = manager.GetServiceAreaByID(context.Request["key"]); context.Response.Write(JsonHelper.DataTableToJson("success", "获取数据成功", dt, "ServiceArea")); context.Response.End(); break; case "UpdateServiceAreaCoordinates": ServiceAreaManager sam = new ServiceAreaManager(); string key = context.Request["key"]; Hashtable ht = sam.GetInfoByID(key); ht["COORDINATES"] = context.Request["Coordinates"]; ht["LONGITUDE"] = context.Request["Longitude"]; ht["LATITUDE"] = context.Request["Latitude"]; string areaType = ht["AREATYPE"].ToString(); string status = ht["STATUS"].ToString(); string deleteMark = ht["DELETEMARK"].ToString(); //AreaType 区域类型 1服务范围 2停车网点 //Status 启动状态:0禁用,1启用 //DeleteMark 0 if ("1".Equals(areaType) && "1".Equals(status) && "True".Equals(deleteMark)) { ICache cache = null; try { cache = CacheFactory.GetCache(); string cacheKey = "Service_Area_" + ht["CITYID"].ToString(); DateTime timeSpan = DateTime.Now.AddDays(10); cache.Set(cacheKey, context.Request["Coordinates"], timeSpan - DateTime.Now); cache.Dispose(); /*List<LatLng> area_pts = new List<LatLng>(); * string coordinates = cache.Get<string>(cacheKey); * if(coordinates!=null&& coordinates.Length>0) * foreach (string str in coordinates.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)) * { * string[] pt_arr = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); * LatLng pt = new LatLng(double.Parse(pt_arr[1]), double.Parse(pt_arr[0])); * area_pts.Add(pt); * }*/ } catch (Exception e) { if (cache != null) { cache.Dispose(); } Logger.Error("更新区域:" + ht["THISNAME"].ToString() + ",报错:" + e); } if (cache != null) { cache.Dispose(); } } if (sam.AddOrEditInfo(ht, key)) { context.Response.Write(JsonHelper.DataTableToJson("success", "更新成功", null, "UpdateServiceAreaCoordinates")); } else { context.Response.Write(JsonHelper.DataTableToJson("faild", "更新失败", null, "UpdateServiceAreaCoordinates")); } context.Response.End(); break; case "GetInviteCouponInfo": SysSettingManager settingManager = new SysSettingManager(); int couponNum = 0; int.TryParse(settingManager.GetValueByKey("InviteCouponNum"), out couponNum); decimal couponMoney = 0.00m; decimal.TryParse(settingManager.GetValueByKey("InviteCouponMoney"), out couponMoney); double CouponPeriod = 0; double.TryParse(settingManager.GetValueByKey("CouponPeriod"), out CouponPeriod); Hashtable result_ht = new Hashtable(); result_ht["CouponNum"] = couponNum; result_ht["CouponMoney"] = couponMoney; result_ht["CouponPeriod"] = DateTime.Now.Date.AddDays(CouponPeriod).ToString("yyyy-MM-dd"); //响应数据到客户端 context.Response.Write(SiteHelper.GetJsonFromHashTable2(result_ht, "success", "获取数据成功", "GetInviteCouponInfo")); break; case "SendVerificationCode": string mobie = context.Request["Mobile"].ToString().Trim(); string code = ""; if (context.Request["Code"] != null) { code = context.Request["Code"].ToString().Trim(); } else { context.Response.Write(SiteHelper.GetJsonFromHashTable2(null, "faild", "参数错误", "SendVerificationCode")); context.Response.End(); break; } string session_code = context.Session["dt_session_code"].ToString(); if (code.ToLower() != session_code.ToLower()) { context.Response.Write(SiteHelper.GetJsonFromHashTable2(null, "faild", "图形验证码错误", "SendVerificationCode")); context.Response.End(); break; } SmsInfoManager sim = new SmsInfoManager(); UserInfoManager uim = new UserInfoManager(); DataTable user = uim.GetUserInfoByBindPhone(mobie); if (user != null && user.Rows.Count > 0) { context.Response.Write(SiteHelper.GetJsonFromHashTable2(null, "faild", "手机号已注册", "SendVerificationCode")); context.Response.End(); break; } bool sendResult = sim.SendVerificationCode(mobie); if (sendResult) { context.Response.Write(SiteHelper.GetJsonFromHashTable2(null, "success", "发送验证码成功", "SendVerificationCode")); context.Response.End(); break; } else { context.Response.Write(SiteHelper.GetJsonFromHashTable2(null, "faild", "发送验证码失败", "SendVerificationCode")); context.Response.End(); break; } case "NewUserRegister": sim = new SmsInfoManager(); UserLoginLogManager ullm = new UserLoginLogManager(); uim = new UserInfoManager(); settingManager = new SysSettingManager(); string mobile = context.Request["Mobile"].ToString().Trim(); string verificationCode = context.Request["VerificationCode"].ToString().Trim(); string invite_userid = context.Request["InviteUserID"].ToString().Trim(); string vcode = sim.GetVerCodeByMobile(mobile); if (verificationCode != vcode) { context.Response.Write(SiteHelper.GetJsonFromHashTable2(null, "faild", "手机验证码错误", "NewUserRegister")); context.Response.End(); return; } user = uim.GetUserInfoByBindPhone(mobile); if (user != null && user.Rows.Count > 0) { context.Response.Write(SiteHelper.GetJsonFromHashTable2(null, "faild", "用户已注册", "NewUserRegister")); context.Response.End(); return; } else { Hashtable newuser = new Hashtable(); newuser["BindPhone"] = mobile; newuser["RealNameCertification"] = (int)UserRealNameCertification.Unauthorized; newuser["UserState"] = (int)UserState.Enable; newuser["Balance"] = 0; newuser["RaiseBalance"] = 0; newuser["IsRaiseUser"] = (int)UserIsRaise.NO; newuser["InviteCode"] = mobile; newuser["InviteUserID"] = invite_userid; int num = uim.AddUserInfo(newuser); if (num > -1) { user = uim.GetUserInfoByBindPhone(mobile); //新注册用户赠送优惠券 couponNum = 0; int.TryParse(settingManager.GetValueByKey("RegCouponNum"), out couponNum); couponMoney = 0.00m; decimal.TryParse(settingManager.GetValueByKey("RegCouponMoney"), out couponMoney); UserCouponManager couponManager = new UserCouponManager(); if (couponNum > 0 && couponMoney > 0) { couponManager.NewUserGiveCoupons(user.Rows[0]["ID"].ToString()); } context.Response.Write(SiteHelper.GetJsonFromHashTable2(null, "success", "新用户注册成功", "NewUserRegister")); context.Response.End(); return; } else { context.Response.Write(SiteHelper.GetJsonFromHashTable2(null, "faild", "手机号错误", "NewUserRegister")); context.Response.End(); return; } } break; default: break; } }
public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["Mobile"] == null || res["Mobile"].ToString().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "手机号码为空")); } if (res["LoginCode"] == null || res["LoginCode"].ToString().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "图形码为空")); } string mobile = res["Mobile"].ToString().Trim(); UserInfoManager uim = new UserInfoManager(); DataTable blackMobile = uim.GetBlackMobileByMobile(mobile); if (blackMobile != null && blackMobile.Rows.Count > 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "手机号被禁用,请联系客服")); } string code = res["LoginCode"].ToString().Trim(); code = code.ToLower(); ICache cache = CacheFactory.GetCache(); string loginCodeKey = "login_code_" + mobile; string code_value = cache.Get <string>(loginCodeKey); Logger.Debug("mobile:" + mobile + ",code:" + code + ",redis_code_value:" + code_value); /*if(string.IsNullOrEmpty(code_value)) * { * return SiteHelper.GetJsonFromHashTable(null, "faild", "图形码超时"); * } * if (!code_value.Equals(code)) * { * return SiteHelper.GetJsonFromHashTable(null, "faild", "图形码错误"); * }*/ if (!ValidateUtil.IsMobilePhone(mobile)) { if (cache != null) { cache.Dispose(); } return(SiteHelper.GetJsonFromHashTable(null, "faild", "手机格式不正确")); } SmsInfoManager sim = new SmsInfoManager(); //判断用户是否禁用状态 DataTable user = uim.GetUserInfoByBindPhone(mobile); if (user != null) { if (user.Rows.Count > 0) { Hashtable hashuser = DataTableHelper.DataRowToHashTable(user.Rows[0]); if (SiteHelper.GetHashTableValueByKey(hashuser, "UserState").Trim() == UserState.Disable.GetHashCode().ToString()) { if (cache != null) { cache.Dispose(); } return(SiteHelper.GetJsonFromHashTable(null, "faild", "用户被禁用,无法收取验证码")); } } } /*string span_key_id = "sms_send_time_span@" + mobile; * if (string.IsNullOrEmpty(Cache.Get<string>(span_key_id))) * { * DateTime dt = DateTime.Now.AddSeconds(60); * Cache.Set(span_key_id, mobile, dt - DateTime.Now); * } * else * { * Cache.Dispose(); * Logger.Error("发送短信,Mobile:" + mobile + "60秒内"); * return SiteHelper.GetJsonFromHashTable(null, "faild", "短信发送失败,请稍后再试"); * }*/ string keyid = "sms_send_times@" + mobile; int sms_send_times = 0; if (string.IsNullOrEmpty(cache.Get <string>(keyid))) { DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); cache.Set(keyid, sms_send_times, dt - DateTime.Now); } else { string tims = cache.Get <string>(keyid); int.TryParse(tims, out sms_send_times); } if (sms_send_times >= MaxSendTimes) { if (cache != null) { cache.Dispose(); } return(SiteHelper.GetJsonFromHashTable(null, "faild", "短信发送失败,短信发送已超过当天最大次数")); } bool sendResult = sim.SendVerificationCode(mobile); if (sendResult) { sms_send_times += 1; DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); cache.Set(keyid, sms_send_times, dt - DateTime.Now); cache.Dispose(); return(SiteHelper.GetJsonFromHashTable(null, "success", "短信发送成功")); } else { if (cache != null) { cache.Dispose(); } return(SiteHelper.GetJsonFromHashTable(null, "faild", "短信发送失败")); } }