/// <summary> /// 普通关注事件 /// </summary> public ReplyBaseMsg AttendHandler(EventAttendMsg msg) { new WxUser().InsertOrUpdateUsers(msg.FromUserName, null); ReplyTextMsg replymsg = new ReplyTextMsg(); replymsg.Content = @"欢迎关注萌宅族!萌物控?周边狂热?二次元中毒?中二毕业?急需回血?求小伙伴?想当现充?绅士福利?一大波你想要的萌货和宅品更多好玩等你来发现~更多新功能陆续添加中!"; return replymsg; }
/// <summary> /// 点击菜单拉取消息时的事件推送 /// </summary> public ReplyBaseMsg ClickHandler(EventClickMsg msg) { CHelper.WriteLog("msg", msg.EventKey); if (msg.EventKey == "checkin") { ReplyTextMsg replymsg = new ReplyTextMsg(); DateTime nowDate = DateTime.Now; string openid = msg.FromUserName; DataSet ds = DbHelperMySQL.Query("select * from tb_signin where openid='" + openid + "' and year(createdtime)=" + nowDate.Year.ToString() + " and month(createdtime)=" + nowDate.Month.ToString() + " and day(createdtime)=" + nowDate.Day.ToString() + " and type='checkin'"); DataTable tb = ds.Tables[0]; if (tb.Rows.Count == 0) { DbHelperMySQL.ExecuteSql("update tb_user set user_integral=user_integral+5 where user_phone='" + openid + "'"); DbHelperMySQL.ExecuteSql("INSERT INTO tb_signin(openid, type,createdtime) VALUES('" + openid + "','checkin',current_timestamp)"); replymsg.Content = "签到成功,谢谢"; } else { replymsg.Content = "您今天已经签到过了,请明天再来。"; } return replymsg; } //JieEn.BLL.WxMenu menuBLL = new JieEn.BLL.WxMenu(); //JieEn.Model.WxMenu menuModel = menuBLL.GetModelList("MenuType='Click' And MenuKeyOrUrl='" + msg.EventKey + "'").FirstOrDefault(); //if (menuModel == null) //{ // return ReplyEmptyMsg.Instance; //} //else //{ // try // { //ReplyTextMsg replymsg = new ReplyTextMsg(); //switch (msg.EventKey) //{ // //case "就餐预订": // // replymsg.Content = "订餐热线:05808227777"; // // return replymsg; // //case "活动介绍": // // replymsg.Content = "暂无优惠活动,敬请关注最新公众号通知。"; // // return replymsg; // //case "领取优惠券": // ////JieEn.BLL.User userBLL = new JieEn.BLL.User(); // ////var userModel = userBLL.GetModel(msg.FromUserName); // ////SendCard sendCard = new SendCard(); // ////if (userModel != null && sendCard.SendFirstCard(userModel.ID)) // ////{ // //// replymsg.Content = "领取成功,<a href='http://wx.zsnanyang.com/ticket.aspx'>点击查看</a>"; // ////} // ////else // ////{ // //// replymsg.Content = sendCard.ErrMsg == "" ? "领取失败。" : sendCard.ErrMsg; // ////} // ////return replymsg; // //default: // // ReplyNewsMsg rNewsMsg = WeiXinSDK.Util.JsonTo<ReplyNewsMsg>(menuModel.Menu_xml); // // return rNewsMsg; //} //} //catch //{ return ReplyEmptyMsg.Instance; //} //} }
/// <summary> /// 用户未关注时,扫描二维码进行关注后的事件推送 /// 1.带参数二维码 /// 2.非带参数二维码 /// </summary> public ReplyBaseMsg ScanHandler(EventUserScanMsg msg) { //更新用户信息 if (msg.EventKey.IndexOf("qrscene_") >= 0)//带参数二维码 { new WxUser().InsertOrUpdateUsers(msg.FromUserName, msg.EventKey.Substring(8)); } else//非带参数二维码 { new WxUser().InsertOrUpdateUsers(msg.FromUserName, null); } ReplyTextMsg replymsg = new ReplyTextMsg(); replymsg.Content = @"欢迎关注萌宅族!萌物控?周边狂热?二次元中毒?中二毕业?急需回血?求小伙伴?想当现充?绅士福利?一大波你想要的萌货和宅品更多好玩等你来发现~更多新功能陆续添加中! "; return replymsg; }