예제 #1
0
    public void BuyDaoJu()
    {
        string userId = UiCommon.UserLoginInfo.UserID;
        string propId = Common.SqlEncode(Common.GetStringOfUrl("id"));

        DataRow drDaoju = new BLL.DaoJu().GetInfo(propId);

        if (drDaoju != null)
        {
            int count = Common.GetIntOfUrl("count");

            int price    = Convert.ToInt32(drDaoju["Price"]);// Common.GetIntOfUrl("price");
            int vipPrice = Convert.ToInt32(drDaoju["VipPrice"]);

            //1.读取当前登录用户的信息,UserID,BankMoney,VipTime
            DataRow dr        = new BLL.Member().GetInfoInTUserInfo(userId);
            string  vipTime   = "1970-01-01 08:00:00";
            Int64   bankMoney = 0;
            if (dr != null)
            {
                //购买vip的公式:当前日期+购买天数*60*60*24
                vipTime   = dr["VipTime2"].ToString();
                bankMoney = Convert.ToInt64(dr["BankMoney"]);
            }

            //2.判断是否有足够的金币购买该道具
            int buyMoney = 0;
            if (DateTime.Now < Convert.ToDateTime(vipTime))
            {
                buyMoney = vipPrice * count;
            }
            else
            {
                buyMoney = price * count;
            }

            if (buyMoney < 0)//数据溢出
            {
                Response.Write("buysb");
                return;
            }

            if (bankMoney < buyMoney)
            {
                Response.Write("notmoney");
            }
            else
            {
                //3.金币足够,判断三种类型的道具:普通道具、1小时双倍积分卡、3小时双倍积分卡
                int doublePointTime = 0;
                if (propId.Trim() == "6")
                {
                    //1小时双倍积分卡
                    doublePointTime = count * 60 * 60;
                }
                else if (propId.Trim() == "7")
                {
                    //3小时双倍积分卡
                    doublePointTime = count * 60 * 60 * 3;
                }

                //4.提交数据
                int iRows = new BLL.Member().BuyDaoJu(userId, propId, count, buyMoney, doublePointTime);
                if (iRows > 0)
                {
                    Response.Write("buycg");
                }
                else
                {
                    Response.Write("buysb");
                }
            }
        }
        else
        {
            Response.Write("nodaoju");
        }
    }
예제 #2
0
    public void BuyDaoJu()
    {
        string userId = UiCommon.UserLoginInfo.UserID;
        string propId = Common.SqlEncode(Common.GetStringOfUrl("id"));

        DataRow drDaoju = new BLL.DaoJu().GetInfo(propId);
        if (drDaoju != null)
        {
            int count = Common.GetIntOfUrl("count");

            int price = Convert.ToInt32(drDaoju["Price"]);// Common.GetIntOfUrl("price");
            int vipPrice = Convert.ToInt32(drDaoju["VipPrice"]);

            //1.读取当前登录用户的信息,UserID,BankMoney,VipTime
            DataRow dr = new BLL.Member().GetInfoInTUserInfo(userId);
            string vipTime = "1970-01-01 08:00:00";
            Int64 bankMoney = 0;
            if (dr != null)
            {
                //购买vip的公式:当前日期+购买天数*60*60*24
                vipTime = dr["VipTime2"].ToString();
                bankMoney = Convert.ToInt64(dr["BankMoney"]);
            }

            //2.判断是否有足够的金币购买该道具
            int buyMoney = 0;
            if (DateTime.Now < Convert.ToDateTime(vipTime))
            {
                buyMoney = vipPrice * count;
            }
            else
            {
                buyMoney = price * count;
            }

            if (buyMoney < 0)//数据溢出
            {
                Response.Write("buysb");
                return;
            }

            if (bankMoney < buyMoney)
            {
                Response.Write("notmoney");
            }
            else
            {
                //3.金币足够,判断三种类型的道具:普通道具、1小时双倍积分卡、3小时双倍积分卡
                int doublePointTime = 0;
                if (propId.Trim() == "6")
                {
                    //1小时双倍积分卡
                    doublePointTime = count * 60 * 60;
                }
                else if (propId.Trim() == "7")
                {
                    //3小时双倍积分卡
                    doublePointTime = count * 60 * 60 * 3;
                }

                //4.提交数据
                int iRows = new BLL.Member().BuyDaoJu(userId, propId, count, buyMoney, doublePointTime);
                if (iRows > 0)
                {
                    Response.Write("buycg");
                }
                else
                {
                    Response.Write("buysb");
                }
            }
        }
        else
        {
            Response.Write("nodaoju");
        }
    }