Beispiel #1
0
        private void EditAwardItem(int dzpId)
        {
            //1删除原来的,2新增
            iBll.DeleteByActId(dzpId);
            Model.wx_zjdAwardItem item = new Model.wx_zjdAwardItem();
            TextBox txtJXName;
            TextBox txtJPName;
            TextBox txtNum;
            TextBox txtRealNum;
            TextBox txtXSName;
            int     sort_id = 0;

            int totJxNum = 0; //一共有多少奖项

            for (int i = 1; i <= 6; i++)
            {
                txtJXName  = this.FindControl("txt" + i + "JXName") as TextBox;
                txtXSName  = this.FindControl("txt" + i + "XSName") as TextBox;
                txtRealNum = this.FindControl("txt" + i + "RealNum") as TextBox;
                txtJPName  = this.FindControl("txt" + i + "JPName") as TextBox;
                txtNum     = this.FindControl("txt" + i + "Num") as TextBox;


                if (txtJXName.Text.Trim() != "" && txtNum.Text.Trim() != "" && txtRealNum.Text.Trim() != "" && MyCommFun.isNumber(txtNum.Text) && MyCommFun.isNumber(txtRealNum.Text))
                {
                    totJxNum++;
                }
            }


            for (int i = 1; i <= 6; i++)
            {
                txtJXName  = this.FindControl("txt" + i + "JXName") as TextBox;  //奖品名称
                txtXSName  = this.FindControl("txt" + i + "XSName") as TextBox;  //显示实际数量
                txtRealNum = this.FindControl("txt" + i + "RealNum") as TextBox; //实际数量
                txtJPName  = this.FindControl("txt" + i + "JPName") as TextBox;  //重命名
                txtNum     = this.FindControl("txt" + i + "Num") as TextBox;     //图片



                if (txtJXName.Text.Trim() != "" && txtNum.Text.Trim() != "" && txtRealNum.Text.Trim() != "" && MyCommFun.isNumber(txtRealNum.Text))
                {
                    sort_id++;
                    //那么添加奖品信息
                    item.jxName      = txtJXName.Text.Trim();                     //奖品
                    item.sort_id     = sort_id;
                    item.jpNum       = MyCommFun.Str2Int(txtXSName.Text.Trim());  //奖品数量
                    item.jpRealNum   = MyCommFun.Str2Int(txtRealNum.Text.Trim()); //奖品数量
                    item.jpName      = txtJPName.Text.Trim();                     //奖品重命名
                    item.jiangpinpic = txtNum.Text.Trim();                        //图片
                    item.actId       = dzpId;
                    item.createDate  = DateTime.Now;
                    //item.jiaodu_min = avgDeg * sort_id;
                    iBll.Add(item);
                }
            }
        }
Beispiel #2
0
        private Model.wx_zjdAwardItem getZJItem(IList <Model.wx_zjdAwardItem> itemlist, IList <Model.wx_zjdAwardUser> haszjlist)
        {
            IList <Model.wx_zjdAwardItem> zjItemlist = new List <Model.wx_zjdAwardItem>();//剩余奖品列表

            Model.wx_zjdAwardItem         tmpItem  = new Model.wx_zjdAwardItem();
            Model.wx_zjdAwardItem         stmpItem = new Model.wx_zjdAwardItem();
            IList <Model.wx_zjdAwardUser> thiszjRs;

            for (int i = 0; i < itemlist.Count; i++)
            {
                tmpItem  = itemlist[i];
                thiszjRs = (from user in haszjlist where user.jpName == tmpItem.jpName && user.jxName == tmpItem.jxName select user).ToArray <Model.wx_zjdAwardUser>();
                int tmpSYNum = 0;
                if (thiszjRs != null)
                {
                    tmpSYNum = MyCommFun.Obj2Int(tmpItem.jpRealNum) - thiszjRs.Count;
                }
                if (tmpSYNum <= 0)
                {
                    continue;
                }
                for (int j = 0; j < tmpSYNum; j++)
                {
                    stmpItem             = new Model.wx_zjdAwardItem();
                    stmpItem.jpName      = tmpItem.jpName;
                    stmpItem.jxName      = tmpItem.jxName;
                    stmpItem.sort_id     = tmpItem.sort_id;
                    stmpItem.jiangpinpic = tmpItem.jiangpinpic;
                    zjItemlist.Add(stmpItem);
                }
            }

            Random rd      = new Random((int)DateTime.Now.Ticks);
            int    jpIndex = rd.Next(0, zjItemlist.Count);//从0到zjItemlist.Count里随机出一个值

            return(zjItemlist[jpIndex]);
        }
