/// <summary>
        /// 获取可用的抽奖次数
        /// </summary>
        /// <returns></returns>
        public int GetCanUseTimes()
        {
            //M_login M_uid = (M_login)DataCache.GetCache(Utils.GetUserIDCookieslocahost().ToString());
            //if (M_uid == null)
            int userID = Settings.Instance.CurrentUserId;

            if (userID < 1)
            {
                return(0);
            }
            //获取登录用户编号
            //int userID = Utils.checkloginsession();
            //可抽奖次数
            int            CanUseTimes = 1;
            B_member_table bllMember   = new B_member_table();
            //获取会员信息
            PartialMemberModel member = bllMember.GetPartialModel(userID);

            //验证用户是否为今天新注册并认证的用户
            if (member.registration_time >= DateTime.Now.Date && member.registration_time < DateTime.Now.AddDays(1).Date&& member.isrealname == 1)
            {
                CanUseTimes += 1;
            }

            //获取用户的抽奖记录(当天的)
            B_LuckDraw bllLuckDraw  = new B_LuckDraw();
            int        recordsCount = bllLuckDraw.GetRecordsCount(userID, DateTime.Now.Date, DateTime.Now.AddDays(1).Date);

            CanUseTimes = CanUseTimes >= recordsCount ? CanUseTimes - recordsCount : 0;
            return(CanUseTimes);
        }
Exemple #2
0
        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="awardType"></param>
        /// <param name="pageIndex"></param>
        private void DataBind(int awardType, string ActivityName, int pageIndex)
        {
            chuangtouEntities ef = new chuangtouEntities();

            pageid = pageIndex;
            B_LuckDraw        bllLuckDraw = new B_LuckDraw();
            List <M_LuckData> dataList    = bllLuckDraw.GetLuckDraw(awardType, ActivityName, pageIndex, pagesize, out RecordCount);

            //IPagedList<M_LuckData> dataListd=
            //计算总页数
            pagecount = (RecordCount - 1) / pagesize + 1;
            if (pageid <= 0)
            {
                pageid = 1;
            }
            //生成分页字符串
            pagenumbers = "共" + pagecount + "页&nbsp;共" + RecordCount + "条&nbsp;" + Utils.GetPageNumbers(pageid, pagecount, "LuckDrawData?awardType=" + awardType, 6, "page").ToString();
            pagenumbers = pagenumbers + "跳转到第 <input name=\"page1\" id=\"page1\" type=\"text\" style=\"width: 26px\"  /> <span class=\"button white small\" style=\"cursor:pointer;\" onclick=\"page()\">转跳</span>  ";

            StringBuilder builder = new StringBuilder();

            foreach (M_LuckData item in dataList)
            {
                builder.Append("<tr>");
                builder.AppendFormat("<td class=\"txtb20 c\">{0}</td>", item.AwardName);                                                                                                                                                                                                                                  //奖品名称
                builder.AppendFormat("<td class=\"txtb20 c\">{0}</td>", item.UserName);                                                                                                                                                                                                                                   //获奖会员
                builder.AppendFormat("<td class=\"txtb40 c\">{0}</td>", item.AwardTime.ToString("yyyy-MM-dd HH:mm"));                                                                                                                                                                                                     //中奖时间
                builder.AppendFormat("<td class=\"txtb40 c\">{0}</td>", item.ActivityName);                                                                                                                                                                                                                               //活动名称
                builder.AppendFormat("<td class=\"txtb20 c\">{0}</td>", item.AwardType == (int)EnumHelp.LuckDrawEnum.E_AwardType.type0 ? "<a class=\"opt\" style=\"display:inline\" actionData=\"" + item.ID + "\" title=\"审核\">审核</a>" : (item.AwardType == (int)EnumHelp.LuckDrawEnum.E_AwardType.type4 ? "已发放" : "")); //操作
                builder.Append("</tr>");
            }
            ViewBag.PageData = pagenumbers;
            ViewBag.TBData   = builder.ToString();
        }
