Ejemplo n.º 1
0
 public JsonResult Post(Game_Record _t)
 {
     if (WMFactory.GameRecord.Insert(_t))
         return Json(ResultMsg.Success("新增成功!"));
     else
         return Json(ResultMsg.Failure("新增失败,请您重试!"));
 }
Ejemplo n.º 2
0
 public string DoAward(Game_Record record)
 {
     try
     {
         if (WMFactory.GameRecord.Insert(record))
         {
             if (record.AwardId == new Guid("BABB0AA4-D835-43B9-95F3-579FFF0969C2")) //一等奖
             {
                 return firstAward();
             }
             else if (record.AwardId == new Guid("D01EB68A-5137-4C99-99E1-B5FBE0829A46")) //二等奖
             {
                 return secondAward();
             }
             else if (record.AwardId == new Guid("61012CBD-D82A-4A6A-9632-6BDB3D90F41A")) //三等奖
             {
                 return thirdAward();
             }
             else if (record.AwardId == new Guid("A370E0FE-0E55-41B6-8566-666152CF5628")) //四等奖
             {
                 return forthAward();
             }
             else
             {
                 return noAward();
             }
         }
         else
             return noAward();
     }
     catch (Exception e)
     {
         string s = e.GetBaseException().Message.ToString();
         if (s == "奖品已经发完啦!") //所中奖品数量为0,奖品向下降级
         {
             if (record.AwardId == new Guid("BABB0AA4-D835-43B9-95F3-579FFF0969C2")) //一等奖变二等奖
             {
                 record.AwardId = new Guid("D01EB68A-5137-4C99-99E1-B5FBE0829A46");
             }
             else if (record.AwardId == new Guid("D01EB68A-5137-4C99-99E1-B5FBE0829A46")) //二等奖变三等奖
             {
                 record.AwardId = new Guid("61012CBD-D82A-4A6A-9632-6BDB3D90F41A");
             }
             else if (record.AwardId == new Guid("61012CBD-D82A-4A6A-9632-6BDB3D90F41A")) //三等奖变四等奖
             {
                 record.AwardId = new Guid("A370E0FE-0E55-41B6-8566-666152CF5628");
             }
             else if (record.AwardId == new Guid("A370E0FE-0E55-41B6-8566-666152CF5628")) //四等奖悲剧
             {
                 record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
                 record.Num = 0;
             }
             return DoAward(record);
         }
         else
         {
             throw e;
         }
     }
 }
Ejemplo n.º 3
0
 public JsonResult Delete(Game_Record _t)
 {
     if (WMFactory.GameRecord.Delete(s => s.Id == _t.Id ))
         return Json(ResultMsg.Success("删除成功!"));
     else
         return Json(ResultMsg.Failure("删除失败,请您重试!"));
 }
Ejemplo n.º 4
0
        public string DoAward(Game_Record record)
        {
            string ticketid = "";
            try
            {
                if (WMFactory.GameRecord.Insert(record))
                {

                    Game_Award ga = WMFactory.GameAward.GetById(record.AwardId.ToString());
                    //搜索中奖券号
                    IEnumerable<Game_Ticket> gt = WMFactory.GameTicket.FindByConditions(null, f => f.Group == 8 && f.AwardId == ga.Id && string.IsNullOrEmpty(f.Oid));

                    if (gt.Count() > 0)
                    {
                        Game_Ticket gt2 = gt.First();
                        gt2.Oid = record.Oid;
                        gt2.ModifyUser = "******";
                        WMFactory.GameTicket.Update(gt2);
                        ticketid = gt2.Ticketid;
                    }
                } return (ticketid);
            }
            catch (Exception e)
            {
                string s = e.GetBaseException().Message.ToString();
                if (s == "奖品已经发完啦!")
                {
                    return (ticketid);
                }
                else
                {
                    return (ticketid);
                }
            }
        }
Ejemplo n.º 5
0
 public JsonResult Put(Game_Record _t)
 {
     IGameRecordService service = WMFactory.GameRecord;
     Game_Record entity = service.GetById(_t.Id.ToString());
     entity = AutoMapper<Game_Record, Game_Record>.Convert(_t, entity);
     if (service.Update(entity))
         return Json(ResultMsg.Success("更新成功!"));
     else
         return Json(ResultMsg.Failure("更新失败,请您重试!"));
 }
Ejemplo n.º 6
0
 public string DoAward(Game_Record record)
 {
     try
     {
         if (WMFactory.GameRecord.Insert(record))
         {
             if (record.AwardId == new Guid("79E82ADD-73C6-456F-86ED-8FE39A08A5B7")) //礼盒配套组合(甜瓜玉米小黄瓜小番茄)
             {
                 return oneAward();
             }
             else if (record.AwardId == new Guid("5775CBFA-06D2-4DB6-8B51-66E7195A0AEA")) //礼盒配套组合(小黄瓜小番茄)
             {
                 return twoAward();
             }
             else if (record.AwardId == new Guid("32C1FCFD-30E6-433B-AE76-B43F69C1CB3C")) //单品礼盒(小黄瓜或小番茄)
             {
                 return threeAward();
             }
             else
             {
                 return noAward();
             }
         }
         else
             return noAward();
     }
     catch (Exception e)
     {
         string s = e.GetBaseException().Message.ToString();
         if (s == "奖品已经发完啦!") //所中奖品数量为0,奖品向下降级
         {
             if (record.AwardId == new Guid("79E82ADD-73C6-456F-86ED-8FE39A08A5B7")) //礼盒配套组合(甜瓜玉米小黄瓜小番茄)
             {
                 record.AwardId = new Guid("5775CBFA-06D2-4DB6-8B51-66E7195A0AEA");
                 //record.AwardName = "yrwj.jpg";
             }
             else if (record.AwardId == new Guid("5775CBFA-06D2-4DB6-8B51-66E7195A0AEA")) //礼盒配套组合(小黄瓜小番茄)
             {
                 record.AwardId = new Guid("32C1FCFD-30E6-433B-AE76-B43F69C1CB3C");
                 //record.AwardName = "hwj.jpg";
             }
             else if (record.AwardId == new Guid("32C1FCFD-30E6-433B-AE76-B43F69C1CB3C")) //单品礼盒(小黄瓜或小番茄)
             {
                 record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
                 //record.AwardName = "s.jpg";
             }
             return DoAward(record);
         }
         else
         {
             throw e;
         }
     }
 }
