/// <summary> /// 短信发送列表 /// </summary> /// <param name="iPage">当前页数</param> /// <param name="accId">店铺Id</param> /// <param name="smsType">短信类型</param> /// <param name="smsStatus">短信状态</param> /// <param name="priority">通道优先级</param> /// <param name="bgDate">开始日期</param> /// <param name="edDate">结束日期</param> /// <returns></returns> public static SmsListModel GetSmsList(int iPage, int accId, int smsType, int smsStatus, int priority, DateTime bgDate, DateTime edDate) { var dal = new T_Sms_ListDAL(); var smsObj = dal.GetSmsList(iPage, accId, smsType, smsStatus, priority, bgDate, edDate); if (smsObj != null && smsObj.Data != null && smsObj.Data.Count > 0) { foreach (var item in smsObj.Data) { item.SmsTypeName = Enum.GetName(typeof(smsEnum.smsType), item.SmsType); item.StatusName = Enum.GetName(typeof(smsEnum.smsStatus), item.SmsStatus); item.ReviewName = Enum.GetName(typeof(smsEnum.smsReview), item.Review); item.PriorityName = Enum.GetName(typeof(smsEnum.smsPriority), item.Priority); item.ContentLength = item.SmsContent.Length; } //分页处理 //smsObj.PageHtml = CommonLib.Helper.GetPagination(iPage, smsObj.PageSize, "SmsListData", 20); } else { smsObj = new SmsListModel(); } return(smsObj); }
public string GetSmsList(int iPage = 1, int accId = 0, int priorityType = -99, int sendType = -99, int smsType = -99, string timePeriod = "7", string start = "", string end = "") { DateTime st = DateTime.Now.AddDays(-6); DateTime ed = DateTime.Now; switch (timePeriod) { case "7": st = DateTime.Now.AddDays(-6); break; case "15": st = DateTime.Now.AddDays(-14); break; case "30": st = DateTime.Now.AddDays(-29); break; case "other": ed = Convert.ToDateTime(end); st = Convert.ToDateTime(start); break; default: break; } SmsListModel smsList = SmsList.GetSmsList(iPage, accId, smsType, sendType, priorityType, st, ed); smsList.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(smsList.rowCount) / 20)); return(CommonLib.Helper.JsonSerializeObject(smsList, "yyyy-MM-dd HH:mm")); }
/// <summary> /// 短信发送列表 /// </summary> /// <param name="iPage">当前页数</param> /// <param name="accId">店铺Id</param> /// <param name="smsType">短信类型</param> /// <param name="smsStatus">短信状态</param> /// <param name="priority">通道优先级</param> /// <param name="bgDate">开始日期</param> /// <param name="edDate">结束日期</param> /// <returns></returns> public SmsListModel GetSmsList(int iPage, int accId, int smsType, int smsStatus, int priority, DateTime bgDate, DateTime edDate) { var smsListModel = new SmsListModel(); var strSql = new StringBuilder(); var strWhereSql = new StringBuilder(); if (priority != -99) { //发送优先级 strWhereSql.Append(" priority=@priority"); } else { //发送优先级 strWhereSql.Append(" priority>-2"); } if (accId != 0) { //店铺Id strWhereSql.Append(" and accID=@accID"); } if (smsType != -99) { //短信类型 strWhereSql.Append(" and smsType=@smsType"); } if (smsStatus != -99) { //短信状态 strWhereSql.Append(" and smsStatus=@smsStatus"); } if (bgDate != null && edDate != null) { //指定时间方式 bgDate = Convert.ToDateTime(Convert.ToDateTime(bgDate).ToShortDateString()); edDate = Convert.ToDateTime(Convert.ToDateTime(edDate).ToShortDateString()).AddHours(23).AddMinutes(59).AddSeconds(59); strWhereSql.Append(" and submitTime between @bgDate and @edDate"); } strSql.Append(" select count(id) [rowCount],sum(totalSmsCnt) as SmsCnt,"); strSql.Append(" sum(realSmsCnt) as RealCnt,"); strSql.Append(" sum(case when isFree=1 then realSmsCnt else 0 end) as FreeCnt"); strSql.Append(" from T_Sms_Notify"); if (strWhereSql.Length > 0) { strSql.Append(" where" + strWhereSql.ToString()); } smsListModel = HelperForFrontend.Query <SmsListModel>(strSql.ToString(), new { bgDate = bgDate, edDate = edDate, priority = priority, accID = accId, smsType = smsType, smsStatus = smsStatus, }).ToList()[0]; strSql.Clear(); strSql.Append(" select TT.*,T_Account.CompanyName StoreName from (select row_number() over(order by completeTime desc) as rowNumer,"); strSql.Append(" id, accID, userCnt, smsContent, smsType, useBalance, priority, succeedCnt, failCnt, skipCnt, smsStatus, submitTime, RegularTime, completeTime, smsChannel, totalSmsCnt, realSmsCnt, isFree,errDesc, ChannelEx,PhoneList,ReviewDesc"); strSql.Append(" FROM T_Sms_Notify"); if (strWhereSql.Length > 0) { strSql.Append(" where" + strWhereSql.ToString()); } strSql.Append(" ) TT"); strSql.Append(" left outer join T_Account on T_Account.id=TT.accID"); strSql.Append(" where TT.rowNumer between @startIndex and @endIndex"); //页数计算 int bgNumber = ((iPage - 1) * 20) + 1; int edNumber = (iPage) * 20; List <SmsNotifyItem> itemList = HelperForFrontend.Query <SmsNotifyItem>(strSql.ToString(), new { priority = priority, accID = accId, smsType = smsType, smsStatus = smsStatus, bgDate = bgDate, edDate = edDate, startIndex = bgNumber, endIndex = edNumber }).ToList(); smsListModel.Data = itemList; return(smsListModel); }
public IActionResult SMSList(SmsSearchModel searchModel) { var storeId = _storeContext.ActiveStoreScopeConfiguration; var sendinBlueSettings = _settingService.LoadSetting <SendinBlueSettings>(storeId); //get message templates which are sending in SMS var messageTemplates = _messageTemplateService.GetAllMessageTemplates(storeId) .Where(messageTemplate => _genericAttributeService.GetAttribute <bool>(messageTemplate, SendinBlueDefaults.UseSmsAttribute)) .ToList().ToPagedList(searchModel); //prepare list model var model = new SmsListModel().PrepareToGrid(searchModel, messageTemplates, () => { return(messageTemplates.Select(messageTemplate => { var phoneTypeID = _genericAttributeService.GetAttribute <int>(messageTemplate, SendinBlueDefaults.PhoneTypeAttribute); var smsModel = new SmsModel { Id = messageTemplate.Id, MessageId = messageTemplate.Id, Name = messageTemplate.Name, PhoneTypeId = phoneTypeID, Text = _genericAttributeService.GetAttribute <string>(messageTemplate, SendinBlueDefaults.SmsTextAttribute) }; if (storeId == 0) { if (storeId == 0 && messageTemplate.LimitedToStores) { var storeIds = _storeMappingService.GetStoresIdsWithAccess(messageTemplate); var storeNames = _storeService.GetAllStores().Where(store => storeIds.Contains(store.Id)).Select(store => store.Name); smsModel.Name = $"{smsModel.Name} ({string.Join(',', storeNames)})"; } } //choose phone number to send SMS //currently supported: "my phone" (filled on the configuration page), customer phone, phone of the billing address switch (phoneTypeID) { case 0: smsModel.PhoneType = _localizationService.GetResource("Plugins.Misc.SendinBlue.MyPhone"); break; case 1: smsModel.PhoneType = _localizationService.GetResource("Plugins.Misc.SendinBlue.CustomerPhone"); break; case 2: smsModel.PhoneType = _localizationService.GetResource("Plugins.Misc.SendinBlue.BillingAddressPhone"); break; default: break; } return smsModel; })); }); return(Json(model)); }