public static object DecodeMsg(String msg) { IDictionary dict = TopUtils.ParseJson(msg); if (dict != null && dict.Count > 0) { IEnumerator em = dict.Keys.GetEnumerator(); em.MoveNext(); IDictionary data = dict[em.Current] as IDictionary; if (data != null) { TopJsonParser tjp = new TopJsonParser(); ITopReader reader = new TopJsonReader(data); //if (dict.Contains(NOTIFY_ITEM)) //{ // return tjp.FromJson(reader, typeof(NotifyItem)); //} if (dict.Contains(NOTIFY_TRADE)) { return(tjp.FromJson(reader, typeof(NotifyTrade))); } //else if (dict.Contains(NOTIFY_REFUND)) //{ // return tjp.FromJson(reader, typeof(NotifyRefund)); //} } } return(null); }
protected void Page_Load(object sender, EventArgs e) { if (Session["LOGINUSERNAME"] == null && !Convert.ToString(Session["LOGINUSERNAME"]).Equals("kimluo")) { Response.Redirect("~/admin/Login.aspx?"); } lbmsg.Text = ""; // BindData(); if (!Page.IsPostBack) { //lbMsgCount.Text = "当前短信账户剩余条数:" + Mobile.GetAcountMsgCount2(); GetCountSYXuNi string sendStatus = Mobile.GetCountSYXuNi(); IDictionary resultDic = TopUtils.ParseJson(sendStatus); lbMsgCount.Text = "当前短信账户剩余条数:" + resultDic["balance"].ToString(); BindData(); } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (string.IsNullOrEmpty(TextBox2.Text)) { Response.Write("<script language='javascript'>alert('请输入发送内容!');</script>"); return; } DataTable trade = null; string sigName = "【" + SellersBLL.GetSignName(Users.Nick) + "】"; string select = drpSType.SelectedValue.ToString(); switch (select) { case "sign_notSure": trade = TradeBLL.GetTradeData(Users.Nick, "taobao_trade_TradeSellerShip"); break; case "sure_notSign": trade = TradeBLL.GetTradeDataNosign(Users.Nick, "taobao_trade_TradeSellerShip"); break; case "sure_notSucce": trade = TradeBLL.GetTradeDataNoSuccess(Users.Nick, "taobao_trade_TradeSellerShip"); break; } if (trade == null || trade.Rows.Count == 0) { Response.Write("<script language='javascript'>alert('无数据!');</script>"); return; } for (int i = 0; i < trade.Rows.Count; i++) { DataTable ds = BuyerBLL.GetBuyerInfo(trade.Rows[i]["buyer_nick"].ToString(), "all", "all", "all", "", "", "", Users.Nick, ""); if (ds == null || ds.Rows.Count == 0) { continue; } string cellPhone = ds.Rows[i]["CellPhone"].ToString(); try { //判断手机 if (Utility.IsCellPhone(cellPhone)) { if (MsgBLL.CheckSellerMsgStatus()) { MsgSendHis objHis = new MsgSendHis(); objHis.TransNumber = DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + cellPhone;//手机号码 2016 yao c objHis.SellerNick = Users.Nick; //objHis.SellerNick = "澄腾科技"; objHis.Buyer_nick = "*****"; objHis.CellPhone = cellPhone; objHis.SendDate = DateTime.Now; objHis.SendType = "手工发送"; objHis.SendStatus = "0"; objHis.Count = "1"; //objHis.MsgContent = "【" + SellersBLL.GetSignName(Users.Nick) + "】" + txtContent.Text.Trim();// +"退订回T"; objHis.MsgContent = sigName + TextBox2.Text + " 退订回N"; if (!Utility.IsYiDongCellPhoneNo(cellPhone)) { objHis.HelpSellerNick = "电信联通"; } else { objHis.HelpSellerNick = "移动"; } //if (true) test if (SmartBLL.AddMsgSendHis(objHis)) { try { objHis.MsgContent = objHis.MsgContent.Replace(" ", ""); if (objHis.MsgContent.Length <= 70) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 1); } else if (objHis.MsgContent.Length > 70 && objHis.MsgContent.Length <= 134) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 2); } else if (objHis.MsgContent.Length > 134 && objHis.MsgContent.Length <= 195) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 3); } else if (objHis.MsgContent.Length > 195 && objHis.MsgContent.Length <= 260) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 4); } if (!Utility.IsYiDongCellPhoneNo(cellPhone)) { //string sendStatus = Mobile.SendMsgKeTongDX(cellPhone, objHis.MsgContent); string sendStatus = Mobile.PostDataToMyServer(cellPhone, objHis.MsgContent.Trim());//20160626 yao c IDictionary resultDic = TopUtils.ParseJson(sendStatus); SmartBLL.UpdateSendStatus(resultDic["status"].ToString(), objHis.TransNumber); } else { string sendStatus = Mobile.SendMsgHubeiYDPost(cellPhone, objHis.MsgContent);//\r\n\r\n\r\n\r\n0 sendStatus = sendStatus.Replace("\r", "").Replace("\n", ""); if (sendStatus.Equals("0")) { sendStatus = "100"; } SmartBLL.UpdateSendStatus(sendStatus, objHis.TransNumber); } } catch (Exception ex) { continue; } } } else { Response.Write("<script language='javascript'>alert('余额不足!');</script>"); return; } } } catch (Exception ex) { continue; } } Response.Write("<script language='javascript'>alert('发送成功!');</script>"); }
public static DnsConfig parse(string json) { DnsConfig dnsConfig = new DnsConfig(); IDictionary root = TopUtils.ParseJson(json); foreach (string configType in root.Keys) { if ("config".Equals(configType)) { dnsConfig.GlobalDict = new Dictionary <string, string>(); IDictionary globalInfo = root[configType] as IDictionary; foreach (string key in globalInfo.Keys) { dnsConfig.GlobalDict[key] = globalInfo[key] as string; } } else if ("env".Equals(configType)) { IDictionary envInfos = root[configType] as IDictionary; dnsConfig.EnvDict = new Dictionary <string, List <EnvConfig> >(); foreach (string envName in envInfos.Keys) { IDictionary envInfo = envInfos[envName] as IDictionary; List <EnvConfig> envConfigs = new List <EnvConfig>(); foreach (string domainName in envInfo.Keys) { IDictionary domainInfo = envInfo[domainName] as IDictionary; EnvConfig envConfig = new EnvConfig(); envConfig.Domain = domainName as string; envConfig.Protocol = domainInfo["proto"] as string; IList vipInfos = domainInfo["vip"] as IList; List <VipRule> vipRules = new List <VipRule>(); foreach (string vipInfo in vipInfos) { string[] vipInfoTmp = vipInfo.ToString().Split('|'); VipRule vipRule = new VipRule(); vipRule.Vip = vipInfoTmp[0]; vipRule.Weight = double.Parse(vipInfoTmp[1]); vipRules.Add(vipRule); } envConfig.VipRules = vipRules; envConfigs.Add(envConfig); } dnsConfig.EnvDict[envName] = envConfigs; } } else if ("api".Equals(configType)) { dnsConfig.ApiDict = new Dictionary <string, ApiConfig>(); IDictionary apiInfos = root[configType] as IDictionary; foreach (string apiName in apiInfos.Keys) { IDictionary apiInfo = apiInfos[apiName] as IDictionary; ApiConfig apiConfig = new ApiConfig(); apiConfig.User = apiInfo["user"] as string; List <ApiRule> apiRules = new List <ApiRule>(); IList apiRuleInfos = apiInfo["rule"] as IList; foreach (string apiRuleInfo in apiRuleInfos) { string[] apiRuleInfoTmp = apiRuleInfo.ToString().Split('|'); ApiRule apiRule = new ApiRule(); apiRule.Name = apiRuleInfoTmp[0]; apiRule.Weight = double.Parse(apiRuleInfoTmp[1]); apiRules.Add(apiRule); } apiConfig.Rules = apiRules; dnsConfig.ApiDict[apiName] = apiConfig; } } else if ("user".Equals(configType)) { dnsConfig.UserDict = new Dictionary <string, IDictionary <string, string> >(); IDictionary userInfos = root[configType] as IDictionary; foreach (string routeName in userInfos.Keys) { IDictionary envInfos = userInfos[routeName] as IDictionary; IDictionary <string, string> tags = new Dictionary <string, string>(); foreach (string envName in envInfos.Keys) { IList tagInfos = envInfos[envName] as IList; foreach (string tagName in tagInfos) { tags.Add(tagName, envName); } } dnsConfig.UserDict[routeName] = tags; } } } return(dnsConfig); }
public static void Main(string[] args) { TmcClient client = new TmcClient(appKey, appSecret, "default"); client.OnMessage += (s, e) => { try { string status = e.Message.Topic; //将消息进行转换 IDictionary obj = TopUtils.ParseJson(e.Message.Content); if (obj != null) { #region //物流信息的处理20160916 yao try { if (obj.Contains("action")) { Console.WriteLine(DateTime.Now.ToString() + ":物流提醒:" + e.Message.Content); LogsticDetailTrace logstic = new LogsticDetailTrace(); logstic.Tid = obj["tid"].ToString(); logstic.Desc = obj["desc"].ToString(); if (obj.Contains("out_sid")) { logstic.Out_side = obj["out_sid"].ToString(); } logstic.Time = obj["time"].ToString(); if (obj.Contains("company_name")) { logstic.Company_name = obj["company_name"].ToString(); } logstic.Action = obj["action"].ToString(); if (LogisticsBLL.TidIsExist(logstic.Tid)) { LogisticsBLL.updateLogistics(logstic); } else { LogisticsBLL.AddLogistics(logstic); } } else { NotifyTrade trade = null; Console.WriteLine(DateTime.Now.ToString() + ":店铺管家订单:" + e.Message.Content); trade = new NotifyTrade(); trade.Tid = obj["tid"].ToString(); trade.BuyerNick = obj["buyer_nick"].ToString(); trade.Status = status; trade.SellerNick = obj["seller_nick"].ToString(); trade.Oid = obj["oid"].ToString(); trade.Payment = obj["payment"].ToString(); if (!DBUtil.CheckNoteTradeIsExit(trade.Tid.ToString())) { DBUtil.AddNoteTradeToDB(trade); //物流提醒之用 if (status.Equals("taobao_trade_TradeCreate")) //订单拦截之用 { DBUtil.AddTradeOrderDenfense(trade); } } else { DBUtil.UpdateNoteTradeToDB(trade); } } } catch (Exception e1) { Console.WriteLine(e1.ToString()); } #endregion } // 默认不抛出异常则认为消息处理成功 } catch (Exception exp) { ExceptionReporter.WriteLog(exp, ExceptionPostion.TBApply_Data); e.Fail(); // 消息处理失败回滚,服务端需要重发 } }; client.Connect("ws://mc.api.taobao.com/"); Console.ReadLine(); }
/// <summary> /// 初始信息处理 /// </summary> /// <param name="hasShop"></param> public static string WriteUserInfoToCookies() { HttpContext context = HttpContext.Current; string code = HttpContext.Current.Request.QueryString["code"]; string state = HttpContext.Current.Request.QueryString["state"]; string client_id = appKey; string client_secret = appSecret; string grant_type = "authorization_code"; string redirect_uri = redirect_URL; int s = 0;//记录code获取源 //从数据库获取code if (string.IsNullOrEmpty(code)) { DataTable dt = SellersBLL.GetSellersCode(Users.Nick); if (dt != null && dt.Rows.Count > 0) { s = 1; code = dt.Rows[0]["code"].ToString(); } } #region 获取授权Code if (!string.IsNullOrEmpty(code)) { DataTable dt = SellersBLL.GetSellersCode(Users.Nick); if (dt != null && dt.Rows.Count > 0 && s == 0) { SellersBLL.UpdateSellersCode(Users.Nick, code); } else if (dt == null || dt.Rows.Count == 0) { SellersBLL.AddSellersCode(Users.Nick, code); } //获取访问令牌 string url = "https://oauth.taobao.com/token?client_id={0}&client_secret={1}&grant_type={2}&code={3}&redirect_uri={4}&scope={5}&view={6}&state={7}"; string urlS = string.Format(url, client_id, client_secret, grant_type, code, redirect_uri, "item", "web", state); string getAuthAcessToken = PostDataToUrl(urlS, urlS); if (string.IsNullOrEmpty(getAuthAcessToken)) { return(null); } //20160907 yao c IDictionary resultDic = TopUtils.ParseJson(getAuthAcessToken); context.Request.Cookies.Clear(); context.Session.Clear(); //获取卖家昵称 string nick = HttpUtility.UrlDecode(resultDic["taobao_user_nick"].ToString(), Encoding.UTF8); //这里的SessionKey就是access_token string sessionKey = resultDic["access_token"].ToString(); //获取刷新令牌,以便令牌过期时重新获取 string refresh_token = resultDic["refresh_token"].ToString(); HttpCookie cookie = new HttpCookie("Top"); cookie["nick"] = CTCRM.Common.DES.Encrypt(nick); UserSellerGetResponse userRsp = null; UserSellerGetRequest req = null; try { Sellers sellers = new Sellers(); sellers.Nick = nick; try { ITopClient client = TBManager.GetClient(); req = new UserSellerGetRequest(); req.Fields = "user_id,type"; userRsp = client.Execute(req, sessionKey); } catch (Exception ex) { userRsp = null; } sellers.Seller_Creadit = 0;//short.Parse(userRsp.User.SellerCredit.Level.ToString()); sellers.Seller_Id = userRsp.User == null? 0: userRsp.User.UserId; sellers.shopType = userRsp.User == null ? "B" : userRsp.User.Type; sellers.Created = DateTime.Now; sellers.SessionKey = sessionKey; sellers.Refresh_token = refresh_token; sellers.SellerType = "pay"; cookie["SellerId"] = sellers.Seller_Id.ToString(); //获取卖家订购信息 ArticleUserSubscribe userSub = UserSubscribe.GetDeadLineDate("ts-1811102", nick); if (userSub != null) { sellers.EndDate = userSub.Deadline.ToString(); #region 标准版一月送200条 if (userSub.ItemCode.Equals("ts-1811102-1")) { sellers.OrderVersion = "标准版一月送200条"; } #endregion #region 自动评价版 if (userSub.ItemCode.Equals("ts-1811102-2")) { sellers.OrderVersion = "自动评价版"; } #endregion #region 订单打印版 if (userSub.ItemCode.Equals("ts-1811102-3")) { sellers.OrderVersion = "订单打印版"; } #endregion #region 流量推广_6个广告位 if (userSub.ItemCode.Equals("ts-1811102-4")) { sellers.OrderVersion = "流量推广_6个广告位"; } #endregion #region 订购一年送3000条短信 if (userSub.ItemCode.Equals("ts-1811102-5")) { sellers.OrderVersion = "订购一年送3000条短信"; } #endregion cookie["Deadline"] = userSub.Deadline.ToString();//比如:2016-07-04 00:00:00 cookie["OrderVersion"] = CTCRM.Common.DES.Encrypt(sellers.OrderVersion); } SellersDAL objDal = new SellersDAL(); if (!SellersDAL.GetList(sellers)) { sellers.CreatedDate = DateTime.Now;//记录卖家的第一次登陆系统时间 sellers.OrderDate = DateTime.Now.ToShortDateString(); objDal.Add(sellers); if (!objDal.AddSellerRecords(sellers.Nick, sellers.OrderVersion, userSub.Deadline.ToString(), "新订")) { File.WriteAllText(@"D:\log\" + nick + "_订购.txt", "新订失败"); } } else { string sellerEndDate = SellersDAL.GetSellerEndDate(nick); sellers.UpdateDate = DateTime.Now;//记录卖家最近一次登陆系统时间 File.WriteAllText(@"D:\log\" + nick + "_shijianOld.txt", sellerEndDate); bool sss = SellersDAL.Update(sellers); File.WriteAllText(@"D:\log\" + nick + "_更新.txt", sss.ToString()); //判断卖家是否续费软件 File.WriteAllText(@"D:\log\" + nick + "_shijianNew.txt", sellers.EndDate); if (sellers.EndDate != sellerEndDate) { if (sellers.OrderVersion == "订购一年送3000条短信") { File.WriteAllText(@"D:\log\" + nick + "_dinggou.txt", sellers.OrderVersion); MsgPackage obj = new MsgPackage(); obj.PackageName = "店铺管家短信套餐(淘宝)3000条"; obj.Type = "永久有效"; obj.SellerNick = nick; obj.Price = 0; obj.PerPrice = "0"; obj.Rank = "短信套餐(赠送)"; obj.OrderDate = DateTime.Now; obj.PayStatus = true; bool dingg = MsgBLL.AddMsgPackage(obj); File.WriteAllText(@"D:\log\" + nick + "_tianjia.txt", dingg.ToString()); DataTable dtDuanxin = MsgBLL.GetSellerMsgTrans(nick); if (dtDuanxin != null && dtDuanxin.Rows.Count > 0) { obj.MsgCanUseCount = 3000 + (dtDuanxin.Rows[0]["msgCanUseCount"] == DBNull.Value ? 0 : Convert.ToInt32(dtDuanxin.Rows[0]["msgCanUseCount"])); obj.MsgTotalCount = 3000 + (dtDuanxin.Rows[0]["msgTotalCount"] == DBNull.Value ? 0 : Convert.ToInt32(dtDuanxin.Rows[0]["msgTotalCount"])); } else { obj.MsgCanUseCount = 3000; obj.MsgTotalCount = 3000; } obj.ServiceStatus = true; obj.CanUseStartDate = DateTime.Now; MsgBLL.UpdateMsgTrans(obj); } else { File.WriteAllText(@"D:\log\" + nick + "_dinggou.txt", sellers.OrderVersion); MsgPackage obj = new MsgPackage(); obj.PackageName = "店铺管家短信套餐(淘宝)200条"; obj.Type = "永久有效"; obj.SellerNick = nick; obj.Price = 0; obj.PerPrice = "0"; obj.Rank = "短信套餐(赠送)"; obj.OrderDate = DateTime.Now; obj.PayStatus = true; bool dingg = MsgBLL.AddMsgPackage(obj); File.WriteAllText(@"D:\log\" + nick + "_tianjia.txt", dingg.ToString()); DataTable dtDuanxin = MsgBLL.GetSellerMsgTrans(nick); if (dtDuanxin != null && dtDuanxin.Rows.Count > 0) { obj.MsgCanUseCount = 200 + (dtDuanxin.Rows[0]["msgCanUseCount"] == DBNull.Value ? 0 : Convert.ToInt32(dtDuanxin.Rows[0]["msgCanUseCount"])); obj.MsgTotalCount = 200 + (dtDuanxin.Rows[0]["msgTotalCount"] == DBNull.Value ? 0 : Convert.ToInt32(dtDuanxin.Rows[0]["msgTotalCount"])); } else { obj.MsgCanUseCount = 200; obj.MsgTotalCount = 200; } obj.ServiceStatus = true; obj.CanUseStartDate = DateTime.Now; MsgBLL.UpdateMsgTrans(obj); } if (!objDal.AddSellerRecords(sellers.Nick, sellers.OrderVersion, userSub.Deadline.ToString(), "续订")) { File.WriteAllText(@"D:\log\" + nick + "_订购.txt", "续订失败"); } } } } catch (Exception ex) { //ExceptionReporter.WriteLog(userRsp.ErrMsg, ex, ExceptionPostion.TopApi, ExceptionRank.urgency); } cookie["sess"] = sessionKey; cookie.Expires = DateTime.Now.AddDays(1d); context.Response.Cookies.Add(cookie); return("1"); } else //Code为空的情况下 { return("0"); } #endregion }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var command = context.Request.Form["command"]; if (!string.IsNullOrEmpty(command)) { switch (command) { #region msgConSave case "msgConSave": { string content = context.Request.Form["msgContent"]; if (MsgBLL.UpdateSellerCusMsgContent(Users.Nick, content)) { context.Response.Write("1"); } else { context.Response.Write("0"); } context.Response.End(); } break; #endregion #region getConSave case "getConSave": { string content = MsgBLL.GetSellerSendMsgCusContent(Users.Nick); context.Response.Write(content); context.Response.End(); } break; #endregion #region sendTestMsg case "sendTestMsg": { string sigNames = SellersBLL.GetSignName(Users.Nick); string sigName = "【" + SellersBLL.GetSignName(Users.Nick) + "】"; string phoneNo = context.Request.Form["phone"]; string content = context.Request.Form["content"]; string[] noWenmings = new string[] { "傻逼", "草", "靠", "黄片", "尼玛", "你妈", "屌丝", "逗比", "你妹", "装逼", "妈蛋", "逼格", "撕逼", "卧草", "我日", "我擦" , "滚粗", "蛋疼", "婊砸", "跪舔", "婊", "碧池", "土肥圆", "矮穷挫" }; for (int s = 0; s < noWenmings.Length - 1; s++) { if (content.IndexOf(noWenmings[s]) > 0) { context.Response.Write("6"); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } } if (Utility.IsCellPhone(phoneNo)) { if (MsgBLL.CheckSellerMsgStatus()) { string msgContent = content.Trim() + " 退订回N"; //string msgContent = ""; //if (RatingBLL.isBshop(Users.Nick)) //{ // msgContent = "【天猫】"+ content.Trim() + " 退订N"; //} //else //{ // msgContent = "【淘宝】"+ content.Trim() + " 退订N"; //} MsgSendHis objHis = new MsgSendHis(); //objHis.TransNumber = DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + phoneNo;//手机号码 objHis.TransNumber = DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + phoneNo; //手机号码 2016 yao c objHis.SellerNick = Users.Nick; objHis.Buyer_nick = "*****"; objHis.CellPhone = phoneNo; objHis.SendDate = DateTime.Now; objHis.SendType = "自测短信"; objHis.SendStatus = "0"; objHis.Count = "1"; objHis.MsgContent = sigName + msgContent; if (Utility.IsYiDongCellPhoneNo(phoneNo)) { objHis.HelpSellerNick = "移动"; } if (SmartBLL.AddMsgSendHis(objHis)) { //把号码添加到测试池 SmartBLL.AddMsgSendHisIntoTestTable(Users.Nick, phoneNo); if (Convert.ToInt32(msgContent.Trim().Length) <= 70) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 1); } else if (Convert.ToInt32(msgContent.Trim().Length) > 70 && Convert.ToInt32(msgContent.Trim().Length) <= 134) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 2); } else if (Convert.ToInt32(msgContent.Trim().Length) > 134 && Convert.ToInt32(msgContent.Trim().Length) <= 195) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 3); } else if (Convert.ToInt32(msgContent.Trim().Length) > 195 && Convert.ToInt32(msgContent.Trim().Length) <= 260) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 4); } string sendStatus = "0"; if (Utility.IsYiDongCellPhoneNo(phoneNo)) { sendStatus = TBSendMSg.SendMsg(phoneNo, sigNames, objHis.MsgContent.Replace(sigName, "")); //sendStatus = Mobile.SendMsgHubeiYDPost(phoneNo, msgContent); //sendStatus = sendStatus.Replace("\r", "").Replace("\n", ""); if (sendStatus.Equals("0")) { sendStatus = "100"; } //sendStatus = Mobile.sendMsgJiuFang(phoneNo, msgContent,"100057", "c9bf7c4cb27c5527c4d757765514498e");//20160621 yao //更新发送状态 SmartBLL.UpdateSendStatus(sendStatus, objHis.TransNumber); //sendStatus = Mobile.SendMsgZhuTongYD(phoneNo, msgContent); } else { sendStatus = TBSendMSg.SendMsg(phoneNo, sigNames, objHis.MsgContent.Replace(sigName, "")); //sendStatus = Mobile.PostDataToMyServer(phoneNo, msgContent); //IDictionary resultDic = null; //resultDic = TopUtils.ParseJson(sendStatus); //string realStaus = resultDic["status"].ToString(); //更新发送状态 SmartBLL.UpdateSendStatus(sendStatus, objHis.TransNumber); //sendStatus = Mobile.SendMsgKeTongDX(phoneNo, msgContent); } context.Response.Write("发送成功"); } else { context.Response.Write("发送阻塞"); } } else { context.Response.Write("余额不足"); //更新短信账户状态 MsgBLL.UpdateMsgTransServiceStatus(Users.Nick, false); } } else { context.Response.Write("手机号码格式不正确"); } context.Response.End(); } break; #endregion #region sendMsg case "sendMsg": { string content = context.Request.Form["content"]; string[] noWenmings = new string[] { "傻逼", "草", "靠", "黄片", "尼玛", "你妈", "屌丝", "逗比", "你妹", "装逼", "妈蛋", "逼格", "撕逼" , "滚粗", "蛋疼", "婊砸", "跪舔", "婊", "碧池", "土肥圆", "矮穷挫" }; for (int s = 0; s < noWenmings.Length - 1; s++) { if (content.IndexOf(noWenmings[s]) > 0) { context.Response.Write("6"); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } } //控制是否过滤移动号码 string flag = context.Request.Form["falg"]; string signShopName = SellersBLL.GetSignName(Users.Nick); MsgSendHis objHis = null; string msgContent = "【" + signShopName + "】" + content.Trim() + " 退订回N"; DataTable tb = HttpContext.Current.Session["MsgData"] as DataTable; if (tb != null && tb.Rows.Count > 0) { for (int i = 0; i < tb.Rows.Count; i++) { try { BlakList objbk = new BlakList(); objbk.SellerNick = Users.Nick; objbk.BlakName = tb.Rows[i]["buyer_nick"].ToString(); //黑名单 if (!BlcakLstBLL.ChekBlaklist(objbk)) { var cellpone = tb.Rows[i]["cellPhone"].ToString(); if (Utility.IsCellPhone(cellpone) && !string.IsNullOrEmpty(cellpone)) { #region 短信发送 if (MsgBLL.CheckSellerMsgStatus()) { objHis = new MsgSendHis(); //objHis.TransNumber = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() // + DateTime.Now.Day.ToString() + cellpone; objHis.TransNumber = DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + cellpone; //手机号码 2016 yao c objHis.SellerNick = Users.Nick; objHis.Buyer_nick = tb.Rows[i]["buyer_nick"].ToString(); objHis.CellPhone = cellpone; objHis.SendDate = DateTime.Now; objHis.SendType = "短信促销"; objHis.SendStatus = "0"; objHis.Count = "1"; objHis.MsgContent = msgContent; if (Utility.IsYiDongCellPhoneNo(cellpone)) { objHis.HelpSellerNick = "移动"; } else { objHis.HelpSellerNick = "电信联通"; } if (SmartBLL.AddMsgSendHis(objHis)) { try { //string sendStatus = Mobile.sendMsg(lstCellPhoneNo, msgContent); if (Convert.ToInt32(msgContent.Trim().Length) <= 70) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 1); } else if (Convert.ToInt32(msgContent.Trim().Length) > 70 && Convert.ToInt32(msgContent.Trim().Length) <= 134) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 2); } else if (Convert.ToInt32(msgContent.Trim().Length) > 134 && Convert.ToInt32(msgContent.Trim().Length) <= 195) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 3); } else if (Convert.ToInt32(msgContent.Trim().Length) > 195 && Convert.ToInt32(msgContent.Trim().Length) <= 260) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 4); } if (Utility.IsYiDongCellPhoneNo(cellpone)) { //string sendStatus = Mobile.SendMsgHuBeiYD(cellpone, msgContent); //string sendStatus = Mobile.sendMsgJiuFang(cellpone, msgContent, "100057", "c9bf7c4cb27c5527c4d757765514498e");//20160625 yao string sendStatus = Mobile.SendMsgHubeiYDPost(cellpone, msgContent); sendStatus = sendStatus.Replace("\r", "").Replace("\n", ""); if (sendStatus.Equals("0")) { sendStatus = "100"; } SmartBLL.UpdateSendStatus(sendStatus, objHis.TransNumber); } else //电信联通号码全部群发 { string sendStatus = Mobile.PostDataToMyServer(cellpone, msgContent.Trim()); IDictionary resultDic = TopUtils.ParseJson(sendStatus); SmartBLL.UpdateSendStatus(resultDic["status"].ToString(), objHis.TransNumber); } } catch (Exception ex) { //ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Web_UI); continue; } } } else { //更新短信账户状态 MsgBLL.UpdateMsgTransServiceStatus(Users.Nick, false); context.Response.Write("余额不足"); context.Response.End(); break; } #endregion } } } catch (Exception ex) { continue; } } HttpContext.Current.Session["MsgData"] = null; //发送成功 context.Response.Write("发送成功"); context.Response.End(); } else { context.Response.Write("没有会员"); context.Response.End(); } } break; #endregion #region sendSmartMsg case "sendSmartMsg": { string content = context.Request.Form["content"]; string sendType = context.Request.Form["sendType"]; string province = context.Request.Form["provinces"]; MsgSendHis objHis = null; string msgContent = "【" + SellersBLL.GetSignName(Users.Nick) + "】" + content.Trim() + " 退订回N"; //if (RatingBLL.isBshop(Users.Nick)) //{ // msgContent = "【天猫】" + content.Trim() + " 退订N"; //} //else //{ // msgContent = "【淘宝】" + content.Trim() + " 退订N"; //} DataTable tb = null; #region 新会员 if (sendType.Equals("10")) { tb = SmartBLL.GetNewBuyer10Days(Users.SellerId); } if (sendType.Equals("30")) { tb = SmartBLL.GetNewBuyer30Days(Users.SellerId); } #endregion #region 会员等级 if (sendType.Equals("puTongBuyer")) { tb = SmartBLL.GetBuyersCount(1, Users.SellerId); } if (sendType.Equals("gaoJiBuyer")) { tb = SmartBLL.GetBuyersCount(2, Users.SellerId); } if (sendType.Equals("vipBuyer")) { tb = SmartBLL.GetBuyersCount(3, Users.SellerId); } if (sendType.Equals("gaoJiVIPBuyer")) { tb = SmartBLL.GetBuyersCount(4, Users.SellerId); } #endregion #region 活跃度 if (sendType.Equals("HuoYueDiGouMaiQiang")) { tb = SmartBLL.GetHuoYueDiGouMaiQiangBuyersCount(Users.SellerId); } if (sendType.Equals("HuoYueBanGouMaiBan")) { tb = SmartBLL.GetHuoYueBanGouMaiBanBuyersCount(Users.SellerId); } if (sendType.Equals("HuoYueGaoGouMaiBan")) { tb = SmartBLL.GetHuoYueGaoGouMaiBanBuyersCount(Users.SellerId); } if (sendType.Equals("HuoYueGaoGouMaiGao")) { tb = SmartBLL.GetHuoYueGaoGouMaiGaoBuyersCount(Users.SellerId); } #endregion #region 节假日 if (sendType.Equals("yuandan")) { string date = DateTime.Now.AddYears(-1).Year.ToString() + "-01-01"; string date2 = DateTime.Now.Year.ToString() + "-01-01"; tb = SmartBLL.GetHuoDongBuyersCount(date, Users.SellerId, date2); } if (sendType.Equals("qinren")) { string date2 = DateTime.Now.AddYears(-1).Year.ToString() + "-02-14"; string date22 = DateTime.Now.Year.ToString() + "-02-14"; tb = SmartBLL.GetHuoDongBuyersCount(date2, Users.SellerId, date22); } if (sendType.Equals("funv")) { string date3 = DateTime.Now.AddYears(-1).Year.ToString() + "-03-18"; string date33 = DateTime.Now.Year.ToString() + "-03-18"; tb = SmartBLL.GetHuoDongBuyersCount(date3, Users.SellerId, date33); } if (sendType.Equals("wuyi")) { string date4 = DateTime.Now.AddYears(-1).Year.ToString() + "-05-01"; string date44 = DateTime.Now.Year.ToString() + "-05-01"; tb = SmartBLL.GetHuoDongBuyersCount(date4, Users.SellerId, date44); } if (sendType.Equals("fuqin")) { string date5 = DateTime.Now.AddYears(-1).Year.ToString() + "-06-17"; string date55 = DateTime.Now.Year.ToString() + "-06-17"; tb = SmartBLL.GetHuoDongBuyersCount(date5, Users.SellerId, date55); } if (sendType.Equals("qixi")) { string date6 = DateTime.Now.AddYears(-1).Year.ToString() + "-08-23"; string date66 = DateTime.Now.Year.ToString() + "-08-23"; tb = SmartBLL.GetHuoDongBuyersCount(date6, Users.SellerId, date66); } if (sendType.Equals("zhongqiu")) { string date7 = DateTime.Now.AddYears(-1).Year.ToString() + "-09-30"; string date77 = DateTime.Now.Year.ToString() + "-09-30"; tb = SmartBLL.GetHuoDongBuyersCount(date7, Users.SellerId, date77); } if (sendType.Equals("guoqing")) { string date8 = DateTime.Now.AddYears(-1).Year.ToString() + "-10-01"; string date88 = DateTime.Now.Year.ToString() + "-10-01"; tb = SmartBLL.GetHuoDongBuyersCount(date8, Users.SellerId, date88); } if (sendType.Equals("11")) { string date9 = DateTime.Now.AddYears(-1).Year.ToString() + "-11-11"; string date99 = DateTime.Now.Year.ToString() + "-11-11"; tb = SmartBLL.GetHuoDongBuyersCount(date9, Users.SellerId, date99); } if (sendType.Equals("12")) { string date10 = DateTime.Now.AddYears(-1).Year.ToString() + "-12-12"; string date1010 = DateTime.Now.Year.ToString() + "-12-12"; tb = SmartBLL.GetHuoDongBuyersCount(date10, Users.SellerId, date1010); } if (sendType.Equals("shengdan")) { string date11 = DateTime.Now.AddYears(-1).Year.ToString() + "-12-25"; string date1111 = DateTime.Now.Year.ToString() + "-12-25"; tb = SmartBLL.GetHuoDongBuyersCount(date11, Users.SellerId, date1111); } #endregion #region 未交易客户营销 if (sendType.Equals("unpay")) { tb = SmartBLL.GetUnPayBuyersCount(Users.SellerId); } if (sendType.Equals("unpay7days")) { tb = SmartBLL.GetUnPay7DaysBuyersCount(Users.SellerId); } #endregion #region 地区营销 if (sendType.Equals("baifang")) { tb = SmartBLL.GetBaiFangBuyersCount(Users.SellerId); } if (sendType.Equals("nanfang")) { tb = SmartBLL.GetNanFangBuyersCount(Users.SellerId); } if (sendType.Equals("province")) { List <string> list = new List <string>(province.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)); tb = SmartBLL.GetProvinceBuyersCount(Users.SellerId, list); } #endregion if (tb != null && tb.Rows.Count > 0) { for (int i = 0; i < tb.Rows.Count; i++) { try { BlakList objbk = new BlakList(); objbk.SellerNick = Users.Nick; objbk.BlakName = tb.Rows[i]["buyer_nick"].ToString(); //黑名单 if (!BlcakLstBLL.ChekBlaklist(objbk)) { var cellpone = tb.Rows[i]["cellPhone"].ToString(); if (Utility.IsCellPhone(cellpone) && !string.IsNullOrEmpty(cellpone)) { #region 短信发送 if (MsgBLL.CheckSellerMsgStatus()) { objHis = new MsgSendHis(); //objHis.TransNumber = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() // + DateTime.Now.Day.ToString() + cellpone; objHis.TransNumber = DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + cellpone; //手机号码 2016 yao c objHis.SellerNick = Users.Nick; objHis.Buyer_nick = tb.Rows[i]["buyer_nick"].ToString(); objHis.CellPhone = cellpone; objHis.SendDate = DateTime.Now; objHis.SendType = "智能营销"; objHis.SendStatus = "0"; objHis.Count = "1"; objHis.MsgContent = msgContent; if (Utility.IsYiDongCellPhoneNo(cellpone)) { objHis.HelpSellerNick = "移动"; } else { objHis.HelpSellerNick = "电信联通"; } if (SmartBLL.AddMsgSendHis(objHis)) { try { if (Convert.ToInt32(msgContent.Trim().Length) <= 70) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 1); } else if (Convert.ToInt32(msgContent.Trim().Length) > 70 && Convert.ToInt32(msgContent.Trim().Length) <= 134) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 2); } else if (Convert.ToInt32(msgContent.Trim().Length) > 134 && Convert.ToInt32(msgContent.Trim().Length) <= 195) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 3); } else if (Convert.ToInt32(msgContent.Trim().Length) > 195 && Convert.ToInt32(msgContent.Trim().Length) <= 260) { MsgBLL.UpdateMsgTransUseCount(Users.Nick, 4); } if (Utility.IsYiDongCellPhoneNo(cellpone)) { //string sendStatus = Mobile.SendMsgHuBeiYD(cellpone, msgContent); //string sendStatus = Mobile.sendMsgJiuFang(cellpone, msgContent, "100057", "c9bf7c4cb27c5527c4d757765514498e");//20160625 yao string sendStatus = Mobile.SendMsgHubeiYDPost(cellpone, msgContent); sendStatus = sendStatus.Replace("\r", "").Replace("\n", ""); if (sendStatus.Equals("0")) { sendStatus = "100"; } SmartBLL.UpdateSendStatus(sendStatus, objHis.TransNumber); } else { string sendStatus = Mobile.PostDataToMyServer(cellpone, msgContent.Trim()); IDictionary resultDic = TopUtils.ParseJson(sendStatus); SmartBLL.UpdateSendStatus(resultDic["status"].ToString(), objHis.TransNumber); } } catch (Exception ex) { //ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Web_UI); continue; } } } else { //更新短信账户状态 MsgBLL.UpdateMsgTransServiceStatus(Users.Nick, false); context.Response.Write("余额不足"); context.Response.End(); break; } #endregion } } } catch (Exception ex) { continue; } } //发送成功 context.Response.Write("发送成功"); context.Response.End(); } else { context.Response.Write("没有会员"); context.Response.End(); } } break; #endregion #region getMsgCount case "getMsgCount": { DataTable tb = MsgBLL.GetSellerMsgStatus(Users.Nick); string count = "0"; if (tb != null && tb.Rows.Count > 0) { count = "剩余短信:" + tb.Rows[0]["msgCanUseCount"].ToString() + "条"; } else { count = "剩余短信:0条"; } context.Response.Write(count); context.Response.End(); } break; #endregion } } }