예제 #1
0
 /// <summary>
 /// 发送验证码
 /// </summary>
 /// <param name="mobile">手机号</param>
 /// <param name="code">验证码</param>
 /// <param name="expireMinute">过期时间(分钟)</param>
 /// <returns>0为成功</returns>
 public int SendSMSUserCaptcha(string mobile, string code,int expireMinute)
 {
     try
     {
         //开关,避免测试发送过多短信
         if (smsSendOnOff == "0")
         {
             return 0;
         }
         var tempParamModel = new
         {
             tel = "羊客",
             code = code,
             lifetime = expireMinute.ToString()
         };
         var token = getToken();
         var smsRequestModel = new SMSRequestModel()
         {
             acceptor_tel = mobile,
             access_token = token,
             app_id = appId,
             template_id = regTempId,
             template_param = tempParamModel.ToJson(),
             timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
         };
         var requestParamList = new List<string>();
         requestParamList.Add("acceptor_tel=" + smsRequestModel.acceptor_tel);
         requestParamList.Add("access_token=" + smsRequestModel.access_token);
         requestParamList.Add("app_id=" + smsRequestModel.app_id);
         requestParamList.Add("template_id=" + smsRequestModel.template_id);
         requestParamList.Add("template_param=" + smsRequestModel.template_param);
         requestParamList.Add("timestamp=" + smsRequestModel.timestamp);
         var sign = getSign(requestParamList);
         requestParamList.Add("sign=" + sign);
         var content = string.Join("&", requestParamList);
         logger.Info("登录短信接口content:" + content);
         var returnJson = Post(templateUrl, content);
         logger.Info("登录短信接口返回:" + returnJson);
         var smsResponseModel = JsonHelper.FromJson<SMSResponseModel>(returnJson);
         return smsResponseModel.res_code;
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         return 1;
     }
    
 }
예제 #2
0
 /// <summary>
 /// 发送订单提交成功短信
 /// </summary>
 /// <param name="mobile">手机号</param>
 /// <param name="orderId">订单金额</param>
 /// <param name="totalPrice">总价</param>
 /// <returns>0为成功</returns>
 public int SendSMSOrderCreated(string mobile,long orderId, decimal totalPrice)
 {
     try
     {
         //开关,避免测试发送过多短信
         if (smsSendOnOff == "0")
         {
             return 0;
         }
         var tempParamModel = new
         {
             order_sn = orderId,
             price = totalPrice
         };
         var token = getToken();
         var smsRequestModel = new SMSRequestModel()
         {
             acceptor_tel = mobile,
             access_token = token,
             app_id = appId,
             template_id = orderTempId,
             template_param = tempParamModel.ToJson(),
             timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
         };
         var requestParamList = new List<string>();
         requestParamList.Add("acceptor_tel=" + smsRequestModel.acceptor_tel);
         requestParamList.Add("access_token=" + smsRequestModel.access_token);
         requestParamList.Add("app_id=" + smsRequestModel.app_id);
         requestParamList.Add("template_id=" + smsRequestModel.template_id);
         requestParamList.Add("template_param=" + smsRequestModel.template_param);
         requestParamList.Add("timestamp=" + smsRequestModel.timestamp);
         var sign = getSign(requestParamList);
         requestParamList.Add("sign=" + sign);
         var content = string.Join("&", requestParamList);
         content = System.Web.HttpUtility.UrlEncode(content);
         
         var returnJson = Post(templateUrl, content);
         var smsResponseModel = JsonHelper.FromJson<SMSResponseModel>(returnJson);
         logger.Info("订单短信接口返回:" + returnJson);
         return smsResponseModel.res_code;
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         return 1;
     }
     
 }
예제 #3
0
 public int SendSMSPreOrderSendProduct(string mobile, string id)
 {
     try
     {
         //开关,避免测试发送过多短信
         if (smsSendOnOff == "0")
         {
             return 0;
         }
         var tempParamModel = new
         {
             id = id
         };
         var token = getToken();
         var smsRequestModel = new SMSRequestModel()
         {
             acceptor_tel = mobile,
             access_token = token,
             app_id = appId,
             template_id = "91550003",
             template_param = tempParamModel.ToJson(),
             timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
         };
         var requestParamList = new List<string>();
         requestParamList.Add("acceptor_tel=" + smsRequestModel.acceptor_tel);
         requestParamList.Add("access_token=" + smsRequestModel.access_token);
         requestParamList.Add("app_id=" + smsRequestModel.app_id);
         requestParamList.Add("template_id=" + smsRequestModel.template_id);
         requestParamList.Add("template_param=" + smsRequestModel.template_param);
         requestParamList.Add("timestamp=" + smsRequestModel.timestamp);
         var sign = getSign(requestParamList);
         requestParamList.Add("sign=" + sign);
         var content = string.Join("&", requestParamList);
         //content = System.Web.HttpUtility.UrlEncode(content);
         logger.Info("预售订单发货短信接口返回content:" + content);
         var returnJson = Post(templateUrl, content);
         var smsResponseModel = JsonHelper.FromJson<SMSResponseModel>(returnJson);
         logger.Info("预售订单发货短信接口返回:" + returnJson);
         return smsResponseModel.res_code;
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         return 1;
     }
 }