Exemplo n.º 1
0
        /// <summary>
        /// 添加短信发送明细
        /// </summary>
        /// <param name="model">短信发送明细实体</param>
        /// <returns>返回1成功;其他失败</returns>
        public int AddSmsDetail(Model.SmsStructure.MSmsDetail model)
        {
            if (model == null || string.IsNullOrEmpty(model.CompanyId) || model.Amount <= 0 ||
                model.Number == null || string.IsNullOrEmpty(model.Content))
            {
                return(0);
            }

            return(_dal.AddSmsDetail(model));
        }
Exemplo n.º 2
0
        /// <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);
        }