public ActionResult SendSms(int id) { string errMsg = string.Empty; var userIDs = getFinalBiddingInfoList(id).GroupBy(g => g.UserID).Select(o => o.Key).ToList(); IBase_UserInfoService base_UserInfoService = BLLContainer.Resolve <IBase_UserInfoService>(); var userMobiles = base_UserInfoService.GetModels(p => userIDs.Contains(p.ID)).Select(o => o.Mobile).ToList(); string phones = string.Join(",", userMobiles); IData_SmsManageService data_SmsManageService = BLLContainer.Resolve <IData_SmsManageService>(); var data_SmsManage = new Data_SmsManage(); data_SmsManage.CreateTime = DateTime.Now; data_SmsManage.Phones = phones; data_SmsManage.State = (int)SmsType.Send; if (!data_SmsManageService.Add(data_SmsManage)) { return(RedirectToAction("NoticePublish", "NoticeManage", new { errMsg = "发送失败" })); } //发送短信 if (!SMSBusiness.SendSMSNotice("2", data_SmsManage.Phones, "", out errMsg)) { return(RedirectToAction("NoticePublish", "NoticeManage", new { errMsg = errMsg })); } return(RedirectToAction("NoticePublish", "NoticeManage", new { errMsg = "发送成功" })); }
// GET: SmsManage public ActionResult SendSms(string phones, string message, int id = 0) { string errMsg = string.Empty; if (string.IsNullOrEmpty(phones)) { errMsg = "手机号不能不能为空"; return(RedirectToAction("Index", "SmsManage", new { errMsg = errMsg })); } if (string.IsNullOrEmpty(message)) { errMsg = "短信内容不能为空"; return(RedirectToAction("Index", "SmsManage", new { errMsg = errMsg })); } IData_SmsManageService data_SmsManageService = BLLContainer.Resolve <IData_SmsManageService>(); var data_SmsManage = new Data_SmsManage(); if (id == 0) { data_SmsManage.CreateTime = DateTime.Now; data_SmsManage.Message = message; data_SmsManage.Phones = phones.Replace(",", ","); data_SmsManage.State = (int)SmsType.Send; if (!data_SmsManageService.Add(data_SmsManage)) { return(RedirectToAction("Index", "SmsManage", new { errMsg = "发送失败" })); } } else { data_SmsManage = data_SmsManageService.GetModels(p => p.ID == id).FirstOrDefault(); data_SmsManage.Message = message; data_SmsManage.Phones = phones.Replace(",", ","); if (!data_SmsManageService.Update(data_SmsManage)) { return(RedirectToAction("Index", "SmsManage", new { errMsg = "发送失败" })); } } //发送短信 if (!SMSBusiness.SendSMSNotice("1", data_SmsManage.Phones, data_SmsManage.Message, out errMsg)) { return(RedirectToAction("Index", "SmsManage", new { errMsg = errMsg })); } return(RedirectToAction("Index", "SmsManage", new { errMsg = "发送成功" })); }