Ejemplo n.º 7
0
        public string Award(Guid sid, string oid)
        {
            OID = oid;

            if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 9 && f.isAward == 1) > 0)
            {
                return repeatAward();
            }
            else if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 9) > 0)
            {
                return repeat();
            }
            Random Rdm = new Random();

            //产生0到4200的随机数
            int iRdm = Rdm.Next(0, 100);
            Game_Record record = new Game_Record();
            record.Oid = oid;
            record.Group = 9;
            record.Num = 1;
            record.isAward = 0;
            record.CreateUser = "******";

            // WxFans wf = ElegantWM.WeiXin.Common.GetFanInfo(sid.ToString(), oid);
            IEnumerable<WX_Fans> fans = WMFactory.WXFans.FindByConditions(null, f => f.AccountId == sid && f.OpenId == oid);
            record.Nickname = fans.First().NickName;
            if (iRdm < 3) //礼盒配套组合(甜瓜玉米小黄瓜小番茄)
            {
                record.AwardId = new Guid("79E82ADD-73C6-456F-86ED-8FE39A08A5B7");
                record.isAward = 1;
                record.AwardName = "礼盒配套组合(甜瓜玉米小黄瓜小番茄)";
                //record.AwardName = "xz.jpg";
            }
            else if (iRdm >= 3 && iRdm < 6) //礼盒配套组合(小黄瓜小番茄)
            {
                record.AwardId = new Guid("5775CBFA-06D2-4DB6-8B51-66E7195A0AEA");
                record.isAward = 1;
                record.AwardName = "礼盒配套组合(小黄瓜小番茄)";
                //record.AwardName = "yrwj.jpg";
            }
            else if (iRdm >= 6 && iRdm < 10) //单品礼盒(小黄瓜或小番茄)
            {
                record.AwardId = new Guid("32C1FCFD-30E6-433B-AE76-B43F69C1CB3C");
                record.isAward = 1;
                record.AwardName = "单品礼盒(小黄瓜或小番茄)";
                // record.AwardName = "hwj.jpg";
            }
            else
            {
                record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");//未中奖
                record.isAward = 0;
            }
            return DoAward(record);
        }
Ejemplo n.º 8
0
        //public static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        //
        // GET: /Game/GLTicket/

        public ActionResult Index(Guid sid, string oid)
        {
            //log.Debug(sid);
            //log.Debug(oid);
            WxFans wf = ElegantWM.WeiXin.Common.GetFanInfo(sid.ToString(), oid);
            string Ticketid = "";
            if (wf == null)
            {
                return Redirect("http://mp.weixin.qq.com/s?__biz=MzA5MTk5ODgzOA==&mid=203506347&idx=1&sn=f7b5f8c4c5ec7443ad8c35f0d646f40a#rd");
            }
            else
            {
                IEnumerable<Game_Record> gr = WMFactory.GameRecord.FindByConditions(null, f => f.Oid == oid && f.Group == 8);
                if (gr.Count() > 0)
                {
                    IEnumerable<Game_Ticket> gt = WMFactory.GameTicket.FindByConditions(null, f => f.Oid == oid && f.Group == 8);
                    Game_Ticket gtf = gt.First();
                    Ticketid = gtf.Ticketid;
                    ViewBag.Content1 = "人民币88元立减优惠";
                    ViewBag.Content2 = "[礼品券代码:" + Ticketid + "]";
                    ViewBag.Ticketid = Ticketid;
                }
                else
                {
                    Game_Record record = new Game_Record();
                    record.Oid = oid;
                    record.Group = 8;
                    record.Num = 1;
                    record.isAward = 1;
                    record.CreateUser = "******";
                    record.Nickname = wf.nickname;

                    IEnumerable<Game_Award> ga = WMFactory.GameAward.FindByConditions(null, f => f.Group == 8 && f.Level == 1);
                    record.AwardId = ga.First().Id;
                    record.AwardName = ga.First().Name;
                    Ticketid = DoAward(record);
                    if (Ticketid == "")
                    {
                        ViewBag.Content1 = "抱歉,您晚来一步!";
                        ViewBag.Content2 = "更多活动可至雅斓名店进行咨询!";
                        ViewBag.Ticketid = "";
                    }
                    else
                    {
                        ViewBag.Content1 = "人民币88元立减优惠";
                        ViewBag.Content2 = "[礼品券代码:" + Ticketid + "]";
                        ViewBag.Ticketid = Ticketid;
                    }
                }
            }

            return View();
        }
