Пример #1
0
        private void call_pm(HttpContext context)
        {
            int uid = DTRequest.GetInt("uid", 0);
            int cid = DTRequest.GetInt("cid", 0);

            if (new BLL.call_pm().GetCount("user_id=" + uid + " and call_id=" + cid) == 0)
            {
                if (new BLL.user().GetModel(uid).point < 30)
                {
                    context.Response.Write("{\"status\":0,\"msg\":\"积分不足30!\"}");
                    return;
                }
                Model.call_pm call = new Model.call_pm();
                call.user_id = uid;
                call.call_id = cid;
                call.time    = DateTime.Now;
                new BLL.call_pm().Add(call);

                Model.point model = new Model.point();
                model.user_id  = uid;
                model.value    = -30;
                model.remark   = "联系产品经理";
                model.add_time = DateTime.Now;
                new BLL.point().Add(model);
                new BLL.user().UpdateField(uid, "point=point+" + model.value);
                context.Response.Write("{\"status\":1,\"msg\":\"成功联系产品经理!\"}");
            }
            else
            {
                context.Response.Write("{\"status\":1,\"msg\":\"非首次联系产品经理,不重复扣除积分!\"}");
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">Model.point</param>
        /// <returns>ID</returns>
        public int Add(Model.point model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [" + databaseprefix + "point](");
            strSql.Append("user_id,value,remark,add_time");
            strSql.Append(") values(");
            strSql.Append("@user_id,@value,@remark,@add_time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",  SqlDbType.Int,        4),
                new SqlParameter("@value",    SqlDbType.Int,        4),
                new SqlParameter("@remark",   SqlDbType.NVarChar, 100),
                new SqlParameter("@add_time", SqlDbType.DateTime)
            };
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.value;
            parameters[2].Value = model.remark;
            parameters[3].Value = model.add_time;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (null != obj)
            {
                return(Convert.ToInt32(obj));
            }
            else
            {
                return(0);
            }
        }
Пример #3
0
 /// <summary>
 /// 组合成对象实体
 /// </summary>
 /// <param name="row">一行数据</param>
 /// <returns>Model.point</returns>
 private Model.point DataRowToModel(DataRow row)
 {
     Model.point model = new Model.point();
     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["value"] && "" != row["value"].ToString())
         {
             model.value = int.Parse(row["value"].ToString());
         }
         if (null != row["remark"])
         {
             model.remark = row["remark"].ToString();
         }
         if (null != row["add_time"] && "" != row["add_time"].ToString())
         {
             model.add_time = DateTime.Parse(row["add_time"].ToString());
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">Model.point</param>
        /// <returns>True or False</returns>
        public bool Update(Model.point model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (rows > 0)
            {
                return(true);
            }
            return(false);
        }
Пример #5
0
        private void go_share(HttpContext context)
        {
            int uid = DTRequest.GetInt("uid", 0);

            Model.share_log share = new Model.share_log();
            share.user_id = uid;
            share.time    = DateTime.Now;
            new BLL.share_log().Add(share);
            if (new BLL.share_log().GetCount("DateDiff(dd,time,getdate())=0 and user_id=" + uid) == 3)
            {//当日第三次分享,获得积分
                Model.point model = new Model.point();
                model.user_id  = uid;
                model.value    = 10;
                model.remark   = "每日分享三次到微信群";
                model.add_time = DateTime.Now;
                new BLL.point().Add(model);
                new BLL.user().UpdateField(uid, "point=point+" + model.value);
                context.Response.Write("{\"status\":1,\"msg\":\"分享成功并获得积分!\"}");
            }
            else
            {
                context.Response.Write("{\"status\":1,\"msg\":\"分享成功!\"}");
            }
        }
Пример #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">Model.point</param>
 /// <returns>True Or False</returns>
 public bool Update(Model.point model)
 {
     return(dal.Update(model));
 }
Пример #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">Model.point</param>
 /// <returns>ID</returns>
 public int Add(Model.point model)
 {
     return(dal.Add(model));
 }
Пример #8
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);
        }