/// <summary> /// 得到一个对象实体 by where条件 /// </summary> public Lebi_Agent_Product_Level GetModel(string strWhere) { if (strWhere.IndexOf("lbsql{") > 0) { SQLPara para = new SQLPara(strWhere, "", ""); return GetModel(para); } StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Agent_Product_Level] "); strSql.Append(" where "+ strWhere +""); Lebi_Agent_Product_Level model=new Lebi_Agent_Product_Level(); DataSet ds=SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString()); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["id"].ToString()!="") { model.id=int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.Name=ds.Tables[0].Rows[0]["Name"].ToString(); if(ds.Tables[0].Rows[0]["Sort"].ToString()!="") { model.Sort=int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } if(ds.Tables[0].Rows[0]["Price"].ToString()!="") { model.Price=decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if(ds.Tables[0].Rows[0]["Count_Product"].ToString()!="") { model.Count_Product=int.Parse(ds.Tables[0].Rows[0]["Count_Product"].ToString()); } if(ds.Tables[0].Rows[0]["Count_product_change"].ToString()!="") { model.Count_product_change=int.Parse(ds.Tables[0].Rows[0]["Count_product_change"].ToString()); } if(ds.Tables[0].Rows[0]["Years"].ToString()!="") { model.Years=int.Parse(ds.Tables[0].Rows[0]["Years"].ToString()); } model.Content=ds.Tables[0].Rows[0]["Content"].ToString(); if(ds.Tables[0].Rows[0]["Commission"].ToString()!="") { model.Commission=decimal.Parse(ds.Tables[0].Rows[0]["Commission"].ToString()); } if(ds.Tables[0].Rows[0]["CardOrder_id"].ToString()!="") { model.CardOrder_id=int.Parse(ds.Tables[0].Rows[0]["CardOrder_id"].ToString()); } return model; } else { return null; } }
/// <summary> /// 得到一个对象实体 by id /// </summary> public Lebi_Agent_Product_Level GetModel(int id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Agent_Product_Level] "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Lebi_Agent_Product_Level model=new Lebi_Agent_Product_Level(); DataSet ds=SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["id"].ToString()!="") { model.id=int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.Name=ds.Tables[0].Rows[0]["Name"].ToString(); if(ds.Tables[0].Rows[0]["Sort"].ToString()!="") { model.Sort=int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } if(ds.Tables[0].Rows[0]["Price"].ToString()!="") { model.Price=decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if(ds.Tables[0].Rows[0]["Count_Product"].ToString()!="") { model.Count_Product=int.Parse(ds.Tables[0].Rows[0]["Count_Product"].ToString()); } if(ds.Tables[0].Rows[0]["Count_product_change"].ToString()!="") { model.Count_product_change=int.Parse(ds.Tables[0].Rows[0]["Count_product_change"].ToString()); } if(ds.Tables[0].Rows[0]["Years"].ToString()!="") { model.Years=int.Parse(ds.Tables[0].Rows[0]["Years"].ToString()); } model.Content=ds.Tables[0].Rows[0]["Content"].ToString(); if(ds.Tables[0].Rows[0]["Commission"].ToString()!="") { model.Commission=decimal.Parse(ds.Tables[0].Rows[0]["Commission"].ToString()); } if(ds.Tables[0].Rows[0]["CardOrder_id"].ToString()!="") { model.CardOrder_id=int.Parse(ds.Tables[0].Rows[0]["CardOrder_id"].ToString()); } return model; } else { return null; } }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_Agent_Product_Level ReaderBind(IDataReader dataReader) { Lebi_Agent_Product_Level model=new Lebi_Agent_Product_Level(); object ojb; ojb = dataReader["id"]; if(ojb != null && ojb != DBNull.Value) { model.id=(int)ojb; } model.Name=dataReader["Name"].ToString(); ojb = dataReader["Sort"]; if(ojb != null && ojb != DBNull.Value) { model.Sort=(int)ojb; } ojb = dataReader["Price"]; if(ojb != null && ojb != DBNull.Value) { model.Price=(decimal)ojb; } ojb = dataReader["Count_Product"]; if(ojb != null && ojb != DBNull.Value) { model.Count_Product=(int)ojb; } ojb = dataReader["Count_product_change"]; if(ojb != null && ojb != DBNull.Value) { model.Count_product_change=(int)ojb; } ojb = dataReader["Years"]; if(ojb != null && ojb != DBNull.Value) { model.Years=(int)ojb; } model.Content=dataReader["Content"].ToString(); ojb = dataReader["Commission"]; if(ojb != null && ojb != DBNull.Value) { model.Commission=(decimal)ojb; } ojb = dataReader["CardOrder_id"]; if(ojb != null && ojb != DBNull.Value) { model.CardOrder_id=(int)ojb; } return model; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Agent_Product_Level model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into [Lebi_Agent_Product_Level]("); strSql.Append("[Name],[Sort],[Price],[Count_Product],[Count_product_change],[Years],[Content],[Commission],[CardOrder_id])"); strSql.Append(" values ("); strSql.Append("@Name,@Sort,@Price,@Count_Product,@Count_product_change,@Years,@Content,@Commission,@CardOrder_id)"); OleDbParameter[] parameters = { new OleDbParameter("@Name", model.Name), new OleDbParameter("@Sort", model.Sort), new OleDbParameter("@Price", model.Price), new OleDbParameter("@Count_Product", model.Count_Product), new OleDbParameter("@Count_product_change", model.Count_product_change), new OleDbParameter("@Years", model.Years), new OleDbParameter("@Content", model.Content), new OleDbParameter("@Commission", model.Commission), new OleDbParameter("@CardOrder_id", model.CardOrder_id)}; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(),parameters); return 1; }
/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_Agent_Product_Level SafeBindForm(Lebi_Agent_Product_Level model) { if (HttpContext.Current.Request["Name"] != null) model.Name=Shop.Tools.RequestTool.RequestSafeString("Name"); if (HttpContext.Current.Request["Sort"] != null) model.Sort=Shop.Tools.RequestTool.RequestInt("Sort",0); if (HttpContext.Current.Request["Price"] != null) model.Price=Shop.Tools.RequestTool.RequestDecimal("Price",0); if (HttpContext.Current.Request["Count_Product"] != null) model.Count_Product=Shop.Tools.RequestTool.RequestInt("Count_Product",0); if (HttpContext.Current.Request["Count_product_change"] != null) model.Count_product_change=Shop.Tools.RequestTool.RequestInt("Count_product_change",0); if (HttpContext.Current.Request["Years"] != null) model.Years=Shop.Tools.RequestTool.RequestInt("Years",0); if (HttpContext.Current.Request["Content"] != null) model.Content=Shop.Tools.RequestTool.RequestSafeString("Content"); if (HttpContext.Current.Request["Commission"] != null) model.Commission=Shop.Tools.RequestTool.RequestDecimal("Commission",0); if (HttpContext.Current.Request["CardOrder_id"] != null) model.CardOrder_id=Shop.Tools.RequestTool.RequestInt("CardOrder_id",0); return model; }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Agent_Product_Level model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update [Lebi_Agent_Product_Level] set "); strSql.Append("Name= @Name,"); strSql.Append("Sort= @Sort,"); strSql.Append("Price= @Price,"); strSql.Append("Count_Product= @Count_Product,"); strSql.Append("Count_product_change= @Count_product_change,"); strSql.Append("Years= @Years,"); strSql.Append("Content= @Content,"); strSql.Append("Commission= @Commission,"); strSql.Append("CardOrder_id= @CardOrder_id"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4), new SqlParameter("@Name", SqlDbType.NVarChar,50), new SqlParameter("@Sort", SqlDbType.Int,4), new SqlParameter("@Price", SqlDbType.Decimal,9), new SqlParameter("@Count_Product", SqlDbType.Int,4), new SqlParameter("@Count_product_change", SqlDbType.Int,4), new SqlParameter("@Years", SqlDbType.Int,4), new SqlParameter("@Content", SqlDbType.NText), new SqlParameter("@Commission", SqlDbType.Decimal,9), new SqlParameter("@CardOrder_id", SqlDbType.Int,4)}; parameters[0].Value = model.id; parameters[1].Value = model.Name; parameters[2].Value = model.Sort; parameters[3].Value = model.Price; parameters[4].Value = model.Count_Product; parameters[5].Value = model.Count_product_change; parameters[6].Value = model.Years; parameters[7].Value = model.Content; parameters[8].Value = model.Commission; parameters[9].Value = model.CardOrder_id; SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(),parameters); }
/// <summary> /// 编辑商品代理级别 /// </summary> public void ProductAgentLevel_Edit() { int id = RequestTool.RequestInt("id", 0); Lebi_Agent_Product_Level model = B_Lebi_Agent_Product_Level.GetModel(id); string User_UserName = RequestTool.RequestString("User_UserName"); if (model == null) { model = new Lebi_Agent_Product_Level(); } B_Lebi_Agent_Product_Level.BindForm(model); model.Years = 1; if (model.id == 0) { //if (!EX_Admin.Power("supplier_group_add", "添加商家分组")) //{ // AjaxNoPower(); // return; //} B_Lebi_Agent_Product_Level.Add(model); id = B_Lebi_Agent_Product_Level.GetMaxId(); Log.Add("添加商品代理级别", "Agent_ProductLevel", id.ToString(), CurrentAdmin); } else { //if (!EX_Admin.Power("supplier_group_edit", "编辑商家分组")) //{ // AjaxNoPower(); // return; //} B_Lebi_Agent_Product_Level.Update(model); Log.Add("编辑商品代理级别", "Agent_ProductLevel", id.ToString(), CurrentAdmin); } string result = "{\"msg\":\"OK\", \"id\":\"" + id + "\"}"; Response.Write(result); }
/// <summary> /// 余额购买其他内容 /// </summary> public void BuyOther() { int keyid = RequestTool.RequestInt("keyid"); string tablename = RequestTool.RequestSafeString("tablename"); decimal postmoney = RequestTool.RequestDecimal("money"); string paypwd = RequestTool.RequestSafeString("paypwd"); decimal money = 0; if (EX_User.MD5(paypwd) != CurrentUser.Pay_Password) { Response.Write("{\"msg\":\"" + Tag("支付密码错误") + "\"}"); return; } if (tablename == "Agent_Product_Level") { Lebi_Agent_Product_Level lev = B_Lebi_Agent_Product_Level.GetModel(keyid); if (lev == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } Lebi_Agent_Product_User user = B_Lebi_Agent_Product_User.GetModel("User_id=" + CurrentUser.id + ""); if (user == null) { //新购买的情况 money = lev.Price; if (money > CurrentUser.Money) { Response.Write("{\"msg\":\"" + Tag("余额不足") + "\"}"); return; } user = new Lebi_Agent_Product_User(); user.Agent_Product_Level_id = lev.id; user.Commission = lev.Commission; user.Count_Product = lev.Count_Product; user.Count_product_change = lev.Count_product_change; user.User_id = CurrentUser.id; user.User_UserName = CurrentUser.UserName; user.Time_end = System.DateTime.Now.AddYears(lev.Years); B_Lebi_Agent_Product_User.Add(user); } else { if (user.Agent_Product_Level_id == lev.id) { //续费的情况 money = lev.Price; if (money > CurrentUser.Money) { Response.Write("{\"msg\":\"" + Tag("余额不足") + "\"}"); return; } user.Time_end = user.Time_end.AddYears(lev.Years); B_Lebi_Agent_Product_User.Update(user); //更新代理商品的过期时间 } else { //升级的情况 Lebi_Agent_Product_Level userlev = B_Lebi_Agent_Product_Level.GetModel(user.Agent_Product_Level_id); if (userlev.Sort > lev.Sort) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } money = lev.Price - userlev.Price; if (money < 0) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } if (money > CurrentUser.Money) { Response.Write("{\"msg\":\"" + Tag("余额不足") + "\"}"); return; } user.Agent_Product_Level_id = lev.id; user.Commission = lev.Commission; user.Count_Product = lev.Count_Product; user.Count_product_change = lev.Count_product_change; B_Lebi_Agent_Product_User.Update(user); } } EX_User.GiveUserCard(CurrentUser, lev.CardOrder_id);//赠送代金券 Money.AddMoney(CurrentUser, 0 - money, 196, null, "", ""); } else if (tablename == "Agent_Area") { Lebi_Agent_Area area = B_Lebi_Agent_Area.GetModel(keyid); if (area == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } if (area.User_id > 0 && area.User_id != CurrentUser.id) { Response.Write("{\"msg\":\"" + Tag("不能代理此区域") + "\"}"); return; } money = area.Price; if (money > CurrentUser.Money) { Response.Write("{\"msg\":\"" + Tag("余额不足") + "\"}"); return; } if (area.User_id == 0) { //新购买的情况 area.User_id = CurrentUser.id; area.User_UserName = CurrentUser.UserName; area.Time_end = System.DateTime.Now.AddYears(1); area.IsFailure = 0; B_Lebi_Agent_Area.Update(area); } else { //续费的情况 area.Time_end = area.Time_end.AddYears(1); area.IsFailure = 0; B_Lebi_Agent_Area.Update(area); } EX_User.GiveUserCard(CurrentUser, area.CardOrder_id);//赠送代金券 Money.AddMoney(CurrentUser, 0 - money, 196, null, "", ""); } else if (tablename == "suppliermargin")//供应商保证金 { Lebi_Supplier supplier = B_Lebi_Supplier.GetModel("User_id=" + CurrentUser.id); if (supplier == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } //新购买的情况 money = supplier.Money_Margin - supplier.Money_Margin_pay; if (money > CurrentUser.Money) { Response.Write("{\"msg\":\"" + Tag("余额不足") + "\"}"); return; } supplier.Money_Margin_pay += money; B_Lebi_Supplier.Update(supplier); Money.AddMoney(CurrentUser, 0 - money, 197, null, "", ""); } else if (tablename == "suppliermargin")//供应商保证金 { Lebi_Supplier supplier = B_Lebi_Supplier.GetModel("User_id=" + CurrentUser.id); if (supplier == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } money = supplier.Money_Margin - supplier.Money_Margin_pay; if (money > CurrentUser.Money) { Response.Write("{\"msg\":\"" + Tag("余额不足") + "\"}"); return; } supplier.Money_Margin_pay += money; B_Lebi_Supplier.Update(supplier); Money.AddMoney(CurrentUser, 0 - money, 197, null, "", ""); } else if (tablename == "supplierservice")//供应商服务费 { Lebi_Supplier supplier = B_Lebi_Supplier.GetModel("User_id=" + CurrentUser.id); if (supplier == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } Lebi_Supplier_Group group = B_Lebi_Supplier_Group.GetModel("id=" + supplier.Supplier_Group_id); if (group == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } money = supplier.Money_Service; if (money > CurrentUser.Money) { Response.Write("{\"msg\":\"" + Tag("余额不足") + "\"}"); return; } supplier.Time_End = supplier.Time_End.AddDays(group.ServiceDays); B_Lebi_Supplier.Update(supplier); Money.AddMoney(CurrentUser, 0 - money, 198, null, "", ""); } Response.Write("{\"msg\":\"OK\"}"); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Agent_Product_Level model) { D_Lebi_Agent_Product_Level.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Agent_Product_Level model) { return(D_Lebi_Agent_Product_Level.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Agent_Product_Level SafeBindForm(Lebi_Agent_Product_Level model) { return(D_Lebi_Agent_Product_Level.Instance.SafeBindForm(model)); }