Beispiel #3
0
        private void ShowInfo(int id)
        {
            hidid.Value = id.ToString();

            IList <Model.wx_zjdAwardItem> aItemlist = iBll.GetModelList("actId=" + id);

            Model.wx_requestRule rule = rBll.GetModelList("modelFunctionName='砸金蛋' and modelFunctionId=" + id)[0];
            txtKW.Text = rule.reqKeywords;

            info = infobll.GetModel(zjdid);
            if (info == null)
            {
                return;
            }

            //基本设置
            if (info.beginPic != null && info.beginPic.Trim() != "/weixin/zjd/image/activity-zjd-start.jpg")
            {
                this.beginPic.Text   = info.beginPic;
                imgbeginPic.ImageUrl = info.beginPic;
            }
            this.actName.Text      = info.actName;
            this.duijiangInfo.Text = info.duijiangInfo;
            this.brief.InnerText   = info.brief;
            this.beginDate.Text    = info.beginDate.ToString();
            this.endDate.Text      = info.endDate.ToString();
            if (info.actContent != null)
            {
                this.actContent.InnerText = info.actContent.ToString();
            }

            this.cfcjhf.Text = info.cfcjhf;


            //活动结束
            if (info.endPic != null && info.endPic.Trim() != "/weixin/zjd/image/activity-zjd-end.jpg")
            {
                endPic.Text        = info.endPic;
                imgEndPic.ImageUrl = info.endPic;
            }
            this.endNotice.Text  = info.endNotice;
            this.endContent.Text = info.endContent;


            //中奖率设置
            this.zhongjianglv.Text = info.personNum.ToString();

            this.personMaxTimes.Text = info.personMaxTimes.ToString();
            this.dayMaxTimes.Text    = info.dayMaxTimes.ToString();
            this.djPwd.Text          = info.djPwd;
            this.backMusic.Text      = info.backMusic;



            //绑定奖项信息
            IList <Model.wx_zjdAwardItem> itemlist = iBll.GetModelList("actId=" + id + " order by sort_id asc");

            if (itemlist != null && itemlist.Count > 0)
            {
                int     count = itemlist.Count;
                TextBox txtJXName;
                TextBox txtJPName;
                TextBox txtNum;
                TextBox txtRealNum;
                TextBox txtXSName;

                Model.wx_zjdAwardItem itemEntity = new Model.wx_zjdAwardItem();
                for (int i = 1; i <= count; i++)
                {
                    itemEntity = itemlist[(i - 1)];
                    txtJXName  = this.FindControl("txt" + i + "JXName") as TextBox;                               //名称
                    txtXSName  = this.FindControl("txt" + i + "XSName") as TextBox;                               //显示奖品数
                    txtRealNum = this.FindControl("txt" + i + "RealNum") as TextBox;                              //实际奖品数
                    txtJPName  = this.FindControl("txt" + i + "JPName") as TextBox;                               //奖品重命名
                    txtNum     = this.FindControl("txt" + i + "Num") as TextBox;                                  //图片

                    txtJXName.Text  = itemEntity.jxName;                                                          //奖品名称
                    txtXSName.Text  = itemEntity.jpNum == null ? "0" : itemEntity.jpNum.Value.ToString();         //显示奖品数量
                    txtRealNum.Text = itemEntity.jpRealNum == null ? "0" : itemEntity.jpRealNum.Value.ToString(); //奖品数量
                    txtJPName.Text  = itemEntity.jpName;                                                          //精品重命名
                    txtNum.Text     = itemEntity.jiangpinpic;                                                     //奖品图片
                }
            }

            this.snShezhi.Text               = info.snShezhi;
            this.snRename.Text               = info.snRename;
            this.telRename.Text              = info.telRename;
            this.jpDisplay.SelectedValue     = info.jpDisplay.ToString();
            this.mrXingyun.SelectedValue     = info.mrXingyun.ToString();
            this.zhongjiangSZ.SelectedValue  = info.zhongjiangSZ.ToString();
            this.choujiangMode.SelectedValue = info.choujiangMode;
        }