Ejemplo n.º 9
0
        public string Award(Guid sid,string oid)
        {
            if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 1) > 0)
            {
                return repeat();
            }

            Random Rdm = new Random();

            //产生0到4200的随机数
            int iRdm = Rdm.Next(0, 2000);

            Game_Record record = new Game_Record();
            record.Oid = oid;
            record.Group = 1;
            record.Num = 1;
            record.isAward = 0;

            DataTable dtUser = GetCurUser();
            record.CreateUser = "******";
            //record.CreateUser = dtUser.Rows[0]["names"].ToString();

            if (iRdm < 5) //一等奖
            {
                record.AwardId = new Guid("BABB0AA4-D835-43B9-95F3-579FFF0969C2");
            }
            else if (iRdm >= 5 && iRdm < 13) //二等奖
            {
                record.AwardId = new Guid("D01EB68A-5137-4C99-99E1-B5FBE0829A46");
            }
            else if (iRdm >= 13 && iRdm < 28) //三等奖
            {
                record.AwardId = new Guid("61012CBD-D82A-4A6A-9632-6BDB3D90F41A");
            }
            else if (iRdm >= 28 && iRdm < 128) //四等奖
            {
                record.AwardId = new Guid("A370E0FE-0E55-41B6-8566-666152CF5628");
            }
            else
            {
                record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
                record.Num = 0;
            }
            return DoAward(record);
        }
        public Guid DoAward(Game_Record record)
        {
            try
            {
                if (WMFactory.GameRecord.Update(record))
                {
                    return record.AwardId;
                }
                else
                    return new Guid("00000000-0000-0000-0000-000000000000");
            }
            catch (Exception e)
            {
                string s = e.GetBaseException().Message.ToString();
                if (s == "奖品已经发完啦!") //所中奖品数量为0,奖品向下降级
                {
                    Game_Award ga = WMFactory.GameAward.GetById(record.AwardId.ToString());
                    int newLevel = ga.Level + 1;

                    IEnumerable<Game_Award> ga2 = WMFactory.GameAward.FindByConditions(null, f => f.Group == 6 && f.Level == newLevel);

                    if (ga2.Count() > 0)
                    {
                        record.AwardId = ga2.First().Id;
                        record.AwardName = ga2.First().Name;
                    }
                    else
                    {
                        record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
                        record.AwardName = "";
                        record.Num = 0;
                    }
                    return DoAward(record);
                }
                else
                {
                    throw e;
                }
            }
        }
        public JsonResult Submit(Guid sid, string oid, string RightOrWrong)
        {
            Game_Record record = null;

            //没有抽奖机会
            if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 6 && f.isAward == 1) > 100000000)
            {
                return Json(ResultMsg.Failure("您已抽过奖"));
            }
            else if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 6 && f.doTimes == 3) > 10000000)
            {
                return Json(ResultMsg.Failure("您抽奖次数已经没有了"));
            }
            else
            {
                //第一次进入游戏
                if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 6) == 0)
                {
                    record = new Game_Record();
                    record.Oid = oid;

                    //WxFans wf = ElegantWM.WeiXin.Common.GetFanInfo(sid.ToString(), oid);
                    //record.Nickname = wf.nickname;
                    record.Nickname = "";
                    record.Group = 6;
                    record.Num = 0;
                    record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
                    record.AwardName = "";
                    record.Seq = "";
                    record.isAward = 0;
                    record.doTimes = 0;
                    record.linkedTimes = 0;
                    record.CreateUser = "******";
                    WMFactory.GameRecord.Insert(record);
                }

                #region 中奖 Right
                if (RightOrWrong == "Right")
                {

                    Random Rdm = new Random();
                    //产生随机数
                    int iRdm = Rdm.Next(0, 1000);

                    IEnumerable<Game_Record> gr = WMFactory.GameRecord.FindByConditions(null, f => f.Oid == oid && f.Group == 6);
                    record = gr.First();
                    record.isAward = 1;
                    record.doTimes = record.doTimes + 1;
                    record.ModifyUser = "******";

                    if (iRdm <= 20) //一等奖
                    {
                        IEnumerable<Game_Award> ga = WMFactory.GameAward.FindByConditions(null, f => f.Group == 6 && f.Level == 1);
                        record.AwardId = ga.First().Id;
                        record.AwardName = ga.First().Name;
                        record.Num = 1;
                    }
                    else if (iRdm > 20 && iRdm <= 100) //二等奖
                    {
                        IEnumerable<Game_Award> ga = WMFactory.GameAward.FindByConditions(null, f => f.Group == 6 && f.Level == 2);
                        record.AwardId = ga.First().Id;
                        record.AwardName = ga.First().Name;
                        record.Num = 1;
                    }
                    else if (iRdm > 100 && iRdm <= 400) //三等奖
                    {
                        IEnumerable<Game_Award> ga = WMFactory.GameAward.FindByConditions(null, f => f.Group == 6 && f.Level == 3);
                        record.AwardId = ga.First().Id;
                        record.AwardName = ga.First().Name;
                        record.Num = 1;
                    }
                    else  //四等奖等于未中奖
                    {
                        IEnumerable<Game_Award> ga = WMFactory.GameAward.FindByConditions(null, f => f.Group == 6 && f.Level == 4);
                        record.AwardId = ga.First().Id;
                        record.AwardName = ga.First().Name;
                        record.Num = 1;
                    }
                    try
                    {
                        //DoAward(record);
                        string awardId = DoAward(record).ToString().ToUpper();
                        Game_Ticket Ticket = new Game_Ticket();
                        Ticket.Group = 6;
                        Ticket.Oid = oid;
                        Ticket.CreateUser = "******";
                        Ticket.ModifyUser = "******";
                        Ticket.AwardId = Guid.Parse(awardId);
                        DataTable dtpList = new DataTable();
                        dtpList.Columns.Add("ticketid");
                        dtpList.Columns.Add("awardId");
                        DataRow dr = dtpList.NewRow();

                        string Ticketid = "";

                        if (awardId.ToUpper() == "C100B881-9D07-46E1-B3DE-F73B407D7C1E")//58
                        {
                            string sums = "58";
                            DataTable dtpTicket = WMFactory.Wsrr.JLTicketCreate(sums);
                            Ticketid = dtpTicket.Rows[0]["Message"].ToString();
                        }
                        else if (awardId.ToUpper() == "F2C6C399-912E-471D-93CF-A7AB83F6A3E8")//88
                        {
                            string sums = "88";
                            DataTable dtpTicket = WMFactory.Wsrr.JLTicketCreate(sums);
                            Ticketid = dtpTicket.Rows[0]["Message"].ToString();
                        }
                        else if (awardId.ToUpper() == "688A34C8-7D3B-42C1-B737-4B1BBB132EC8")//128
                        {
                            string sums = "128";
                            DataTable dtpTicket = WMFactory.Wsrr.JLTicketCreate(sums);
                            Ticketid = dtpTicket.Rows[0]["Message"].ToString();
                        }
                        else if (awardId.ToUpper() == "0162AF90-60F9-4B41-8281-70F06453A18E")//答对未中奖
                        {
                            Ticketid = "";
                        }
                        // WMFactory.GameTicket.Insert(Ticket);
                        dr["ticketid"] = Ticketid;
                        dr["awardId"] = awardId;
                        dtpList.Rows.Add(dr);
                        string jsonStr = JsonHelper.ToJson(dtpList);
                        return Json(ResultMsg.Success(jsonStr));
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                    //if (WMFactory.GameRecord.Update(record))
                    //{
                    //    string awardId = DoAward(record).ToString().ToUpper();

                    //    if (awardId == "00000000-0000-0000-0000-000000000000")
                    //        return Json(ResultMsg.Failure("00000000-0000-0000-0000-000000000000"));
                    //    else
                    //        ///调取WSRR 插入POS和插入绑定表券号返回券号
                    //        return Json(ResultMsg.Success(awardId));
                    //} 

                }

                #endregion

                #region 未中奖

                else if (RightOrWrong == "Wrong")
                {
                    record = WMFactory.GameRecord.FindByConditions(null, f => f.Oid == oid && f.Group == 6).First();
                    record.isAward = 0;
                    record.doTimes = record.doTimes + 1;
                    record.ModifyUser = "******";
                    DoAward(record);
                    //return Json(ResultMsg.Failure("未中奖"));
                    //return Json(ResultMsg.Success("未中奖"));
                }
                return Json(ResultMsg.Success(""));
                #endregion

            }

        }
