Exemplo n.º 1
0
        /// <summary>
        /// 判断当日用户是否抽奖
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public bool Exists(ChouJiang info)
        {
            StringBuilder ExistStr = new StringBuilder();
            ExistStr.Append("select count(1) from tbl_ChouJiang  where  CONVERT(varchar(20), ChouJiangShiJian, 23)  =@ChouJiangShiJian  AND  CaoZuoRenID=@CaoZuoRenID   and  FangShi=@FangShi ");

            DbCommand ExistsCmd = this._db.GetSqlStringCommand(ExistStr.ToString());
            this._db.AddInParameter(ExistsCmd, "ChouJiangShiJian", System.Data.DbType.String, info.ChouJiangShiJian.ToString("yyyy-MM-dd"));
            this._db.AddInParameter(ExistsCmd, "CaoZuoRenID", System.Data.DbType.String, info.CaoZuoRenID);
            this._db.AddInParameter(ExistsCmd, "FangShi", System.Data.DbType.Byte, info.FangShi);

            return DbHelper.Exists(ExistsCmd, this._db);
        }
Exemplo n.º 2
0
        /// <summary>
        ///  抽奖
        /// </summary>
        void getFxResult()
        {
            EyouSoft.Model.SSOStructure.MUserInfo m = null;
            bool isLogin = EyouSoft.Common.Page.HuiyuanPage.IsLogin(out m);

            if (!isLogin)
            {
                Utils.RCWE_AJAX("0", "请登录后重新操作");
            }



            var hongbao = new Eyousoft_yhq.BLL.BHongBao().GetInfoByUserID(Utils.GetQueryStringValue("huiyuanid")); //判断是否存在红包

            if (hongbao == null)
            {
                return;
            }

            if (hongbao.HongBaoJinE <= 1M)
            {
                Utils.RCWE_AJAX("0", "红包被分光啦");
            }


            //判断用户当日是否已经抽奖
            bool isExists = new Eyousoft_yhq.BLL.BChouJiang().Exists(new Eyousoft_yhq.Model.ChouJiang()
            {
                CaoZuoRenID = m.UserID, ChouJiangShiJian = DateTime.Now, FangShi = JiangLiFangShi.分享
            });

            if (isExists)
            {
                Utils.RCWE_AJAX("0", "每天分享第一次才可以获得奖励");
            }

            Eyousoft_yhq.Model.ChouJiang info = new Eyousoft_yhq.Model.ChouJiang();
            info.ID          = hongbao.ID;
            info.CaoZuoRenID = m.UserID;
            info.JieGuo      = ChouJiangJieGuo.未中奖;
            info.DianShu     = 1M;
            info.FangShi     = JiangLiFangShi.分享;
            int result = new Eyousoft_yhq.BLL.BChouJiang().Insert(info);

            Utils.RCWE_AJAX(result == 1 ? "1" : "0", result == 1 ? "操作成功" : "操作失败");
            //抽奖
            //返回结果
        }
