/// <summary> /// 容联。云通讯 /// </summary> /// <param name="mobile">手机号</param> /// <param name="msg">内容数据,需定义成数组方式,如模板中有两个参数,定义方式为{"1234","10"}</param> /// <param name="templateId">短信模板id</param> /// <returns></returns> public static string CCPSendSms(string mobile, string[] data, string templateId) { string appId = ConfigurationManager.AppSettings["SMS_AppId"].ToString(); string accountsid = ConfigurationManager.AppSettings["SMS_AccountSid"].ToString(); string authtoken = ConfigurationManager.AppSettings["SMS_Authtoken"].ToString(); string ret = null; CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount(accountsid, authtoken); api.setAppId(appId); try { if (isInit) { Dictionary <string, object> retData = api.SendTemplateSMS(mobile, templateId, data); ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } return(ret); }
private bool Init(CCPRestSDK.CCPRestSDK restSdk) { var isInit = Api.init(_restServerip, _restPort); Api.setAccount(_accountsid, _authToken); Api.setAppId(_appId); return isInit; }
protected void reg_send_submit_Click1(object sender, System.EventArgs e) { string mobile = this.cell_txt.Value; //验证码 Session["code1"] = DateTime.Now.Millisecond.ToString(); //验证码时间 Session["codetime1"] = DateTime.Now.ToString(); CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5514f73ea32014f848582a61f2d", "42d2934251534741ab39067f67645812"); api.setAppId("8a48b5514f73ea32014f84882bd81f2f"); string[] data = { Session["code1"].ToString(), "5" }; if (isInit) { api.SendTemplateSMS(mobile, "34439", data); } Response.Redirect("updatePassB.aspx?mobile=" + mobile); }
/// <summary> /// 【荣联云】发送短信 /// </summary> private static void SendSmsByRly(string mobile, string[] templateParam, int tempateId) { CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init(RlySmsIpDomain, RlySmsPort); api.setAccount(ConfigUtil.SmsAccountSid_rly, ConfigUtil.SmsAuthToken_rly); api.setAppId(ConfigUtil.SmsAppId_rly); try { if (isInit) { Dictionary <string, object> retData = api.SendTemplateSMS(mobile, tempateId.ToString(), templateParam); string ret = GetRlySmsDictData(retData); LogUtil.Info(ret); } else { LogUtil.Error("短信模版初始化失败!"); } } catch (Exception exc) { LogUtil.Error(exc.ToString()); } }
/// <summary> /// 创建子账户 /// </summary> /// <param name="userid"></param> /// <returns></returns> public ReturnResult CreateSubAccount(int userid) { CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init(url, port); if (isInit) { api.setAccount(accountSid, token); api.setAppId(appId); api.enabeLog(true); Dictionary <string, object> data = api.CreateSubAccount(userid.ToString()); if (data["statusCode"].ToString() == "000000") { Dictionary <string, object> retdata = ((data["data"] as Dictionary <string, object>)["SubAccount"] as Dictionary <string, object>); return(new ReturnResult { Msg = "", Code = 0, Obj = new { sid = retdata["subAccountSid"], account = retdata["voipAccount"], pwd = retdata["voipPwd"], token = retdata["subToken"] } }); } else { return(new ReturnResult { Msg = "发送失败", Code = 1 }); } } else { return(new ReturnResult { Msg = "CCP初始化失败", Code = 1 }); } }
/// <summary> /// 模版短信 /// </summary> public static void TemplateSms() { string ret = null; CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init("sandboxapp.cloopen.com", "8883"); api.setAccount("8a48b55146472691014689aa664f2", "f1258a0cc1a7492aa55e9eafb4b05f"); api.setAppId("8a48b5514647269101468a07a0d428c"); try { if (isInit) { Dictionary <string, object> retData = api.SendTemplateSMS("手机号", "1783", new string[] { "123456,2" }); ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } finally { Console.WriteLine(ret); } }
/// <summary> /// 获取短信验证 /// </summary> void GetMsg() { string inputphone = string.Empty; string imgcode = string.Empty; string writemsg = string.Empty; string statusCode = string.Empty; string statusMsg = string.Empty; if (Request["inputphone"] != null && Request["inputphone"] != "") { inputphone = Common.Common.NoHtml(Request["inputphone"]); } if (Request["imgcode"] != null && Request["imgcode"] != "") { imgcode = Request["imgcode"].ToString(); } if (inputphone.Trim() != null && inputphone.Trim() != "" && imgcode != null && imgcode != "") { CCPRestSDK api = CCPRestSDK.GetInstance(); try { if (api != null) { Dictionary <string, object> retData = api.SendTemplateSMS(inputphone, "8281", new string[] { imgcode, "5" }); try { statusCode = retData["statusCode"].ToString(); } catch (Exception) { } try { statusMsg = retData["statusMsg"].ToString(); } catch (Exception) { } if (statusCode != null && statusCode != "" && statusCode.ToString().Trim().ToLower() == "000000") { Response.Write("{\"success\":true}"); } else { Response.Write("{\"error\":true,\"msg\":\"" + statusMsg + "\"}"); } } else { Response.Write("{\"error\":true,\"msg\":\"初始化失败\"}"); } } catch (Exception exc) { Response.Write("{\"error\":true,\"msg\":\"操作失败,请重新操作\"}"); } } Response.End(); }
public void Initialize() { api = new CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init(this.Context.Host, this.Context.Port); api.setAccount(this.Context.AccountId, this.Context.AccessToken); api.setAppId(this.Context.AppId); }
private static CCPRestSDK GetApi() { CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init("sandboxapp.cloopen.com", "8883"); api.setAccount("8a48b55146472691014689aa664f2", "f1258a0cc1a7492aa55e9eafb4b05"); api.setAppId("aaf98f8946471bb0014689b7fa4927"); api.setSubAccount("aaf98f8946471bb0014689b7fa6327", "ffbd6baa633346edb04b8159c56049", "81617100000001", "kalyrn0i"); return(api); }
/// <summary> /// 发送短信 /// </summary> /// <param name="telNo">手机号</param> /// <param name="code">短信模版号</param> /// <param name="Minute">有效的分钟数</param>> public bool Send(string telNo, string code, string Minute) { string[] result = { "" }; Random random = new Random(); string ran = random.Next(100000, 1000000).ToString(); CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init("sandboxapp.cloopen.com", "8883"); api.setAccount("8a48b5514ae16942014ae6ff251903ca", "9eba3e71cd8f4655a801af9d9a9696c6"); api.setAppId("8a48b5514ae16942014ae7008f9203d3"); try { if (isInit) { string[] data_content = { ran, Minute }; string IsSendSms = ConfigurationManager.AppSettings["IsSendSms"].ToString(); string status = ""; if (IsSendSms == "1") { Dictionary <string, object> retData = api.SendTemplateSMS(telNo, code, data_content); result = getDictionaryData(retData).Split(';'); status = result[0].Split('=')[1]; } else { status = "000000"; } if (status == "000000") { return(true); } else { ErrorMsg = result[1].Split('=')[1]; return(false); } } else { ErrorMsg = "发送出现异常"; return(false); } } catch { ErrorMsg = "发送出现异常"; return(false); } }
/// <summary> /// 发送短信 /// </summary> /// <param name="config"></param> /// <returns></returns> public MmbjSendSmsResult SendSms(MmbjSMSConfig config) { //类型不可转换,那么报错 if (!(config is CCPSendSMSConfig sendSmsConfig)) { throw new ArgumentException("参数类型传输错误"); } CCPRestSDK api = new CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init(sendSmsConfig.RestAddress, sendSmsConfig.RestPort); api.setAccount(sendSmsConfig.AccountSid, sendSmsConfig.AccountToken); api.setAppId(sendSmsConfig.AppId); try { if (isInit) { CCPResponseStatus ccpResponseStatus = api.SendTemplateSMS(sendSmsConfig.PhoneNumbers, sendSmsConfig.TemplateCode, sendSmsConfig.Params); return(new CCPSendSmsResult() { Code = ccpResponseStatus.StatusCode == "000000" ? "OK" : ccpResponseStatus.StatusCode, Message = ccpResponseStatus.StatusMsg, RequestId = ccpResponseStatus.TemplateSMS?.SmsMessageSid ?? "" }); } else { return(new CCPSendSmsResult() { Message = "初始化失败", Code = "CCPServerError", RequestId = string.Empty }); } } catch (Exception exc) { return(new CCPSendSmsResult() { Message = "运行错误", Code = "CCPClientError", RequestId = string.Empty }); } }
/// <summary> /// 海峡竞技短信验证码推送 /// author:白尚德 /// </summary> /// <param name="phone">推送手机号码</param> /// <param name="val">验证码</param> /// <param name="type">1短信,2语音</param> /// <param name="templates">推送模板</param> public bool StraitMessageCode(string phone, string val, int type, string templates = "377916") { Infrastructure.Sdk.CCPRestSDK api = new CCPRestSDK(); /*服务器地址,服务器端口*/ bool bIsInit = api.init("app.cloopen.com", "8883"); string strRet = string.Empty; string strResult = string.Empty; /*主账号,主账号令牌,如果主页更换了token需要在这里更改令牌*/ api.setAccount("8aaf070857acf7a70157adee1554019f", "587ffc830e3d46c59e70f907f50e78e0"); api.setAppId("8aaf070866f7197701670ab5393309e7"); /*应用ID*/ string template = "377916"; try { Dictionary <string, object> RetData = null; if (type == 1) //短信 { /*手机号码,短信模板,验证码*/ RetData = api.SendTemplateSMS(phone, template, new string[] { val, "1" }); } else { /*手机号码,验证码,显示主叫号码,重复次数,回调地址*/ RetData = api.VoiceVerify(phone, val, null, "3", null); } //推送短信/电话 strRet = api.getDictionaryData(RetData); } catch (Exception) { throw; } finally { string[] str_Temp = strRet.Split(';'); strResult = str_Temp[0]; strResult = strResult.Substring(strResult.IndexOf("=") + 1); } if (strResult != "000000") { //推送失败 return(false); } return(true); }
/// <summary> /// /// </summary> /// <param name="mobile">短信接收端手机号码集合,用英文逗号分开,每批发送的手机号数量不得超过100个</param> /// <param name="templateId">模板Id</param> /// <param name="data">可选字段 内容数据,用于替换模板中{序号}</param> public bool SendSMS(string mobile, string templateId, string[] data) { CCPRestSDK api = new CCPRestSDK(); string SMSAcountSid = "8aaf070858cd982e0158d723732b0644"; string SMSAuthToken = "ae968441a62e4e929cb02f85046b65df"; string SMSRestUrl = "app.cloopen.com"; string SMSAppID = "8aaf07086077a6e601607d907edc0316"; //ip格式如下,不带https:// bool isInit = api.init(SMSRestUrl, "8883"); api.setAccount(SMSAcountSid, SMSAuthToken); api.setAppId(SMSAppID); string ret = string.Empty; try { if (isInit) { Dictionary <string, object> retData = api.SendTemplateSMS(mobile, templateId, data); ret = getDictionaryData(retData); if (ret.IndexOf("000000") > 0) { return(true); } else { //sMSSendLogInfo.SendStutas = "失败"; return(false); } //LogTextHelper.Info(ret); } else { //LogTextHelper.Info("SMS短信接口初始化失败"); return(false); } } catch (Exception exc) { //LogTextHelper.Error("SMS短信接口异常:" + exc.Message); return(false); } }
/// <summary> /// /// </summary> /// <param name="mobile"></param> /// <param name="data"></param> /// <returns></returns> public static ReturnResult SendVoice(string mobile, string data) { if (!ValidateUtil.IsMobile(mobile)) { return(new ReturnResult { Msg = "错误的手机号", Code = 1 }); } try { CCPRestSDK api = new CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init(url, port); api.setAccount(accountSid, token); api.setAppId(appId); api.enabeLog(true); if (isInit) { Dictionary <string, object> retData = api.VoiceVerify(mobile, data, "", "3", ""); if (retData["statusCode"].ToString() == "000000") { return(new ReturnResult { Msg = "发送成功", Code = 0 }); } else { return(new ReturnResult { Msg = "发送失败", Code = 1 }); } } else { return(new ReturnResult { Msg = "短信模块初始化失败", Code = 1 }); } } catch { return(new ReturnResult { Msg = "发送失败", Code = 1 }); } }
public bool Send(string phoneNumber, string validateCode) { string ret = null; try { var api = new CCPRestSDK(); //ip格式如下,不带https:// string restAddress = ConfigHelper.GetAppSetting("restAddress"); string restPort = ConfigHelper.GetAppSetting("restPort"); string accountSid = ConfigHelper.GetAppSetting("accountSid"); string accountToken = ConfigHelper.GetAppSetting("accountToken"); string appId = ConfigHelper.GetAppSetting("appId"); string smsTemplateId = ConfigHelper.GetAppSetting("smsTemplateId"); int smsValidMinutes = Convert.ToInt32(ConfigHelper.GetAppSetting("smsValidMinutes")); var isInit = api.init(restAddress, restPort); api.setAccount(accountSid, accountToken); api.setAppId(appId); if (isInit) { var retData = api.SendTemplateSMS(phoneNumber, smsTemplateId, new string[] { validateCode /*, smsValidMinutes.ToString()*/ }); var statusMsg = retData["statusMsg"].ToString(); if (statusMsg != "成功") { ret = statusMsg; } } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } return(ret == null); }
protected void reg_send_submit_Click(object sender, EventArgs e) { string mobile = this.cell_txt.Value; resp res = new resp(); res = Util.GetResp("http://120.27.45.83:8085/api/User/ValidatePhone", "Phone=" + mobile); if (res.code == 1000) { //验证码 Session["code"] = DateTime.Now.Millisecond.ToString(); //验证码时间 Session["codetime"] = DateTime.Now.ToString(); CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5514f73ea32014f848582a61f2d", "42d2934251534741ab39067f67645812"); api.setAppId("8a48b5514f73ea32014f84882bd81f2f"); string[] data = { Session["code"].ToString(), "5" }; if (isInit) { api.SendTemplateSMS(mobile, "34439", data); } Response.Redirect("registB.aspx?mobile=" + mobile); } else { Response.Write("<script>alert('您的手机号已被注册过!')</script>"); } }
public ActionResult GetCode(string phone) { try { //member:register:code:tplid Random rand = new Random(); int num = rand.Next(100000, 999999); Session["code"] = num.ToString(); CCPRestSDK api = new CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5514ff457cc014ff868438f0aa5", "63e6fcb07a6843c4b851cc8d6abc2bb5"); api.setAppId("8a48b5514ff457cc014ff86a83330ab9"); Common.CustomLog.WriteLog(isInit.ToString()); if (isInit) { string[] array = new string[] { num.ToString(), "2" }; Dictionary <string, object> retData = api.SendTemplateSMS(phone, "41259", array); Common.CustomLog.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(retData)); if (retData["statusCode"].ToString() == "000000") { return(Json(true, JsonRequestBehavior.AllowGet)); } } else { return(Json(false, JsonRequestBehavior.AllowGet)); } //Dictionary<string, string> dir = new Dictionary<string, string>(); //dir.Add("{{code}}", num.ToString()); //Helpers.SendmailHelper.SendEmail(email, "member:register:code:tplid", dir); //return Json(true, JsonRequestBehavior.AllowGet); return(Json(false, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
internal static bool SendSms(string mobilePhone, string smsTemplateId, string[] smsData, out string errMsg) { var ret = false; errMsg = string.Empty; //return true; CCPRestSDK api = new CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.Init(Global.ApplicationConstants.SmsRestServerIp, Global.ApplicationConstants.SmsRestServerPort); api.SetAccount(Laplace.LiteCOS.Global.ApplicationConstants.SmsAccountSid, Laplace.LiteCOS.Global.ApplicationConstants.SmsAuthToken); api.SetAppId(Laplace.LiteCOS.Global.ApplicationConstants.SmsAppId); try { if (isInit) { Dictionary <string, object> retData = api.SendTemplateSMS(mobilePhone, smsTemplateId, smsData); if (retData.ContainsKey("statusCode") && retData["statusCode"].ToString() == "000000" /*表示请求发送成功*/) { ret = true; } else { errMsg = GetStatusMsg(retData); } } else { errMsg = "初始化失败"; } } catch (Exception ex) { errMsg = ex.Message; } Debug.WriteLine(errMsg); return(ret); }
/// <summary> /// 配置 /// </summary> /// <param name="_phoneAccount">联荣云通讯账户</param> /// <param name="_phoneToken">token</param> /// <param name="_phoneAppid">appid</param> /// <param name="_phoneRest">发送短信服务接口地址</param> /// <param name="_phoneProt">发送短信服务端口</param> /// <param name="_phoneTepmplate">短信模版id号</param> public static void SetConfig(string _phoneAccount, string _phoneToken, string _phoneAppid, string _phoneRest, string _phoneProt, string _phoneTepmplate) { phoneAccount = _phoneAccount; phoneToken = _phoneToken; phoneAppid = _phoneAppid; phoneRest = _phoneRest; phoneProt = _phoneProt; phoneTepmplate = _phoneTepmplate; // api = new CCPRestSDK(); bool isInit = api.init(phoneRest, phoneProt); if (isInit) { api.setAccount(phoneAccount, phoneToken); api.setAppId(phoneAppid); } else { Console.Write("短信模块初始化失败"); } }
protected void Page_Load(object sender, EventArgs e) { string ret = null; //CCPRestSDK api = new CCPRestSDK(); ////ip格式如下,不带https:// //bool isInit = api.init("sandboxapp.cloopen.com", "8883"); //api.setAccount("aaf98f89499d24b50149cb1353b91900", "f5241e29e403406aaeecad5ab4a3a68c"); //api.setAppId("8a48b55149896cfd0149cb14a05429cf"); CCPRestSDK api = CCPRestSDK.GetInstance(); try { if (api != null) { string code = DateTime.Now.ToString("HHmmss"); string tel = "13577073155"; //默认模板消息[1]:【云通讯】您使用的是云通讯短信模板,您的验证码是{1},请于{2}分钟内正确输入 //参数Data对应模板消息的索引 Dictionary <string, object> retData = api.SendTemplateSMS(tel, "1", new string[] { code, "2" }); ret = getDictionaryData(retData); //对响应解析后,statusCode为“000000”表示请求发送成功。statusCode不是“000000”,表示请求发送失败,客户服务端可以根据自己的逻辑进行重发或者其他处理。 //statusCode=000000;statusMsg=成功;data={TemplateSMS={dateCreated=20141122134226;smsMessageSid=201411221342253809119;};}; } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } finally { Response.Write(ret); } }
// return SMSService.SendTemplateSMS(mobile, "227982", new string[] { code,"30" }, "vender"); public static int SendTemplateSMS(string mobile, string template, string[] data) { if (!ValidateUtil.IsMobile(mobile)) { return(1); } try { //初始化短信接口 CCPRestSDK api = new CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init(url, port); api.setAccount(accountSid, token); api.setAppId(appId); api.enabeLog(true); Dictionary <string, object> retData = new Dictionary <string, object>(); if (isInit) { //短信发送 retData = api.SendTemplateSMS(mobile, template, data); var ret = getDictionaryData(retData); if (retData["statusCode"].ToString() == "000000") { return(0); } else { return(1); } } else { return(1); } } catch { return(1); } }
protected void repeatBt_Click(object sender, EventArgs e) { Session.Remove("code1"); Session.Remove("codetime1"); //验证码 Session["code1"] = DateTime.Now.Millisecond.ToString(); //验证码时间 Session["codetime1"] = DateTime.Now.ToString(); CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5514f73ea32014f848582a61f2d", "42d2934251534741ab39067f67645812"); api.setAppId("8a48b5514f73ea32014f84882bd81f2f"); string[] data = { Session["code1"].ToString(), "5" }; if (isInit) { api.SendTemplateSMS(Request.QueryString["mobile"].ToString(), "34439", data); } }
public ActionResult Test(string phone) { CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5514ff457cc014ff868438f0aa5", "63e6fcb07a6843c4b851cc8d6abc2bb5"); api.setAppId("8a48b5514ff457cc014ff86a83330ab9"); if (isInit) { Random rand = new Random(); int num = rand.Next(100000, 999999); string[] array = new string[] { num.ToString(), "3" }; Dictionary <string, object> retData = api.SendTemplateSMS(phone, "41259", array); if (retData["statusCode"].ToString() == "000000") { return(Json(true, JsonRequestBehavior.AllowGet)); } } else { return(Json(false, JsonRequestBehavior.AllowGet)); } return(Content("test")); //获取所有已经购买的产品 //IContentType ct = Services.ContentTypeService.GetContentType("PayRecords"); //IEnumerable<IContent> list = Services.ContentService.GetContentOfContentType(ct.Id).Where(e => e.GetValue<bool>("isdeposit") == true && e.GetValue<bool>("isexpired") == false); //IEnumerable<int> memberids = list.GroupBy(e => e.GetValue<int>("memberPicker")).Select(e => e.Key); //foreach (int memberid in memberids) //{ // decimal sumProfit = 0; // IMember member = Services.MemberService.GetById(memberid); // StringBuilder sb = new StringBuilder(); // //获取product的收益率 // foreach (IContent content in list.Where(e => e.GetValue<int>("memberPicker") == memberid)) // { // //yyyy-MM-dd // if (content.GetValue<DateTime>("expirationtime") > DateTime.Now.AddDays(1)) // { // int productId = content.GetValue<int>("buyproduct"); // IContent product = Services.ContentService.GetById(productId); // int number = 0; // if (int.TryParse(product.GetValue<string>("rate"), out number)) // { // decimal rate = (decimal)number / (decimal)100; // decimal profit = (content.GetValue<decimal>("amountCny") * rate) / (decimal)365; // //修改member的最新收益 // sumProfit += profit; // //记录这次计算结果; // string earningsName = string.Format("{0} ({1})", content.GetValue<string>("username"), profit.ToString("F2")); // IContentType earningsContentType = Services.ContentTypeService.GetContentType("EarningsRecordsElement"); // IContent earningsContent = Services.ContentService.CreateContent(earningsName, earningsContentType.Id, "EarningsRecordsElement"); // earningsContent.SetValue("memberid", memberid); // earningsContent.SetValue("productid", content.Id); // earningsContent.SetValue("earning", profit.ToString("f2")); // Services.ContentService.Save(earningsContent); // sb.AppendFormat("<p style='orphans: 2; widows: 2; padding: 1px 34px 21px; margin: 0px;'><span style='font-size: 14px; line-height: 21px;'>您购买的产品《{0}》投入了{1}元;昨日的收益是:{2}元</span></p>", product.GetValue<string>("title"), content.GetValue<decimal>("amountCny").ToString("N2"), profit.ToString("N2")); // } // } // else // { // //到期的 将余额提出到账户余额中 // decimal assets = member.GetValue<decimal>("assets"); // member.SetValue("assets", (assets + content.GetValue<decimal>("amountCny")).ToString("f2")); // Services.MemberService.Save(member); // //修改基金到期 // content.SetValue("isexpired", true); // Services.ContentService.Save(content); // } // } // member.SetValue("latestearnings", sumProfit.ToString("f2")); // decimal accumulatedEarnings = member.GetValue<decimal>("accumulatedEarnings"); // member.SetValue("accumulatedEarnings", (accumulatedEarnings + sumProfit).ToString("f2")); // Services.MemberService.Save(member); // //发送邮件通知 // if (sb.Length > 0) // { // sb.AppendFormat("<p style='orphans: 2; widows: 2; padding: 1px 34px 21px; margin: 0px;'><span style='font-size: 14px; line-height: 21px;'>您购买的所有产品总收益:{0}</span></p>", sumProfit.ToString("N2")); // //获取收益通知邮件模板 // Dictionary<string, string> dic = new Dictionary<string, string>(); // dic.Add("{{msg}}", sb.ToString()); // dic.Add("{{name}}", member.Name); // Helpers.SendmailHelper.SendEmail(member.Username, "member:newprofit", dic); // } //} //return Content("test"); }
public ActionResult GetCode(string phone) { try { //member:register:code:tplid Random rand = new Random(); int num = rand.Next(100000, 999999); Session["code"] = num.ToString(); CCPRestSDK api = new CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5514ff457cc014ff868438f0aa5", "63e6fcb07a6843c4b851cc8d6abc2bb5"); api.setAppId("8a48b5514ff457cc014ff86a83330ab9"); Common.CustomLog.WriteLog(isInit.ToString()); if (isInit) { string[] array = new string[] { num.ToString(), "2" }; Dictionary<string, object> retData = api.SendTemplateSMS(phone, "41259", array); Common.CustomLog.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(retData)); if (retData["statusCode"].ToString() == "000000") { return Json(true, JsonRequestBehavior.AllowGet); } } else { return Json(false, JsonRequestBehavior.AllowGet); } //Dictionary<string, string> dir = new Dictionary<string, string>(); //dir.Add("{{code}}", num.ToString()); //Helpers.SendmailHelper.SendEmail(email, "member:register:code:tplid", dir); //return Json(true, JsonRequestBehavior.AllowGet); return Json(false, JsonRequestBehavior.AllowGet); } catch (Exception) { return Json(false, JsonRequestBehavior.AllowGet); } }
public ActionResult Test(string phone) { CCPRestSDK api = new CCPRestSDK(); bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5514ff457cc014ff868438f0aa5", "63e6fcb07a6843c4b851cc8d6abc2bb5"); api.setAppId("8a48b5514ff457cc014ff86a83330ab9"); if (isInit) { Random rand = new Random(); int num = rand.Next(100000, 999999); string[] array = new string[] { num.ToString(), "3" }; Dictionary<string, object> retData = api.SendTemplateSMS(phone, "41259", array); if (retData["statusCode"].ToString() == "000000") { return Json(true, JsonRequestBehavior.AllowGet); } } else { return Json(false, JsonRequestBehavior.AllowGet); } return Content("test"); //获取所有已经购买的产品 //IContentType ct = Services.ContentTypeService.GetContentType("PayRecords"); //IEnumerable<IContent> list = Services.ContentService.GetContentOfContentType(ct.Id).Where(e => e.GetValue<bool>("isdeposit") == true && e.GetValue<bool>("isexpired") == false); //IEnumerable<int> memberids = list.GroupBy(e => e.GetValue<int>("memberPicker")).Select(e => e.Key); //foreach (int memberid in memberids) //{ // decimal sumProfit = 0; // IMember member = Services.MemberService.GetById(memberid); // StringBuilder sb = new StringBuilder(); // //获取product的收益率 // foreach (IContent content in list.Where(e => e.GetValue<int>("memberPicker") == memberid)) // { // //yyyy-MM-dd // if (content.GetValue<DateTime>("expirationtime") > DateTime.Now.AddDays(1)) // { // int productId = content.GetValue<int>("buyproduct"); // IContent product = Services.ContentService.GetById(productId); // int number = 0; // if (int.TryParse(product.GetValue<string>("rate"), out number)) // { // decimal rate = (decimal)number / (decimal)100; // decimal profit = (content.GetValue<decimal>("amountCny") * rate) / (decimal)365; // //修改member的最新收益 // sumProfit += profit; // //记录这次计算结果; // string earningsName = string.Format("{0} ({1})", content.GetValue<string>("username"), profit.ToString("F2")); // IContentType earningsContentType = Services.ContentTypeService.GetContentType("EarningsRecordsElement"); // IContent earningsContent = Services.ContentService.CreateContent(earningsName, earningsContentType.Id, "EarningsRecordsElement"); // earningsContent.SetValue("memberid", memberid); // earningsContent.SetValue("productid", content.Id); // earningsContent.SetValue("earning", profit.ToString("f2")); // Services.ContentService.Save(earningsContent); // sb.AppendFormat("<p style='orphans: 2; widows: 2; padding: 1px 34px 21px; margin: 0px;'><span style='font-size: 14px; line-height: 21px;'>您购买的产品《{0}》投入了{1}元;昨日的收益是:{2}元</span></p>", product.GetValue<string>("title"), content.GetValue<decimal>("amountCny").ToString("N2"), profit.ToString("N2")); // } // } // else // { // //到期的 将余额提出到账户余额中 // decimal assets = member.GetValue<decimal>("assets"); // member.SetValue("assets", (assets + content.GetValue<decimal>("amountCny")).ToString("f2")); // Services.MemberService.Save(member); // //修改基金到期 // content.SetValue("isexpired", true); // Services.ContentService.Save(content); // } // } // member.SetValue("latestearnings", sumProfit.ToString("f2")); // decimal accumulatedEarnings = member.GetValue<decimal>("accumulatedEarnings"); // member.SetValue("accumulatedEarnings", (accumulatedEarnings + sumProfit).ToString("f2")); // Services.MemberService.Save(member); // //发送邮件通知 // if (sb.Length > 0) // { // sb.AppendFormat("<p style='orphans: 2; widows: 2; padding: 1px 34px 21px; margin: 0px;'><span style='font-size: 14px; line-height: 21px;'>您购买的所有产品总收益:{0}</span></p>", sumProfit.ToString("N2")); // //获取收益通知邮件模板 // Dictionary<string, string> dic = new Dictionary<string, string>(); // dic.Add("{{msg}}", sb.ToString()); // dic.Add("{{name}}", member.Name); // Helpers.SendmailHelper.SendEmail(member.Username, "member:newprofit", dic); // } //} //return Content("test"); }