Ejemplo n.º 12
0
        public ActionResult CountDown(Guid sid, string oid)
        {
            Guid id = new Guid("00000000-0000-0000-0000-000000000000");
            //不存在记录,新建倒计时
            if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 2) == 0)
            {
                Game_Record record = new Game_Record();
                record.Oid = oid;

                WxFans wf = ElegantWM.WeiXin.Common.GetFanInfo(sid.ToString(), oid);
                record.Nickname = wf.nickname;
                record.Group = 2;
                record.Num = 0;
                record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
                record.AwardName = "";
                record.Seq = "";
                record.isAward = 0;
                record.doTimes = 0;
                record.linkedTimes = 0;

                record.CreateUser = "******";

                if (WMFactory.GameRecord.Insert(record))
                {
                    ViewBag.Info = "15";
                }
            }
            //存在记录,并且中奖
            else if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 2 && f.AwardId != id) > 0)
            {
                return Redirect("~/Game/NpaiaChristmas/Info?sid=" + sid + "&oid=" + oid);
            }
            //已参与3次
            else if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 2 && f.doTimes == 3) > 0)
            {
                ViewBag.Info = "抽奖次数已用完";
            }
            //存在记录,未中奖,倒计时结束,重新计时
            else if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 2 && f.isAward == 0) == 0)
            {
                IEnumerable<Game_Record> gr = WMFactory.GameRecord.FindByConditions(null, f => f.Oid == oid && f.Group == 2 && f.isAward != 0);

                Game_Record record = gr.First();
                record.isAward = 0;

                record.ModifyUser = "******";

                if (WMFactory.GameRecord.Update(record))
                {
                    ViewBag.Info = "15";
                }
            }
            //存在记录,倒计时进行中
            else
            {
                IEnumerable<Game_Record> gr = WMFactory.GameRecord.FindByConditions(null, f => f.Oid == oid && f.Group == 2 && f.isAward == 0);
                DateTime date = DateTime.Now;
                int second;
                if (gr.First().ModifyTime != null)
                {
                    second = (int)(date - (DateTime)gr.First().ModifyTime).TotalSeconds;
                }
                else
                {
                    second = (int)(date - gr.First().CreateTime).TotalSeconds;
                }

                if (second > 15)
                    ViewBag.Info = 0;
                else
                    ViewBag.Info = (15 - second);
            }

            return View();
        }