Exemple #3
0
        /// <summary>
        /// 绑定活动名称下拉框
        /// </summary>
        private void BindActivityName()
        {
            B_LuckDraw bllLuckDraw = new B_LuckDraw();
            List <M_LuckActivityNameData> dataList = bllLuckDraw.GetActivityNameList();
            StringBuilder builder = new StringBuilder();

            foreach (M_LuckActivityNameData item in dataList)
            {
                builder.AppendFormat("<option value='{0}'>{1}</option>", item.ActivityName, item.ActivityName);
            }
            ViewBag.ActivityNameData = builder.ToString();
        }
        /// <summary>
        /// 中奖榜单初始化
        /// </summary>
        private void FillDrawPersons()
        {
            string msg   = "";
            int    state = CheckActivityTime(ref msg);

            if (state != 0)
            {
                ViewBag.ltrCanUseTimes = "0";
                ViewBag.ltrLuckCount   = "0";
                Response.Write("<script>alert('" + msg + "');</script>");
                return;
            }

            int              luckCount   = 0;
            B_LuckDraw       bllLuckDraw = new B_LuckDraw();
            List <M_LuckMan> lucks       = bllLuckDraw.GetLastLuckMan(out luckCount);

            lucks.ForEach(c =>
            {
                c.UserName  = c.UserName.Substring(0, 1) + "*******" + c.UserName.Substring(c.UserName.Length - 1, 1);
                c.AwardName = c.AwardName.Replace("9月抽奖送", ""); //c.AwardName.Length > 6 ? c.AwardName.Substring(c.AwardName.Length - 6, 6) : c.AwardName;
            });
            //if (lucks == null || lucks.Count < 20)
            //{
            //    Dictionary<int, string> dicAwards = new Dictionary<int, string>();
            //    dicAwards.Add(1, "50元现金");
            //    dicAwards.Add(2, "50元代金券");
            //    dicAwards.Add(3, "20元代金券");
            //    dicAwards.Add(4, "10元代金券");
            //    dicAwards.Add(5, "1%加息券");
            //    dicAwards.Add(6, "2%加息券");
            //    Random random = new Random();
            //    int lucksCount = lucks.Count;
            //    for (int i = 1; i <= 20 - lucksCount; i++)
            //    {
            //        //Random random = new Random(unchecked((int)DateTime.Now.Ticks) / (20 - i) * i);
            //        lucks.Add(new M_LuckMan { AwardName = dicAwards[random.Next(1, 7)], UserName = random.Next(1, 10) + "*******" + random.Next(1, 10) });
            //        luckCount++;
            //    }
            //}
            StringBuilder builder = new StringBuilder();

            foreach (M_LuckMan luck in lucks)
            {
                builder.Append(" <li>");
                builder.AppendFormat("<p><span>{0}</span>抽中了<strong>{1}</strong></p>", luck.UserName, luck.AwardName);
                builder.Append("</li>");
            }
            ViewBag.ltrLuckMan     = builder.ToString();
            ViewBag.ltrLuckCount   = luckCount.ToString();
            ViewBag.ltrCanUseTimes = GetCanUseTimes().ToString();
        }
