예제 #1
0
 public DataSet AuthenticateLogin(string _username, string _password, string _page)
 {
     oMemberDAL    = new DAL.MemberDAL();
     this.UserName = _username;
     this.Password = _password;
     this.Page     = _page;
     try
     {
         return(oMemberDAL.ValidateLogin(this));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #2
0
        /// <summary>
        /// 回复逻辑
        /// </summary>
        /// <param name="MsgXml"></param>
        public string SendEvent(XmlElement rootElement)
        {
            RequestXML MsgXml = new RequestXML();

            MsgXml.MsgType      = rootElement.SelectSingleNode("MsgType").InnerText;
            MsgXml.ToUserName   = rootElement.SelectSingleNode("ToUserName").InnerText;
            MsgXml.FromUserName = rootElement.SelectSingleNode("FromUserName").InnerText;
            MsgXml.CreateTime   = rootElement.SelectSingleNode("CreateTime").InnerText;
            MsgXml.KeyTypeId    = MsgXml.MsgType;



            StringBuilder s = new StringBuilder();
            StringBuilder c = new StringBuilder();

            BLL.MerchantBLL mbll = new MerchantBLL();
            s.Append(" select * from dbo.MemberView with(nolock) where WxOpenId='" + MsgXml.FromUserName + "' and Invalid=0 and YuanShiId='" + MsgXml.ToUserName + "' ");
            s.Append(" SELECT * FROM dbo.WxPtView  with(nolock) WHERE YuanShiId='" + MsgXml.ToUserName + "' AND Invalid=0 ");



            DataSet   dsMember = DAL.DalComm.BackData(s.ToString());
            DataTable dtWxPt   = dsMember.Tables[1];

            if (dtWxPt.Rows.Count != 1)
            {
                throw new Exception(" 原始ID为'" + MsgXml.ToUserName + "'数量是'" + dtWxPt.Rows.Count + "'! 请联系管理员:qq19278765 ");
            }
            DataRow drWxPt = dtWxPt.Rows[0];
            DataRow drMember;

            if (dsMember.Tables[0].Rows.Count > 0)
            {
                drMember = dsMember.Tables[0].Rows[0];
                //更改最后操作时间
                DAL.DalComm.ExReInt(" Update dbo.Member set LastTime='" + DateTime.Now + "' where MemberId='" + drMember["MemberId"] + "' ");
            }
            else
            {
                //首次关注,添加
                Model.MemberModel MemberModel = new MemberModel();
                MemberModel.Birthday   = DateTime.Parse("1900-01-01");
                MemberModel.CreateTime = DateTime.Now;
                MemberModel.LastTime   = DateTime.Now;
                MemberModel.Email      = "";
                MemberModel.WxPtId     = decimal.Parse(drWxPt["WxPtId"].ToString());
                MemberModel.WxOpenId   = MsgXml.FromUserName;
                DAL.MemberDAL mbDal = new DAL.MemberDAL();
                mbDal.Add(MemberModel);
                int codeSize = 8 - MemberModel.MemberId.ToString().Length;
                MemberModel.MemberCode = MemberModel.MemberId.ToString();
                for (int i = 0; i < codeSize; i++)
                {
                    MemberModel.MemberCode = "0" + MemberModel.MemberCode;    //补齐前位的0,填充会员卡号
                }



                DataSet ds_ls = DAL.DalComm.BackData(" Update dbo.Member set MemberCode='" + MemberModel.MemberCode + "' where MemberId='" + MemberModel.MemberId + "'  select * from dbo.MemberView with(nolock) where  MemberId='" + MemberModel.MemberId + "'       UPDATE dbo.Member SET MerId=(SELECT TOP 1 dbo.WxPtInfo.MerId FROM dbo.WxPtInfo WHERE WxPtId=member.WxPtId ) WHERE MerId=0  ");

                drMember = ds_ls.Tables[0].Rows[0];
            }


            s.Clear();
            switch (MsgXml.MsgType.ToLower())
            {
            case "event":

                MsgXml.KeyTypeDetailId = rootElement.SelectSingleNode("Event").InnerText;     //按钮 click
                MsgXml.KeyTitle        = GetMsgNodeValue(rootElement, "EventKey", "");
                break;

            case "voice":                                                                //如果是语音消息

                MsgXml.KeyTitle = rootElement.SelectSingleNode("Recognition").InnerText; //语音识别内容

                break;

            case "text":       //如果是文本消息
                MsgXml.KeyTitle = rootElement.SelectSingleNode("Content").InnerText;

                #region 系统功能(例如派送订单确认)

                #region 派送订单确认


                //如果输入了全部订单号, 或者以小数点开头输入了部分订单
                if (MsgXml.KeyTitle.Trim().Length == 20 || MsgXml.KeyTitle.Trim().Substring(0, 1) == ".")
                {
                    return(QueakSend(MsgXml, mbll.QueRenDingDan(MsgXml.KeyTitle, MsgXml.FromUserName, "")));
                }


                #endregion
                #endregion

                break;

            case "image":      //如果是图片消息

                MsgXml.KeyTitle = "";
                break;
            }

            #region 判断是否快捷会员公共方法


            if (MsgXml.KeyTitle.ToLower() == "quickcard")
            {
                return(MyMemberQuickCard(MsgXml));
            }

            #endregion



            s.Append("  SELECT * FROM CORE.dbo.WxKeyView with(nolock) WHERE YuanShiId='" + MsgXml.ToUserName + "' AND KeyTypeId='" + MsgXml.MsgType.ToLower() + "'  ");
            s.Append(" and  WxSendInvalid=0 and WxPtInvalid=0  ");
            if (MsgXml.KeyTitle != "")
            {
                s.Append(" AND  KeyTitle='" + MsgXml.KeyTitle + "' ");
            }

            if (MsgXml.KeyTypeDetailId != "")
            {
                s.Append(" AND KeyTypeDetailId='" + MsgXml.KeyTypeDetailId + "' ");
            }

            DataSet ds = DAL.DalComm.BackData(s.ToString());

            DataTable dtKey = ds.Tables[0];

            if (dtKey.Rows.Count > 0)
            {
                DataRow drKey = dtKey.Rows[0];


                string SendContent = Common.StringPlus.WxSendStr(HttpUtility.UrlDecode(drKey["SendContent"].ToString()));

                switch (drKey["WxSendClassId"].ToString())
                {
                case "1":     //快速文本回复

                    return(QueakSend(MsgXml, SendContent));

                    break;

                case "5":      //素材回复

                    string WxSuCaiId = drKey["WxSuCaiId"].ToString();

                    s.Clear();
                    s.Append(" select * from dbo.WxSuCaiInfo Where WxSuCaiInfoId='" + WxSuCaiId + "' ");
                    s.Append(" select * from dbo.WxSuCaiDetailView where WxSuCaiInfoId='" + WxSuCaiId + "'  ");
                    DataSet dsSuCai = DAL.DalComm.BackData(s.ToString());

                    DataTable dtSuCaiInfo = dsSuCai.Tables[0];
                    if (dtSuCaiInfo.Rows.Count == 0)
                    {
                        throw new Exception("没有找到对应的素材!");
                    }
                    DataRow drSuCaiInfo = dtSuCaiInfo.Rows[0];
                    switch (drSuCaiInfo["WxSuCaiClassId"].ToString())
                    {
                    case "1":         //文本素材
                        return(QueakSend(MsgXml, drSuCaiInfo["WxSuCaiContent"].ToString()));

                        break;

                    case "2":         //图文素材
                        DataTable dtSuCaiDetail = dsSuCai.Tables[1];
                        return(ImgTextSend(MsgXml, dtSuCaiDetail));

                        break;
                    }
                    break;
                }
            }
            else
            {
            }

            return("");
        }