public string sendCodebyqq(string ramcode, string phoneNumber) { // 请根据实际 appid 和 appkey 进行开发,以下只作为演示 sdk 使用 int sdkappid = 1400036626; string appkey = "523bf885d88484e5f65952187520c0fe"; int tmplId = 31143; string returncode = string.Empty; SmsSingleSenderResult singleResult; try { SmsSingleSender singleSender = new SmsSingleSender(sdkappid, appkey); List <string> templParams = new List <string>(); templParams.Add(ramcode); // 指定模板单发 singleResult = singleSender.SendWithParam("86", phoneNumber, tmplId, templParams, "", "", ""); returncode = singleResult.result.ToString(); } catch (Exception e) { } return(returncode); }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, TelphoneLiangJoinEntity entity) { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); this.BaseRepository().Update(entity); } else { entity.Create(); this.BaseRepository().Insert(entity); //短信提醒上级审核 IRepository db = new RepositoryFactory().BaseRepository().BeginTrans(); var parentOrg = db.FindEntity <OrganizeEntity>(t => t.OrganizeId == entity.OrganizeId); if (parentOrg != null) { SmsSingleSenderResult singleResult; SmsSingleSender singleSender = new SmsSingleSender(1400040861, "a92c87d0d291698777a9b5f323c0388a"); List <string> templParams = new List <string>(); templParams.Add(parentOrg.FullName); singleResult = singleSender.SendWithParam("86", parentOrg.OuterPhone, 205528, templParams, "", "", ""); } //申请加盟+1 orgService.UpdateJoinCount(entity.OrganizeId); } }
/// <summary> /// 核单 /// </summary> /// <param name="entity">主键值</param> /// <param name="State">状态:1-启动;0-禁用</param> public string UpdateTopOrg(TelphoneLiangJoinEntity entity, int State) { //获取0级机构id IRepository db = new RepositoryFactory().BaseRepository().BeginTrans(); //生成靓号商场平台 OrganizeEntity orgEntity = new OrganizeEntity() { ParentId = "0",//0级机构 FullName = entity.CompanyName, ShortName = entity.NickName, OuterPhone = entity.Telphone, InnerPhone = entity.WxAccount, //微信账号 Nature = entity.WxQRcode, //微信二维码 ManagerId = entity.OpenId, Manager = entity.FullName, Layer = 1, DeleteMark = 0 }; OrganizeEntity newEntity = orgService.SaveReturnEntity(orgEntity); //更新申请状态 TelphoneLiangJoinEntity reserveEntity = new TelphoneLiangJoinEntity(); reserveEntity.Modify(entity.Id); reserveEntity.TopMark = State; this.BaseRepository().Update(reserveEntity); //创建vip机构 TelphoneLiangVipEntity telphoneLiangVipEntity = new TelphoneLiangVipEntity() { OrganizeId = newEntity.OrganizeId, FullName = newEntity.FullName, UploadMax = 1000, OtherMax = 0, OrgMax = 10, Price = 0, VipStartDate = DateTime.Now, VipEndDate = DateTime.Now.AddDays(7) }; telphoneLiangVipIService.SaveForm(null, telphoneLiangVipEntity); //发送通过短信 if (!string.IsNullOrEmpty(newEntity.Description)) { SmsSingleSenderResult singleResult; SmsSingleSender singleSender = new SmsSingleSender(1400040861, "a92c87d0d291698777a9b5f323c0388a"); List <string> templParams = new List <string>(); templParams.Add(entity.FullName); templParams.Add(newEntity.Description); //成功 singleResult = singleSender.SendWithParam("86", entity.Telphone, 205617, templParams, "", "", ""); } return($"已通过短信的方式通知了你的下级,其靓号商城为:{newEntity.Description}"); }
static void Main(string[] args) { // 请根据实际 appid 和 appkey 进行开发,以下只作为演示 sdk 使用 // appid,appkey,templId申请方式可参考接入指南 https://www.qcloud.com/document/product/382/3785#5-.E7.9F.AD.E4.BF.A1.E5.86.85.E5.AE.B9.E9.85.8D.E7.BD.AE int sdkappid = 123456; string appkey = "1234567890abcdef1234567890abcdef"; string phoneNumber1 = "12345678901"; string phoneNumber2 = "12345678902"; string phoneNumber3 = "12345678903"; int tmplId = 7839; try { SmsSingleSenderResult singleResult; SmsSingleSender singleSender = new SmsSingleSender(sdkappid, appkey); singleResult = singleSender.Send(0, "86", phoneNumber2, "测试短信,普通单发,深圳,小明,上学。", "", ""); Console.WriteLine(singleResult); List <string> templParams = new List <string>(); templParams.Add("指定模板单发"); templParams.Add("深圳"); templParams.Add("小明"); // 指定模板单发 // 假设短信模板内容为:测试短信,{1},{2},{3},上学。 singleResult = singleSender.SendWithParam("86", phoneNumber2, tmplId, templParams, "", "", ""); Console.WriteLine(singleResult); SmsMultiSenderResult multiResult; SmsMultiSender multiSender = new SmsMultiSender(sdkappid, appkey); List <string> phoneNumbers = new List <string>(); phoneNumbers.Add(phoneNumber1); phoneNumbers.Add(phoneNumber2); phoneNumbers.Add(phoneNumber3); // 普通群发 // 下面是 3 个假设的号码 multiResult = multiSender.Send(0, "86", phoneNumbers, "测试短信,普通群发,深圳,小明,上学。", "", ""); Console.WriteLine(multiResult); // 指定模板群发 // 假设短信模板内容为:测试短信,{1},{2},{3},上学。 templParams.Clear(); templParams.Add("指定模板群发"); templParams.Add("深圳"); templParams.Add("小明"); multiResult = multiSender.SendWithParam("86", phoneNumbers, tmplId, templParams, "", "", ""); Console.WriteLine(multiResult); } catch (Exception e) { Console.WriteLine(e); } }
static void Main(string[] args) { // 请根据实际 appid 和 appkey 进行开发,以下只作为演示 sdk 使用 int sdkappid = 123456; string appkey = "1234567890abcdef1234567890abcdef"; string phoneNumber1 = "12345678901"; string phoneNumber2 = "12345678902"; string phoneNumber3 = "12345678903"; int tmplId = 7839; try { SmsSingleSenderResult singleResult; SmsSingleSender singleSender = new SmsSingleSender(sdkappid, appkey); singleResult = singleSender.Send(0, "86", phoneNumber2, "测试短信,普通单发,深圳,小明,上学。", "", ""); Console.WriteLine(singleResult); List <string> templParams = new List <string>(); templParams.Add("指定模板单发"); templParams.Add("深圳"); templParams.Add("小明"); // 指定模板单发 // 假设短信模板内容为:测试短信,{1},{2},{3},上学。 singleResult = singleSender.SendWithParam("86", phoneNumber2, tmplId, templParams, "", "", ""); Console.WriteLine(singleResult); SmsMultiSenderResult multiResult; SmsMultiSender multiSender = new SmsMultiSender(sdkappid, appkey); List <string> phoneNumbers = new List <string>(); phoneNumbers.Add(phoneNumber1); phoneNumbers.Add(phoneNumber2); phoneNumbers.Add(phoneNumber3); // 普通群发 // 下面是 3 个假设的号码 multiResult = multiSender.Send(0, "86", phoneNumbers, "测试短信,普通群发,深圳,小明,上学。", "", ""); Console.WriteLine(multiResult); // 指定模板群发 // 假设短信模板内容为:测试短信,{1},{2},{3},上学。 templParams.Clear(); templParams.Add("指定模板群发"); templParams.Add("深圳"); templParams.Add("小明"); multiResult = multiSender.SendWithParam("86", phoneNumbers, tmplId, templParams, "", "", ""); Console.WriteLine(multiResult); } catch (Exception e) { Console.WriteLine(e); } }
public JsonResult doCodeGet(String mobile) { int sdkappid = 1400096240; string appkey = "409fa0923289125b7b12025b0b281535"; SmsSingleSenderResult singleResult; SmsSingleSender singleSender = new SmsSingleSender(sdkappid, appkey); List <string> templParams = new List <string>(); SMSCode = GetRandomString(4, true, false, false, false, ""); templParams.Add(SMSCode); singleResult = singleSender.SendWithParam("86", mobile, 128733, templParams, "", "", ""); //var result = "{\"response\": {\"issuccess\": \"0\",\"msg\": \"用户名或密码错误!\"}}"; return(Json(singleResult, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 作废 /// </summary> /// <param name="keyValue">主键值</param> /// <param name="State">状态:1-启动;0-禁用</param> public void UpdateDeleteState(string keyValue, int State) { TelphoneLiangJoinEntity reserveEntity = new TelphoneLiangJoinEntity(); reserveEntity.Modify(keyValue); reserveEntity.DeleteMark = State; this.BaseRepository().Update(reserveEntity); var entity = this.BaseRepository().FindEntity(keyValue); if (entity != null) { SmsSingleSenderResult singleResult; SmsSingleSender singleSender = new SmsSingleSender(1400040861, "a92c87d0d291698777a9b5f323c0388a"); List <string> templParams = new List <string>(); templParams.Add(entity.FullName); //申请失败提醒 singleResult = singleSender.SendWithParam("86", entity.Telphone, 205531, templParams, "", "", ""); } }
/// <summary> /// 发送短信验证码 /// </summary> /// <param name="mobilePhone">手机号</param> /// <param name="smsMessage">短信内容</param> /// <param name="appID">appID</param> /// <param name="appKey">appKey</param> /// <param name="signature">短信签名</param> /// <param name="templateID">短信模板id</param> /// <returns>是否成功发送</returns> private bool SendMsg2User(string mobilePhone, List <string> smsMessage, int appID, string appKey, string signature, int templateID) { try { SmsSingleSender smsSender = new SmsSingleSender(appID, appKey); SmsSingleSenderResult smsResult = smsSender.SendWithParam("86", mobilePhone, templateID, smsMessage, signature, "", ""); if (smsResult.result != 0) { NLog.LogManager.GetCurrentClassLogger().Error("SmsMultiSender has error: " + smsResult); return(false); } return(true); } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message); return(false); } }
public JsonResult SendSmsCode(int sendType, string mobiles, int tempId, string parameters) { try { var appId = CommonVariable.SmsAppId; var appKey = CommonVariable.SmsAppKey; List <string> templParams = parameters.Split(',').ToList(); List <string> phoneNumbers = mobiles.Split(',').ToList(); if (sendType == 1) { MemoryCacheManager cache = new MemoryCacheManager(); LoginUser loginUser = cache.Get <LoginUser>(phoneNumbers[0]); if (loginUser == null) { loginUser = new LoginUser(phoneNumbers[0], 0); } if (loginUser.smsSendTimes >= 5) { return(Json(new { result = 1 })); } SmsSingleSender singleSender = new SmsSingleSender(appId, appKey); SmsSingleSenderResult singleResult = singleSender.SendWithParam("86", phoneNumbers[0], tempId, templParams, "", "", ""); loginUser.smsSendTimes += 1; //记录该用户今日发短信验证码的次数 cache.Set(phoneNumbers[0], loginUser, 60 * 24); return(Json(singleResult)); } else if (sendType == 2) { SmsMultiSender multiSender = new SmsMultiSender(appId, appKey); SmsMultiSenderResult multiResult = multiSender.SendWithParam("86", phoneNumbers, tempId, templParams, "", "", ""); return(Json(multiResult)); } } catch (Exception e) { Console.WriteLine(e); } return(Json(new { result = -1 })); }
public static bool Send(string phone, int templateId, List <string> parameter) { try { SmsSingleSenderResult singleResult; SmsSingleSender singleSender = new SmsSingleSender(sdkappid, appkey); singleResult = singleSender.SendWithParam("86", phone, templateId, parameter, "", "", ""); if (singleResult.errmsg == "OK") { return(true); } else { return(false); } } catch (Exception) { return(false); } }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public string SaveForm(string keyValue, TelphoneCertificationEntity entity) { IRepository db = new RepositoryFactory().BaseRepository().BeginTrans(); SmsSingleSenderResult singleResult; SmsSingleSender singleSender = new SmsSingleSender(1400040861, "a92c87d0d291698777a9b5f323c0388a"); TelphonePuEntity puData = db.FindEntity <TelphonePuEntity>(t => t.Telphone == entity.mobileNumber); TelphoneLiangEntity liangData = db.FindEntity <TelphoneLiangEntity>(t => t.Telphone == entity.mobileNumber); if (puData == null && liangData == null) { return("Error!认证的手机号码不存在!"); } if (!string.IsNullOrEmpty(keyValue)) { //发送短信 if (entity.sendMessage == 1) { TelphoneCertificationEntity oldEntity = this.BaseRepository().FindEntity(keyValue); if (oldEntity.loadMark == 0 && entity.loadMark == 2) { List <string> templParams = new List <string>(); templParams.Add(entity.mobileNumber); //成功 singleResult = singleSender.SendWithParam("86", entity.custTelphone, 172611, templParams, "", "", ""); //微信提醒模板:审核通过 WechatHelper.SendToOK(oldEntity.createId); } else if (oldEntity.loadMark == 0 && entity.loadMark == 1) { List <string> templParams = new List <string>(); templParams.Add(entity.mobileNumber); templParams.Add(entity.description); //失败 singleResult = singleSender.SendWithParam("86", entity.custTelphone, 172613, templParams, "", "", ""); //微信提醒模板:审核不通过 WechatHelper.SendToFail(oldEntity.createId, entity.description); } } entity.Modify(keyValue); this.BaseRepository().Update(entity); return("OK!操作成功"); } else { //已经提交过的号码,覆盖 var CertificationData = db.FindEntity <TelphoneCertificationEntity>(t => t.mobileNumber == entity.mobileNumber); if (CertificationData != null) { if (CertificationData.loadMark == 2) { return("Error!该号码已经激活,无需再次提交。"); } else if (CertificationData.loadMark == 0) { return("Error!正在认证中,请先耐心等待认证结果,不要重复提交!"); } else { //失败的再处理 entity.loadCount = CertificationData.loadCount + 1;//提交次数加1 entity.loadMark = 0; entity.description = ""; entity.Modify(CertificationData.ID); this.BaseRepository().Update(entity); //删除老照片 DirFileHelper.DeleteFile(CertificationData.photo_z); DirFileHelper.DeleteFile(CertificationData.photo_b); DirFileHelper.DeleteFile(CertificationData.photo_s); return("OK!再次上传成功!请耐心等待审核结果……"); } } else { entity.Create(); this.BaseRepository().Insert(entity); return("OK!提交成功!请耐心等待审核结果……"); } } }
/// <summary> /// 核单 /// </summary> /// <param name="entity">主键值</param> /// <param name="State">状态:1-启动;0-禁用</param> public string UpdateCheckState(TelphoneLiangJoinEntity entity, int State) { //获取0级机构id IRepository db = new RepositoryFactory().BaseRepository().BeginTrans(); if (OperatorProvider.Provider.Current().Account != "System") { var checkEntity = db.FindEntity <OrganizeEntity>(t => t.OuterPhone == entity.Telphone); if (checkEntity != null) { return("该申请人的手机号已经通过审核,请刷新机构列表查看!"); } var parentOrg0 = orgService.GetParentIdByOrgId(OperatorProvider.Provider.Current().CompanyId);//获得当前机构的所属0级机构 if (!string.IsNullOrEmpty(parentOrg0.First().OrganizeId)) { string parentOrg = parentOrg0.First().OrganizeId; //获取0级vip表 var vipEntity = db.FindEntity <TelphoneLiangVipEntity>(t => t.OrganizeId == parentOrg && t.VipEndDate > DateTime.Now); if (vipEntity == null) { return("平台机构未开放【申请加盟】功能!"); } else { int? orgMax = vipEntity.OrgMax; DataTable dt = orgService.GetOrgCount(parentOrg0.First().OrganizeId);//获取0级机构数量 int parentOrgCount = Convert.ToInt32(dt.Rows[0][0].ToString()); //如果0级机构,超过了设置的机构上限 if (parentOrgCount > orgMax) { return("平台机构已超过上限,请联系上级增加机构容量!"); } } } } if (State == 2) { entity.OrganizeId = "e21c39be-da56-4f1c-9120-a0926a520947";//修改审核机构为我 } //判断2,3级数量是个超限 //生成靓号商场平台 OrganizeEntity orgEntity = new OrganizeEntity() { ParentId = entity.OrganizeId, FullName = entity.CompanyName, ShortName = entity.NickName, OuterPhone = entity.Telphone, InnerPhone = entity.WxAccount, //微信账号 Nature = entity.WxQRcode, //微信二维码 ManagerId = entity.OpenId, Manager = entity.FullName, Layer = 1, DeleteMark = 0 }; OrganizeEntity newEntity = orgService.SaveReturnEntity(orgEntity); //更新申请状态 TelphoneLiangJoinEntity reserveEntity = new TelphoneLiangJoinEntity(); reserveEntity.Modify(entity.Id); reserveEntity.CheckMark = State; reserveEntity.OrganizeId = entity.OrganizeId;//审核机构为我 this.BaseRepository().Update(reserveEntity); //发送通过短信 if (!string.IsNullOrEmpty(newEntity.Description)) { SmsSingleSenderResult singleResult; SmsSingleSender singleSender = new SmsSingleSender(1400040861, "a92c87d0d291698777a9b5f323c0388a"); List <string> templParams = new List <string>(); templParams.Add(entity.FullName); templParams.Add(newEntity.Description); //成功 singleResult = singleSender.SendWithParam("86", entity.Telphone, 205617, templParams, "", "", ""); } return($"已通过短信的方式通知了你的下级,其靓号商城为:{newEntity.Description}"); }