示例#1
0
 public JsonResult Delete(Game_Ticket _t)
 {
     if (WMFactory.GameTicket.Delete(s => s.Id == _t.Id ))
         return Json(ResultMsg.Success("删除成功!"));
     else
         return Json(ResultMsg.Failure("删除失败,请您重试!"));
 }
示例#2
0
 public JsonResult Post(Game_Ticket _t)
 {
     if (WMFactory.GameTicket.Insert(_t))
         return Json(ResultMsg.Success("新增成功!"));
     else
         return Json(ResultMsg.Failure("新增失败,请您重试!"));
 }
示例#3
0
 public JsonResult Put(Game_Ticket _t)
 {
     IGameTicketService service = WMFactory.GameTicket;
     Game_Ticket entity = service.GetById(_t.Id.ToString());
     entity = AutoMapper<Game_Ticket, Game_Ticket>.Convert(_t, entity);
     if (service.Update(entity))
         return Json(ResultMsg.Success("更新成功!"));
     else
         return Json(ResultMsg.Failure("更新失败,请您重试!"));
 }
        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

            }

        }
示例#5
0
        public string SendTicket(Guid sid, string oid)
        {
            string strTicket = Guid.NewGuid().ToString();
            IEnumerable<Game_Ticket> gt = WMFactory.GameTicket.FindByConditions(null, f => f.Oid == oid && f.Group == 9);

            if (gt.Count() > 0)
            {
                return "领取代金券失败,你已经领过代金券,你的代金券为:" + gt.First().Ticketid + " \n\r代金券使用需知:\r凭此券可购买“红庵里”任意农产品 \r每次满30元可使用一张5元代金券 \r每人单次最多可使用10张。";
            }
            else
            {
                Game_Ticket Ticket = new Game_Ticket();
                Ticket.Group = 9;
                Ticket.AwardId = new Guid("07F63C5B-44AE-4EA3-86BC-7E463ACEBFF7");
                Ticket.Ticketid = strTicket;
                Ticket.Oid = oid;
                Ticket.CreateUser = "******";
                Ticket.ModifyUser = "******";
                Ticket.Oid = oid;
                WMFactory.GameTicket.Insert(Ticket);
                return "恭喜你!成功领取5元代金券 \r代金券号:" + strTicket + " \r代金券使用需知:\n\r凭此券可购买“红庵里”任意农产品 \r每次满30元可使用一张5元代金券 \r每人单次最多可使用10张。";
            }
        }