Ejemplo n.º 1
0
        /// <summary>
        /// 取中奖的项目
        /// </summary>
        /// <param name="itemlist">所有的奖品信息</param>
        /// <param name="haszjlist">已经中奖的列表</param>
        /// <returns></returns>
        private Model.wx_ggkAwardItem getZJItem(IList <Model.wx_ggkAwardItem> itemlist, IList <Model.wx_ggkAwardUser> haszjlist)
        {
            IList <Model.wx_ggkAwardItem> zjItemlist = new List <Model.wx_ggkAwardItem>();//剩余奖品列表

            Model.wx_ggkAwardItem         tmpItem  = new Model.wx_ggkAwardItem();
            Model.wx_ggkAwardItem         stmpItem = new Model.wx_ggkAwardItem();
            IList <Model.wx_ggkAwardUser> 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_ggkAwardUser>();
                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_ggkAwardItem();
                    stmpItem.jpName = tmpItem.jpName;
                    stmpItem.jxName = tmpItem.jxName;
                    zjItemlist.Add(stmpItem);
                }
            }

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

            return(zjItemlist[jpIndex]);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加奖品项目
        /// </summary>
        private void EditAwardItem(int ggkId)
        {
            //1删除原来的,2新增
            iBll.DeleteByActId(ggkId);
            Model.wx_ggkAwardItem item = new Model.wx_ggkAwardItem();
            TextBox txtJXName;
            TextBox txtJPName;
            TextBox txtNum;
            TextBox txtRealNum;
            int     sort_id = 0;

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

                if (txtJXName.Text.Trim() != "" && txtJPName.Text.Trim() != "" && txtNum.Text.Trim() != "" && txtRealNum.Text.Trim() != "" && MyCommFun.isNumber(txtNum.Text) && MyCommFun.isNumber(txtRealNum.Text))
                {
                    sort_id++;
                    //那么添加奖品信息
                    item.jxName     = txtJXName.Text.Trim();
                    item.sort_id    = sort_id;
                    item.jpName     = txtJPName.Text.Trim();
                    item.jpNum      = MyCommFun.Str2Int(txtNum.Text.Trim());
                    item.jpRealNum  = MyCommFun.Str2Int(txtRealNum.Text.Trim());
                    item.actId      = ggkId;
                    item.createDate = DateTime.Now;
                    iBll.Add(item);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 绑定页面上的基本信息
        /// </summary>
        private void bindData(int id, string openid)
        {
            #region 活动详情
            ggkAction = actbll.GetModel(id);
            if (ggkAction == null)
            {
                errorInfo = "该活动不存在!";
                return;
            }
            if (ggkAction.endDate <= DateTime.Now)
            { //说明活动已经结束
                errorInfo = "活动已结束!";
                ggkAction = null;
                return;
            }
            else if (ggkAction.beginDate > DateTime.Now)
            {
                //活动未开始
                errorInfo = "活动尚未开始!<br/>活动时间为:" + ggkAction.beginDate.ToString() + "到" + ggkAction.endDate.ToString();
                ggkAction = null;
                return;
            }
            this.Title = ggkAction.actName;
            List <Model.wx_ggkAwardItem> itemlist = itemBll.GetModelList("actId=" + id);
            StringBuilder         sb   = new StringBuilder("");
            Model.wx_ggkAwardItem item = new Model.wx_ggkAwardItem();
            int ttJpNum = 0;//实际奖品数量
            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;
            }

            if (ggkAction.djPwd.Trim().Length > 0)
            {
                litPwd.Text = "  <p>  <input name=\"\" class=\"px\" id=\"parssword\" type=\"password\" value=\"\" placeholder=\"商家输入兑奖密码\"></p>";
            }

            litJiangXing.Text = sb.ToString();

            litRemark.Text      = ggkAction.brief;
            litContentInfo.Text = ggkAction.contractInfo;
            litTTTimes.Text     = ggkAction.personMaxTimes == null ? "0" : ggkAction.personMaxTimes.Value.ToString();

            #endregion

            lock (this)
            {
                ProcZJ(ttJpNum, id, openid, itemlist);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 绑定页面上的基本信息
        /// </summary>
        private void bindData(int id, string openid)
        {
            #region 活动详情
            ggkAction = actbll.GetModel(id);
            if (ggkAction == null)
            {
                hidStatus.Value = "-2";
                hidErrInfo.Value = "该活动不存在!";
                MessageBox.ResponseScript(this, "alert(\"该活动不存在\");");
                return;
            }
            this.Title = ggkAction.actName;
            List<Model.wx_ggkAwardItem> itemlist = itemBll.GetModelList("actId="+id);
            StringBuilder sb = new StringBuilder("");
            Model.wx_ggkAwardItem item = new Model.wx_ggkAwardItem();
            int ttJpNum = 0;
            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;
            }

            if (ggkAction.djPwd.Trim().Length > 0)
            {
                litPwd.Text = "  <p>  <input name=\"\" class=\"px\" id=\"parssword\" type=\"password\" value=\"\" placeholder=\"商家输入兑奖密码\"></p>";
            }

            litJiangXing.Text = sb.ToString();

            litRemark.Text = ggkAction.brief;
            litContentInfo.Text = ggkAction.contractInfo;
            litTTTimes.Text = ggkAction.personMaxTimes == null ? "0" : ggkAction.personMaxTimes.Value.ToString();

            #endregion
            #region 判断

            if (ggkAction.endDate <= DateTime.Now)
            { //说明活动已经结束
                //非活动期间
                hidStatus.Value = "-1";
                hidErrInfo.Value = "活动已结束!";
                return;
            }
            else if (ggkAction.beginDate > DateTime.Now)
            { 
                //活动未开始
                //非活动期间
                hidStatus.Value = "-2";
                hidErrInfo.Value = "活动尚未开始!";
                return;
            }

            Model.wx_ggkAwardUser awardUser = ubll.getZJinfoByOpenid(id, openid);
            if (awardUser != null &&  awardUser.id > 0)
            {  //说明已经中奖了

                litPrize.Text = awardUser.jxName;
              
                hidAwardId.Value = awardUser.id.ToString();
             
              

                if (awardUser.uTel != null && awardUser.uTel.Trim() != "")
                { //说明已经提交成功了 
                    hidStatus.Value = "110";
                    hidErrInfo.Value = "您已中过奖了,欢迎下次再来!";
                    litJp.Text = awardUser.jxName + " " + awardUser.jpName;
                    litSNM.Text = awardUser.sn;
                }
                else
                {  //中奖了,但是未提交 
                    hidStatus.Value = "100";
                    hidErrInfo.Value = "您已中奖,请提交!";
                    litJiangPing.Text = awardUser.jpName;
                    litSnCode.Text = awardUser.sn;

                    litJp.Text = awardUser.jxName + " " + awardUser.jpName;
                    litSNM.Text = awardUser.sn;

                }
                return;
            }


            int dayMaxTimes = ggkAction.dayMaxTimes == null ? 0 : ggkAction.dayMaxTimes.Value;
            int perMaxTimes = ggkAction.personMaxTimes == null ? 0 : ggkAction.personMaxTimes.Value;
            //判断每人最大抽奖次数,是否超过了
            if (personCJTimes(openid, id) >= ggkAction.personMaxTimes)
            {
                hidStatus.Value = "0";
                hidErrInfo.Value = "您已抽过奖了,欢迎下次再来!";
                return;
            }
            if (isTodayOverSum(id, openid, dayMaxTimes))
            {
                hidStatus.Value = "0";
                hidErrInfo.Value = "每人每天只有" + dayMaxTimes.ToString() + "次抽奖机会。";
                return;
            }

          
            #endregion

            #region 计算中奖信息

            /// 处理是否中奖
            /// hidStatus 状态为-1:不能抽奖,直接跳转到end.aspx页面;
            /// 0:抽奖次数超过设置的最高次数;
            /// 1:还可以继续抽奖;
            /// 2:中奖了;
            IList<Model.wx_ggkAwardUser> auserlist = ubll.getHasZJList(id);//已经中奖的人列表
            int ZhongJiangNum = 0;
            if (auserlist != null)
            {
                ZhongJiangNum = auserlist.Count; //已经中奖的人数
            }
            int syZjNum = ttJpNum - ZhongJiangNum; //剩余的奖品数量
            if (syZjNum <= 0)
            {  //说明已经没有奖品了
                hidStatus.Value = "1";
                hidErrInfo.Value = ggkAction.cfcjhf;
                litPrize.Text = NoAward;
                return;
            }
            ggkAction.personNum = MyCommFun.Obj2Int(ggkAction.personNum, 1);
            ggkAction.personMaxTimes = MyCommFun.Obj2Int(ggkAction.personMaxTimes, 1);
            int fenmo = ggkAction.personNum.Value * ggkAction.personMaxTimes.Value;

            Random rd = new Random((int)DateTime.Now.Ticks);
            int radNum = rd.Next(0, fenmo);//从0到fenmo里随机出一个值
            if (radNum < syZjNum)
            {
                //中奖了,再从剩余奖品里抽取一个奖品
                Model.wx_ggkAwardItem dajiang = getZJItem(itemlist, auserlist);
                if (dajiang != null)
                {
                    //这是中的中奖了
                    string snumber = Get_snumber(id);
                    int uId = ubll.Add(id, "", "", openid, dajiang.jxName, dajiang.jpName, snumber);
                    hidStatus.Value = "2";
                    hidErrInfo.Value = "恭喜你中奖了!";
                    litPrize.Text = dajiang.jxName;
                    litJiangPing.Text = dajiang.jpName;
                    hidAwardId.Value = uId.ToString();
                    litSnCode.Text = snumber;

                    litJp.Text = dajiang.jxName + " " + dajiang.jpName;
                    litSNM.Text = snumber;
                    return;
                }
                else
                {
                    //奖品已经全部中完了
                    hidStatus.Value = "1";
                    hidErrInfo.Value = ggkAction.cfcjhf;
                    litPrize.Text = NoAward;
                    return;
                }

            }
            else
            {
                //这个条件说明:未中奖
                //抛出未中奖的数据 
                hidStatus.Value = "1";
                hidErrInfo.Value = ggkAction.cfcjhf;
                litPrize.Text = NoAward;
            }




            #endregion


        }
Ejemplo n.º 5
0
        /// <summary>
        /// 取中奖的项目
        /// </summary>
        /// <param name="itemlist">所有的奖品信息</param>
        /// <param name="haszjlist">已经中奖的列表</param>
        /// <returns></returns>
        private Model.wx_ggkAwardItem getZJItem(IList<Model.wx_ggkAwardItem> itemlist, IList<Model.wx_ggkAwardUser> haszjlist)
        {
            IList<Model.wx_ggkAwardItem> zjItemlist = new List<Model.wx_ggkAwardItem>();//剩余奖品列表
           
            Model.wx_ggkAwardItem tmpItem = new Model.wx_ggkAwardItem();
             Model.wx_ggkAwardItem stmpItem = new Model.wx_ggkAwardItem();
            IList<Model.wx_ggkAwardUser> 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_ggkAwardUser>();
                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_ggkAwardItem();
                    stmpItem.jpName = tmpItem.jpName;
                    stmpItem.jxName = tmpItem.jxName;
                    zjItemlist.Add(stmpItem);
                }
            }

            Random rd = new Random((int)DateTime.Now.Ticks);
            int jpIndex = rd.Next(0, zjItemlist.Count);//从0到zjItemlist.Count里随机出一个值
            return zjItemlist[jpIndex];
        }
