Example #1
0
        /// <summary>
        /// 根据卡片类别调用名称和用户名,检查用户卡片是否有效
        /// </summary>
        /// <param name="callIndex">卡片类别调用名称</param>
        /// <param name="username">用户名</param>
        /// <returns></returns>
        public bool CheckUserCard(string callIndex, string username)
        {
            bool check = false;

            BLL.Card         cardBll         = new BLL.Card();
            BLL.CardCategory cardCategoryBll = new BLL.CardCategory();
            BLL.UserCard     ucBLL           = new BLL.UserCard();
            BLL.users        usersBll        = new BLL.users();

            var user                  = usersBll.GetModel(username);
            var cardCategory          = cardCategoryBll.GetModel(callIndex);
            var uclist                = ucBLL.GetModelList("UserId=" + user.id);
            var cardList              = cardBll.GetModelList("CardCategoryId=" + cardCategory.CardCategoryId);
            List <Model.UserCard> ucl = (from uc in uclist
                                         join c in cardList on uc.CardId equals c.CardId
                                         select new Model.UserCard()
            {
                UserId = uc.UserId,
                CardId = uc.CardId,
                UserCardId = uc.UserCardId,
                CardCategoryId = cardCategory.CardCategoryId
            }).ToList();

            foreach (var uc in ucl)
            {
                var card = cardBll.GetModel(uc.CardId);
                if (card.StartDate <= DateTime.Now && card.EndDate >= DateTime.Now)
                {
                    check = true;
                }
            }
            return(check);
        }
Example #2
0
        /// <summary>
        /// 根据卡片类别调用名称和用户名,为用户创建卡片
        /// </summary>
        /// <param name="callindex">卡片类别调用名称</param>
        /// <param name="username">用户名</param>
        /// <param name="token">token</param>
        /// <returns></returns>
        public int CreateUserCard(string callindex, string username)
        {
            BLL.Card         cardBll         = new BLL.Card();
            BLL.CardCategory cardCategoryBll = new BLL.CardCategory();
            BLL.UserCard     ucBLL           = new BLL.UserCard();
            BLL.users        usersBll        = new BLL.users();

            var user         = usersBll.GetModel(username);
            var cardCategory = cardCategoryBll.GetModel(callindex);
            var card         = new Model.Card();

            card.CardCategoryId = cardCategory.CardCategoryId;
            card.Code           = Common.Utils.GetCheckCode(7);
            card.CreateDate     = DateTime.Now;
            card.StartDate      = DateTime.Now;
            card.EndDate        = card.StartDate.AddDays(double.Parse(cardCategory.Duration.ToString()));

            int cardId = cardBll.Add(card);
            var uc     = new Model.UserCard();

            uc.CardId         = cardId;
            uc.UserId         = user.id;
            uc.CardCategoryId = cardCategory.CardCategoryId;
            return(ucBLL.Add(uc));
        }
Example #3
0
        /// <summary>
        /// 获取用户的有效期内的卡片
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public List <Model.Card> GetCards(string username)
        {
            BLL.Card         cardBll         = new BLL.Card();
            BLL.CardCategory cardCategoryBll = new BLL.CardCategory();
            BLL.UserCard     ucBLL           = new BLL.UserCard();
            BLL.users        usersBll        = new BLL.users();

            var user           = usersBll.GetModel(username);
            var uclist         = ucBLL.GetModelList("UserId=" + user.id);
            var categoryIdlist = from uc in uclist
                                 group uc by uc.CardCategoryId into g
                                 select new { id = g.Key };
            List <Model.Card> cardList = new List <Model.Card>();

            foreach (var i in categoryIdlist)
            {
                var cc   = cardCategoryBll.GetModel(i.id);
                var card = GetUsersCard(cc.CallIndex, user.user_name);
                if (card != null)
                {
                    cardList.Add(card);
                }
            }
            return(cardList);
        }
Example #4
0
        public bool CheckUserCard(string code)
        {
            bool check = false;

            BLL.Card cardBll = new BLL.Card();

            var model = cardBll.GetModelList("Code=" + code)[0];

            if (model.StartDate < DateTime.Now && model.EndDate > DateTime.Now)
            {
                check = true;
            }
            return(check);
        }
