Example #1
0
        /// <summary>
        /// 批量添加代理地区
        /// </summary>
        public void AreaAgent_MutiAdd()
        {
            int id                 = RequestTool.RequestInt("id", 0);
            int Area_id            = RequestTool.RequestInt("Area_id", 0);
            int PArea_id           = RequestTool.RequestInt("PArea_id", 0);
            List <Lebi_Area> areas = B_Lebi_Area.GetList("Parentid=" + PArea_id + "", "");
            Lebi_Agent_Area  model;

            foreach (Lebi_Area area in areas)
            {
                int count = B_Lebi_Agent_Area.Counts("Area_id=" + area.id + "");
                if (count > 0)
                {
                    continue;
                }
                model = new Lebi_Agent_Area();
                B_Lebi_Agent_Area.BindForm(model);
                model.Area_id = area.id;
                B_Lebi_Agent_Area.Add(model);
            }
            Log.Add("批量添加代理区域", "Agent_Area", id.ToString(), CurrentAdmin, "");
            string result = "{\"msg\":\"OK\", \"id\":\"" + id + "\"}";

            Response.Write(result);
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = RequestTool.RequestInt("id", 0);

            //if (id == 0)
            //{
            //    if (!EX_Admin.Power("supplier_group_edit", "添加商家分组"))
            //    {
            //        WindowNoPower();
            //    }
            //}
            //else
            //{
            //    if (!EX_Admin.Power("supplier_group_edit", "编辑商家分组"))
            //    {
            //        WindowNoPower();
            //    }
            //}
            model = B_Lebi_Agent_Area.GetModel(id);
            if (model == null)
            {
                model = new Lebi_Agent_Area();
            }
            cos = B_Lebi_CardOrder.GetList("Type_id_CardType=312", "");
        }
Example #3
0
        /// <summary>
        /// 编辑区域代理
        /// </summary>
        public void AreaAgent_Edit()
        {
            int id       = RequestTool.RequestInt("id", 0);
            int Area_id  = RequestTool.RequestInt("Area_id", 0);
            int PArea_id = RequestTool.RequestInt("PArea_id", 0);

            if (Area_id == 0)
            {
                Area_id = PArea_id;
            }
            Lebi_Agent_Area model = B_Lebi_Agent_Area.GetModel(id);
            int             count = B_Lebi_Agent_Area.Counts("Area_id=" + Area_id + " and id!=" + id + "");

            if (count > 0)
            {
                Response.Write("{\"msg\":\"" + Tag("不能选择此区域") + "\"}");
                return;
            }
            if (model == null)
            {
                model = new Lebi_Agent_Area();
            }
            B_Lebi_Agent_Area.BindForm(model);
            model.Area_id = Area_id;
            if (model.id == 0)
            {
                //if (!EX_Admin.Power("supplier_group_add", "添加商家分组"))
                //{
                //    AjaxNoPower();
                //    return;
                //}
                B_Lebi_Agent_Area.Add(model);
                id = B_Lebi_Agent_Area.GetMaxId();
                Log.Add("添加代理区域", "Agent_Area", id.ToString(), CurrentAdmin, model.User_UserName + "[" + model.Area_id + "]");
            }
            else
            {
                //if (!EX_Admin.Power("supplier_group_edit", "编辑商家分组"))
                //{
                //    AjaxNoPower();
                //    return;
                //}
                B_Lebi_Agent_Area.Update(model);
                Log.Add("编辑代理区域", "Agent_Area", id.ToString(), CurrentAdmin, model.User_UserName + "[" + model.Area_id + "]");
            }
            string result = "{\"msg\":\"OK\", \"id\":\"" + id + "\"}";

            Response.Write(result);
        }