Ejemplo n.º 13
0
        public JsonResult Award(Guid sid, string oid)
        {
            Game_Record record = null;

            //没有抽奖机会
            if (WMFactory.GLGameRecord.GetCount(f => f.Oid == oid && f.Group == 3 && f.isAward == 1) > 0)
            {
                return Json(ResultMsg.Failure("您已抽过奖"));
            }
            else
            {
                //第一次进入游戏
                if (WMFactory.GLGameRecord.GetCount(f => f.Oid == oid && f.Group == 3) == 0)
                {
                    record = new Game_Record();
                    record.Oid = oid;

                    //WxFans wf = ElegantWM.WeiXin.Common.GetFanInfo(sid.ToString(), oid);
                    //record.Nickname = wf.nickname;
                    record.Nickname = "";
                    record.Group = 3;
                    record.Num = 0;
                    record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
                    record.AwardName = "";
                    record.Seq = "";
                    record.isAward = 0;
                    record.doTimes = 0;
                    record.linkedTimes = 0;
                    record.CreateUser = "******";

                    WMFactory.GLGameRecord.Insert(record);
                }

                record = WMFactory.GLGameRecord.FindByConditions(null, f => f.Oid == oid && f.Group == 3 && f.isAward == 0).First();

                record.isAward = 1;
                record.doTimes = record.doTimes + 1;
                record.ModifyUser = "******";

                Random Rdm = new Random();

                //产生随机数
                int iRdm = Rdm.Next(0, 1000);

                string seq = "";
                if (iRdm < 10) //一等奖
                {
                    IEnumerable<Game_Award> ga = WMFactory.GLGameAward.FindByConditions(null, f => f.Group == 3 && f.Level == 1);
                    record.AwardId = ga.First().Id;
                    record.AwardName = ga.First().Name;
                    record.Num = 1;

                    seq = "0" + (WMFactory.GLGameRecord.GetCount(f => f.Group == 3 && f.AwardId == record.AwardId) + 1).ToString();
                    record.Seq = seq.Substring(seq.Length - 2, 2);
                }
                else if (iRdm >= 10 && iRdm < 20) //二等奖
                {
                    IEnumerable<Game_Award> ga = WMFactory.GLGameAward.FindByConditions(null, f => f.Group == 3 && f.Level == 2);
                    record.AwardId = ga.First().Id;
                    record.AwardName = ga.First().Name;
                    record.Num = 1;

                    seq = "0" + (WMFactory.GLGameRecord.GetCount(f => f.Group == 3 && f.AwardId == record.AwardId) + 1).ToString();
                    record.Seq = seq.Substring(seq.Length - 2, 2);
                }
                else if (iRdm >= 20 && iRdm < 35) //三等奖
                {
                    IEnumerable<Game_Award> ga = WMFactory.GLGameAward.FindByConditions(null, f => f.Group == 3 && f.Level == 3);
                    record.AwardId = ga.First().Id;
                    record.AwardName = ga.First().Name;
                    record.Num = 1;

                    seq = "0" + (WMFactory.GLGameRecord.GetCount(f => f.Group == 3 && f.AwardId == record.AwardId) + 1).ToString();
                    record.Seq = seq.Substring(seq.Length - 2, 2);
                }
                else if (iRdm >= 35 && iRdm < 85) //四等奖
                {
                    IEnumerable<Game_Award> ga = WMFactory.GLGameAward.FindByConditions(null, f => f.Group == 3 && f.Level == 4);
                    record.AwardId = ga.First().Id;
                    record.AwardName = ga.First().Name;
                    record.Num = 1;

                    seq = "0" + (WMFactory.GLGameRecord.GetCount(f => f.Group == 3 && f.AwardId == record.AwardId) + 1).ToString();
                    record.Seq = seq.Substring(seq.Length - 2, 2);
                }
                else if (iRdm >= 85 && iRdm < 150) //五等奖
                {
                    IEnumerable<Game_Award> ga = WMFactory.GLGameAward.FindByConditions(null, f => f.Group == 3 && f.Level == 5);
                    record.AwardId = ga.First().Id;
                    record.AwardName = ga.First().Name;
                    record.Num = 1;

                    seq = "000" + (WMFactory.GLGameRecord.GetCount(f => f.Group == 3 && f.AwardId == record.AwardId) + 1).ToString();
                    record.Seq = seq.Substring(seq.Length - 4, 4);
                }
                else if (record.doTimes == 2) //第二次必中五等奖
                {
                    IEnumerable<Game_Award> ga = WMFactory.GLGameAward.FindByConditions(null, f => f.Group == 3 && f.Level == 5);
                    record.AwardId = ga.First().Id;
                    record.AwardName = ga.First().Name;
                    record.Num = 1;

                    seq = "000" + (WMFactory.GLGameRecord.GetCount(f => f.Group == 3 && f.AwardId == record.AwardId) + 1).ToString();
                    record.Seq = seq.Substring(seq.Length - 4, 4);
                }
                else
                {
                    record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
                    record.Num = 0;
                }

                string awardId = DoAward(record).ToString().ToUpper();

                if (awardId == "00000000-0000-0000-0000-000000000000")
                    return Json(ResultMsg.Failure("00000000-0000-0000-0000-000000000000"));
                else
                    return Json(ResultMsg.Success(awardId));
            }
        }
Ejemplo n.º 14
0
        public string DoAward(Game_Record record)
        {
            try
            {
                if (WMFactory.GameRecord.Insert(record))
                {
                    Game_Award ga = WMFactory.GameAward.GetById(record.AwardId.ToString());
                    //未中奖
                    if (ga == null)
                    {
                        return noAward(true);
                    }

                    //搜索中奖券号
                    IEnumerable<Game_Ticket> gt = WMFactory.GameTicket.FindByConditions(null, f => f.Group == 4 && f.AwardId == ga.Id && string.IsNullOrEmpty(f.Oid));

                    if (gt.Count() > 0)
                    {
                        Game_Ticket gt2 = gt.First();
                        gt2.Oid = record.Oid;

                        gt2.ModifyUser = "******";

                        if (WMFactory.GameTicket.Update(gt2))
                        {
                            if (ga.Level == 1) //一等奖
                            {
                                return firstAward(true, gt2.Ticketid);
                            }
                            else if (ga.Level == 2) //二等奖
                            {
                                return secondAward(true, gt2.Ticketid);
                            }
                            else if (ga.Level == 3) //三等奖
                            {
                                return thirdAward(true, gt2.Ticketid);
                            }
                            else
                            {
                                return noAward(true);
                            }
                        }
                        else
                        {
                            return noAward(true);
                        }
                    }
                    //券号已用完
                    else
                    {
                        return noAward(true);
                    }
                }
                else
                    return noAward(true);
            }
            catch (Exception e)
            {
                string s = e.GetBaseException().Message.ToString();
                if (s == "奖品已经发完啦!") //所中奖品数量为0,奖品向下降级
                {
                    Game_Award ga = WMFactory.GameAward.GetById(record.AwardId.ToString());
                    int newLevel = ga.Level + 1;

                    IEnumerable<Game_Award> ga2 = WMFactory.GameAward.FindByConditions(null, f => f.Group == 4 && f.Level == newLevel);

                    if (ga2.Count() > 0)
                    {
                        record.AwardId = ga2.First().Id;
                        record.AwardName = ga2.First().Name;
                    }
                    else
                    {
                        record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
                        record.AwardName = "";
                        record.Num = 0;
                    }
                    return DoAward(record);
                }
                else
                {
                    throw e;
                }
            }
        }