Beispiel #4
0
        private void BindData()
        {
            zjdAction = actBll.GetModel(aid);
            IList <Model.wx_zjdAwardItem> itemlist = itemBll.GetModelList("actId=" + aid);

            if (zjdAction == null || itemlist == null || itemlist.Count <= 0)
            {
                ErrLevel  = 1;
                ErrorInfo = "未获得到数据";
                return;
            }
            this.Title = zjdAction.actName;

            if (zjdAction.endDate <= DateTime.Now)
            {   //说明活动已经结束
                ErrLevel  = 101;
                ErrorInfo = "活动已结束";
                return;
            }

            StringBuilder sb = new StringBuilder("");

            Model.wx_zjdAwardItem item = new Model.wx_zjdAwardItem();
            int ttJpNum = 0;

            shuzu = "[";
            for (int i = 0; i < itemlist.Count; i++)
            {
                item = itemlist[i];
                sb.Append("<p>" + item.jxName + ":" + item.jpName + "  数量:" + item.jpNum + "</p>");
                ttJpNum += item.jpRealNum.Value;
                picIndex++;
                if (i < (itemlist.Count - 1))
                {
                    shuzu += item.jiaodu_min + ",";
                }
                else
                {
                    shuzu += item.jiaodu_min;
                }
            }
            shuzu += "]";


            littotTimes.Text  = zjdAction.personMaxTimes == null ? "0" : zjdAction.personMaxTimes.Value.ToString();
            litdaysTimes.Text = zjdAction.dayMaxTimes == null ? "0" : zjdAction.dayMaxTimes.Value.ToString();

            if (zjdAction.beginDate > DateTime.Now)
            {
                hidStatus.Value = "-2";
                ErrorInfo       = hidErrInfo.Value = "活动尚未开始";
            }


            getjiangpin(aid);
            zjjlist(openid); //中奖记录
            zjtel(aid);      //最新中奖手机号



            int hasCjTimes = utbll.getCJCiShu(aid, openid);//返回该用户的抽奖次数

            this.litHasUsedTimes.Text = hasCjTimes.ToString();

            int dayMaxTimes = zjdAction.dayMaxTimes == null ? 0 : zjdAction.dayMaxTimes.Value;
            int perMaxTimes = zjdAction.personMaxTimes == null ? 0 : zjdAction.personMaxTimes.Value;

            //判断是否中奖了

            Model.wx_zjdAwardUser award = ubll.getZJinfoByOpenid(aid, openid);
            if (award != null && award.id > 0)
            {
                this.hastime.Value = "1";

                //您中奖了
                if (award.uTel != null && award.uTel.ToString().Trim() != "")
                {//已经中奖,并且提交了
                    hidAwardId.Value = award.id.ToString();
                    isZhJing         = true;
                }
                else
                { //已经中奖,但是未提交
                    hidStatus.Value = "100";

                    hidAwardId.Value = award.id.ToString();
                }

                sectinstring += "<section  class=\"stage\">";
                sectinstring += " <img src=\"image/stage.jpg\">";
                sectinstring += "      <div    class=\"red\">";
                sectinstring += "    亲你已经中过奖了,不能再抽了!            </div>";

                sectinstring += "    </section>";
            }
            else
            {
                //判断每人最大抽奖次数,是否超过了
                if (hasCjTimes >= zjdAction.personMaxTimes)
                {
                    hidStatus.Value = "2";
                    // litOtherTip.Text = "<p class='red'>您已经抽了" + hasCjTimes + "次了。</p>";
                }
                if (isTodayOverSum(dayMaxTimes))
                {
                    this.daytime.Value = "1";
                    hidStatus.Value    = "2";
                    //  litOtherTip.Text = "<p class='red'>每人每天只有" + dayMaxTimes.ToString() + "次抽奖机会,您已经使用完了。</p>";
                }

                sectinstring += " <section class=\"stage\">";

                sectinstring += " <img src=\"image/stage.jpg\">";
                sectinstring += " <div id=\"shape\" class=\"cube on\">";
                sectinstring += "  <div class=\"plane one\">";
                sectinstring += "  <span>";
                sectinstring += "   <figure>&nbsp;</figure>";
                sectinstring += "    </span>";
                sectinstring += " </div>";
                sectinstring += " <div class=\"plane two\">";
                sectinstring += "   <span>";
                sectinstring += "   <figure>&nbsp;</figure>";
                sectinstring += "   </span>";
                sectinstring += "  </div>";
                sectinstring += " <div class=\"plane three\">";
                sectinstring += "   <span>";
                sectinstring += "      <figure>&nbsp;</figure>";
                sectinstring += "   </span>";
                sectinstring += "  </div>";
                sectinstring += "  </div>";
                sectinstring += " <div id=\"hit\" class=\"hit\">";
                sectinstring += "  <img src=\"image/1.png\"></div> </section>";
            }
        }
