Esempio n. 1
0
        private void BindData()
        {
            BLL.wx_qp_img             imgBLl    = new BLL.wx_qp_img();
            BLL.wx_qp_base            actBll    = new BLL.wx_qp_base();
            BLL.wx_qp_users           usersBll  = new BLL.wx_qp_users();
            Model.wx_qp_base          baseModel = actBll.GetModelList(" id=" + aid)[0];
            IList <Model.wx_qp_users> userList  = usersBll.GetModelList(string.Format(" openid='{0}' and bId={1}", openid, aid));

            //判断活动是否过期
            if (baseModel.actEnd < DateTime.Now || baseModel.actBegin > DateTime.Now)
            {
                ErrLevel  = 1;
                ErrorInfo = "此活动时间不对,很遗憾!";
                return;
            }
            if (userList.Count > 0)
            {
                ErrLevel  = 1;
                ErrorInfo = "你已参加过活动,每人只能参加一次!";
                return;
            }

            //轮播图片
            this.rptImglist.DataSource = imgBLl.GetList(" bId=" + aid + " and iType=3 ");
            if (imgBLl.GetList(" bId=" + aid + " and iType=3 ").Tables[0].Rows.Count <= 0)
            {
                mark = "no";
            }
            this.rptImglist.DataBind();
            this.rptNum.DataSource = imgBLl.GetList(" bId=" + aid + " and iType=3 ");
            this.rptNum.DataBind();

            this.Page.Title     = baseModel.bName;
            this.ltrUserxz.Text = baseModel.qpRemark;
        }
Esempio n. 2
0
        private void ckState()
        {
            BLL.wx_qp_base            actBll    = new BLL.wx_qp_base();
            BLL.wx_qp_users           userBll   = new BLL.wx_qp_users();
            Model.wx_qp_base          baseModel = actBll.GetModel(aid);
            IList <Model.wx_qp_users> userList  = userBll.GetModelList(" openid='" + openid + "' and bId=" + aid);

            Model.wx_qp_users userModel = null;
            string            gpTime    = DateTime.Parse(baseModel.yyGouPiaoBeginDate.ToString()).ToString("MM月dd日-HH:mm") +
                                          "~" + DateTime.Parse(baseModel.yyGouPiaoEndDate.ToString()).ToString("MM月dd日-HH:mm");

            if (userList != null && userList.Count > 0)
            {
                userModel = userList[0];
            }

            string Fulltext = "<h1><i class=\"text-icon\">✔</i>已有" + baseModel.maxPersonNum + "人抢到票啦!</h1>" +
                              "<dl class=\"list\">" +
                              "<dd class=\"dd-padding\">特价票已售完即止!</dd>" +
                              "<dd class=\"dd-padding\">请抓紧时间购票把!</dd>" +
                              "<dd class=\"dd-padding\">购票时间:" + gpTime + "</dd></dl><br />";

            //活动人数已满
            if (baseModel.cyPersonNum > baseModel.maxPersonNum)
            {
                this.litFull.Text = Fulltext;
                return;
            }

            //非法用户
            if (userModel == null)
            {
                if (baseModel.cyPersonNum == baseModel.maxPersonNum)//最后一个用户
                {
                    this.litFull.Text = Fulltext;
                }
                else
                {
                    Response.Redirect(string.Format("index.aspx?wid={0}&aid={1}&openid={2}", wid, aid, openid));
                }
                return;
            }

            //第一次参与活动
            if (joined == "true")
            {
                string snNum = userModel.sn;
                this.litShow.Text = "<h1><i class=\"text-icon\">✔</i>您是第" + baseModel.cyPersonNum + "位参加本次抢票!</h1>" +
                                    "<dl class=\"list\">" +
                                    "<dd class=\"dd-padding\">您的sn码:" + snNum + " </dd>" +
                                    "<dd class=\"dd-padding\">购票时间:" + gpTime + "</dd></dl><br />";
                return;
            }//已参与过本次活动,不可以再参加
            else if (joined == "false")
            {
                string snNum = userModel.sn;
                this.litJoined.Text = "<h1><i class=\"text-icon\">✔</i>您已成功参加本次抢票!</h1>" +
                                      "<dl class=\"list\">" +
                                      "<dd class=\"dd-padding\">您的sn码:" + snNum + " </dd>" +
                                      "<dd class=\"dd-padding\">购票时间:" + gpTime + "</dd></dl><br />";
                return;
            }
        }