Ejemplo n.º 6
0
        private void ShowInfo(int id)
        {
            hidid.Value = id.ToString();
            Model.wx_ggkActionInfo        ggk       = ggkBll.GetModel(id);
            IList <Model.wx_ggkAwardItem> aItemlist = iBll.GetModelList("actId=" + id);

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

            if (ggk.beginPic != null && ggk.beginPic.Trim() != "/weixin/ggk/images/start.jpg")
            {
                txtImgUrl.Text       = ggk.beginPic;
                imgbeginPic.ImageUrl = ggk.beginPic;
            }
            txtactName.Text      = ggk.actName;
            txtcontractInfo.Text = ggk.contractInfo;
            txtbrief.Value       = ggk.brief;
            txtbeginDate.Text    = ggk.beginDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
            txtendDate.Text      = ggk.endDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
            txtactContent.Value  = ggk.actContent;
            txtcfcjhf.Text       = ggk.cfcjhf;
            this.txtdjPwd.Text   = ggk.djPwd;
            //结束
            if (ggk.endPic != null && ggk.endPic.Trim() != "/weixin/ggk/images/end.jpg")
            {
                txtEndPic.Text     = ggk.endPic;
                imgEndPic.ImageUrl = ggk.endPic;
            }
            txtendNotice.Text  = ggk.endNotice;
            txtendContent.Text = ggk.endContent;

            //奖项基本信息
            txtpersonNum.Text      = MyCommFun.ObjToStr(ggk.personNum);
            txtpersonMaxTimes.Text = MyCommFun.ObjToStr(ggk.personMaxTimes);
            txtdayMaxTimes.Text    = MyCommFun.ObjToStr(ggk.dayMaxTimes);


            //绑定奖项信息
            IList <Model.wx_ggkAwardItem> 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;
                Model.wx_ggkAwardItem itemEntity = new Model.wx_ggkAwardItem();
                for (int i = 1; i <= count; i++)
                {
                    itemEntity = itemlist[(i - 1)];
                    txtJXName  = this.FindControl("txt" + i + "JXName") as TextBox;
                    txtJPName  = this.FindControl("txt" + i + "JPName") as TextBox;
                    txtNum     = this.FindControl("txt" + i + "Num") as TextBox;
                    txtRealNum = this.FindControl("txt" + i + "RealNum") as TextBox;

                    txtJXName.Text  = itemEntity.jxName;
                    txtJPName.Text  = itemEntity.jpName;
                    txtNum.Text     = itemEntity.jpNum == null?"0":itemEntity.jpNum.Value.ToString();
                    txtRealNum.Text = itemEntity.jpRealNum == null ? "0" : itemEntity.jpRealNum.Value.ToString();
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 绑定页面上的基本信息
        /// </summary>
        private void bindData(int id, string openid)
        {
            #region 活动详情
            ggkAction = actbll.GetModel(id);
            if (ggkAction == null)
            {
                hidStatus.Value  = "-2";
                hidErrInfo.Value = "该活动不存在!";
                MessageBox.ResponseScript(this, "alert(\"该活动不存在\");");
                return;
            }
            this.Title = ggkAction.actName;
            List <Model.wx_ggkAwardItem> itemlist = itemBll.GetModelList("actId=" + id);
            StringBuilder         sb   = new StringBuilder("");
            Model.wx_ggkAwardItem item = new Model.wx_ggkAwardItem();
            int ttJpNum = 0;
            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;
            }

            if (ggkAction.djPwd.Trim().Length > 0)
            {
                litPwd.Text = "  <p>  <input name=\"\" class=\"px\" id=\"parssword\" type=\"password\" value=\"\" placeholder=\"商家输入兑奖密码\"></p>";
            }

            litJiangXing.Text = sb.ToString();

            litRemark.Text      = ggkAction.brief;
            litContentInfo.Text = ggkAction.contractInfo;
            litTTTimes.Text     = ggkAction.personMaxTimes == null ? "0" : ggkAction.personMaxTimes.Value.ToString();

            #endregion
            #region 判断

            if (ggkAction.endDate <= DateTime.Now)
            { //说明活动已经结束
                //非活动期间
                hidStatus.Value  = "-1";
                hidErrInfo.Value = "活动已结束!";
                return;
            }
            else if (ggkAction.beginDate > DateTime.Now)
            {
                //活动未开始
                //非活动期间
                hidStatus.Value  = "-2";
                hidErrInfo.Value = "活动尚未开始!";
                return;
            }

            Model.wx_ggkAwardUser awardUser = ubll.getZJinfoByOpenid(id, openid);
            if (awardUser != null && awardUser.id > 0)
            {  //说明已经中奖了
                litPrize.Text = awardUser.jxName;

                hidAwardId.Value = awardUser.id.ToString();



                if (awardUser.uTel != null && awardUser.uTel.Trim() != "")
                { //说明已经提交成功了
                    hidStatus.Value  = "110";
                    hidErrInfo.Value = "您已中过奖了,欢迎下次再来!";
                    litJp.Text       = awardUser.jxName + " " + awardUser.jpName;
                    litSNM.Text      = awardUser.sn;
                }
                else
                {  //中奖了,但是未提交
                    hidStatus.Value   = "100";
                    hidErrInfo.Value  = "您已中奖,请提交!";
                    litJiangPing.Text = awardUser.jpName;
                    litSnCode.Text    = awardUser.sn;

                    litJp.Text  = awardUser.jxName + " " + awardUser.jpName;
                    litSNM.Text = awardUser.sn;
                }
                return;
            }


            int dayMaxTimes = ggkAction.dayMaxTimes == null ? 0 : ggkAction.dayMaxTimes.Value;
            int perMaxTimes = ggkAction.personMaxTimes == null ? 0 : ggkAction.personMaxTimes.Value;
            //判断每人最大抽奖次数,是否超过了
            if (personCJTimes(openid, id) >= ggkAction.personMaxTimes)
            {
                hidStatus.Value  = "0";
                hidErrInfo.Value = "您已抽过奖了,欢迎下次再来!";
                return;
            }
            if (isTodayOverSum(id, openid, dayMaxTimes))
            {
                hidStatus.Value  = "0";
                hidErrInfo.Value = "每人每天只有" + dayMaxTimes.ToString() + "次抽奖机会。";
                return;
            }


            #endregion

            #region 计算中奖信息

            /// 处理是否中奖
            /// hidStatus 状态为-1:不能抽奖,直接跳转到end.aspx页面;
            /// 0:抽奖次数超过设置的最高次数;
            /// 1:还可以继续抽奖;
            /// 2:中奖了;
            IList <Model.wx_ggkAwardUser> auserlist = ubll.getHasZJList(id);//已经中奖的人列表
            int ZhongJiangNum = 0;
            if (auserlist != null)
            {
                ZhongJiangNum = auserlist.Count;   //已经中奖的人数
            }
            int syZjNum = ttJpNum - ZhongJiangNum; //剩余的奖品数量
            if (syZjNum <= 0)
            {                                      //说明已经没有奖品了
                hidStatus.Value  = "1";
                hidErrInfo.Value = ggkAction.cfcjhf;
                litPrize.Text    = NoAward;
                return;
            }
            ggkAction.personNum      = MyCommFun.Obj2Int(ggkAction.personNum, 1);
            ggkAction.personMaxTimes = MyCommFun.Obj2Int(ggkAction.personMaxTimes, 1);
            int fenmo = ggkAction.personNum.Value * ggkAction.personMaxTimes.Value;

            Random rd     = new Random((int)DateTime.Now.Ticks);
            int    radNum = rd.Next(0, fenmo);//从0到fenmo里随机出一个值
            if (radNum < syZjNum)
            {
                //中奖了,再从剩余奖品里抽取一个奖品
                Model.wx_ggkAwardItem dajiang = getZJItem(itemlist, auserlist);
                if (dajiang != null)
                {
                    //这是中的中奖了
                    string snumber = Get_snumber(id);
                    int    uId     = ubll.Add(id, "", "", openid, dajiang.jxName, dajiang.jpName, snumber);
                    hidStatus.Value   = "2";
                    hidErrInfo.Value  = "恭喜你中奖了!";
                    litPrize.Text     = dajiang.jxName;
                    litJiangPing.Text = dajiang.jpName;
                    hidAwardId.Value  = uId.ToString();
                    litSnCode.Text    = snumber;

                    litJp.Text  = dajiang.jxName + " " + dajiang.jpName;
                    litSNM.Text = snumber;
                    return;
                }
                else
                {
                    //奖品已经全部中完了
                    hidStatus.Value  = "1";
                    hidErrInfo.Value = ggkAction.cfcjhf;
                    litPrize.Text    = NoAward;
                    return;
                }
            }
            else
            {
                //这个条件说明:未中奖
                //抛出未中奖的数据
                hidStatus.Value  = "1";
                hidErrInfo.Value = ggkAction.cfcjhf;
                litPrize.Text    = NoAward;
            }



            #endregion
        }
Ejemplo n.º 8
0
        private void ShowInfo(int id)
        {
            hidid.Value = id.ToString();
            Model.wx_ggkActionInfo ggk = ggkBll.GetModel(id);
            IList<Model.wx_ggkAwardItem> aItemlist = iBll.GetModelList("actId="+id);
            Model.wx_requestRule rule = rBll.GetModelList("modelFunctionName='刮刮卡' and modelFunctionId="+id )[0];
            txtKW.Text = rule.reqKeywords;

            if (ggk.beginPic != null && ggk.beginPic.Trim() != "/weixin/ggk/images/start.jpg")
            {
                txtImgUrl.Text = ggk.beginPic;
                imgbeginPic.ImageUrl = ggk.beginPic;
            }
            txtactName.Text = ggk.actName;
            txtcontractInfo.Text = ggk.contractInfo;
            txtbrief.Value = ggk.brief;
            txtbeginDate.Text = ggk.beginDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
            txtendDate.Text = ggk.endDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
            txtactContent.Value = ggk.actContent;
            txtcfcjhf.Text = ggk.cfcjhf;
            this.txtdjPwd.Text = ggk.djPwd;
            //结束
            if (ggk.endPic != null && ggk.endPic.Trim() != "/weixin/ggk/images/end.jpg")
            {
                txtEndPic.Text = ggk.endPic;
                imgEndPic.ImageUrl = ggk.endPic;
            }
            txtendNotice.Text = ggk.endNotice;
            txtendContent.Text = ggk.endContent;

            //奖项基本信息
            txtpersonNum.Text =MyCommFun.ObjToStr(ggk.personNum);
            txtpersonMaxTimes.Text =MyCommFun.ObjToStr( ggk.personMaxTimes);
            txtdayMaxTimes.Text = MyCommFun.ObjToStr(ggk.dayMaxTimes);

            //绑定奖项信息
            IList<Model.wx_ggkAwardItem> 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;
                 Model.wx_ggkAwardItem itemEntity=new Model.wx_ggkAwardItem();
                for (int i = 1; i <= count; i++)
                {
                   itemEntity=itemlist[(i-1)];
                    txtJXName = this.FindControl("txt" + i + "JXName") as TextBox;
                    txtJPName = this.FindControl("txt" + i + "JPName") as TextBox;
                    txtNum = this.FindControl("txt" + i + "Num") as TextBox;
                    txtRealNum = this.FindControl("txt" + i + "RealNum") as TextBox;

                    txtJXName.Text = itemEntity.jxName;
                    txtJPName.Text = itemEntity.jpName;
                    txtNum.Text = itemEntity.jpNum==null?"0":itemEntity.jpNum.Value.ToString();
                    txtRealNum.Text = itemEntity.jpRealNum == null ? "0" : itemEntity.jpRealNum.Value.ToString();
                }

            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 添加奖品项目
        /// </summary>
        private void EditAwardItem(int ggkId)
        {
            //1删除原来的,2新增
            iBll.DeleteByActId(ggkId);
            Model.wx_ggkAwardItem item = new Model.wx_ggkAwardItem();
            TextBox txtJXName;
            TextBox txtJPName;
            TextBox txtNum;
            TextBox txtRealNum;
            int sort_id = 0;
            for (int i = 1; i <= 6; i++)
            {
                txtJXName = this.FindControl("txt"+i+"JXName") as TextBox;
                txtJPName = this.FindControl("txt" + i + "JPName") as TextBox;
                txtNum = this.FindControl("txt" + i + "Num") as TextBox;
                txtRealNum = this.FindControl("txt" + i + "RealNum") as TextBox;

                if (txtJXName.Text.Trim() != "" && txtJPName.Text.Trim() != "" && txtNum.Text.Trim() != "" && txtRealNum.Text.Trim() != "" && MyCommFun.isNumber(txtNum.Text) && MyCommFun.isNumber(txtRealNum.Text))
                {
                    sort_id++;
                   //那么添加奖品信息
                    item.jxName = txtJXName.Text.Trim();
                    item.sort_id = sort_id;
                    item.jpName = txtJPName.Text.Trim();
                    item.jpNum = MyCommFun.Str2Int(txtNum.Text.Trim());
                    item.jpRealNum = MyCommFun.Str2Int(txtRealNum.Text.Trim());
                    item.actId = ggkId;
                    item.createDate = DateTime.Now;
                    iBll.Add(item);
                }

            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 处理中奖信息
        /// </summary>
        /// <param name="ttJpNum"></param>
        /// <param name="id"></param>
        /// <param name="openid"></param>
        /// <param name="itemlist"></param>
        private void ProcZJ(int ttJpNum, int id, string openid, List <Model.wx_ggkAwardItem> itemlist)
        {
            BLL.ggkProc gproc = new BLL.ggkProc();
            #region 判断
            Model.wx_ggkAwardUser awardUser = ubll.getZJinfoByOpenid(id, openid);
            litRemainTimes.Text = gproc.personCJTimes(openid, id).ToString();
            if (awardUser != null && awardUser.id > 0)
            {  //说明已经中奖了
                litPrize.Text = awardUser.jxName;

                hidAwardId.Value = awardUser.id.ToString();
                if (awardUser.uTel != null && awardUser.uTel.Trim() != "")
                { //说明已经提交成功了
                    hidStatus.Value  = "110";
                    hidErrInfo.Value = "您已中过奖了,欢迎下次再来!";
                    litJp.Text       = awardUser.jxName + " " + awardUser.jpName;
                    litSNM.Text      = awardUser.sn;
                    if (awardUser.hasLingQu)
                    {
                        litLQStatus.Text = "你已经兑奖成功,本SN码自定作废!";
                    }
                    else
                    {
                        litLQStatus.Text = ggkAction.contractInfo;
                    }
                }
                else
                {  //中奖了,但是未提交
                    hidStatus.Value   = "100";
                    hidErrInfo.Value  = "您已中奖,请提交!";
                    litJiangPing.Text = awardUser.jpName;
                    litSnCode.Text    = awardUser.sn;

                    litJp.Text  = awardUser.jxName + " " + awardUser.jpName;
                    litSNM.Text = awardUser.sn;
                }
                return;
            }


            int dayMaxTimes = ggkAction.dayMaxTimes == null ? 0 : ggkAction.dayMaxTimes.Value;
            int perMaxTimes = ggkAction.personMaxTimes == null ? 0 : ggkAction.personMaxTimes.Value;
            //判断每人最大抽奖次数,是否超过了
            if (gproc.personCJTimes(openid, id) >= ggkAction.personMaxTimes)
            {
                hidStatus.Value  = "0";
                hidErrInfo.Value = "您已抽过奖了,欢迎下次再来!";
                return;
            }
            int RemainTime = 0;
            if (gproc.isTodayOverSum(id, openid, dayMaxTimes, out RemainTime))
            {
                hidStatus.Value     = "0";
                hidErrInfo.Value    = "每人每天只有" + dayMaxTimes.ToString() + "次抽奖机会。";
                litRemainTimes.Text = RemainTime.ToString();
                return;
            }
            litRemainTimes.Text = RemainTime.ToString();


            #endregion

            #region 计算中奖信息

            /// 处理是否中奖
            /// hidStatus 状态为-1:不能抽奖,直接跳转到end.aspx页面;
            /// 0:抽奖次数超过设置的最高次数;
            /// 1:还可以继续抽奖;
            /// 2:中奖了;
            IList <Model.wx_ggkAwardUser> auserlist = ubll.getHasZJList(id);//已经中奖的人列表
            int ZhongJiangNum = 0;
            if (auserlist != null)
            {
                ZhongJiangNum = auserlist.Count;   //已经中奖的人数
            }
            int syZjNum = ttJpNum - ZhongJiangNum; //剩余的奖品数量
            if (syZjNum <= 0)
            {                                      //说明已经没有奖品了
                hidStatus.Value  = "1";
                hidErrInfo.Value = ggkAction.cfcjhf;
                litPrize.Text    = NoAward;
                return;
            }
            ggkAction.personNum      = MyCommFun.Obj2Int(ggkAction.personNum, 1);
            ggkAction.personMaxTimes = MyCommFun.Obj2Int(ggkAction.personMaxTimes, 1);
            int fenmo = ggkAction.personNum.Value * ggkAction.personMaxTimes.Value;

            Random rd     = new Random((int)DateTime.Now.Ticks);
            int    radNum = rd.Next(0, fenmo);//从0到fenmo里随机出一个值
            if (radNum < syZjNum)
            {
                //中奖了,再从剩余奖品里抽取一个奖品
                Model.wx_ggkAwardItem dajiang = gproc.getZJItem(itemlist, auserlist);
                if (dajiang != null)
                {
                    //这是中的中奖了
                    string snumber = gproc.Get_snumber(id);
                    int    uId     = ubll.Add(id, "", "", openid, dajiang.jxName, dajiang.jpName, snumber);
                    hidStatus.Value   = "2";
                    hidErrInfo.Value  = "恭喜你中奖了!";
                    litPrize.Text     = dajiang.jxName;
                    litJiangPing.Text = dajiang.jpName;
                    hidAwardId.Value  = uId.ToString();
                    litSnCode.Text    = snumber;

                    litJp.Text  = dajiang.jxName + " " + dajiang.jpName;
                    litSNM.Text = snumber;
                    return;
                }
                else
                {
                    //奖品已经全部中完了
                    hidStatus.Value  = "1";
                    hidErrInfo.Value = ggkAction.cfcjhf;
                    litPrize.Text    = NoAward;
                    return;
                }
            }
            else
            {
                //这个条件说明:未中奖
                //抛出未中奖的数据
                hidStatus.Value  = "1";
                hidErrInfo.Value = ggkAction.cfcjhf;
                litPrize.Text    = NoAward;
            }



            #endregion
        }