Ejemplo n.º 15
0
        public string Award(Guid sid, string oid)
        {
            OID = oid;
            if (WMFactory.GameRecord.GetCount(f => f.Oid == oid && f.Group == 5) > 0)
            {
                return repeat();
            }

            Random Rdm = new Random();

            //产生0到4200的随机数
            int iRdm = Rdm.Next(0, 2500);

            Game_Record record = new Game_Record();
            record.Oid = oid;
            record.Group = 5;
            record.Num = 1;
            record.isAward = 0;
            record.CreateUser = "******";


            WxFans wf = ElegantWM.WeiXin.Common.GetFanInfo(sid.ToString(), oid);
            record.Nickname = wf.nickname;

            if (iRdm < 14) //香皂
            {
                record.AwardId = new Guid("3a4c0d33-7405-4bef-a534-0dbe135e093a");
                record.AwardName = "xz.jpg";
            }
            else if (iRdm >= 14 && iRdm < 28) //羊绒围巾
            {
                record.AwardId = new Guid("3e005e48-7646-4fe4-b103-b0a83a4b0003");
                record.AwardName = "yrwj.jpg";
            }
            else if (iRdm >= 28 && iRdm < 42) //红围巾
            {
                record.AwardId = new Guid("513471b7-dff3-4e91-926c-2d03da3a718c");
                record.AwardName = "hwj.jpg";
            }
            else if (iRdm >= 42 && iRdm < 56) //伞
            {
                record.AwardId = new Guid("a33e09a9-09c7-4393-aa1f-ee4b47f7083d");
                record.AwardName = "s.jpg";
            }
            else if (iRdm >= 56 && iRdm < 70) //杯子组
            {
                record.AwardId = new Guid("23256a32-3028-44b1-a705-e6b24dd4896c");
                record.AwardName = "bzz.jpg";
            }
            else if (iRdm >= 70 && iRdm < 200) //白
            {
                record.AwardId = new Guid("51822c8a-113a-449e-a92e-7a1da18af1cf");
            }
            else if (iRdm >= 200 && iRdm < 400) //橙
            {
                record.AwardId = new Guid("b4f5f06d-0c20-4676-b00e-b7b468332995");
            }
            else if (iRdm >= 400 && iRdm < 700) //粉
            {
                record.AwardId = new Guid("00a24f0a-807b-47d9-a85b-b0f5a60df836");
            }
            else if (iRdm >= 700 && iRdm < 900) //红
            {
                record.AwardId = new Guid("3c5d463d-5f1a-47cf-baca-141325d4e7df");
            }
            else if (iRdm >= 900 && iRdm < 1100) //黄
            {
                record.AwardId = new Guid("9367e840-ed3b-4473-8ea8-8798bb0320d5");
            }
            else if (iRdm >= 1100 && iRdm < 1400) //蓝
            {
                record.AwardId = new Guid("f7f1d78e-d611-409d-86df-f9c88023d386");
            }
            else if (iRdm >= 1400 && iRdm < 1600) //绿
            {
                record.AwardId = new Guid("f4e70a89-51c4-42f3-92b9-a9c5cee0e8f2");
            }
            else if (iRdm >= 1600 && iRdm < 1800) //青
            {
                record.AwardId = new Guid("b6739896-b18e-4ca4-b149-ed5939846c88");
            }
            else if (iRdm >= 1800 && iRdm < 2500) //紫
            {
                record.AwardId = new Guid("ba817dee-d82d-495f-8033-5b20cad95f1c");
            }
            else
            {
                record.AwardId = new Guid("ba817dee-d82d-495f-8033-5b20cad95f1c");
            }
            return DoAward(record);
        }
