public void ProcessRequest(HttpContext context) { string id = context.Request["id"]; string type = context.Request["type"]; string content = context.Request["content"]; string articleName = context.Request["article_name"]; string moduleName = "积分"; if (!string.IsNullOrWhiteSpace(context.Request["module_name"])) { moduleName = context.Request["module_name"]; } UserInfo toUser = bllUser.GetUserInfoByAutoID(Convert.ToInt32(id), bll.WebsiteOwner); if (toUser == null) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; apiResp.msg = "通知对象未找到"; bll.ContextResponse(context, apiResp); return; } if (type == "2") // 收费短信通知 { string sendNoticePrice = bllKeyValueData.GetDataVaule("SendNoticePrice", "1", bllKeyValueData.WebsiteOwner); if (string.IsNullOrWhiteSpace(sendNoticePrice)) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; apiResp.msg = "未配置短信消费" + moduleName; bll.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(toUser.Phone)) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; apiResp.msg = "通知对象的手机未找到"; bll.ContextResponse(context, apiResp); return; } int sendNoticePriceNum = Convert.ToInt32(sendNoticePrice); if (CurrentUserInfo.TotalScore < sendNoticePriceNum) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = moduleName + "不足"; bll.ContextResponse(context, apiResp); return; } bool sendSmsResult = false; string smsMsg = "您的"; if (!string.IsNullOrEmpty(articleName)) { smsMsg += "《" + articleName + "》有最新提醒:" + content + " 提醒人:" + bllUser.GetUserDispalyName(CurrentUserInfo); } string verCode = new Random().Next(111111, 999999).ToString(); string msg = ""; string smsSignature = string.Format("{0}", bllSms.GetWebsiteInfoModelFromDataBase().SmsSignature);//短信签名 bllSms.SendSmsMisson(toUser.Phone, smsMsg, DateTime.Now.ToString(), smsSignature, out sendSmsResult, out msg); if (sendSmsResult) { bllUser.AddUserScoreDetail(CurrentUserInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.SendMessage), bll.WebsiteOwner, (0 - sendNoticePriceNum), string.Format("短信通知消耗{0}{1}", sendNoticePriceNum, moduleName)); apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "短信发送成功"; apiResp.status = true; } else { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "短信发送失败," + msg; } } else { BLLJIMP.Model.SystemNotice notice = new BLLJIMP.Model.SystemNotice(); notice.InsertTime = DateTime.Now; notice.UserId = CurrentUserInfo.UserID; notice.Receivers = toUser.UserID; notice.WebsiteOwner = bll.WebsiteOwner; notice.NoticeType = (int)BLLSystemNotice.NoticeType.Message; notice.SendType = 2; notice.Ncontent = bll.GetContentHtml(BLLSystemNotice.NoticeType.Message, CurrentUserInfo, null, content); notice.SerialNum = bll.GetGUID(TransacType.SendSystemNotice); bool addResult = bll.Add(notice); if (addResult) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "通知发送成功"; apiResp.status = true; } else { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "通知发送失败"; } } bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; context.Response.Expires = 0; string result = "false"; string phone = context.Request["phone"]; string smsContent = context.Request["smscontent"]; string is_register = context.Request["is_register"]; string is_reset = context.Request["is_reset"]; string is_member = context.Request["is_member"]; string content = context.Request["content"]; List <string> blackIpList = new List <string>(); blackIpList.Add("139.196.16.189"); if (blackIpList.Contains(context.Request.UserHostAddress)) { resp.errcode = 1; resp.errmsg = "Ip Invai"; goto outoff; } if (string.IsNullOrEmpty(phone)) { resp.errcode = 1; resp.errmsg = "请输入手机号"; goto outoff; } if ((!phone.StartsWith("1")) || (!phone.Length.Equals(11))) { resp.errcode = 2; resp.errmsg = "手机号格式不正确"; goto outoff; } if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(phone)) { resp.errcode = 2; resp.errmsg = "手机格式不正确"; goto outoff; } if (string.IsNullOrEmpty(smsContent)) { resp.errcode = 1; resp.errmsg = "短信内容不能为空"; goto outoff; } if (!smsContent.Contains("{{SMSVERCODE}}"))//验证码标签 { resp.errcode = 1; resp.errmsg = "缺少标签{{SMSVERCODE}}"; goto outoff; } if (is_register == "1") { BLLUser bllUser = new BLLUser(); BLLJIMP.Model.UserInfo ouser = bllUser.GetUserInfoByPhone(phone, bllUser.WebsiteOwner); if (ouser != null) { resp.errcode = 1; resp.errmsg = "手机号码已存在账号,请尝试找回密码"; goto outoff; } } if (is_reset == "1") { BLLUser bllUser = new BLLUser(); BLLJIMP.Model.UserInfo ouser = bllUser.GetUserInfoByPhone(phone, bllUser.WebsiteOwner); if (ouser == null) { resp.errcode = 1; resp.errmsg = "手机号未注册"; goto outoff; } if (ouser.IsDisable == 1) { resp.errcode = 1; resp.errmsg = "账号已被禁用"; goto outoff; } if (is_member == "1" && ouser.MemberLevel == 0) { resp.errcode = 1; resp.errmsg = "您不是会员"; goto outoff; } } var lastSmsVerificationCode = bllSms.GetLastSmsVerificationCode(phone); if (lastSmsVerificationCode != null) { if ((DateTime.Now - lastSmsVerificationCode.InsertDate).TotalSeconds < 60) { resp.errcode = 3; resp.errmsg = "验证码限制每60秒发送一次"; goto outoff; } } bool isSuccess = false; string verCode = new Random().Next(111111, 999999).ToString(); string msg = ""; smsContent = smsContent.Replace("{{SMSVERCODE}}", verCode);//替换验证码标签 if (content == "1") { smsContent = "金融玩家欢迎你,验证码" + verCode; } string smsSignature = string.Format("{0}", bllSms.GetWebsiteInfoModelFromDataBase().SmsSignature);//短信签名 bllSms.SendSmsVerificationCode(phone, smsContent, smsSignature, verCode, out isSuccess, out msg); if (isSuccess) { resp.errcode = 0; resp.errmsg = "ok"; //resp.sms_vercode = verCode; } else { resp.errcode = 4; resp.errmsg = string.Format("发送验证码失败{0}", msg); } outoff: result = ZentCloud.Common.JSONHelper.ObjectToJson(resp); if (!string.IsNullOrEmpty(context.Request["callback"])) { //返回 jsonp数据 context.Response.Write(string.Format("{0}({1})", context.Request["callback"], result)); } else { //返回json数据 context.Response.Write(result); } }
public void ProcessRequest(HttpContext context) { string phone = context.Request["phone"]; string smsContent = context.Request["sms_content"]; string sendTime = context.Request["send_time"]; string result = "false"; if (string.IsNullOrEmpty(phone)) { resp.errcode = 1; resp.errmsg = "phone 参数不能为空"; goto outoff; } if ((!phone.StartsWith("1")) || (!phone.Length.Equals(11))) { resp.errcode = 2; resp.errmsg = "手机号格式不正确"; goto outoff; } if (string.IsNullOrEmpty(smsContent)) { resp.errcode = 1; resp.errmsg = "sms_content 参数不能为空"; goto outoff; } if (string.IsNullOrEmpty(sendTime)) { resp.errcode = 1; resp.errmsg = "send_time 参数不能为空"; goto outoff; } bool isSuccess = false; string msg = ""; string smsSignature = bllSms.GetWebsiteInfoModelFromDataBase().SmsSignature;//短信签名 if (string.IsNullOrEmpty(smsSignature)) { smsSignature = "至云"; } bllSms.SendSmsMisson(phone, smsContent, sendTime, smsSignature, out isSuccess, out msg); if (isSuccess) { resp.errcode = 0; resp.errmsg = "ok"; } else { resp.errcode = 4; resp.errmsg = string.Format("提交失败,错误码{0}", msg); } outoff: result = ZentCloud.Common.JSONHelper.ObjectToJson(resp); if (!string.IsNullOrEmpty(context.Request["callback"])) { //返回 jsonp数据 context.Response.Write(string.Format("{0}({1})", context.Request["callback"], result)); } else { //返回json数据 context.Response.Write(result); } }
public void ProcessRequest(HttpContext context) { string phone = context.Request["phone"]; string smsContent = context.Request["smscontent"]; string check_user = context.Request["check_user"]; string limit_user = context.Request["limit_user"]; #region 判断手机格式 if (!MyRegex.PhoneNumLogicJudge(phone)) { apiResp.code = (int)APIErrCode.PhoneFormatError; apiResp.msg = "手机格式错误"; bllSms.ContextResponse(context, apiResp); return; } #endregion #region 判断手机是否已被使用,且是否是当前账号 if (check_user == "1") { UserInfo model = bllUser.GetUserInfoByPhone(phone); if (limit_user == "1" && model == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "该手机号没有账号"; bllSms.ContextResponse(context, apiResp); return; } if (limit_user == "2" && model != null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "该手机号已有账号"; bllSms.ContextResponse(context, apiResp); return; } if (model != null) { UserInfo CurrentUserInfo = bllUser.GetCurrentUserInfo(); if (CurrentUserInfo != null && model.UserID != CurrentUserInfo.UserID) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机号码已被其他账号使用,请联系管理员"; bllSms.ContextResponse(context, apiResp); return; } //if (model.IsPhoneVerify == 1) //{ // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "手机号码已验证"; // bllSms.ContextResponse(context, apiResp); // return; //} } } #endregion var lastSmsVerificationCode = bllSms.GetLastSmsVerificationCode(phone); if (lastSmsVerificationCode != null) { if ((DateTime.Now - lastSmsVerificationCode.InsertDate).TotalSeconds < 60) { apiResp.code = (int)APIErrCode.IsRepeat; apiResp.msg = "验证码限制每60秒发送一次"; bllSms.ContextResponse(context, apiResp); return; } } string verCode = new Random().Next(111111, 999999).ToString(); string smsSignature = string.Format("{0}", bllSms.GetWebsiteInfoModelFromDataBase().SmsSignature);//短信签名 if (string.IsNullOrWhiteSpace(smsContent) || !smsContent.Contains("{{SMSVERCODE}}")) { smsContent = "手机验证码:{{SMSVERCODE}}"; } smsContent = smsContent.Replace("{{SMSVERCODE}}", verCode);//替换验证码标签 string msg = ""; bool isSuccess = false; bllSms.SendSmsVerificationCode(phone, smsContent, smsSignature, verCode, out isSuccess, out msg); if (!isSuccess) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机验证码发送失败"; bllSms.ContextResponse(context, apiResp); return; } apiResp.status = isSuccess; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "手机验证码已发送"; bllSms.ContextResponse(context, apiResp); }