Beispiel #5
0
        public void ProcessRequest(HttpContext context)
        {
            Dictionary <string, string> jsonDict = new Dictionary <string, string>();

            context.Response.ContentType = "text/json";
            string _action = MyCommFun.QueryString("myact");
            int    aid     = MyCommFun.RequestInt("aid");
            int    wid     = MyCommFun.RequestInt("wid");
            string openid  = MyCommFun.QueryString("openid");


            if (_action == "choujiang")
            {
                BLL.wx_zjdAwardItem    itemBll   = new BLL.wx_zjdAwardItem();
                Model.wx_zjdActionInfo zjdAction = new Model.wx_zjdActionInfo();
                #region 判断

                if (aid == 0 || wid == 0 || openid.Trim() == "")
                {
                    jsonDict.Add("error", "sys");
                    jsonDict.Add("content", "参数错误!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                zjdAction = actbll.GetModel(aid);
                if (zjdAction == null)
                {
                    jsonDict.Add("error", "sys");
                    jsonDict.Add("content", "参数错误!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                if (zjdAction.endDate <= DateTime.Now)
                { //说明活动已经结束
                    //非活动期间
                    jsonDict.Add("error", "end");
                    jsonDict.Add("content", "活动已结束");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                else if (zjdAction.beginDate > DateTime.Now)
                {
                    //活动未开始
                    //非活动期间
                    jsonDict.Add("error", "nostart");
                    jsonDict.Add("content", "活动未开始");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int dayMaxTimes = zjdAction.dayMaxTimes == null ? 0 : zjdAction.dayMaxTimes.Value;
                int perMaxTimes = zjdAction.personMaxTimes == null ? 0 : zjdAction.personMaxTimes.Value;
                //判断每人最大抽奖次数,是否超过了
                if (personCJTimes(openid, aid) >= zjdAction.personMaxTimes)
                {
                    jsonDict.Add("error", "notimes");
                    jsonDict.Add("content", "您已抽过奖了,欢迎下次再来!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                if (isTodayOverSum(aid, openid, dayMaxTimes))
                {
                    jsonDict.Add("error", "notimes");
                    jsonDict.Add("content", "每人每天只有" + dayMaxTimes.ToString() + "次抽奖机会,您已经用完了!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                Model.wx_zjdAwardUser award = ubll.getZJinfoByOpenid(aid, openid);
                if (award != null)
                {
                    //您中奖了
                    jsonDict.Add("error", "notimes");
                    jsonDict.Add("content", "您已抽过奖了,欢迎下次再来!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }


                #endregion
                #region 计算中奖信息

                /// 处理是否中奖
                /// hidStatus 状态为-1:不能抽奖,直接跳转到end.aspx页面;
                /// 0:抽奖次数超过设置的最高次数;
                /// 1:还可以继续抽奖;
                /// 2:中奖了;

                List <Model.wx_zjdAwardItem> itemlist = itemBll.GetModelList("actId=" + aid);//该活动的所有奖项信息
                int ttJpNum = 0;
                for (int i = 0; i < itemlist.Count; i++)
                {
                    ttJpNum += itemlist[i].jpRealNum.Value;
                }


                IList <Model.wx_zjdAwardUser> auserlist = ubll.getHasZJList(aid);//已经中奖的人列表
                int ZhongJiangNum = 0;
                if (auserlist != null)
                {
                    ZhongJiangNum = auserlist.Count; //已经中奖的人数
                }

                int syZjNum = ttJpNum - ZhongJiangNum; //剩余的奖品数量
                if (syZjNum <= 0)
                {                                      //说明已经没有奖品了
                    jsonDict.Add("error", "-1");
                    jsonDict.Add("content", zjdAction.cfcjhf);
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                zjdAction.personNum      = MyCommFun.Obj2Int(zjdAction.personNum, 1);
                zjdAction.personMaxTimes = MyCommFun.Obj2Int(zjdAction.personMaxTimes, 1);
                int fenmo = zjdAction.personNum.Value * zjdAction.personMaxTimes.Value;

                Random rd     = new Random((int)DateTime.Now.Ticks);
                int    radNum = rd.Next(0, fenmo);//从0到fenmo里随机出一个值
                if (radNum < syZjNum)
                {
                    //中奖了,再从剩余奖品里抽取一个奖品
                    Model.wx_zjdAwardItem dajiang = getZJItem(itemlist, auserlist);
                    if (dajiang != null)
                    {
                        //这是中的中奖了
                        string snumber = Get_snumber(aid);
                        int    uId     = ubll.Add(aid, "", "", openid, dajiang.jxName, dajiang.jpName, snumber, dajiang.sort_id.Value);

                        jsonDict.Add("error", "succ");
                        jsonDict.Add("content", "恭喜你中奖了!");
                        jsonDict.Add("sortid", dajiang.sort_id.Value.ToString());
                        jsonDict.Add("c_type", dajiang.jxName);
                        jsonDict.Add("c_name", dajiang.jpName);
                        jsonDict.Add("uid", uId.ToString());
                        jsonDict.Add("c_pic", dajiang.jiangpinpic.ToString());
                        jsonDict.Add("code", snumber);
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                        return;
                    }
                    else
                    {
                        //奖品已经全部中完了
                        jsonDict.Add("error", "-1");
                        jsonDict.Add("content", zjdAction.cfcjhf);
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                        return;
                    }
                }
                else
                {
                    //这个条件说明:未中奖
                    //抛出未中奖的数据

                    jsonDict.Add("error", "-1");
                    jsonDict.Add("content", zjdAction.cfcjhf);
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }



                #endregion
            }

            else if (_action == "update")//领取
            {
                try
                {
                    #region 提交手机
                    /// 提交手机号码

                    string username = MyCommFun.QueryString("username");
                    string tel      = MyCommFun.QueryString("tel");
                    string snumber  = MyCommFun.QueryString("snumber");
                    int    id       = MyCommFun.RequestInt("id");

                    if (aid == 0 || id == 0 || snumber == "" || tel == "" || username == "")
                    {
                        context.Response.Write("{\"msg\":\"提交出现异常!!\",\"success\":\"0\"}");
                        return;
                    }

                    BLL.wx_zjdAwardUser   ubll  = new BLL.wx_zjdAwardUser();
                    Model.wx_zjdAwardUser model = ubll.GetModel(id);
                    if (model == null)
                    {
                        context.Response.Write("{\"msg\":\"提交出现异常2!!\",\"success\":\"0\"}");
                        return;
                    }



                    model.uName = username;
                    model.uTel  = tel;
                    ubll.Update(model);

                    context.Response.Write("{\"msg\":\"提交成功!\",\"success\":\"1\"}");
                    return;

                    #endregion
                }
                catch
                {
                    context.Response.Write("{\"msg\":\"提交出现异常!!\",\"success\":\"0\"}");

                    return;
                }
            }


            else if (_action == "updatestatus")//申请兑换
            {
                try
                {
                    #region 提交手机
                    /// 提交手机号码

                    string pwd = MyCommFun.QueryString("pwd");
                    int    id  = MyCommFun.RequestInt("id");



                    BLL.wx_zjdActionInfo   infobll   = new BLL.wx_zjdActionInfo();
                    Model.wx_zjdActionInfo infomodel = new Model.wx_zjdActionInfo();
                    infomodel = infobll.GetModel(aid);
                    if (infomodel == null)
                    {
                        return;
                    }
                    else if (infomodel.djPwd == "")
                    {
                        if (aid == 0 || id == 0)
                        {
                            context.Response.Write("{\"msg\":\"提交出现异常!!\",\"success\":\"0\"}");
                            return;
                        }

                        BLL.wx_zjdAwardUser   ubll  = new BLL.wx_zjdAwardUser();
                        Model.wx_zjdAwardUser model = ubll.GetModel(id);
                        if (model == null)
                        {
                            context.Response.Write("{\"msg\":\"提交出现异常2!!\",\"success\":\"0\"}");
                            return;
                        }


                        model.hasLingQu = true;


                        ubll.Update(model);

                        context.Response.Write("{\"msg\":\"提交成功!\",\"success\":\"1\"}");
                        return;
                    }
                    else
                    {
                        if (aid == 0 || id == 0 || pwd == "")
                        {
                            context.Response.Write("{\"msg\":\"提交出现异常!!\",\"success\":\"0\"}");
                            return;
                        }

                        if ((pwd.Length > 0) && (!actbll.ExistsPwd(aid, pwd)))
                        {
                            context.Response.Write("{\"msg\":\"商家兑换密码错误!!\",\"success\":\"0\"}");
                            return;
                        }

                        BLL.wx_zjdAwardUser   ubll  = new BLL.wx_zjdAwardUser();
                        Model.wx_zjdAwardUser model = ubll.GetModel(id);
                        if (model == null)
                        {
                            context.Response.Write("{\"msg\":\"提交出现异常2!!\",\"success\":\"0\"}");
                            return;
                        }

                        if (pwd.Length > 0)
                        {
                            model.hasLingQu = true;
                        }
                        else
                        {
                            model.hasLingQu = false;
                        }
                        ubll.Update(model);

                        context.Response.Write("{\"msg\":\"提交成功!\",\"success\":\"1\"}");
                        return;
                    }



                    #endregion
                }
                catch
                {
                    context.Response.Write("{\"msg\":\"提交出现异常!!\",\"success\":\"0\"}");

                    return;
                }
            }
        }