Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">Model.user_sign</param>
        /// <returns>ID</returns>
        public int Add(Model.user_sign model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [" + databaseprefix + "user_sign](");
            strSql.Append("user_id,time,day");
            strSql.Append(") values(");
            strSql.Append("@user_id,@time,@day)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id", SqlDbType.Int,       4),
                new SqlParameter("@time",    SqlDbType.DateTime),
                new SqlParameter("@day",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.time;
            parameters[2].Value = model.day;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (null != obj)
            {
                return(Convert.ToInt32(obj));
            }
            else
            {
                return(0);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">Model.user_sign</param>
        /// <returns>True or False</returns>
        public bool Update(Model.user_sign model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [" + databaseprefix + "user_sign] set ");
            strSql.Append("user_id=@user_id,");
            strSql.Append("time=@time,");
            strSql.Append("day=@day");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id", SqlDbType.Int,       4),
                new SqlParameter("@time",    SqlDbType.DateTime),
                new SqlParameter("@day",     SqlDbType.Int,       4),
                new SqlParameter("@id",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.time;
            parameters[2].Value = model.day;
            parameters[3].Value = model.id;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
 /// <summary>
 /// 组合成对象实体
 /// </summary>
 /// <param name="row">一行数据</param>
 /// <returns>Model.user_sign</returns>
 private Model.user_sign DataRowToModel(DataRow row)
 {
     Model.user_sign model = new Model.user_sign();
     if (row != null)
     {
         if (null != row["id"] && "" != row["id"].ToString())
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (null != row["user_id"] && "" != row["user_id"].ToString())
         {
             model.user_id = int.Parse(row["user_id"].ToString());
         }
         if (null != row["time"] && "" != row["time"].ToString())
         {
             model.time = DateTime.Parse(row["time"].ToString());
         }
         if (null != row["day"] && "" != row["day"].ToString())
         {
             model.day = int.Parse(row["day"].ToString());
         }
     }
     return(model);
 }
Esempio n. 4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">Model.user_sign</param>
 /// <returns>True Or False</returns>
 public bool Update(Model.user_sign model)
 {
     return(dal.Update(model));
 }
Esempio n. 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">Model.user_sign</param>
 /// <returns>ID</returns>
 public int Add(Model.user_sign model)
 {
     return(dal.Add(model));
 }
Esempio n. 6
0
        /// <summary>
        /// 积分记录
        /// </summary>
        /// <param name="context"></param>
        private void point_log(HttpContext context)
        {
            //type:1签到,2发表评论,3每天分享3个50人以上群或分享资讯到朋友圈,4联系产品经理
            int    type   = DTRequest.GetInt("type", 0);
            int    uid    = DTRequest.GetInt("uid", 0);
            int    val    = DTRequest.GetInt("val", 0);
            string remark = DTRequest.GetString("remark");

            Model.point model = new Model.point();
            model.user_id = uid;
            //model.value = val;
            //model.remark = remark;
            model.add_time = DateTime.Now;

            switch (type)
            {
            case 1:    //签到
                #region 签到
                if (new BLL.user_sign().GetCount("user_id=" + uid + " and DateDiff(dd,time,getdate())=0") == 0)
                {
                    model.value = 5;    //每日签到5点积分
                    DataTable       dt   = new BLL.user_sign().GetList(0, "user_id=" + uid + " and DateDiff(dd,time,getdate())=1", "").Tables[0];
                    Model.user_sign sign = new Model.user_sign();
                    sign.user_id = uid;
                    sign.time    = DateTime.Now;
                    if (new BLL.user_sign().GetCount("user_id=" + uid + " and DateDiff(dd,time,getdate())=1") > 0)
                    {
                        int day = Convert.ToInt32(dt.Rows[0]["day"]) + 1;
                        sign.day     = day;
                        model.remark = "连续签到第" + day + "天";
                        if (day == 10 || day == 30)
                        {    //连续签到10天或30天送红包
                            Model.amount amount = new Model.amount();
                            amount.user_id = uid;
                            amount.type    = 1;
                            amount.remark  = "连续签到";
                            amount.time    = DateTime.Now;
                            if (day == 10 && new BLL.amount().GetCount("user_id=" + uid + " and type=1 and amount=0.88") == 0)
                            {
                                amount.Amount = 0.88M;
                            }
                            if (day == 10 && new BLL.amount().GetCount("user_id=" + uid + " and type=1 and amount=1.88") == 0)
                            {
                                amount.Amount = 1.88M;
                            }
                            new BLL.amount().Add(amount);
                            new BLL.user().UpdateField(uid, "amount=amount+" + amount.Amount);
                        }
                    }
                    else
                    {
                        sign.day     = 1;
                        model.remark = "连续签到第1天";
                    }
                    new BLL.user_sign().Add(sign);
                    new BLL.point().Add(model);
                    context.Response.Write("{\"status\":1,\"msg\":\"" + model.remark + ",签到成功!\"}");
                }
                else
                {
                    context.Response.Write("{\"status\":1,\"msg\":\"今天已经签到过了!\"}");
                    return;
                }
                #endregion
                break;

            case 2:    //发表评论
                #region 评论
                int isPN = DTRequest.GetInt("isPN", 0);
                int nid  = DTRequest.GetInt("nid", 0);
                if (new BLL.news_commend().GetCount("user_id=" + uid + " and isPN=" + isPN + " and news_id=" + nid) > 1)
                {
                    context.Response.Write("{\"status\":1,\"msg\":\"已经评论过,无法重复获得积分!\"}");
                    return;
                }
                else
                {
                    model.value  = 5;
                    model.remark = "发表评论";
                    new BLL.point().Add(model);
                    context.Response.Write("{\"status\":1,\"msg\":\"评论成功获得积分!\"}");
                }
                #endregion
                break;

            case 3:    //分享

                break;

            case 4:    //联系产品经理

                break;
            }
            new BLL.user().UpdateField(uid, "point=point+" + model.value);
        }