/// <summary> /// 发送短信/定时发送 /// </summary> /// <param name="sendMessage">发送短信提交的业务实体</param> /// <returns></returns> public Model.SmsStructure.MSendResult Send(Model.SmsStructure.MSendMessage sendMessage) { var model = new Model.SmsStructure.MSendResult(); if (sendMessage == null) { model.IsSucceed = false; model.ErrorMessage = "没有构造发送短信实体"; return(model); } if (sendMessage.SendType == SendType.直接发送) { model = DirectlySend(sendMessage); } else if (sendMessage.SendType == SendType.定时发送) { model = TimeSend(sendMessage); } return(model); }
/// <summary> /// 直接发送 /// </summary> /// <param name="sendMessage">发送短信实体</param> /// <returns></returns> private Model.SmsStructure.MSendResult DirectlySend(Model.SmsStructure.MSendMessage sendMessage) { var sysModel = new Model.SmsStructure.MSendResult(); if (sendMessage == null) { sysModel.IsSucceed = false; sysModel.ErrorMessage = "没有构造发送短信实体"; return(sysModel); } var smsPlan = new SmsCenter.MSmsPlan { Channel = (SmsCenter.Channel)Convert.ToInt32(sendMessage.SendChannel), Content = sendMessage.SmsContentSendComplete, IssueTime = DateTime.Now, Number = GetSmsNumber(sendMessage.Mobiles).ToArray(), PlanId = string.Empty, SendAmount = 0, SmsAccount = GetSmsAccount(sendMessage.CompanyId), IsSend = false, SendTime = null, UnitPrice = 0 }; SmsCenter.MSendResult smsModel = _smsCenter.SendMessage(smsPlan); if (smsModel == null) { sysModel.IsSucceed = false; sysModel.ErrorMessage = "未知错误"; return(sysModel); } //写系统发送短信明细 if (smsModel.IsSucceed) { var detailModel = new Model.SmsStructure.MSmsDetail { Amount = smsModel.CountFee, Channel = sendMessage.SendChannel, CompanyId = sendMessage.CompanyId, Content = sendMessage.SmsContentSendComplete, IssueTime = DateTime.Now, Number = sendMessage.Mobiles, OperatorId = sendMessage.UserId, PlanId = string.Empty, Status = SendStatus.发送成功, StatusDesc = string.Empty }; _smsBll.AddSmsDetail(detailModel); } sysModel.AccountMoney = smsModel.AccountMoney; sysModel.CountFee = smsModel.CountFee; sysModel.ErrorMessage = smsModel.ErrorMessage; sysModel.FactCount = smsModel.FactCount; sysModel.IsSucceed = smsModel.IsSucceed; sysModel.MobileNumberCount = smsModel.MobileNumberCount; sysModel.PhsFactCount = smsModel.PhsFactCount; sysModel.PhsNumberCount = smsModel.PhsNumberCount; sysModel.PhsSuccessCount = smsModel.PhsSuccessCount; sysModel.SmsCenterPlanId = smsModel.SmsCenterPlanId; sysModel.SuccessCount = smsModel.SuccessCount; return(sysModel); }