Example #4
0
        /// <summary>
        /// 查询对于的代理资格设置
        /// </summary>
        /// <param name="areaid"></param>
        /// <returns></returns>
        private Lebi_Agent_Area GetAgentArea(int areaid)
        {
            Lebi_Agent_Area agentarea = B_Lebi_Agent_Area.GetModel("Area_id=" + areaid + " and IsFailure=0");

            if (agentarea != null)
            {
                return(agentarea);
            }
            else
            {
                Lebi_Area area = B_Lebi_Area.GetModel(areaid);
                if (area != null)
                {
                    return(GetAgentArea(area.Parentid));
                }
            }
            return(null);
        }
Example #5
0
        /// <summary>
        /// 编辑区域代理-代理人
        /// </summary>
        public void AreaAgentUser_Edit()
        {
            int             id    = RequestTool.RequestInt("id", 0);
            Lebi_Agent_Area model = B_Lebi_Agent_Area.GetModel(id);

            if (model == null)
            {
                Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}");
                return;
            }
            string User_UserName = RequestTool.RequestString("User_UserName");

            if (User_UserName == "")
            {
                Response.Write("{\"msg\":\"" + Tag("用户名不能空") + "\"}");
                return;
            }
            Lebi_User user = B_Lebi_User.GetModel("UserName=lbsql{'" + User_UserName + "'}");

            if (user == null)
            {
                Response.Write("{\"msg\":\"" + Tag("用户不存在") + "\"}");
                return;
            }

            if (model.Time_end > System.DateTime.Now.Date && model.User_id != user.id)
            {
                Response.Write("{\"msg\":\"" + Tag("其他代理还未到期") + "\"}");
                return;
            }
            if (model == null)
            {
                model = new Lebi_Agent_Area();
            }
            B_Lebi_Agent_Area.BindForm(model);
            model.User_id = user.id;
            B_Lebi_Agent_Area.Update(model);
            Log.Add("绑定区域代理", "Agent_Area", id.ToString(), CurrentAdmin, model.User_UserName + "[" + model.Area_id + "]");
            string result = "{\"msg\":\"OK\", \"id\":\"" + id + "\"}";

            Response.Write(result);
        }
Example #6
0
        /// <summary>
        /// 处理地区代理佣金
        /// </summary>
        private void AgentAreaMoney()
        {
            if (Order.T_Area_id > 0)
            {
                Lebi_Agent_Area agentarea = GetAgentArea(Order.T_Area_id);
                if (agentarea != null)
                {
                    if (agentarea.Time_end.Date > System.DateTime.Now.Date)
                    {
                        Lebi_User user = B_Lebi_User.GetModel(agentarea.User_id);
                        if (user != null)
                        {
                            //按籍贯的佣金
                            decimal yongjin = agentarea.Commission_1;
                            decimal money   = Order.Money_Product * yongjin / 100;
                            AddMoney(money, user, 393, agentarea.Area_id, 0, 0);
                        }
                    }
                }
            }

            if (OrderUser.Area_id > 0)
            {
                Lebi_Agent_Area agentarea = GetAgentArea(OrderUser.Area_id);
                if (agentarea != null)
                {
                    if (agentarea.Time_end.Date > System.DateTime.Now.Date)
                    {
                        Lebi_User user = B_Lebi_User.GetModel(agentarea.User_id);
                        if (user != null)
                        {
                            //按籍贯的佣金
                            decimal yongjin = agentarea.Commission_2;
                            decimal money   = Order.Money_Product * yongjin / 100;
                            AddMoney(money, user, 394, agentarea.Area_id, 0, 0);
                        }
                    }
                }
            }
        }
Example #7
0
        /// <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\"}");
        }
Example #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Agent_Area model)
 {
     D_Lebi_Agent_Area.Instance.Update(model);
 }
Example #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Agent_Area model)
 {
     return(D_Lebi_Agent_Area.Instance.Add(model));
 }
Example #10
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Agent_Area SafeBindForm(Lebi_Agent_Area model)
 {
     return(D_Lebi_Agent_Area.Instance.SafeBindForm(model));
 }