Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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\"}");
        }