/// <summary> /// 更新短信设置 /// </summary> /// <param name="user"></param> /// <returns></returns> internal bool UpdateAccountSMS(SMS.Model.EnterpriseUser user) { try { var rc = SMSProxy.GetSMSService().GetChannel(user.Channel); if (rc.Success) { Channel c = rc.Value; user.SMSType = c.SMSType; } else { return(false); } bool ok = EnterpriseUserDB.UpdateAccountSMS(user); if (ok) { SMS.Model.EnterpriseUser account = GetAccountFromDB(user.AccountCode); CacheManager <SMS.Model.EnterpriseUser> .Instance.Set(account.AccountCode, account); } return(ok); } catch (Exception ex) { } return(false); }
public RPC_Result <SMS.DTO.SMSDTO> SendSMS(string LoginName, string Password, SMS.DTO.SMSDTO sms, string Source) { if (string.IsNullOrWhiteSpace(LoginName)) { return(new RPC_Result <SMS.DTO.SMSDTO>(false, sms, "用户名不能为空")); } //权限验证 var account = AccountServer.Instance.GetAccount(LoginName); if (account == null) { return(new RPC_Result <SMS.DTO.SMSDTO>(false, sms, "用户不存在")); } if (Password != account.Password) { return(new RPC_Result <SMS.DTO.SMSDTO>(false, sms, "密码不正确")); } int Priority = SMS.Util.SMSHelper.GetPriorityByNumberCount(sms.Message.NumberCount); sms.Message.Source = Source; sms.Message.AccountID = account.AccountID; sms.Message.Channel = account.Channel; sms.Message.SMSLevel = Priority + account.Priority; sms.Message.SPNumber = account.SPNumber; sms.Message.StatusReportType = (int)account.StatusReport; if (account.Audit == SMS.Model.AccountAuditType.NonAudit) { sms.Message.AuditType = AuditType.Auto; sms.Message.Status = "待发送"; } else if (account.Audit == SMS.Model.AccountAuditType.SingleNonAudit && sms.Message.NumberCount == 1) { sms.Message.AuditType = AuditType.Auto; sms.Message.Status = "待发送"; } else if (account.Audit == SMS.Model.AccountAuditType.InterfaceNonAudit && sms.Message.Source != "平台") { sms.Message.AuditType = AuditType.Auto; sms.Message.Status = "待发送"; } else { //判断是否匹配模板 bool match = SMSTempletMatching(LoginName, sms.Message.Content); if (match) { sms.Message.AuditType = AuditType.Template; sms.Message.Status = "待发送"; } else { sms.Message.AuditType = AuditType.Manual; sms.Message.Status = "待审核"; } } return(SMSProxy.GetSMSService().SendSMS(sms)); }
/// <summary> /// 添加企业 /// </summary> /// <param name="user"></param> /// <returns></returns> public SMS.Model.RPCResult ISMPAddEnterprise(SMS.Model.EnterpriseUser user) { try { if (user.AccountCode == "-1") { return(new SMS.Model.RPCResult(false, "已存在此企业帐号")); } SMS.Model.EnterpriseUser a = AccountServer.Instance.GetAccount(user.AccountCode); if (a != null) { return(new SMS.Model.RPCResult(false, "已存在此企业帐号")); } if (string.IsNullOrEmpty(user.Signature)) { return(new SMS.Model.RPCResult(false, "企业签名不能为空")); } SMS.Model.Account account = new SMS.Model.Account(); account.AccountID = ""; account.SMSNumber = 0; if (!string.IsNullOrWhiteSpace(user.AccountID)) { account.AccountID = user.AccountID; } SMS.Model.RPCResult <Guid> r = SMSProxy.GetSMSService().CreateAccount(account); if (!r.Success) { return(new SMS.Model.RPCResult(false, r.Message)); } user.AccountID = r.Value.ToString(); user.Signature = "【" + user.Signature + "】"; user.Channel = user.Channel == "-1-" ? "" : user.Channel; user.SecretKey = ""; user.AppPassword = DESEncrypt.Encrypt(user.Password, user.AccountID); user.Password = DESEncrypt.Encrypt(user.Password); bool ok = AccountServer.Instance.CreateAccount(user); if (ok) { return(new SMS.Model.RPCResult(true, "创建成功")); } return(new SMS.Model.RPCResult(false, "创建失败")); } catch { return(new SMS.Model.RPCResult(false, "创建失败")); } }
/// <summary> /// 获取短信统计 /// </summary> /// <param name="BeginDate"></param> /// <param name="EndDate"></param> /// <returns></returns> public SMS.Model.RPCResult <List <string> > GetSMSStatisticsAll(DateTime BeginDate, DateTime EndDate) { var Enterprises = AccountServer.Instance.GetAccounts(); //取当前余额 var Balance = SMSProxy.GetSMSService().GetAccounts().Value; //获取指定时间范围内,充值金额 var ChargeStatics = ChargeRecordDB.GetChargeStatics(BeginDate.Date, EndDate.AddDays(1).Date); //获取 var ReportStatistics = SMSProxy.GetSMSService().GetStatisticsReportAll(BeginDate.Date, EndDate.Date).Value; var qry = from e in Enterprises join b in Balance on e.AccountID equals b.AccountID into EnterpriseBalance from eb in EnterpriseBalance.DefaultIfEmpty() join r in (from t in ReportStatistics group t by new { t.AccountID, t.Channel } into g select new { Account = g.Key.AccountID, Channel = g.Key.Channel, SendCount = g.Sum(t => t.SendCount), Succeed = g.Sum(t => t.SuccessCount) }) on e.AccountID equals r.Account into EnterpriseReport from er in EnterpriseReport.DefaultIfEmpty() join c in ChargeStatics on e.AccountCode equals c.Enterprese into EnterpriseCharge from ec in EnterpriseCharge.DefaultIfEmpty() select Newtonsoft.Json.JsonConvert.SerializeObject( new { EnterpriseCode = e.AccountCode, AccountId = e.AccountID, Channel = e.Channel, ChargeCount = ec == null ? 0 : ec.SMSCount, ChargeMoney = ec == null ? 0 : ec.TotalMoney, SendCount = er == null ? 0 : er.SendCount, Succeed = er == null ? 0 : er.Succeed, Balance = eb == null ? 0 : eb.SMSNumber }); return(new SMS.Model.RPCResult <List <string> >(true, qry.ToList(), "")); }
public SMS.Model.RPCResult <List <SMS.Model.Keywords> > GetAllKeywords() { var list = SMSProxy.GetSMSService().GetAllKeywords(0, 100000000); return(new SMS.Model.RPCResult <List <SMS.Model.Keywords> >(true, list.Value.Values.FirstOrDefault(), "")); }
/// <summary> /// 审核短信 -失败 /// </summary> /// <param name="AuditAccountLoginName"></param> /// <param name="SMSIDList"></param> /// <param name="FailureCase"></param> /// <returns></returns> public RPC_Result AuditSMSFailure(string AuditAccountLoginName, List <string> SMSIDList, string FailureCase) { return(SMSProxy.GetSMSService().AuditSMSFailure(AuditAccountLoginName, SMSIDList, FailureCase)); }
/// <summary> /// 获取待审核短信 /// </summary> /// <param name="qp"></param> /// <returns></returns> public RPC_Result <QueryResult <SMSMessage> > GetSMSForAudit(QueryParams qp) { return(SMSProxy.GetSMSService().GetSMSForAudit(qp)); }
/// <summary> /// 获取审核失败原因列表 /// </summary> /// <returns></returns> public RPC_Result <List <AuditFailureReason> > GetAuditFailureReasonList() { return(SMSProxy.GetSMSService().GetAuditFailureReasonList()); }
/// <summary> /// 根据短信ID 获取号码 /// </summary> /// <param name="SMSID"></param> /// <returns></returns> public RPC_Result <string> GetSMSNumbersBySMSID(string SMSID) { return(SMSProxy.GetSMSService().GetSMSNumbersBySMSID(SMSID)); }
/// <summary> /// 查询短信发送记录 /// </summary> /// <param name="qp"></param> /// <returns></returns> public RPC_Result <QueryResult <SMSMessage> > GetSMSListByAccountID(string AccountID, QueryParams qp) { qp.add("AccountID", AccountID); return(SMSProxy.GetSMSService().GetSMSList(qp)); }
public RPC_Result <List <NumSect> > GetNumSect() { return(SMSProxy.GetSMSService().GetNumSect()); }
/// <summary> /// 审核短信 - 成功 /// </summary> /// <param name="AuditAccountLoginName"></param> /// <param name="SMSIDList"></param> /// <returns></returns> public RPC_Result AuditSMSSuccess(string AuditAccountLoginName, List <string> SMSIDList, string SendChannel) { return(SMSProxy.GetSMSService().AuditSMSSuccess(AuditAccountLoginName, SMSIDList, SendChannel)); }