Exemple #5
0
        /// <summary>
        /// 发放现金奖励
        /// </summary>
        /// <param name="luckDrawID"></param>
        /// <returns></returns>
        public ActionResult CheckCashAward(string luckDrawID)
        {
            JavaScriptSerializer jss   = new JavaScriptSerializer();
            int     online_adminuserid = 0;
            M_login M_uid = (M_login)DataCache.GetCache(CacheRemove._loginCachePrefix + Utils.GetUserIDCookieslocahost().ToString());

            if (M_uid == null)
            {
                return(Content(jss.Serialize(new { code = -1, data = "请登录后在进行该操作!" })));
            }
            B_LuckDraw       bllLuckDraw = new B_LuckDraw();
            M_LuckDrawRecord record      = bllLuckDraw.GetModel(luckDrawID);

            if (record.Ldre_AwardType != (int)EnumHelp.LuckDrawEnum.E_AwardType.type0)
            {
                return(Content(jss.Serialize(new { code = -1, data = "只有未发放的现金奖励才能进行该操作!" })));
            }
            B_member_table bllUser = new B_member_table();
            M_member_table user    = bllUser.GetModel(record.Ldre_UserID);

            decimal orderID = decimal.Parse(Utils.Createcode());
            string  errMsg  = "";

            if (string.IsNullOrWhiteSpace(user.UsrCustId))
            {
                return(Content(jss.Serialize(new { code = -1, data = "会员未开通汇付账号,无法完成转账操作" })));
            }
            record.Ldre_AwardType = (int)EnumHelp.LuckDrawEnum.E_AwardType.type4;
            record.Ldre_OrderID   = orderID.ToString();
            if (!bllLuckDraw.UpdateModel(record))
            {
                LogInfo.WriteLog("九月抽奖活动,后台列表审核,更新抽奖记录状态失败:" + string.Format(" operater:{0};operateTime:{1};", online_adminuserid, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                return(Content(jss.Serialize(new { code = -1, data = "更新抽奖记录失败" })));
            }
            //hx_Activity_schedule 活动表中 50元红包的ID 为 53,对应于LuckDrawRecord中的awardID 为 -2 的数据均替换为 53
            //if (!LuckDrawSendCash(orderID, 50, user.UsrCustId, 53, user.registerid, record.Ldre_AwardName, ref errMsg))
            if (SendCash(record.Ldre_AwardID, user.registerid))
            {
                LogInfo.WriteLog("九月抽奖活动,后台列表审核,现金奖励发放失败:" + string.Format(" operater:{0};operateTime:{1};errMsg:{2}", online_adminuserid, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), errMsg));
                return(Content(jss.Serialize(new { code = -1, data = errMsg })));
            }
            LogInfo.WriteLog("九月抽奖活动,后台列表审核,现金发放成功:" + string.Format(" operater:{0};operateTime:{1};", online_adminuserid, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            return(Content(jss.Serialize(new { code = 0, data = "现金发放成功" })));
        }
        /// <summary>
        /// 抽奖方法
        /// </summary>
        /// <returns></returns>
        public ActionResult LuckDrawAward()
        {
            JavaScriptSerializer jss    = new JavaScriptSerializer();
            AjaxResponseData     arData = new AjaxResponseData();

            try
            {
                string msg   = "";
                int    state = CheckActivityTime(ref msg);
                if (state != 0)
                {
                    arData = new AjaxResponseData {
                        code = "4", data = msg
                    };
                    return(Content(jss.Serialize(arData)));
                }

                int userID = Settings.Instance.CurrentUserId;

                //M_login M_uid = (M_login)DataCache.GetCache(Utils.GetUserIDCookieslocahost().ToString());
                //if (M_uid == null)
                if (userID < 1)
                {
                    arData = new AjaxResponseData {
                        code = "1", data = "请登录后重试"
                    };
                    return(Content(jss.Serialize(arData)));
                }
                //if (M_uid.codeno != Utils.getSessioncode())
                //{
                //    arData = new AjaxResponseData { code = "1", data = "请登录后重试" };
                //    return Content(jss.Serialize(arData));
                //}
                //获取登录用户编号
                //int userID = M_uid.userid;
                //可抽奖次数
                int            CanUseTimes = 1;
                B_member_table bllMember   = new B_member_table();
                //获取会员信息
                PartialMemberModel member = bllMember.GetPartialModel(userID);
                //验证用户是否为今天新注册的用户
                if (member.registration_time >= DateTime.Now.Date && member.registration_time < DateTime.Now.AddDays(1).Date&& member.isrealname == 1)
                {
                    CanUseTimes += 1;
                }
                B_LuckDraw bllLuckDraw = new B_LuckDraw();
                //获取用户的抽奖记录数量(当天的)
                int recordsCount = bllLuckDraw.GetRecordsCount(userID, DateTime.Now.Date, DateTime.Now.AddDays(1).Date);
                CanUseTimes -= recordsCount;

                if (CanUseTimes <= 0)
                {
                    arData = new AjaxResponseData {
                        code = "2", data = "抽奖机会已用完,请明天再来"
                    };
                    return(Content(jss.Serialize(arData)));
                }
                #region 规则及数据
                // 现金50元   50  0.17 %(60次抽满后,每天限中2次,概率填充入50元代金券)
                //1 -17
                //50元代金券  2450    23.33 %
                //18-2350
                //20元代金卷  2100    20.00 %
                //2351-4350
                //10元代金卷  2100    20.00 %
                //4351-6350
                //1 % 加息券   1750    16.67 %
                //6351-8017
                //2 % 加息券   1400    13.33 %
                //8018-9350
                //谢谢参与    682.5   6.50 %
                //9351-10000

                //47    9月注册送500元奖励
                //48    9月注册送200元奖励
                //49    9月注册送50元奖励
                //50    9月注册送20元奖励
                //51    [9月注册送10元奖励]
                //52    [9月注册送8元奖励]

                //1   3 % 加息券
                //2   1 % 加息券
                //3   2 % 加息券
                //4   加息券
                #endregion
                //现金50元已抽中的个数
                int cash50Count = bllLuckDraw.GetCash50RecordsCount(-2, DateTime.Now.Date, DateTime.Now.AddDays(1).Date);
                //B_Activity_schedule bllASchedule = new B_Activity_schedule();
                ActFacade act = new ActFacade();
                //B_Activity bllActivity = new B_Activity();
                //admin.users.AddBonusForUser adfu = new admin.users.AddBonusForUser();
                //奖品编号
                int awardID = 0;
                //奖品标题
                string title = "";
                //奖品类型
                int awardType = -1;
                //轮盘区块编号
                int    awardBlockID = 0;
                Random random       = new Random();
                //随机数
                int randomRate = random.Next(1, 10001);
                //randomRate = 9350;
                //switch (randomRate)
                //{
                if (randomRate <= 8)
                {
                    //每天限中2次,概率填充入50元代金券
                    if (cash50Count < 2)
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardCash50");
                        awardType    = 0;
                        title        = "现金50元";
                        awardBlockID = 3;
                    }
                    else
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardBonus50");
                        awardType    = 1;
                        awardBlockID = 7;
                    }
                }
                //现金50元
                else if (randomRate <= 17)
                {
                    //每天限中2次,概率填充入50元代金券
                    if (cash50Count < 2)
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardCash50");
                        awardType    = 0;
                        title        = "现金50元";
                        awardBlockID = 5;
                    }
                    else
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardBonus50");
                        awardType    = 1;
                        awardBlockID = 7;
                    }
                }
                //50元代金券
                else if (randomRate <= 2350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus50"); awardType = 1; awardBlockID = 7;
                }
                //20元代金卷
                else if (randomRate <= 4350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; awardBlockID = 4;
                }
                //10元代金卷
                else if (randomRate <= 6350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus10"); awardType = 1; awardBlockID = 6;
                }
                //1 % 加息券
                else if (randomRate <= 8017)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardRate1"); awardType = 2; awardBlockID = 0;
                }
                //2 % 加息券
                else if (randomRate <= 9350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardRate2"); awardType = 2; awardBlockID = 2;
                }
                //谢谢参与
                else if (randomRate <= 10000)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardThankYou"); awardType = 3; title = "谢谢参与"; awardBlockID = 1;
                }
                //谢谢参与
                if (awardType == -1)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardThankYou"); awardType = 3; title = "谢谢参与"; awardBlockID = 1;
                }
                //}
                //发放代金券
                if (awardType == 1 || awardType == 2)
                {
                    var sourceData = act.GetActivityModel(awardID); //bllASchedule.GetModel(awardID);
                    title = sourceData.ActName;                     //sourceData.activity_schedule_name.Replace("活动", "抽奖");
                    if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord {
                        Ldre_AwardID = awardID, Ldre_AwardName = sourceData.ActName, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID
                    }))
                    {
                        DrawBonus(sourceData, userID);
                        arData = new AjaxResponseData {
                            code = "0", data = awardBlockID.ToString()
                        };
                        return(Content(jss.Serialize(arData)));
                    }
                    else
                    {
                        arData = new AjaxResponseData {
                            code = "3", data = "碰到点小问题,刷新一下试试^v^"
                        };
                        return(Content(jss.Serialize(arData)));
                    }
                }
                ////发放加息券
                //if (awardType == 2)
                //{
                //    var sourceData = bllActivity.GetModel(awardID);
                //    title = "9月抽奖" + sourceData.ActivityName;
                //    if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord { Ldre_AwardID = awardID, Ldre_AwardName = sourceData.ActivityName, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID }))
                //    {
                //        thisObj.SubmitRate(awardID, 1, userID, DateTime.Now, sourceData.EndDate, title);
                //        arData = new AjaxResponseData { code = "0", data = awardBlockID.ToString() };
                //        return jss.Serialize(arData);
                //    }
                //}
                //增加现金和“谢谢参与”的抽奖记录
                if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord {
                    Ldre_AwardID = awardID, Ldre_AwardName = title, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID
                }))
                {
                    arData = new AjaxResponseData {
                        code = "0", data = awardBlockID.ToString()
                    };
                    return(Content(jss.Serialize(arData)));
                }
                //没有增加任何抽奖记录时的异常状态
                arData = new AjaxResponseData {
                    code = "3", data = "碰到点小问题,刷新一下试试"
                };
                return(Content(jss.Serialize(arData)));
            }
            catch (Exception ex)
            {
                LogInfo.WriteLog("9月抽奖活动异常日志:" + "msg:" + ex.Message + "   StackTrace" + ex.StackTrace);

                //没有增加任何抽奖记录时的异常状态
                arData = new AjaxResponseData {
                    code = "3", data = ex.Message
                };
                return(Content(jss.Serialize(arData)));
            }
        }
        int amount         = 1000; //规则金额
        #endregion
        /// <summary>
        /// 中奖榜单初始化
        /// </summary>
        private void FillDrawPersons()
        {
            string msg   = "";
            int    state = TActivity_Luck.CheckActivityTime(startTime, endTime, ref msg);

            if (state != 0)
            {
                ViewBag.ltrCanUseTimes = "0";
                ViewBag.ltrLuckCount   = "0";
                //Response.Write("<script>alert('" + msg + "');</script>");
                return;
            }

            int              luckCount   = 0;
            B_LuckDraw       bllLuckDraw = new B_LuckDraw();
            List <M_LuckMan> lucks       = bllLuckDraw.GetLuckDrawRecordList(30, "双12抽奖", out luckCount);

            lucks.ForEach(c =>
            {
                c.Mobile = c.Mobile.Substring(0, 3) + "****" + c.Mobile.Substring(c.Mobile.Length - 4, 4);
                //c.UserName = c.UserName.Substring(0, 1) + "*******" + c.UserName.Substring(c.UserName.Length - 1, 1);
                c.AwardName = c.AwardName.Replace("双12抽奖送", ""); //c.AwardName.Length > 6 ? c.AwardName.Substring(c.AwardName.Length - 6, 6) : c.AwardName;
            });
            StringBuilder builder = new StringBuilder();

            builder.Append("<ul id='xstCont'>");
            foreach (M_LuckMan luck in lucks)
            {
                builder.Append(" <li>");
                builder.AppendFormat("<span>恭喜{0}用户</span><span>获得{1}</span>", luck.Mobile, luck.AwardName);
                builder.Append("</li>");
            }
            builder.Append("</ul>");
            ViewBag.ltrLuckMan   = builder.ToString();
            ViewBag.ltrLuckCount = luckCount.ToString();

            M_login M_uid = (M_login)DataCache.GetCache(CacheRemove._loginCachePrefix + Utils.GetUserIDCookieslocahost().ToString());

            if (M_uid == null)
            {
                ViewBag.ltrCanUseTimes = 0;
            }
            else
            {
                int userID = M_uid.userid;//PC获取登录用户编号
                if (!TActivity_Luck.CheckChannel(userID))
                {
                    string channelType = "";
                    if (TActivity_Luck.CheckIsChannel(userID, ref channelType))
                    {
                        if (channelType == "cps1")
                        {
                            Response.Write("<script>alert('抱歉,您是渠道用户,不可以参加本次活动,再投一笔即可抽奖!');</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('抱歉,您是渠道用户,不可以参加本次活动!');</script>");
                        }
                    }
                }
                ViewBag.ltrCanUseTimes = TActivity_Luck.GetCanUseTimes(userID, startTime, endTime, amount).ToString();
            }
        }
        int amount         = 1000; //规则金额
        #endregion
        /// <summary>
        /// 中奖榜单初始化
        /// </summary>
        private void FillDrawPersons()
        {
            string app   = DNTRequest.GetString("app");
            string msg   = "";
            int    state = TActivity_Luck.CheckActivityTime(startTime, endTime, ref msg);

            if (state != 0)
            {
                ViewBag.ltrCanUseTimes = "0";
                ViewBag.ltrLuckCount   = "0";
                return;
            }

            int              luckCount   = 0;
            B_LuckDraw       bllLuckDraw = new B_LuckDraw();
            List <M_LuckMan> lucks       = bllLuckDraw.GetLuckDrawRecordList(30, "双12抽奖", out luckCount);

            lucks.ForEach(c =>
            {
                c.Mobile    = c.Mobile.Substring(0, 3) + "****" + c.Mobile.Substring(c.Mobile.Length - 4, 4);
                c.AwardName = c.AwardName.Replace("双12抽奖送", "");
            });
            StringBuilder builder = new StringBuilder();

            builder.Append("<ul id='xstCont'>");
            foreach (M_LuckMan luck in lucks)
            {
                builder.Append(" <li>");
                builder.AppendFormat("<span>恭喜{0}用户</span><span>获得{1}</span>", luck.Mobile, luck.AwardName);
                builder.Append("</li>");
            }
            builder.Append("</ul>");
            ViewBag.ltrLuckMan   = builder.ToString();
            ViewBag.ltrLuckCount = luckCount.ToString();
            int userID = 0;

            if (app.ToLower() == "clt")
            {
                string uid = DNTRequest.GetString("userid");
                userID = int.Parse(string.IsNullOrWhiteSpace(uid) ? "0" : uid);
            }
            else
            {
                userID = Settings.Instance.CurrentUserId;//获取登录用户编号
            }

            if (userID <= 0)
            {
                ViewBag.ltrCanUseTimes = 0;
            }
            else
            {
                if (!TActivity_Luck.CheckChannel(userID))
                {
                    string channelType = "";
                    if (TActivity_Luck.CheckIsChannel(userID, ref channelType))
                    {
                        if (channelType == "cps1")
                        {
                            Response.Write("<script>alert('抱歉,您是渠道用户,不可以参加本次活动,再投一笔即可抽奖!');</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('抱歉,您是渠道用户,不可以参加本次活动!');</script>");
                        }
                    }
                }
                ViewBag.ltrCanUseTimes = TActivity_Luck.GetCanUseTimes(userID, startTime, endTime, amount).ToString();
            }
        }