Exemplo n.º 3
0
 /// <summary>
 /// 添加一条抽奖记录
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public int Insert(ChouJiang info)
 {
     info.ChouJiangShiJian = DateTime.Now;
     info.ChouJiangID = Guid.NewGuid().ToString();
     info.LiuShuiHao = DateTime.Now.ToString("yyyyMMddHHmmssfff");
     int result = dal.Insert(info);
     if (result == 1)
     {
         var hongbao = new Eyousoft_yhq.BLL.BHongBao().GetInfo(info.ID);
         if (hongbao != null)
         {
             new Eyousoft_yhq.BLL.BHongBao().Update(new HongBao() { HongBaoJinE = hongbao.HongBaoJinE - info.DianShu, ID = hongbao.ID });
         }
         var model = new Eyousoft_yhq.BLL.Member().GetModel(info.CaoZuoRenID);
         if (model != null)
         {
             new Eyousoft_yhq.BLL.Member().setMoney(info.CaoZuoRenID, model.YuE + info.DianShu);
         }
     }
     return result;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="RecordCount"></param>
        /// <param name="serModel"></param>
        /// <returns></returns>
        public IList<ChouJiang> GetList(int PageSize, int PageIndex, ref int RecordCount, ChouJiangSer serModel)
        {
            IList<ChouJiang> list = new List<ChouJiang>();

            string tableName = "view_ChouJiang";
            string fileds = "  *    ";
            string orderByString = "ChouJiangShiJian desc";

            StringBuilder query = new StringBuilder();
            query.AppendFormat(" 1=1 ");

            if (serModel != null)
            {
                if (!string.IsNullOrEmpty(serModel.CaoZuoRenID))
                {
                    query.AppendFormat(" and  CaoZuoRenID  = '{0}' ", serModel.CaoZuoRenID);
                }
            }

            using (IDataReader dr = DbHelper.ExecuteReader1(this._db, PageSize, PageIndex, ref RecordCount, tableName, fileds, query.ToString(), orderByString, null))
            {
                while (dr.Read())
                {
                    ChouJiang model = new ChouJiang();
                    model.CaoZuoRenID = dr.GetString(dr.GetOrdinal("CaoZuoRenID"));
                    model.ChouJiangID = dr.GetString(dr.GetOrdinal("ChouJiangID"));
                    model.ChouJiangShiJian = dr.GetDateTime(dr.GetOrdinal("ChouJiangShiJian"));
                    model.ContactName = dr.GetString(dr.GetOrdinal("ContactName"));
                    model.DianShu = dr.GetDecimal(dr.GetOrdinal("DianShu"));
                    model.ID = dr.GetString(dr.GetOrdinal("ID"));
                    model.JieGuo = (ChouJiangJieGuo)dr.GetByte(dr.GetOrdinal("JieGuo"));
                    model.LiuShuiHao = dr.GetString(dr.GetOrdinal("LiuShuiHao"));
                    model.UserName = dr.GetString(dr.GetOrdinal("UserName"));
                    model.FangShi = (JiangLiFangShi)dr.GetByte(dr.GetOrdinal("FangShi"));

                    list.Add(model);
                }
            }
            return list;
        }
Exemplo n.º 5
0
        /// <summary>
        ///  抽奖
        /// </summary>
        void getResult()
        {
            EyouSoft.Model.SSOStructure.MUserInfo m = null;
            bool isLogin = EyouSoft.Common.Page.HuiyuanPage.IsLogin(out m);

            if (!isLogin)
            {
                Utils.RCWE_AJAX("0", "未登录");
            }



            var hongbao = new Eyousoft_yhq.BLL.BHongBao().GetInfoByUserID(Utils.GetQueryStringValue("huiyuanid")); //判断是否存在红包

            if (hongbao == null)
            {
                Utils.RCWE_AJAX("0", "该用户未设置红包");
            }

            if (hongbao.UserID == m.UserID)
            {
                Utils.RCWE_AJAX("0", "不能抽取自己的红包");
            }

            //判断用户当日是否已经抽奖
            bool isExists = new Eyousoft_yhq.BLL.BChouJiang().Exists(new Eyousoft_yhq.Model.ChouJiang()
            {
                CaoZuoRenID = m.UserID, ChouJiangShiJian = DateTime.Now, FangShi = JiangLiFangShi.抽奖
            });

            if (isExists)
            {
                Utils.RCWE_AJAX("0", "每天只能抽奖一次");
            }


            Eyousoft_yhq.Model.ChouJiang info = new Eyousoft_yhq.Model.ChouJiang();
            info.ID          = hongbao.ID;
            info.CaoZuoRenID = m.UserID;
            int i = new Random().Next(1000);

            if (i > 700)
            {
                info.JieGuo  = ChouJiangJieGuo.中奖;
                info.DianShu = Utils.GetDecimal(getResultMoney(hongbao.HongBaoJinE));
            }
            else
            {
                info.JieGuo  = ChouJiangJieGuo.未中奖;
                info.DianShu = 0M;
            }
            int result = new Eyousoft_yhq.BLL.BChouJiang().Insert(info);

            if (result == 1)
            {
                if (info.JieGuo == ChouJiangJieGuo.中奖)
                {
                    Utils.RCWE_AJAX("1", "恭喜中奖", info.DianShu);
                }
                else
                {
                    Utils.RCWE_AJAX("-99", "未中奖,明天再来或分享红包领取奖励", info.DianShu);
                }
            }
            else
            {
                Utils.RCWE_AJAX("0", "操作异常");
            }
            //抽奖
            //返回结果
        }
Exemplo n.º 6
0
 /// <summary>
 /// 判断当日用户是否抽奖
 /// </summary>
 /// <param name="userid"></param>
 /// <returns></returns>
 public bool Exists(ChouJiang info)
 {
     if (string.IsNullOrEmpty(info.CaoZuoRenID)
          || info.ChouJiangShiJian == DateTime.MinValue) return false;
     return dal.Exists(info);
 }
Exemplo n.º 7
0
        /// <summary>
        /// 添加一条抽奖记录
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int Insert(ChouJiang info)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(" INSERT INTO tbl_ChouJiang (ChouJiangID ,LiuShuiHao ,ID ,CaoZuoRenID ,ChouJiangShiJian ,JieGuo ,DianShu,FangShi) VALUES ( @ChouJiangID , @LiuShuiHao , @ID , @CaoZuoRenID , @ChouJiangShiJian , @JieGuo , @DianShu ,@FangShi) ");

            DbCommand cmd = this._db.GetSqlStringCommand(strSql.ToString());
            this._db.AddInParameter(cmd, "ChouJiangID", System.Data.DbType.AnsiStringFixedLength, info.ChouJiangID);
            this._db.AddInParameter(cmd, "LiuShuiHao", System.Data.DbType.String, info.LiuShuiHao);
            this._db.AddInParameter(cmd, "ID", System.Data.DbType.AnsiStringFixedLength, info.ID);
            this._db.AddInParameter(cmd, "CaoZuoRenID", System.Data.DbType.AnsiStringFixedLength, info.CaoZuoRenID);
            this._db.AddInParameter(cmd, "ChouJiangShiJian", System.Data.DbType.DateTime, info.ChouJiangShiJian);
            this._db.AddInParameter(cmd, "JieGuo", System.Data.DbType.Byte, info.JieGuo);
            this._db.AddInParameter(cmd, "DianShu", System.Data.DbType.Decimal, info.DianShu);
            this._db.AddInParameter(cmd, "FangShi", System.Data.DbType.Byte, info.FangShi);

            return DbHelper.ExecuteSql(cmd, this._db);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取列表数据
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="RecordCount"></param>
        /// <param name="serModel"></param>
        /// <returns></returns>
        public IList<ChouJiang> GetList(ChouJiangSer serModel)
        {
            IList<ChouJiang> list = new List<ChouJiang>();

            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT  *  FROM   view_ChouJiang WHERE  1=1 ");

            if (serModel != null)
            {
                if (!string.IsNullOrEmpty(serModel.CaoZuoRenID))
                {
                    strSql.AppendFormat(" and  CaoZuoRenID  = '{0}' ", serModel.CaoZuoRenID);
                }
                if (!string.IsNullOrEmpty(serModel.ID))
                {
                    strSql.AppendFormat(" and  ID  = '{0}' ", serModel.ID);
                }
            }
            strSql.Append("  order by  ChouJiangShiJian  desc ");
            DbCommand cmd = this._db.GetSqlStringCommand(strSql.ToString());

            using (IDataReader dr = DbHelper.ExecuteReader(cmd, this._db))
            {
                while (dr.Read())
                {
                    ChouJiang model = new ChouJiang();
                    model.CaoZuoRenID = dr.GetString(dr.GetOrdinal("CaoZuoRenID"));
                    model.ChouJiangID = dr.GetString(dr.GetOrdinal("ChouJiangID"));
                    model.ChouJiangShiJian = dr.GetDateTime(dr.GetOrdinal("ChouJiangShiJian"));
                    model.ContactName = dr.GetString(dr.GetOrdinal("ContactName"));
                    model.DianShu = dr.GetDecimal(dr.GetOrdinal("DianShu"));
                    model.ID = dr.GetString(dr.GetOrdinal("ID"));
                    model.JieGuo = (ChouJiangJieGuo)dr.GetByte(dr.GetOrdinal("JieGuo"));
                    model.LiuShuiHao = dr.GetString(dr.GetOrdinal("LiuShuiHao"));
                    model.UserName = dr.GetString(dr.GetOrdinal("UserName"));

                    list.Add(model);

                }
            }

            return list;
        }