private void update_user(HttpContext context) { string openid = DTRequest.GetString("openid"); string name = DTRequest.GetString("name"); int sex = DTRequest.GetInt("sex", 0); string phone = DTRequest.GetString("phone"); string email = DTRequest.GetString("email"); Model.user model = new BLL.user().GetModel(openid); model.nickname = name; model.sex = sex; model.phone = phone; model.email = email; if (new BLL.user().Update(model)) { if ((model.nickname != "" && model.sex != 0 && model.phone != "" && model.email != "") && new BLL.amount().GetCount("type=3 and user_id=" + model.id) == 0) { Model.amount amount = new Model.amount() { user_id = model.id, type = 3, Amount = 1.88M, remark = "填写完整个人信息", time = DateTime.Now }; new BLL.amount().Add(amount); new BLL.user().UpdateField(model.id, "amount=amount+" + amount.Amount); } context.Response.Write("{\"status\":1,\"msg\":\"修改成功!\"}"); } else { context.Response.Write("{\"status\":0,\"msg\":\"修改失败!\"}"); } }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">Model.amount</param> /// <returns>ID</returns> public int Add(Model.amount model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [" + databaseprefix + "amount]("); strSql.Append("user_id,type,amount,remark,time"); strSql.Append(") values("); strSql.Append("@user_id,@type,@amount,@remark,@time)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@user_id", SqlDbType.Int, 4), new SqlParameter("@type", SqlDbType.Int, 4), new SqlParameter("@amount", SqlDbType.Decimal, 13), new SqlParameter("@remark", SqlDbType.NText), new SqlParameter("@time", SqlDbType.DateTime) }; parameters[0].Value = model.user_id; parameters[1].Value = model.type; parameters[2].Value = model.Amount; parameters[3].Value = model.remark; parameters[4].Value = model.time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (null != obj) { return(Convert.ToInt32(obj)); } else { return(0); } }
/// <summary> /// 组合成对象实体 /// </summary> /// <param name="row">一行数据</param> /// <returns>Model.amount</returns> private Model.amount DataRowToModel(DataRow row) { Model.amount model = new Model.amount(); 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["type"] && "" != row["type"].ToString()) { model.type = int.Parse(row["type"].ToString()); } if (null != row["amount"] && "" != row["amount"].ToString()) { model.Amount = decimal.Parse(row["amount"].ToString()); } if (null != row["remark"]) { model.remark = row["remark"].ToString(); } if (null != row["time"] && "" != row["time"].ToString()) { model.time = DateTime.Parse(row["time"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">Model.amount</param> /// <returns>True or False</returns> public bool Update(Model.amount model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [" + databaseprefix + "amount] set "); strSql.Append("user_id=@user_id,"); strSql.Append("type=@type,"); strSql.Append("amount=@amount,"); strSql.Append("remark=@remark,"); strSql.Append("time=@time"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@user_id", SqlDbType.Int, 4), new SqlParameter("@type", SqlDbType.Int, 4), new SqlParameter("@amount", SqlDbType.Decimal, 13), new SqlParameter("@remark", SqlDbType.NText), new SqlParameter("@time", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.user_id; parameters[1].Value = model.type; parameters[2].Value = model.Amount; parameters[3].Value = model.remark; parameters[4].Value = model.time; parameters[5].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } return(false); }
private void register(HttpContext context) { string avatar = DTRequest.GetString("avatar"); string nickname = DTRequest.GetString("nickname"); string openid = DTRequest.GetString("openid"); int parent_id = DTRequest.GetInt("parent_id", 0); int gender = DTRequest.GetInt("gender", 0); string country = DTRequest.GetString("country"); string province = DTRequest.GetString("province"); string city = DTRequest.GetString("city"); Model.user model = new Model.user(); model.avatar = avatar; model.nickname = nickname; model.openid = openid; model.parent_id = parent_id; model.sex = gender; model.amount = 0M; if (new BLL.user().GetCount("openid='" + openid + "'") == 0 && new BLL.user().Add(model) > 0) //注册 //成功邀请 { if (new BLL.amount().GetCount("type=2 and user_id=" + parent_id) < 10) { Model.amount amount = new Model.amount() { user_id = parent_id, type = 2, Amount = 0.88M, remark = "成功邀请用户", time = DateTime.Now }; new BLL.amount().Add(amount); new BLL.user().UpdateField(parent_id, "amount=amount+" + amount.Amount); } string ret = JsonHelper.DataTableToJSON(new BLL.user().GetList(1, "openid='" + openid + "'", "").Tables[0]); ret = ret.TrimEnd(']').TrimStart('['); context.Response.Write(ret); } else { string ret = JsonHelper.DataTableToJSON(new BLL.user().GetList(1, "openid='" + openid + "'", "").Tables[0]); ret = ret.TrimEnd(']').TrimStart('['); context.Response.Write(ret); } }
private void product_add(HttpContext context) { int id = DTRequest.GetInt("id", 0); int cateogry = DTRequest.GetInt("category", 0); string title = DTRequest.GetString("title"); string cont = DTRequest.GetString("cont"); string lat = DTRequest.GetString("lat"); string lon = DTRequest.GetString("lon"); string city = DTRequest.GetString("city"); string addr = DTRequest.GetString("addr"); int uid = DTRequest.GetInt("uid", 0); Model.product model = new Model.product(); if (id != 0) { model = new BLL.product().GetModel(id); } model.user_id = uid; model.category = cateogry; model.title = title; model.cont = cont; model.lat = lat; model.lon = lon; model.city = city; model.addr = addr; model.status = 1; if (id == 0) { if (new BLL.product().Add(model) > 0) { if (new BLL.amount().GetCount("type=4 and user_id=" + uid) < 3) { Model.amount amount = new Model.amount() { user_id = uid, type = 4, Amount = 1.88M, remark = "发布产品获得红包", time = DateTime.Now }; new BLL.amount().Add(amount); new BLL.user().UpdateField(uid, "amount=amount+" + amount.Amount); } context.Response.Write("{\"status\":1,\"msg\":\"提交成功!\"}"); } else { context.Response.Write("{\"status\":0,\"msg\":\"提交失败!\"}"); } } else { if (new BLL.product().Update(model)) { context.Response.Write("{\"status\":1,\"msg\":\"修改成功!\"}"); } else { context.Response.Write("{\"status\":0,\"msg\":\"提交失败!\"}"); } } }
/// <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); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">Model.amount</param> /// <returns>True Or False</returns> public bool Update(Model.amount model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">Model.amount</param> /// <returns>ID</returns> public int Add(Model.amount model) { return(dal.Add(model)); }