Ejemplo n.º 16
0
 public string DoAward(Game_Record record)
 {
     try
     {
         if (WMFactory.GameRecord.Insert(record))
         {
             if (record.AwardId == new Guid("3a4c0d33-7405-4bef-a534-0dbe135e093a")) //香皂
             {
                 return xzAward();
             }
             else if (record.AwardId == new Guid("3e005e48-7646-4fe4-b103-b0a83a4b0003")) //羊绒围巾
             {
                 return yrwjAward();
             }
             else if (record.AwardId == new Guid("513471b7-dff3-4e91-926c-2d03da3a718c")) //红围巾
             {
                 return hwjAward();
             }
             else if (record.AwardId == new Guid("a33e09a9-09c7-4393-aa1f-ee4b47f7083d")) //伞
             {
                 return sAward();
             }
             else if (record.AwardId == new Guid("23256a32-3028-44b1-a705-e6b24dd4896c")) //杯子组
             {
                 return bzzAward();
             }
             else if (record.AwardId == new Guid("51822c8a-113a-449e-a92e-7a1da18af1cf")) //白
             {
                 return baiAward();
             }
             else if (record.AwardId == new Guid("b4f5f06d-0c20-4676-b00e-b7b468332995")) //橙
             {
                 return cengAward();
             }
             else if (record.AwardId == new Guid("00a24f0a-807b-47d9-a85b-b0f5a60df836")) //粉
             {
                 return fenAward();
             }
             else if (record.AwardId == new Guid("3c5d463d-5f1a-47cf-baca-141325d4e7df")) //红
             {
                 return hongAward();
             }
             else if (record.AwardId == new Guid("9367e840-ed3b-4473-8ea8-8798bb0320d5")) //黄
             {
                 return huangAward();
             }
             else if (record.AwardId == new Guid("f7f1d78e-d611-409d-86df-f9c88023d386")) //蓝
             {
                 return lanAward();
             }
             else if (record.AwardId == new Guid("f4e70a89-51c4-42f3-92b9-a9c5cee0e8f2")) //绿
             {
                 return lvAward();
             }
             else if (record.AwardId == new Guid("b6739896-b18e-4ca4-b149-ed5939846c88")) //青
             {
                 return qingAward();
             }
             else if (record.AwardId == new Guid("ba817dee-d82d-495f-8033-5b20cad95f1c")) //紫
             {
                 return ziAward();
             }
             else
             {
                 return noAward();
             }
         }
         else
             return noAward();
     }
     catch (Exception e)
     {
         string s = e.GetBaseException().Message.ToString();
         if (s == "奖品已经发完啦!") //所中奖品数量为0,奖品向下降级
         {
             if (record.AwardId == new Guid("3a4c0d33-7405-4bef-a534-0dbe135e093a")) //香皂
             {
                 record.AwardId = new Guid("3e005e48-7646-4fe4-b103-b0a83a4b0003");
                 record.AwardName = "yrwj.jpg";
             }
             else if (record.AwardId == new Guid("3e005e48-7646-4fe4-b103-b0a83a4b0003")) //羊绒围巾
             {
                 record.AwardId = new Guid("513471b7-dff3-4e91-926c-2d03da3a718c");
                 record.AwardName = "hwj.jpg";
             }
             else if (record.AwardId == new Guid("513471b7-dff3-4e91-926c-2d03da3a718c")) //红围巾
             {
                 record.AwardId = new Guid("a33e09a9-09c7-4393-aa1f-ee4b47f7083d");
                 record.AwardName = "s.jpg";
             }
             else if (record.AwardId == new Guid("a33e09a9-09c7-4393-aa1f-ee4b47f7083d")) //伞
             {
                 record.AwardId = new Guid("23256a32-3028-44b1-a705-e6b24dd4896c");
                 record.AwardName = "bzz.jpg";
             }
             else if (record.AwardId == new Guid("23256a32-3028-44b1-a705-e6b24dd4896c")) //杯子组
             {
                 record.AwardId = new Guid("51822c8a-113a-449e-a92e-7a1da18af1cf");
                 record.AwardName = "";
             }
             else if (record.AwardId == new Guid("51822c8a-113a-449e-a92e-7a1da18af1cf")) //白
             {
                 record.AwardId = new Guid("b4f5f06d-0c20-4676-b00e-b7b468332995");
             }
             else if (record.AwardId == new Guid("b4f5f06d-0c20-4676-b00e-b7b468332995")) //橙
             {
                 record.AwardId = new Guid("00a24f0a-807b-47d9-a85b-b0f5a60df836");
             }
             else if (record.AwardId == new Guid("00a24f0a-807b-47d9-a85b-b0f5a60df836")) //粉
             {
                 record.AwardId = new Guid("3c5d463d-5f1a-47cf-baca-141325d4e7df");
             }
             else if (record.AwardId == new Guid("3c5d463d-5f1a-47cf-baca-141325d4e7df")) //红
             {
                 record.AwardId = new Guid("9367e840-ed3b-4473-8ea8-8798bb0320d5");
             }
             else if (record.AwardId == new Guid("9367e840-ed3b-4473-8ea8-8798bb0320d5")) //黄
             {
                 record.AwardId = new Guid("f7f1d78e-d611-409d-86df-f9c88023d386");
             }
             else if (record.AwardId == new Guid("f7f1d78e-d611-409d-86df-f9c88023d386")) //蓝
             {
                 record.AwardId = new Guid("f4e70a89-51c4-42f3-92b9-a9c5cee0e8f2");
             }
             else if (record.AwardId == new Guid("f4e70a89-51c4-42f3-92b9-a9c5cee0e8f2")) //绿
             {
                 record.AwardId = new Guid("b6739896-b18e-4ca4-b149-ed5939846c88");
             }
             else if (record.AwardId == new Guid("b6739896-b18e-4ca4-b149-ed5939846c88")) //青
             {
                 record.AwardId = new Guid("a33e09a9-09c7-4393-aa1f-ee4b47f7083d");
             }
             else if (record.AwardId == new Guid("ba817dee-d82d-495f-8033-5b20cad95f1c")) //紫
             {
                 record.AwardId = new Guid("ba817dee-d82d-495f-8033-5b20cad95f1c");
             }
             //else if (record.AwardId == new Guid("a33e09a9-09c7-4393-aa1f-ee4b47f7083d")) //
             //{
             //    record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
             //    record.Num = 0;
             //}
             return DoAward(record);
         }
         else
         {
             throw e;
         }
     }
 }