Esempio n. 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            int    aid     = MyCommFun.RequestInt("aid");
            int    wid     = MyCommFun.RequestWid();
            string openid  = MyCommFun.RequestOpenid();
            string _action = MXRequest.GetQueryString("mycat");

            BLL.wx_qp_base  actBll  = new wx_qp_base();
            BLL.wx_qp_users userBll = new BLL.wx_qp_users();
            //验证码
            if (_action == "sendCardCheckCode")
            {
                Model.wx_qp_base actModel  = actBll.GetModel(aid);
                string           actName   = actModel.bName;
                smsMgr           smgr      = null;
                string           Number    = string.Empty;
                string           smsStatus = string.Empty;
                string           telephone = MXRequest.GetQueryString("telephone");
                #region 验证码
                Dictionary <string, string> jsonDict = new Dictionary <string, string>();
                IList <Model.wx_qp_users>   userList = userBll.GetModelList(string.Format(" (openid='{0}'and bId={2}) or (uTel='{1}' and bId={2})", openid, telephone, aid));
                try
                {
                    if (Regexlib.IsValidMobile(telephone))
                    {
                        //判断是否超过活动最大人数
                        if (actModel.cyPersonNum >= actModel.maxPersonNum)
                        {
                            jsonDict.Add("errno", "sys");
                            jsonDict.Add("content", "活动人数已满!");
                            context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                            return;
                        }

                        if (userList.Count > 0)//已参加过本次活动,不发送验证码
                        {
                            jsonDict.Add("errno", "sys");
                            jsonDict.Add("content", "你已参加过本次活动!");
                            context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                            return;
                        }
                        smgr      = new smsMgr(wid);
                        Number    = Utils.Number(6, true);
                        smsStatus = smgr.SendSMS(telephone, Number + "(动态验证码),您于" + DateTime.Now.ToString("yyyy年MM月dd日 hh点mm分") + "参与\"" + actName + "\"抢票活动,请在10分钟内输入该验证码!", Number, actName, aid);
                        if (smsStatus == "成功")
                        {
                            //获取验证码
                            jsonDict.Add("errno", "0");
                            jsonDict.Add("content", "获取验证码成功");
                            context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                            return;
                        }
                        else
                        {
                            jsonDict.Add("errno", "sys");
                            jsonDict.Add("content", "发送验证码失败!");
                            context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                            return;
                        }
                    }
                    else
                    {
                        jsonDict.Add("errno", "sys");
                        jsonDict.Add("content", "手机格式错误!");
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                        return;
                    }
                }
                catch (Exception ex)
                {
                    jsonDict.Add("errno", "sys");
                    jsonDict.Add("content", "发送验证码失败!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                #endregion
            }

            //index页面抢票时判断是否已参加过活动
            if (_action == "qp_ckJoined")
            {
                Dictionary <string, string> jsonDict = new Dictionary <string, string>();
                //判断此人是否已参与过活动
                bool joined = userBll.GetModelList(string.Format(" bId={0} and openid='{1}'", aid, openid)).Count > 0;
                if (joined)//已参与,跳转结果显示页面
                {
                    string goUrl = string.Format("order_Result.aspx?wid={0}&aid={1}&openid={2}&join=false", wid, aid, openid);
                    jsonDict.Add("errno", "0");
                    jsonDict.Add("content", goUrl);
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                else//还未参与,跳转订单页面
                {
                    string goUrl = string.Format("order.aspx?wid={0}&aid={1}&openid={2}", wid, aid, openid);
                    jsonDict.Add("errno", "0");
                    jsonDict.Add("content", goUrl);
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
            }

            //抢票得到订单
            if (_action == "qp_ckOrder")
            {
                string                      identCode = MyCommFun.QueryString("identCode");
                string                      telephone = MyCommFun.QueryString("telephone");
                BLL.wx_sms_info             smsBll    = new BLL.wx_sms_info();
                Dictionary <string, string> jsonDict  = new Dictionary <string, string>();
                string                      goUrl     = "";
                //判断用户是否已经参与过活动
                IList <Model.wx_qp_users> userList = userBll.GetModelList(string.Format(" (openid='{0}'and bId={2}) or (uTel='{1}' and bId={2}) ", openid, telephone, aid));
                //判断验证码
                bool ckIdentcode = smsBll.ExistsYzm(telephone, identCode);

                Model.wx_qp_base actModel = actBll.GetModel(aid);

                //判断是否超过活动最大人数
                if (actModel.cyPersonNum >= actModel.maxPersonNum)
                {
                    jsonDict.Add("errno", "sys");
                    jsonDict.Add("content", "活动人数已满!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                if (userList.Count > 0)
                {
                    jsonDict.Add("errno", "sys");
                    jsonDict.Add("content", "你已参加过活动,每人只能参加一次!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                if (!Regexlib.IsValidMobile(telephone))
                {
                    jsonDict.Add("errno", "sys");
                    jsonDict.Add("content", "手机格式错误!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                if (!ckIdentcode)
                {
                    jsonDict.Add("errno", "sys");
                    jsonDict.Add("content", "验证码错误!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }



                Model.wx_qp_users model = new Model.wx_qp_users();
                model.bId        = aid;
                model.openid     = openid;
                model.uTel       = telephone;
                model.createDate = DateTime.Now;
                model.sn         = "sn_" + Utils.Number(6, true);
                //添加参与活动用户并给递加活动人数
                int res = userBll.Add(model);
                actModel.cyPersonNum  = actModel.cyPersonNum + 1;
                actModel.yingyuanlist = null;
                actBll.Update(actModel);

                //判断该活动是否发送SN码通知用户
                if (actModel.isSnSendsms && res > 0)//发送
                {
                    smsMgr smgr      = new smsMgr(wid);
                    string smsStatus = smgr.SendSMS("您于" + DateTime.Now.ToString("yyyy年MM月dd日 hh点mm分") + "参与\"" + actModel.bName + "\"抢票活动!恭喜你,抢票成功!(SN码)" + telephone, model.sn, model.sn, actModel.bName, aid);
                }
                goUrl = string.Format("order_Result.aspx?wid={0}&aid={1}&openid={2}&join=true", wid, aid, openid);
                jsonDict.Add("errno", "0");
                jsonDict.Add("content", goUrl);
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));
            }
        }