Example #5
0
        public void BindLogList()
        {
            string where = " and player='" + UiCommon.UserLoginInfo.UserName + "' ";
            //string queryString = "&tid=" + Utility.Common.GetStringOfUrl("tid");
            int       counts;
            DataTable dt = new BLL.Card().PagerList(/*WebPager1.PageSize, WebPager1.CurrentPageIndex,*/ anpPageIndex.PageSize, PageIndex, out counts, where);

            anpPageIndex.RecordCount      = counts;
            anpPageIndex.CurrentPageIndex = PageIndex;
            //WebPager1.ItemCount = counts;
            //WebPager1.UrlQueryString = queryString;
            //Rowid = WebPager1.CurrentPageIndex * WebPager1.PageSize - WebPager1.PageSize;
            rpList.DataSource = dt.DefaultView;
            rpList.DataBind();
        }
Example #6
0
        public Model.Card GetUsersCard(string code)
        {
            BLL.Card   cardBll = new BLL.Card();
            Model.Card model;
            var        list = cardBll.GetModelList("Code='" + code + "'");

            if (list.Count > 0)
            {
                model = list[0];
            }
            else
            {
                throw new AppCommonException("没有找到卡片!");
            }
            return(model);
        }
Example #7
0
        /// <summary>
        /// 获取用户的所有的卡片
        /// </summary>
        /// <param name="username"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public List <Model.Card> GetAllCards(string username)
        {
            BLL.Card         cardBll         = new BLL.Card();
            BLL.CardCategory cardCategoryBll = new BLL.CardCategory();
            BLL.UserCard     ucBLL           = new BLL.UserCard();
            BLL.users        usersBll        = new BLL.users();

            var user   = usersBll.GetModel(username);
            var uclist = ucBLL.GetModelList("UserId=" + user.id);
            List <Model.Card> cardList = new List <Model.Card>();

            foreach (var uc in uclist)
            {
                cardList.Add(cardBll.GetModel(uc.CardId));
            }
            return(cardList);
        }
Example #8
0
        /// <summary>
        /// 根据卡片类别调用名称和用户名,获取卡片信息
        /// </summary>
        /// <param name="callIndex"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public Model.Card GetUsersCard(string callIndex, string username)
        {
            BLL.Card         cardBll         = new BLL.Card();
            BLL.CardCategory cardCategoryBll = new BLL.CardCategory();
            BLL.UserCard     ucBLL           = new BLL.UserCard();
            BLL.users        usersBll        = new BLL.users();

            var user                  = usersBll.GetModel(username);
            var cardCategory          = cardCategoryBll.GetModel(callIndex);
            var uclist                = ucBLL.GetModelList("UserId=" + user.id);
            var cardList              = cardBll.GetModelList("CardCategoryId=" + cardCategory.CardCategoryId);
            List <Model.UserCard> ucl = (from uc in uclist
                                         join c in cardList on uc.CardId equals c.CardId
                                         select new Model.UserCard()
            {
                UserId = uc.UserId,
                CardId = uc.CardId,
                UserCardId = uc.UserCardId,
                CardCategoryId = cardCategory.CardCategoryId
            }).ToList();

            Model.Card tcard = null;
            foreach (var uc in ucl)
            {
                Model.Card card = cardBll.GetModel(uc.CardId);
                if (card.StartDate <= DateTime.Now && card.EndDate >= DateTime.Now)
                {
                    if (tcard != null)
                    {
                        if (tcard.EndDate < card.EndDate)
                        {
                            tcard = card;
                        }
                    }
                    else
                    {
                        tcard = card;
                    }
                }
            }
            return(tcard);
        }
