/// <summary> /// 获取短信账户信息 /// </summary> /// <param name="companyId">公司编号</param> /// <returns></returns> public EyouSoft.Model.SmsStructure.MSmsAccountInfo GetAccountInfo(string companyId) { if (string.IsNullOrEmpty(companyId)) { return(null); } var setting = new EyouSoft.BLL.ComStructure.BComSetting().GetModel(companyId); if (setting == null || setting.SmsConfig == null || !setting.SmsConfig.IsEnabled) { return(null); } var api = GetSmsCenterApi(); var account = new EyouSoft.BLL.SmsCenter.MSmsAccountBase(); account.AccountId = setting.SmsConfig.Account; account.AppKey = setting.SmsConfig.AppKey; account.AppSecret = setting.SmsConfig.AppSecret; var apiRetInfo = api.GetSmsAccount(account); if (apiRetInfo != null) { var info = new EyouSoft.Model.SmsStructure.MSmsAccountInfo(); info.Account = apiRetInfo.AccountId; info.AppKey = apiRetInfo.AppKey; info.AppSecret = apiRetInfo.AppSecret; info.YuE = apiRetInfo.Amount; if (apiRetInfo.SmsUnitPrice != null && apiRetInfo.SmsUnitPrice.Length > 0) { info.Prices = new List <EyouSoft.Model.SmsStructure.MSmsPriceInfo>(); foreach (var item in apiRetInfo.SmsUnitPrice) { var tmp = new EyouSoft.Model.SmsStructure.MSmsPriceInfo(); tmp.ChannelIndex = (int)item.Cnannel; tmp.Price = item.Price; tmp.ChannelName = item.Name; info.Prices.Add(tmp); } } return(info); } return(null); }
/// <summary> /// 构造短信中心的短信帐号信息实体 /// </summary> /// <param name="companyId">当前系统公司编号</param> /// <returns></returns> private SmsCenter.MSmsAccountBase GetSmsAccount(string companyId) { if (string.IsNullOrEmpty(companyId)) { return(null); } var setting = new EyouSoft.BLL.ComStructure.BComSetting().GetModel(companyId); if (setting == null || setting.SmsConfig == null || !setting.SmsConfig.IsEnabled) { return(null); } var info = new EyouSoft.BLL.SmsCenter.MSmsAccountBase(); info.AccountId = setting.SmsConfig.Account; info.AppKey = setting.SmsConfig.AppKey; info.AppSecret = setting.SmsConfig.AppSecret; return(info); }
/// <summary> /// 设置短信账户价格信息 /// </summary> /// <param name="accountId">短信账户编号</param> /// <param name="appKey">短信账户appKey</param> /// <param name="appSecret">短信账户appSecret</param> /// <param name="items">价格信息集合</param> /// <returns></returns> bool SetSmsPrices(string accountId, string appKey, string appSecret, IList <EyouSoft.Model.SmsStructure.MSmsPriceInfo> items) { var api = GetSmsWebmasterCenterApi(); var account = new EyouSoft.BLL.SmsCenter.MSmsAccountBase(); var prices = new EyouSoft.BLL.SmsCenter.MSmsChannelInfo[items.Count]; account.AccountId = accountId; account.AppKey = appKey; account.AppSecret = appSecret; int i = 0; foreach (var item in items) { prices[i] = new EyouSoft.BLL.SmsCenter.MSmsChannelInfo(); prices[i].Cnannel = (EyouSoft.BLL.SmsCenter.Channel)item.ChannelIndex; prices[i].Price = item.Price; i++; } return(api.SetSmsUnitPrices(account, prices) == 1); }