/// <summary> /// 请求代理一个商品 /// </summary> public void Product_Request() { int id = RequestTool.RequestInt("id"); int oldid = RequestTool.RequestInt("oldid"); Lebi_Agent_Product apro = B_Lebi_Agent_Product.GetModel(id); if (apro == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } if (apro.User_id > 0) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } Lebi_Agent_Product_User user = B_Lebi_Agent_Product_User.GetModel("User_id=" + CurrentUser.id + ""); if (user == null) { user = new Lebi_Agent_Product_User(); } if (user.Count_product_change - user.Count_product_change_used < 1) { //验证是否超过可用的修改次数 Response.Write("{\"msg\":\"" + Tag("无权修改") + "\"}"); return; } if (oldid == 0 && B_Lebi_Agent_Product.Counts("User_id=" + CurrentUser.id + "") >= user.Count_Product) { //验证是否超过代理商品的上限 Response.Write("{\"msg\":\"" + Tag("不能申请更多商品") + "\"}"); return; } Lebi_Agent_Product_request model = B_Lebi_Agent_Product_request.GetModel("User_id=" + CurrentUser.id + " and Product_id=" + apro.Product_id + " and Type_id_AgentProductRequestStatus=370"); if (model != null) { Response.Write("{\"msg\":\"" + Tag("不能重复申请") + "\"}"); return; } model = new Lebi_Agent_Product_request(); model.Product_id = apro.Product_id; model.Type_id_AgentProductRequestStatus = 370; model.User_id = CurrentUser.id; model.User_UserName = CurrentUser.UserName; model.Product_id_old = oldid; B_Lebi_Agent_Product_request.Add(model); Response.Write("{\"msg\":\"OK\"}"); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Agent_Product_request model) { D_Lebi_Agent_Product_request.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Agent_Product_request model) { return(D_Lebi_Agent_Product_request.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Agent_Product_request SafeBindForm(Lebi_Agent_Product_request model) { return(D_Lebi_Agent_Product_request.Instance.SafeBindForm(model)); }
/// <summary> /// 处理商品代理申请 /// </summary> public void ProductRequest_Manage() { int id = RequestTool.RequestInt("id"); int t = RequestTool.RequestInt("t"); Lebi_Agent_Product_request model = B_Lebi_Agent_Product_request.GetModel(id); if (model == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } Lebi_Agent_Product pro = B_Lebi_Agent_Product.GetModel("Product_id=" + model.Product_id); if (pro == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } Lebi_Agent_Product_User user = B_Lebi_Agent_Product_User.GetModel("User_id=" + model.User_id + ""); if (user == null) { Response.Write("{\"msg\":\"" + Tag("此用户无代理资格") + "\"}"); return; } if (pro.User_id > 0) { Response.Write("{\"msg\":\"" + Tag("其他用户已代理此商品") + "\"}"); return; } if (t == 1) { if (model.Product_id_old > 0)//替换商品的情况。修改旧数据 { Lebi_Agent_Product oldpro = B_Lebi_Agent_Product.GetModel("Product_id=" + model.Product_id_old + ""); if (oldpro != null) { if (oldpro.User_id != model.User_id) { Response.Write("{\"msg\":\"" + Tag("提换商品非此用户代理") + "\"}"); return; } oldpro.User_id = 0; oldpro.User_UserName = ""; B_Lebi_Agent_Product.Update(oldpro); } } model.Type_id_AgentProductRequestStatus = 371; pro.User_id = model.User_id; pro.User_UserName = model.User_UserName; //pro.Commission = user.Commission; B_Lebi_Agent_Product.Update(pro); } else { model.Type_id_AgentProductRequestStatus = 372; } model.Admin_id = CurrentAdmin.id; model.Admin_UserName = CurrentAdmin.UserName; B_Lebi_Agent_Product_request.Update(model); Log.Add("处理代理商品申请", "Agent_Product", id.ToString(), CurrentAdmin); Response.Write("{\"msg\":\"OK\"}"); }