/// <summary> /// 全屏点赞 /// </summary> public void Praise() { QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Init); if (RunStatus != RunStatus.Sucess && CodeStatus != CodeStatus.NotNeedCode) { Check(); } else { try { _miniBrowser.DownloadString(IndexPage, Praise); } catch (Exception ex) { RunStatus = RunStatus.Fail; QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Fail); CodeStatus = CodeStatus.NeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NeedCode); Log4Logger.Error(UserName + " Login失败!\r\n" + ex.Message, ex); MailLogger.LogError(UserName + " Login失败!\r\n" + ex.Message, ex); QqMsgLogger.LogError(UserName + " Login失败!", ex); } } }
/// <summary> /// 向ISMP发送日志 /// </summary> /// <param name="module"></param> /// <param name="logMessage"></param> /// <param name="logDetail"></param> /// <param name="operationType"></param> /// <param name="currentUser"></param> /// <returns></returns> public static bool SendSystemLogToISMP(string module, string logMessage, string logDetail, string operationType, ISMPUser currentUser) { try { Sys_Log log = new Sys_Log { AccountId = currentUser.OperatorAccountId, LoginName = currentUser.OperatorLoginName, Platform = Util.SMSProductId, Module = module, LogMessage = logMessage, LogType = LogType.Operation, LogTime = DateTime.Now, Log = logDetail, OperationType = operationType, IPAddress = currentUser.IPAddress }; string Param = JsonSerialize.Instance.Serialize <Sys_Log>(log); string url = Util.ISMPHost + "/CallBack/LogOperation?"; url += "Param=" + System.Web.HttpUtility.UrlEncode(Param); string resultISMP = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8); var o = JsonConvert.DeserializeAnonymousType(resultISMP, new { success = true, message = string.Empty }); return(o.success); } catch (Exception ex) { Log4Logger.Error(ex); return(false); } }
/// <summary> /// 登录 /// </summary> /// <param name="scrapingBrowser"></param> /// <param name="htmlStr"></param> private void Login(ScrapingBrowser scrapingBrowser, string htmlStr) { if (htmlStr.Contains("登录成功")) { Log4Logger.Info(UserName + "登录成功!\r\n" + htmlStr); RunStatus = RunStatus.Sucess; QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Sucess); CodeStatus = CodeStatus.NotNeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NotNeedCode); scrapingBrowser.DownloadString(IndexPage, Praise); } else { RunStatus = RunStatus.Fail; QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Fail); CodeStatus = CodeStatus.NeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NeedCode); Log4Logger.Error(UserName + " Login失败!\r\n" + htmlStr); //MailLogger.LogError(UserName + " Login失败!\r\n" + htmlStr); QqMsgLogger.LogError(UserName + " Login失败!" + htmlStr); } }
private void OnMessage(object source, System.Timers.ElapsedEventArgs e) { lock (Mylock) { try { var qqs = QqProvider.Instance.ListBy5Mi(); foreach (var qq in qqs) { var key = qq.TenantId + "_" + qq.Id; if (!QqPraiseCacheProvider.Instance.Exists(key)) { var qqPraiseProvider = new QqPraiseProvider(qq.QqNumber, qq.Pwd); qqPraiseProvider.Id = qq.Id; qqPraiseProvider.TenantId = qq.TenantId; QqPraiseCacheProvider.Instance.Add(key, qqPraiseProvider); qqPraiseProvider.Praise(); } else { var qqPraiseProvider = QqPraiseCacheProvider.Instance.Get(key); qqPraiseProvider.Praise(); } } } catch (Exception ex) { Log4Logger.Error(ex.StackTrace, ex); QqMsgLogger.LogError(ex.Message, ex); } } }
private void Success(ScrapingBrowser scrapingBrowser, string htmlStr) { if (htmlStr.Contains("succ")) { Log4Logger.Info(UserName + " 点赞成功"); } else { Log4Logger.Error(UserName + " 点赞失败!\r\n" + htmlStr); QqMsgLogger.LogError(UserName + " 点赞失败!" + htmlStr); } }
/// <summary> /// 通过短信发送警示信息 /// </summary> /// <param name="message"></param> /// <param name="title"></param> /// <returns></returns> public static bool SendAlertMessageBySMS(string message) { try { string url = Util.ISMPHost + "/CallBack/SendAlertMessageBySMS?"; url += "Message=" + System.Web.HttpUtility.UrlEncode(message); string resultISMP = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8); var o = JsonConvert.DeserializeAnonymousType(resultISMP, new { success = true, message = string.Empty }); return(o.success); } catch (Exception ex) { Log4Logger.Error(ex); return(false); } }
public string Check(bool needSendMail = true) { try { var postForm = new NameValueCollection(); postForm["uin"] = UserName; postForm["appid"] = AppId; //todo 研究下 postForm["r"] = "0.10299430438317358"; _miniBrowser.NavigateTo(CheckUrl, postForm, Check); if (CodeStatus == CodeStatus.NeedCode) { var wr = _miniBrowser.DownloadWebResource(new Uri(string.Format(CodeImage, AppId, UserName, cap_cd))); var baseStartupPath = AppDomain.CurrentDomain.BaseDirectory; if (!Directory.Exists(baseStartupPath + "\\CodeImages")) { Directory.CreateDirectory(baseStartupPath + "\\CodeImages"); } File.WriteAllBytes(baseStartupPath + "\\CodeImages\\" + UserName + ".jpg", wr.Content.ToArray()); if (needSendMail) { //var msq = string.Format( // "{0} 需要验证码,请尽快输入验证码!<a href='http://123.57.83.216:8000/QQVeryCool/{1}/Check/{2}'>进入</a>", // UserName, TenantId, Id); //MailLogger.LogInfo(msq); var msq = string.Format( "{0} 需要验证码,请尽快输入验证码!http://123.57.83.216:8000/QQVeryCool/{1}/Check/{2}", UserName, TenantId, Id); QqMsgLogger.LogInfo(msq); } return(string.Format("/QQVeryCool/{0}/GetCodeImage/{1}", TenantId, Id)); } else { return("ok."); } } catch (Exception ex) { Log4Logger.Error("Check失败!\r\n" + UserName + "\r\n" + ex.Message, ex); QqMsgLogger.LogError("Check失败!" + UserName + ":" + ex.Message, ex); return("error."); } }
/// <summary> /// 向ISMP发送日志 /// </summary> /// <param name="log"></param> /// <returns></returns> public static bool SendSystemLogToISMP(Sys_Log log) { try { string Param = JsonSerialize.Instance.Serialize <Sys_Log>(log); string url = Util.ISMPHost + "/CallBack/LogOperation?"; url += "Param=" + System.Web.HttpUtility.UrlEncode(Param); string resultISMP = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8); var o = JsonConvert.DeserializeAnonymousType(resultISMP, new { success = true, message = string.Empty }); return(o.success); } catch (Exception ex) { Log4Logger.Error(ex); return(false); } }
public void Run(QqContext context) { var miniBrowser = (ScrapingBrowser)context["miniBrowser"]; var userName = context["userName"].ToString(); var postForm = new NameValueCollection(); postForm["uin"] = userName; postForm["appid"] = Constants.QqAppId; postForm["js_ver"] = "10095"; postForm["js_type"] = "0"; postForm["u1"] = "http://w.qq.com/proxy.html&r=0.6158497643191367"; postForm["r"] = "0.6158497643191367"; var htmlStr = miniBrowser.NavigateTo(new Uri(Constants.QqMsgCheckUrl), HttpVerb.Get, postForm); //将验证码信息的三部分存入数组 int checkCodePosition = htmlStr.IndexOf("(", StringComparison.Ordinal) + 1; var checkCode = htmlStr.Substring(checkCodePosition, htmlStr.LastIndexOf(")", StringComparison.Ordinal) - checkCodePosition); var checkArray = checkCode.Replace("'", "").Split(','); //验证码数组 context["qq16"] = checkArray[2]; if (checkArray[0] == "0") { context["code"] = checkArray[1]; context.QqMsgCodeStatus = QqMsgCodeStatus.NotNeedCode; } else if (checkArray[0] == "1") { //必要的参数 var url = string.Format(Constants.QqMsgCodeImageTemplate, Constants.QqAppId, "0.8478438374586403", userName); var param = new Dictionary <object, object> { { "username", context["ruokuaiUser"] }, { "password", context["ruokuaiPwd"] }, { "typeid", context["ruokuaiTypeid"] }, { "timeout", "90" }, { "softid", context["ruokuaiSoftid"] }, { "softkey", context["ruokuaiSoftkey"] } }; var wr = miniBrowser.DownloadWebResource(new Uri(url)); try { string httpResult = RuoKuaiHttp.Post("http://api.ruokuai.com/create.xml", param, wr.Content.ToArray()); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(httpResult); XmlNode idNode = xmlDoc.SelectSingleNode("Root/Id"); XmlNode resultNode = xmlDoc.SelectSingleNode("Root/Result"); //XmlNode errorNode = xmlDoc.SelectSingleNode("Root/Error"); if (resultNode != null && idNode != null) { //var topidid = idNode.InnerText; var result = resultNode.InnerText; context["code"] = result; context.QqMsgCodeStatus = QqMsgCodeStatus.NotNeedCode; //停顿下,否则qq会认为是在攻击它 Thread.Sleep(2000); } } catch (Exception ex) { Log4Logger.Error(ex.Message, ex); } if (string.IsNullOrWhiteSpace((context["code"] ?? "").ToString())) { var baseStartupPath = AppDomain.CurrentDomain.BaseDirectory; if (!Directory.Exists(baseStartupPath + "\\CodeImages")) { Directory.CreateDirectory(baseStartupPath + "\\CodeImages"); } File.WriteAllBytes(baseStartupPath + "\\CodeImages\\qqmsg_" + userName + ".jpg", wr.Content.ToArray()); context.QqMsgCodeStatus = QqMsgCodeStatus.NeedCode; if ((bool)context["needSendMail"]) { Log4Logger.Info("QQMsgLogger需要验证码,请尽快输入验证码!"); MailLogger.LogInfo("QQMsgLogger需要验证码,请尽快输入验证码!<a href='http://123.57.83.216:8001/QQMsgLogger/Check'>进入</a>"); } } } else { context.QqMsgStatus = QqMsgStatus.Fail; } context["verifysession"] = miniBrowser.GetCookie(new Uri(Constants.QqMsgCheckUrl), "verifysession").Value; }
/// <summary> /// 点赞 /// </summary> /// <param name="scrapingBrowser"></param> /// <param name="htmlStr"></param> private void Praise(ScrapingBrowser scrapingBrowser, string htmlStr) { var cookie = scrapingBrowser.GetCookie(new Uri(IndexPage), "skey"); if (cookie == null) { RunStatus = RunStatus.Fail; QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Fail); CodeStatus = CodeStatus.NeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NeedCode); Log4Logger.Error(UserName + ":skey为空了"); QqMsgLogger.LogError(UserName + ":skey为空了"); return; } var gtk = Gtk.GetGtk(cookie.Value); PraiseUrl = string.Format(PraiseUrl, gtk); var document = new HtmlDocument(); document.LoadHtml(htmlStr); var list = document.DocumentNode.CssSelect("li.f-single"); if (!list.Any()) { QqMsgLogger.LogInfo(UserName + " :li.f-single 找不到点赞的模块"); Log4Logger.Info(UserName + " :li.f-single 找不到点赞的模块.\r\n" + htmlStr); if (document.DocumentNode.CssSelect("i.ico_login").Any()) { RunStatus = RunStatus.Fail; QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Fail); CodeStatus = CodeStatus.NeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NeedCode); } return; } else { var isContinue = htmlStr.Contains("g_ic_fpfeedsType='friend',"); if (!isContinue) { //其它角色对用户进行点赞评论后会跳转到与我相关页面,这时候再请求一次 //QqMsgLogger.LogInfo(UserName + " 有人关注,需要重新定位到主页."); //_miniBrowser.DownloadString(IndexPage, Praise); return; } } foreach (var htmlNode in list) { if (htmlNode == null || string.IsNullOrWhiteSpace(htmlNode.InnerHtml)) { continue; } try { var nameNode = htmlNode.CssSelect("a.f-name"); var praiseNode = htmlNode.CssSelect("a.qz_like_btn_v3").FirstOrDefault(); if (praiseNode != null && praiseNode.Attributes["data-clicklog"] != null && praiseNode.Attributes["data-clicklog"].Value == "like") { Thread.Sleep(1000); Log4Logger.Info(UserName + "为《" + nameNode.First().InnerHtml + "》点赞!"); var unikey = praiseNode.Attributes["data-unikey"].Value; var curkey = praiseNode.Attributes["data-curkey"].Value; var postForm = new NameValueCollection(); postForm["qzreferrer"] = IndexPage; postForm["opuin"] = UserName; postForm["unikey"] = unikey; postForm["curkey"] = curkey; postForm["from"] = "1"; postForm["appid"] = "311"; postForm["typeid"] = "0"; postForm["abstime"] = "1423372434"; postForm["fid"] = "3611d32392f0d654e5a20900"; postForm["active"] = "0"; postForm["fupdate"] = "1"; scrapingBrowser.NavigateTo(PraiseUrl, postForm, Success, HttpVerb.Post); } else if (praiseNode == null) { QqMsgLogger.LogInfo(UserName + " :a.qz_like_btn_v3 没有找到点赞的按钮"); //Log4Logger.Info(UserName + " :a.qz_like_btn_v3 没有找到点赞的按钮.\r\n" + htmlStr); } else if (praiseNode.Attributes["data-clicklog"] == null) { QqMsgLogger.LogInfo(UserName + " :data-clicklog 没有找到点赞的按钮"); Log4Logger.Info(UserName + " :data-clicklog 没有找到点赞的按钮.\r\n" + htmlStr); } } catch (Exception ex) { Log4Logger.Error(UserName + " 点赞失败!\r\n" + htmlStr, ex); QqMsgLogger.LogError(UserName + " 点赞失败!" + ex.Message, ex); } } RunStatus = RunStatus.Sucess; QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Sucess); }
/// <summary> ///获取验证信息 //验证信息格式为:ptui_checkVC('0','!MIW','\x00\x00\x00\x00\x9a\x65\x0f\xd7') //其中分为三部分,第一个值0或1判断是否需要图片验证码 // 第二个值是默认验证码,若不需要图片验证码,就用此验证码来提交 // 第三部分是所使用的QQ号码的16进制形式 /// </summary> /// <param name="scrapingBrowser"></param> /// <param name="htmlStr"></param> private void Check(ScrapingBrowser scrapingBrowser, string htmlStr) { cap_cd = string.Empty; //将验证码信息的三部分存入数组 int checkCodePosition = htmlStr.IndexOf("(", System.StringComparison.Ordinal) + 1; var checkCode = htmlStr.Substring(checkCodePosition, htmlStr.LastIndexOf(")", System.StringComparison.Ordinal) - checkCodePosition); var checkArray = checkCode.Replace("'", "").Split(','); //验证码数组 if (checkArray[0] == "0") { CodeStatus = CodeStatus.NotNeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NotNeedCode); Log4Logger.Info(UserName + " 获取验证信息成功! " + htmlStr); Login(checkArray[1]); } else if (checkArray[0] == "1") { cap_cd = checkArray[1]; var ruokuaiUser = ConfigurationManager.AppSettings["ruokuaiUser"] ?? ""; var ruokuaiPwd = ConfigurationManager.AppSettings["ruokuaiPwd"] ?? ""; var ruokuaiTypeid = ConfigurationManager.AppSettings["ruokuaiTypeid"] ?? ""; var ruokuaiSoftid = ConfigurationManager.AppSettings["ruokuaiSoftid"] ?? ""; var ruokuaiSoftkey = ConfigurationManager.AppSettings["ruokuaiSoftkey"] ?? ""; var param = new Dictionary <object, object> { { "username", ruokuaiUser }, { "password", ruokuaiPwd }, { "typeid", ruokuaiTypeid }, { "timeout", "90" }, { "softid", ruokuaiSoftid }, { "softkey", ruokuaiSoftkey } }; var url = string.Format(CodeImage, AppId, UserName, cap_cd); var wr = scrapingBrowser.DownloadWebResource(new Uri(url)); try { string httpResult = RuoKuaiHttp.Post("http://api.ruokuai.com/create.xml", param, wr.Content.ToArray()); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(httpResult); XmlNode idNode = xmlDoc.SelectSingleNode("Root/Id"); XmlNode resultNode = xmlDoc.SelectSingleNode("Root/Result"); //XmlNode errorNode = xmlDoc.SelectSingleNode("Root/Error"); if (resultNode != null && idNode != null) { //var topidid = idNode.InnerText; var result = resultNode.InnerText; CodeStatus = CodeStatus.NotNeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NotNeedCode); Log4Logger.Info(UserName + " 获取验证信息成功! " + htmlStr); QqMsgLogger.LogInfo(UserName + " 若快识别成功! "); //停顿下,否则qq会认为是在攻击它 Thread.Sleep(2000); Login(result); } else { CodeStatus = CodeStatus.NeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NeedCode); Log4Logger.Info(UserName + " 需要验证码,请尽快输入验证码!"); } } catch (Exception ex) { Log4Logger.Error(ex.Message, ex); CodeStatus = CodeStatus.NeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NeedCode); Log4Logger.Info(UserName + " 需要验证码,请尽快输入验证码!"); QqMsgLogger.LogInfo(UserName + " 若快识别失败! " + ex.Message, ex); } } else { CodeStatus = CodeStatus.NeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NeedCode); Log4Logger.Error("Check失败!\r\n" + UserName + "\r\n" + htmlStr); QqMsgLogger.LogError("Check失败!" + UserName + ":" + htmlStr); } }
public ActionResult SaleSubmit(SMS.Model.EnterpriseUser eu) { try { var sr = new SMS.Model.RPCResult(false, ""); string enterpriseCode = Request["EnterpriseCode"]; string enterpriseAccountID = Request["EnterpriseAccountID"]; string agentAccountID = Request["AgentAccountID"]; string Description = "企业新开充值"; eu.AccountCode = enterpriseCode; eu.AccountID = enterpriseAccountID; eu.Name = ""; eu.IsAgent = false; eu.IsOpen = false; eu.FilterType = (ushort)FilterType.Replace; eu.Audit = AccountAuditType.Audit; eu.SMSType = Util.SMSType; eu.StatusReport = StatusReportType.Disable; eu.Enabled = true; eu.RegisterDate = DateTime.Now; eu.Password = Util.GeneratePassword(8); //随机生成8位密码。 eu.Channel = Util.DefaultChannel; eu.ParentAccountCode = "-1"; //无上级企业 string spNumber = Util.GenSpNumber(); //随机算法生成 var entlist = Util.SMSProxy.ISMPGetAllEnterprise().Value; //检验号码是否可用 while (true) { if (entlist.Any(e => e.SPNumber == spNumber)) { spNumber = Util.GenSpNumber();//重新生成 } else { break; } } eu.SPNumber = spNumber; //检查企业是否已存在 if (!entlist.Any(e => e.AccountCode == eu.AccountCode)) { //不存在,注册企业,不审核 sr = Util.SMSProxy.ISMPAddEnterprise(eu); if (sr.Success) { try { //添加默认通讯录分组 bool resultAddContactGroup = PhoneAndGroupDB.GroupAdd(enterpriseCode, "0", "未分组"); } catch (Exception ex) { Log4Logger.Error(ex); } //ISMP 订单 string url = Util.ISMPHost + "/CallBack/OpenProduct_CallBack?"; url += "Id=" + System.Web.HttpUtility.UrlEncode(System.Guid.NewGuid().ToString()) + "&EnterpriseAccountId=" + System.Web.HttpUtility.UrlEncode(enterpriseAccountID) + "&ProductId=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductId) + "&Description=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductName + "订单"); string result = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8); var o = JsonConvert.DeserializeAnonymousType(result, new { success = true, message = string.Empty }); if (!o.success) { //需要通知运维进行处理或再次尝试 Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "短信中开通企业成功,回调ISMP添加订单失败", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】,添加订单失败原因【" + o.message + "】", "开通失败", CurrentUser); return(GetActionResult(new RPC_Result(false, "添加短信订单失败,请联系客服"))); } else { Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "短信中开通企业成功", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】", "开通产品", CurrentUser); } } else { return(GetActionResult(sr)); } } else { return(GetActionResult(new RPC_Result(false, "该企业已开通短信产品,不能重复开通!"))); } var smsNumber = int.Parse(string.IsNullOrWhiteSpace(Request["smsNumber"]) ? "0" : Request["smsNumber"]); //开通同时给企业充值 if (smsNumber > 0) { ChargeRecord cr = new ChargeRecord(); cr.ChargeFlag = 0; cr.Money = smsNumber * Util.SMSRate; cr.SMSCount = smsNumber; cr.ThenRate = Convert.ToDecimal(Util.SMSRate); cr.OperatorAccount = CurrentUser.LoginName; cr.PrepaidAccount = enterpriseCode; cr.PrepaidTime = DateTime.Now; cr.PrepaidType = 1; //ISMP 扣费 string url = Util.ISMPHost + "/CallBack/DeductForProduct?"; url += "DeductAccountId=" + System.Web.HttpUtility.UrlEncode(agentAccountID) + "&RechargeAccountId=" + System.Web.HttpUtility.UrlEncode(enterpriseAccountID) + "&Money=" + System.Web.HttpUtility.UrlEncode(Convert.ToString(cr.Money)) + "&Description=" + System.Web.HttpUtility.UrlEncode(Description) + "&ProductPayType=" + System.Web.HttpUtility.UrlEncode("短信充值") + "&ApplyAccountId=" + System.Web.HttpUtility.UrlEncode(CurrentUser.OperatorAccountId) + "&ApplyName=" + System.Web.HttpUtility.UrlEncode(CurrentUser.OperatorName) + "&Type=" + System.Web.HttpUtility.UrlEncode("21") + "&ProductId=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductId); string result = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8); var o = JsonConvert.DeserializeAnonymousType(result, new { success = true, message = string.Empty }); if (o.success) { var r = Util.SMSProxy.AccountPrepaid(cr); if (r.Success) { Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "开通完成,充值短信【" + smsNumber + "】条。", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】", "短信充值", CurrentUser); return(GetActionResult(new RPC_Result(true, "开通完成,充值短信【" + smsNumber + "】条。"))); } else { //此处应记录日志和错误,并及时通知 //此处扣费成功但充值失败。 Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "开通且扣费成功,充值失败", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】,充值失败原因【" + r.Message + "】", "短信充值失败", CurrentUser); return(GetActionResult(new RPC_Result(false, "开通且扣费成功,充值失败,请联系客服"))); } } else { Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "注册完成,扣费失败", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】,金额【" + cr.Money + "】,扣费失败原因【" + o.message + "】", "开通", CurrentUser); return(GetActionResult(new RPC_Result(false, "注册完成,扣费失败,失败原因【" + o.message + "】"))); } } else { Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "开通完成,充值短信【" + smsNumber + "】条", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】", "开通", CurrentUser); return(GetActionResult(new RPC_Result(true, "开通完成,充值短信【" + smsNumber + "】条。"))); } //return GetActionResult(sr); } catch (Exception ex) { Log4Logger.Error(ex); return(GetActionResult(new RPC_Result(true, "操作异常"))); } }
public ActionResult DoRecharge() { try { string enterpriseCode = Request["EnterpriseCode"]; string enterpriseAccountID = Request["EnterpriseAccountID"]; string agentAccountID = Request["AgentAccountID"]; string Description = Request["Description"]; string IsGrant = Request["IsGrant"]; string Type = "22"; string GrantType = ""; if (IsGrant == "1") { //验证key string key = Request["key"]; var skey = Session["key"]; if (skey != null && skey.ToString() == key) { GrantType = Request["GrantType"]; Type = "2"; } else { return(GetActionResult(new RPC_Result(false, "充值失败,请重新登录后操作"))); } } if (string.IsNullOrWhiteSpace("enterpriseCode") || string.IsNullOrWhiteSpace("enterpriseAccountID") || string.IsNullOrWhiteSpace("agentAccountID")) { return(GetActionResult(new RPC_Result(false, "充值失败,缺少参数"))); } var smsNumber = int.Parse(string.IsNullOrWhiteSpace(Request["smsNumber"]) ? "0" : Request["smsNumber"]); //给企业充值 if (smsNumber > 0) { ChargeRecord cr = new ChargeRecord(); cr.ChargeFlag = 0; cr.Money = smsNumber * Util.SMSRate; cr.SMSCount = smsNumber; cr.ThenRate = Convert.ToDecimal(Util.SMSRate); cr.OperatorAccount = CurrentUser.LoginName; cr.PrepaidAccount = enterpriseCode; cr.PrepaidTime = DateTime.Now; cr.PrepaidType = 1; //ISMP 扣费 string url = Util.ISMPHost + "/CallBack/DeductForProduct?" + "DeductAccountId=" + System.Web.HttpUtility.UrlEncode(agentAccountID) + "&RechargeAccountId=" + System.Web.HttpUtility.UrlEncode(enterpriseAccountID) + "&Money=" + System.Web.HttpUtility.UrlEncode(Convert.ToString(cr.Money)) + "&Description=" + System.Web.HttpUtility.UrlEncode(Description) + "&ProductPayType=" + System.Web.HttpUtility.UrlEncode("短信充值") + "&ApplyAccountId=" + System.Web.HttpUtility.UrlEncode(CurrentUser.OperatorAccountId) + "&ApplyName=" + System.Web.HttpUtility.UrlEncode(CurrentUser.OperatorName) + "&Type=" + System.Web.HttpUtility.UrlEncode(Type) + "&ProductId=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductId); if (IsGrant == "1") { url += "&GrantType=" + System.Web.HttpUtility.UrlEncode(GrantType); } string result = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8); var o = JsonConvert.DeserializeAnonymousType(result, new { success = true, message = string.Empty }); if (o.success) { var r = Util.SMSProxy.AccountPrepaid(cr); if (r.Success) { Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "充值短信【" + smsNumber + "】条。", "企业AccountID【" + enterpriseAccountID + "】,代理商AccountID【" + agentAccountID + "】,金额【" + cr.Money + "】", "充值", CurrentUser); return(GetActionResult(new RPC_Result(true, "充值成功,充值短信【" + smsNumber + "】条。"))); } else { //此处应记录日志和错误,并及时通知 Util.SendAlertMessageByEmail(Util.SMSProductName + "产品充值扣费成功,充值失败:企业AccountID【" + enterpriseAccountID + "】,代理商AccountID【" + agentAccountID + "】,金额【" + cr.Money + "】,充值失败原因【" + r.Message + "】"); //此处扣费成功但充值失败。 Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "扣费成功,充值失败", "企业AccountID【" + enterpriseAccountID + "】,代理商AccountID【" + agentAccountID + "】,金额【" + cr.Money + "】,充值失败原因【" + r.Message + "】", "充值", CurrentUser); return(GetActionResult(new RPC_Result(false, "给代理商扣费成功,充值失败,失败原因【" + r.Message + "】"))); } } else { Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "扣费失败", "企业AccountID【" + enterpriseAccountID + "】,代理商AccountID【" + agentAccountID + "】,金额【" + cr.Money + "】,扣费失败原因【" + o.message + "】", "充值", CurrentUser); return(GetActionResult(new RPC_Result(false, "扣费失败,失败原因【" + o.message + "】"))); } } else { return(GetActionResult(new RPC_Result(false, "请输入正确的充值条数"))); } //return View(); } catch (Exception ex) { Log4Logger.Error(ex); return(GetActionResult(new RPC_Result(false, "操作异常"))); } }