Ejemplo n.º 17
0
        public string Award(Guid sid, string oid)
        {
            string viptel = "";
            IEnumerable<WX_LK_RegMemberFans> fans = WMFactory.WXLKRegMemberFans.FindByConditions(null, f => f.AccountId == sid && f.OpenId == oid && f.IsUsing == 0);
            if (fans == null || fans.Count() <= 0)
            {
                return register(sid, oid);
            }
            else
            {
                viptel = fans.First().Telphone;
                DataTable dtpCentum = WMFactory.Wsrr.GetUserCentumInfo(viptel);

                if (dtpCentum.Rows[0]["mobtel"].ToString() == "")
                {
                    return register(sid, oid);
                }
            }

            IEnumerable<Game_Record> gr = WMFactory.GameRecord.FindByConditions(null, f => f.Oid == oid && f.Group == 4);

            //重复抽奖
            if (gr.Count() > 0)
            {
                //未中奖
                if (gr.First().AwardId == new Guid("00000000-0000-0000-0000-000000000000"))
                {
                    return noAward(false);
                }

                Game_Award gaf = WMFactory.GameAward.GetById(gr.First().AwardId.ToString());

                //中奖,查看是否有中券号
                IEnumerable<Game_Ticket> gt = WMFactory.GameTicket.FindByConditions(null, f => f.Oid == oid && f.Group == 4);
                //中券号
                if (gt.Count() > 0)
                {
                    if (gaf.Level == 1) //一等奖
                    {
                        return firstAward(false, gt.First().Ticketid);
                    }
                    else if (gaf.Level == 2) //二等奖
                    {
                        return secondAward(false, gt.First().Ticketid);
                    }
                    else if (gaf.Level == 3) //三等奖
                    {
                        return thirdAward(false, gt.First().Ticketid);
                    }
                    else
                    {
                        return noAward(false);
                    }
                }
                //未中券号,重新赋券号
                else
                {
                    //搜索中奖券号
                    IEnumerable<Game_Ticket> gt2 = WMFactory.GameTicket.FindByConditions(null, f => f.Group == 4 && f.AwardId == gaf.Id && string.IsNullOrEmpty(f.Oid));

                    if (gt2.Count() > 0)
                    {
                        Game_Ticket gtf = gt2.First();
                        gtf.Oid = gr.First().Oid;

                        gtf.ModifyUser = "******";

                        if (WMFactory.GameTicket.Update(gtf))
                        {
                            if (gaf.Level == 1) //一等奖
                            {
                                return firstAward(false, gtf.Ticketid);
                            }
                            else if (gaf.Level == 2) //二等奖
                            {
                                return secondAward(false, gtf.Ticketid);
                            }
                            else if (gaf.Level == 3) //三等奖
                            {
                                return thirdAward(false, gtf.Ticketid);
                            }
                            else
                            {
                                return noAward(false);
                            }
                        }
                        else
                        {
                            return noAward(false);
                        }
                    }
                    //券号已用完
                    else
                    {
                        return noAward(false);
                    }
                }
            }

            Random Rdm = new Random();

            //产生0到4200的随机数
            int iRdm = Rdm.Next(0, 841);

            Game_Record record = new Game_Record();
            record.Oid = oid;
            record.Group = 4;
            record.Num = 1;
            record.isAward = 0;
            record.CreateUser = "******";

            WxFans wf = ElegantWM.WeiXin.Common.GetFanInfo(sid.ToString(), oid);
            record.Nickname = wf.nickname;

            if (iRdm < 2) //一等奖
            {
                IEnumerable<Game_Award> ga = WMFactory.GameAward.FindByConditions(null, f => f.Group == 4 && f.Level == 1);
                record.AwardId = ga.First().Id;
                record.AwardName = ga.First().Name;
            }
            else if (iRdm >= 2 && iRdm < 5) //二等奖
            {
                IEnumerable<Game_Award> ga = WMFactory.GameAward.FindByConditions(null, f => f.Group == 4 && f.Level == 2);
                record.AwardId = ga.First().Id;
                record.AwardName = ga.First().Name;
            }
            else if (iRdm >= 5 && iRdm < 505) //三等奖
            {
                IEnumerable<Game_Award> ga = WMFactory.GameAward.FindByConditions(null, f => f.Group == 4 && f.Level == 3);
                record.AwardId = ga.First().Id;
                record.AwardName = ga.First().Name;
            }
            else
            {
                record.AwardId = new Guid("00000000-0000-0000-0000-000000000000");
                record.AwardName = "";
                record.Num = 0;
            }
            return DoAward(record);
        }
Ejemplo n.º 18
0
        public ActionResult GameInfo(int level, string lid, string sid, string oid)
        {
            return Redirect("~/Game/NpaiaWomen/End?sid=" + sid + "&oid=" + oid);

            Game_Record record;
            //自己点开
            if (lid.ToUpper() == oid.ToUpper())
            {
                ViewBag.TYPE = 1;
                //表中没有记录,插入新记录
                if (WMFactory.GameRecord.GetCount(f => f.Group == 10 && f.Oid == oid) == 0)
                {
                    record = new Game_Record();
                    record.Oid = oid;

                    WxFans wf = ElegantWM.WeiXin.Common.GetFanInfo(sid.ToString(), oid);
                    record.Nickname = wf.nickname;
                    record.Group = 10;
                    record.Num = 0;

                    IEnumerable<Game_Award> ga = WMFactory.GameAward.FindByConditions(null, f => f.Group == 10 && f.Level == level);
                    record.AwardId = ga.First().Id;
                    record.AwardName = ga.First().Name;
                    record.Seq = "";
                    record.Num = 0;
                    record.isAward = 0;
                    if (level == 1)
                    {
                        record.doTimes = 3298;
                    }
                    else if (level == 2)
                    {
                        record.doTimes = 2398;
                    }
                    else if (level == 3)
                    {
                        record.doTimes = 1898;
                    }
                    else
                    {
                        record.doTimes = 1298;
                    }

                    record.linkedTimes = 0;
                    record.CreateUser = "******";

                    WMFactory.GameRecord.Insert(record);
                }
                else
                {
                    IEnumerable<Game_Record> gr = WMFactory.GameRecord.FindByConditions(null, f => f.Group == 10 && f.Oid == oid);
                    record = gr.First();

                    Game_Award ga = WMFactory.GameAward.GetById(gr.First().AwardId.ToString());
                    level = ga.Level;

                    if (record.linkedTimes >= record.doTimes)
                    {
                        return Redirect("~/Game/NpaiaWomen/Winning?sid=" + sid + "&oid=" + oid);
                    }
                }
            }
            //好友打开
            else
            {
                ViewBag.TYPE = 2;
                IEnumerable<Game_Record> gr = WMFactory.GameRecord.FindByConditions(null, f => f.Group == 10 && f.Oid == lid);
                record = gr.First();

                Game_Award ga = WMFactory.GameAward.GetById(gr.First().AwardId.ToString());
                level = ga.Level;

                if (WMFactory.GameLink.GetCount(f => f.Group == 10 && f.Lid == lid && f.Oid == oid) > 0)
                {
                    ViewBag.BTN = 2;
                }
                else
                {
                    ViewBag.BTN = 1;
                }
            }

            WxFans wx = ElegantWM.WeiXin.Common.GetFanInfo(sid.ToString(), lid);
            ViewBag.LEVEL = level;
            ViewBag.AVATAR = wx.headimgurl;
            ViewBag.NAME = wx.nickname;
            ViewBag.MONEY = record.linkedTimes;

            IEnumerable<Game_Link> gl = WMFactory.GameLink.FindByConditions(null, f => f.Group == 10 && f.Lid == lid);
            ViewBag.LIST = gl.OrderByDescending(o => o.CreateTime);

            return View();
        }