Example #9
0
        public IHttpActionResult PaySuccess(string ordernum, string tradeno)
        {
            var result = new PayResult();

            if (ordernum.StartsWith("R")) //充值订单
            {
                BLL.user_recharge   bll   = new BLL.user_recharge();
                Model.user_recharge model = bll.GetModel(ordernum);
                if (model == null)
                {
                    result.msg     = "该订单号不存在";
                    result.success = false;
                    result.status  = 201;
                }
                else
                {
                    if (model.status == 1)
                    {
                        result.msg     = "该订单已经支付,请不要重复支付";
                        result.success = false;
                        result.status  = 202;
                    }
                    //订单编号验证通过后执行
                    bool r = bll.Confirm(ordernum);
                    if (r)
                    {
                        result.msg     = "充值成功";
                        result.status  = 200;
                        result.success = true;
                    }
                    else
                    {
                        result.msg     = "充值订单信息更新失败";
                        result.status  = 204;
                        result.success = false;
                    }
                }
            }
            else if (ordernum.StartsWith("B"))
            {
                BLL.orders   bll   = new BLL.orders();
                Model.orders model = bll.GetModel(ordernum);
                if (model == null)
                {
                    result.msg     = "该订单号不存在";
                    result.success = false;
                    result.status  = 201;
                }
                else
                {
                    if (model.payment_status == 2) //已付款
                    {
                        result.msg     = "该订单已经支付,请不要重复支付";
                        result.success = false;
                        result.status  = 202;
                    }
                    //订单编号验证通过后执行
                    bool r = bll.UpdateField(ordernum, "trade_no='" + tradeno + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'");
                    if (r)
                    {
                        var articlebll = new BLL.article();
                        foreach (var g in model.order_goods)
                        {
                            //判断是否有卡片商品,如果有卡片商品,添加卡片和用户卡片
                            //todo:此处需要增加事务性操作
                            if (articlebll.IsCard(g.article_id))
                            {
                                var    article      = articlebll.GetModel(g.article_id);
                                string callindex    = article.fields["cardcategorycallindex"];
                                var    user         = new BLL.users().GetModel(model.user_name);
                                var    cardcategory = new BLL.CardCategory().GetModel(callindex);
                                var    card         = new Model.Card();
                                card.CardCategoryId = cardcategory.CardCategoryId;
                                card.Code           = Utils.GetCheckCode(7);
                                card.CreateDate     = DateTime.Now;
                                card.StartDate      = DateTime.Now;
                                card.EndDate        = DateTime.Now.AddDays((double)cardcategory.Duration);
                                var cardBll     = new BLL.Card();
                                int cardId      = cardBll.Add(card);
                                var usercardBll = new BLL.UserCard();
                                var usercard    = new Model.UserCard();
                                usercard.CardId         = cardId;
                                usercard.CardCategoryId = cardcategory.CardCategoryId;
                                usercard.UserId         = user.id;
                                usercardBll.Add(usercard);
                            }
                        }
                        result.msg     = "支付成功";
                        result.status  = 200;
                        result.success = true;
                    }
                    else
                    {
                        result.msg     = "商品订单信息更新失败";
                        result.status  = 204;
                        result.success = false;
                    }
                }
            }
            else
            {
                result.msg     = "订单号不正确";
                result.success = false;
                result.status  = 203;
            }
            return(Ok(result));
        }
Example #10
0
        protected void button5_ServerClick(object sender, EventArgs e)
        {
            if (!BCST.Common.CommonManager.Web.CheckPostSource())
                return;
            //1.У����֤��
            if (UiCommon.ValidCode.CurrentCode == null)
            {
                lblMsg.Text = "��֤���ѹ��ڣ��������µ���֤�룡";
                txtValidCode.Text = string.Empty;
                return;
            }
            else if (txtValidCode.Text.Trim() != UiCommon.ValidCode.CurrentCode)
            {
                lblMsg.Text = "��֤����������������µ���֤�룡";
                txtValidCode.Text = string.Empty;
                return;
            }

            //2.�ж��û����Ƿ����
            BLL.Member member = new BLL.Member();
            string userName = Utility.Common.SqlEncode(txtUserName.Text.Trim());
            if (!member.ExistName(userName))
            {
                lblMsg.Text = "���������Ϸ�ʺ�(�û���)�����ڣ�";
                txtValidCode.Text = string.Empty;
                return;
            }
            //�ж���ҳ�ֵʱ����������Ϸ��
            if (member.IsInRoomOrGame(userName))
            {
                lblMsg.Text = "Ҫ��ֵ���ʺ�������Ϸ�У������˳���Ϸ�ٽ��г�ֵ��";
                txtValidCode.Text = string.Empty;
                return;

            }
            //3.�жϳ�ֵ���Ƿ��ѳ�ֵ���򿨺ż��������
            string cardNo = Utility.Common.SqlEncode(txtCardNo.Text.Trim());
            string cardPwd = Utility.Common.SqlEncode(txtCardPwd.Text.Trim());
            int cardState = new BLL.Card().PointCardState(cardNo, cardPwd);
            if (cardState == -1)
            {
                lblMsg.Text = "�Բ���������Ŀ��Ż���������";
                txtValidCode.Text = string.Empty;
                return;
            }
            else if (cardState == 1)
            {
                lblMsg.Text = "�Բ���������Ŀ����Ѿ�����ֵ��";
                txtValidCode.Text = string.Empty;
                return;
            }

            #region ��ѿ�

            // ��ѿ�������
            int freeCardForUser = 0;
            DataRow dr = member.GetFreeCardCount();
            if (dr != null)
            {
            freeCardForUser = Convert.ToInt32(dr["FreeCardCount"]);
            }

            //������ѿ������ж��û��Ƿ��Ѿ���ֵ��XX�š��磺��ѿ�ÿ���û�ֻ�ܳ�ֵ2�š�
            if (member.IsFreeCard(cardNo))
            {
            int cardCount = member.FreeCardCount(userName);
            if (cardCount >= freeCardForUser)
            {
                lblMsg.Text = "���Ѿ�ʹ��" + freeCardForUser + "����ѿ��ˣ�";
                txtValidCode.Text = string.Empty;
                return;
            }
            }
            #endregion

            //4.����ֵ���ת���ɽ�Ҵ�������
            //����ֵ�û�������Ƽ��ˣ���Web_Config�и��ݲ���ֵ�����Ƽ���
            //���µ㿨״̬
            //by YMH 2012-9-4  ��ֵ����
             //���ֳ�ֵ����
            if (ConfigurationManager.AppSettings["IsPayToPoint"] == "1" && rblPayType.SelectedValue=="point" && ddlGameList.SelectedValue!="")
            {
            //��ֵ����
            int result = member.PointCardFull2(userName, cardNo, cardPwd, Utility.Common.RequestIP,ddlGameList.SelectedValue);
            if (result == 0)
            {
                lblMsg.Text = "��ֵ��[" + cardNo + "]��ֵ�ɹ�����ֵ����Ϸ�ʺ�(�û���)��" + userName + "��" + DateTime.Now;
                txtUserName.Text = string.Empty;
                txtUserName2.Text = string.Empty;
                txtCardNo.Text = string.Empty;
                txtValidCode.Text = string.Empty;
            }
            else if (result == -1)
            {
                lblMsg.Text = "��Ǹ���㿨�����ڻ�㿨�š����벻��ȷ��";
                txtValidCode.Text = string.Empty;
            }
            else
            {
                lblMsg.Text = "��Ǹ���㿨��ֵʧ�ܣ������Ƿ�������æ�����Ժ����ԣ�";
                txtValidCode.Text = string.Empty;
            }
            }
            else//��ֵ���
            {
            if (member.PointCardFull(userName, cardNo, cardPwd, Utility.Common.RequestIP))
            {
                lblMsg.Text = "��ֵ��[" + cardNo + "]��ֵ�ɹ�����ֵ����Ϸ�ʺ�(�û���)��" + userName + "��" + DateTime.Now;
                txtUserName.Text = string.Empty;
                txtUserName2.Text = string.Empty;
                txtCardNo.Text = string.Empty;
                txtValidCode.Text = string.Empty;
            }
            else
            {
                lblMsg.Text = "��Ǹ���㿨��ֵʧ�ܣ������Ƿ�������æ�����Ժ����ԣ�";
                txtValidCode.Text = string.Empty;
            }
            }
        }
Example #11
0
        protected void button5_ServerClick(object sender, EventArgs e)
        {
            if (!BCST.Common.CommonManager.Web.CheckPostSource())
            {
                return;
            }
            //1.校验验证码
            if (UiCommon.ValidCode.CurrentCode == null)
            {
                lblMsg.Text       = "验证码已过期,请输入新的验证码!";
                txtValidCode.Text = string.Empty;
                return;
            }
            else if (txtValidCode.Text.Trim() != UiCommon.ValidCode.CurrentCode)
            {
                lblMsg.Text       = "验证码输入错误,请输入新的验证码!";
                txtValidCode.Text = string.Empty;
                return;
            }

            //2.判断用户名是否存在
            BLL.Member member   = new BLL.Member();
            string     userName = Utility.Common.SqlEncode(txtUserName.Text.Trim());

            if (!member.ExistName(userName))
            {
                lblMsg.Text       = "您输入的游戏帐号(用户名)不存在!";
                txtValidCode.Text = string.Empty;
                return;
            }
            //判断玩家充值时,不能在游戏中
            if (member.IsInRoomOrGame(userName))
            {
                lblMsg.Text       = "要充值的帐号正在游戏中,请先退出游戏再进行充值!";
                txtValidCode.Text = string.Empty;
                return;
            }
            //3.判断充值卡是否已充值,或卡号及密码错误
            string cardNo    = Utility.Common.SqlEncode(txtCardNo.Text.Trim());
            string cardPwd   = Utility.Common.SqlEncode(txtCardPwd.Text.Trim());
            int    cardState = new BLL.Card().PointCardState(cardNo, cardPwd);

            if (cardState == -1)
            {
                lblMsg.Text       = "对不起,您输入的卡号或密码有误!";
                txtValidCode.Text = string.Empty;
                return;
            }
            else if (cardState == 1)
            {
                lblMsg.Text       = "对不起,您输入的卡号已经被充值!";
                txtValidCode.Text = string.Empty;
                return;
            }

            #region 免费卡

            // 免费卡的张数
            int     freeCardForUser = 0;
            DataRow dr = member.GetFreeCardCount();
            if (dr != null)
            {
                freeCardForUser = Convert.ToInt32(dr["FreeCardCount"]);
            }


            //若是免费卡,先判断用户是否已经充值了XX张。如:免费卡每个用户只能充值2张。
            if (member.IsFreeCard(cardNo))
            {
                int cardCount = member.FreeCardCount(userName);
                if (cardCount >= freeCardForUser)
                {
                    lblMsg.Text       = "您已经使用" + freeCardForUser + "张免费卡了!";
                    txtValidCode.Text = string.Empty;
                    return;
                }
            }
            #endregion

            //4.将充值金额转换成金币存入银行
            //被充值用户如果有推荐人,在Web_Config中根据参数值奖励推荐人
            //更新点卡状态
            //by YMH 2012-9-4  充值积分
            //积分充值存在
            if (ConfigurationManager.AppSettings["IsPayToPoint"] == "1" && rblPayType.SelectedValue == "point" && ddlGameList.SelectedValue != "")
            {
                //充值积分
                int result = member.PointCardFull2(userName, cardNo, cardPwd, Utility.Common.RequestIP, ddlGameList.SelectedValue);
                if (result == 0)
                {
                    lblMsg.Text       = "充值卡[" + cardNo + "]充值成功,充值的游戏帐号(用户名)是" + userName + "!" + DateTime.Now;
                    txtUserName.Text  = string.Empty;
                    txtUserName2.Text = string.Empty;
                    txtCardNo.Text    = string.Empty;
                    txtValidCode.Text = string.Empty;
                }
                else if (result == -1)
                {
                    lblMsg.Text       = "抱歉,点卡不存在或点卡号、密码不正确!";
                    txtValidCode.Text = string.Empty;
                }
                else
                {
                    lblMsg.Text       = "抱歉,点卡充值失败,可能是服务器繁忙,请稍候再试!";
                    txtValidCode.Text = string.Empty;
                }
            }
            else//充值金币
            {
                if (member.PointCardFull(userName, cardNo, cardPwd, Utility.Common.RequestIP))
                {
                    lblMsg.Text       = "充值卡[" + cardNo + "]充值成功,充值的游戏帐号(用户名)是" + userName + "!" + DateTime.Now;
                    txtUserName.Text  = string.Empty;
                    txtUserName2.Text = string.Empty;
                    txtCardNo.Text    = string.Empty;
                    txtValidCode.Text = string.Empty;
                }
                else
                {
                    lblMsg.Text       = "抱歉,点卡充值失败,可能是服务器繁忙,请稍候再试!";
                    txtValidCode.Text = string.Empty;
                }
            }
        }
Example #12
0
 public void BindLogList()
 {
     string where = " and player='" + UiCommon.UserLoginInfo.UserName + "' ";
     //string queryString = "&tid=" + Utility.Common.GetStringOfUrl("tid");
     int counts;
     DataTable dt = new BLL.Card().PagerList(/*WebPager1.PageSize, WebPager1.CurrentPageIndex,*/ anpPageIndex.PageSize, PageIndex, out counts, where);
     anpPageIndex.RecordCount = counts;
     anpPageIndex.CurrentPageIndex = PageIndex;
     //WebPager1.ItemCount = counts;
     //WebPager1.UrlQueryString = queryString;
     //Rowid = WebPager1.CurrentPageIndex * WebPager1.PageSize - WebPager1.PageSize;
     rpList.DataSource = dt.DefaultView;
     rpList.DataBind();
 }