Beispiel #1
0
        /// <summary>
        /// 发送出团提醒短信
        /// </summary>
        /// <param name="model">出回团提醒短信任务实体</param>
        /// <param name="message">短信内容(未替换)</param>
        private void SendMessage(MSmsTourTimePlan model, string message)
        {
            if (model == null || string.IsNullOrEmpty(model.CompanyId) || model.Traveller == null ||
                model.Traveller.Count < 1 || string.IsNullOrEmpty(message))
            {
                return;
            }

            string smscontent = message.Replace("[线路名称]", model.RouteName).Replace("[出团时间]", model.LeaveTime.ToString("yyyy-MM-dd")).Replace("[集合方式]", model.Gather).Replace("[本团导游]", model.DaoYouName).Replace("[导游电话]", model.DaoYouTelephone);

            foreach (var t in model.Traveller)
            {
                var sendMessage = new EyouSoft.BackgroundServices.SmsApi.MSendMessage
                {
                    CompanyId = model.CompanyId,
                    Mobiles   =
                        new[] { new EyouSoft.BackgroundServices.SmsApi.MSmsNumber {
                                    Code = t.Code
                                } },
                    SendChannel  = 0,
                    SendTime     = DateTime.Now,
                    SendType     = SendType.直接发送,
                    SmsContent   = smscontent.Replace("[游客姓名]", t.Traveller),
                    UserFullName = string.Empty,                      //直接包含在内容中
                    UserId       = model.SellerId
                };

                SmsUtils.GetSmsApi().SendMessage(sendMessage);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 根据公司编号获取待发送的短信实体
        /// </summary>
        /// <param name="companyId">公司编号</param>
        /// <param name="beforeDay">提前X天</param>
        /// <param name="settingType">类型</param>
        /// <returns></returns>
        public IList <MSmsTourTimePlan> GetSmsTourTimePlanByType(string companyId, int beforeDay, SettingType settingType)
        {
            IList <MSmsTourTimePlan> list = new List <MSmsTourTimePlan>();

            if (string.IsNullOrEmpty(companyId))
            {
                return(list);
            }

            if (beforeDay < 0)
            {
                beforeDay = 0;
            }
            DateTime cTime = DateTime.Now.AddDays(beforeDay);

            #region Sql语句构造

            var strSql = new StringBuilder();
            //团队信息
            strSql.Append(" select CompanyId,TourId,LDate,RDate,Gather,SellerId ");
            //游客信息
            strSql.Append(" ,(select TravellerId,CnName,Contact from tbl_TourOrderTraveller where OrderId in ");
            //订单编号条件
            strSql.AppendFormat(
                " (select OrderId from tbl_TourOrder where tbl_TourOrder.TourId = tbl_Tour.TourId and tbl_TourOrder.[Status] = {0} and tbl_TourOrder.IsDelete = '0') ",
                (int)Model.EnumType.TourStructure.OrderStatus.已成交);
            strSql.AppendFormat(" and [Status] = {0}  ", (int)Model.EnumType.TourStructure.TravellerStatus.在团);
            string strTmp     = string.Empty;
            string strTmpTour = string.Empty;
            switch (settingType)
            {
            case SettingType.出团通知:
                strTmp     = " and [LNotice] = '1' ";
                strTmpTour = string.Format(" and year(LDate) = {0} and month(LDate) = {1} and day(LDate) = {2} ",
                                           cTime.Year, cTime.Month, cTime.Day);
                break;

            case SettingType.回团通知:
                strTmp     = " and [RNotice] = '1' ";
                strTmpTour = string.Format(" and year(RDate) = {0} and month(RDate) = {1} and day(RDate) = {2} ",
                                           cTime.Year, cTime.Month, cTime.Day);
                break;
            }
            strSql.Append(strTmp);
            strSql.Append(" for xml raw,root('root')) as TravellerInfo ");

            strSql.Append(" ,RouteName ");
            strSql.Append(" ,(SELECT SourceName,ContactPhone FROM tbl_Plan AS B WHERE B.TourId=tbl_Tour.TourId AND B.IsDelete='0' AND [Status]=4 FOR XML RAW,ROOT('root')) AS DaoYouXml ");

            strSql.Append(" from tbl_Tour where IsDelete = '0' ");
            strSql.Append(strTmpTour);
            strSql.AppendFormat(" and tbl_Tour.CompanyId = '{0}' ", companyId);
            strSql.Append(" and exists (");
            strSql.AppendFormat(" select 1 from tbl_TourOrder where tbl_TourOrder.TourId = tbl_Tour.TourId AND tbl_TourOrder.IsDelete='0' AND tbl_TourOrder.Status={0} ", (int)Model.EnumType.TourStructure.OrderStatus.已成交);
            strSql.Append(" and exists (select 1 from tbl_TourOrderTraveller where tbl_TourOrderTraveller.OrderId = tbl_TourOrder.OrderId and Contact is not null and Contact <> '' ");
            strSql.Append(strTmp);
            strSql.Append(" ) ");
            strSql.Append(" ) ");

            #endregion

            DbCommand dc = _db.GetSqlStringCommand(strSql.ToString());

            using (IDataReader dr = DbHelper.ExecuteReader(dc, _db))
            {
                MSmsTourTimePlan model;
                while (dr.Read())
                {
                    model = new MSmsTourTimePlan();
                    if (!dr.IsDBNull(dr.GetOrdinal("CompanyId")))
                    {
                        model.CompanyId = dr.GetString(dr.GetOrdinal("CompanyId"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("TourId")))
                    {
                        model.TourId = dr.GetString(dr.GetOrdinal("TourId"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("LDate")))
                    {
                        model.LeaveTime = dr.GetDateTime(dr.GetOrdinal("LDate"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("RDate")))
                    {
                        model.BackTime = dr.GetDateTime(dr.GetOrdinal("RDate"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("Gather")))
                    {
                        model.Gather = dr.GetString(dr.GetOrdinal("Gather"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("SellerId")))
                    {
                        model.SellerId = dr.GetString(dr.GetOrdinal("SellerId"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("TravellerInfo")))
                    {
                        model.Traveller = GetTravellerListByXml(dr.GetString(dr.GetOrdinal("TravellerInfo")));
                    }

                    string[] daoyou = ParseDaoYouXml(dr["DaoYouXml"].ToString());

                    model.DaoYouName      = daoyou[0];
                    model.DaoYouTelephone = daoyou[1];
                    model.RouteName       = dr["RouteName"].ToString();

                    list.Add(model);
                }
            }

            return(list);
        }