Beispiel #1
0
        public static int GetDT()
        {
            int DT_id = Shop.Tools.RequestTool.RequestInt("dt", 0);

            if (DT_id == 0)
            {
                var    nv       = Shop.Tools.CookieTool.GetCookie("URLPara");
                string dt_id_   = nv.Get("dt");
                int    outdt_id = 0;
                int.TryParse(dt_id_, out outdt_id);
                DT_id = Convert.ToInt16(dt_id_);
                if (DT_id > 0)
                {
                    return(DT_id);
                }
            }
            if (DT_id == 0)
            {
                string  domain    = Shop.Tools.RequestTool.GetRequestDomain();
                Lebi_DT CurrentDT = B_Lebi_DT.GetModel("Domain = lbsql{'" + domain + "'} and Domain != ''");
                if (CurrentDT != null)
                {
                    return(CurrentDT.id);
                }
            }
            return(DT_id);
        }
Beispiel #2
0
 /// <summary>
 /// 站点名称
 /// </summary>
 /// <param name="siteid"></param>
 /// <returns></returns>
 public string SiteName(int siteid, int DT_id, string LanuageCode)
 {
     if (DT_id == 0)
     {
         Lebi_Site model = B_Lebi_Site.GetModel(siteid);
         if (model == null)
         {
             model = ShopCache.GetMainSite();
         }
         return(model.SubName);
     }
     else
     {
         Lebi_DT model = B_Lebi_DT.GetModel(DT_id);
         if (model == null)
         {
             model = new Lebi_DT();
         }
         return(Shop.Bussiness.Language.Content(model.Site_Name, LanuageCode));
     }
 }
Beispiel #3
0
        /// <summary>
        /// 推广佣金
        /// </summary>
        private void AgentMoney()
        {
            //SystemLog.Add("计算佣金orderid" + Order.id + "userid" + OrderUser.User_id_parent);
            SystemLog.Add("推广佣金-开始");
            if (OrderUser.User_id_parent == 0)
            {
                return;
            }
            //string Money_Product_Profit_ = Common.GetValue("select sum((Price - Price_Cost)*(Count-Count_Return)) from Lebi_Order_Product where Order_id = " + Order.id + "");
            string  Money_Product_Profit_ = Common.GetValue("select sum((Price - Price_Cost)*Count) from Lebi_Order_Product where Order_id = " + Order.id + "");
            decimal Money_Product_Profit  = 0;

            decimal.TryParse(Money_Product_Profit_, out Money_Product_Profit);
            if (Order.Type_id_OrderType == 212)
            {
                Money_Product_Profit = 0 - Money_Product_Profit;//zhangshijia  退货时产生负数佣金
            }
            //处理一级代理
            Lebi_User user1 = B_Lebi_User.GetModel(OrderUser.User_id_parent);

            if (user1 == null)
            {
                return;
            }
            decimal       yongjin1        = 0; //1级佣金比例
            decimal       yongjin2        = 0; //2级佣金比例
            decimal       yongjin3        = 0; //3级佣金比例
            Lebi_DT_Agent dt_agent        = B_Lebi_DT_Agent.GetModel(0);
            Lebi_User     DT_User         = new Lebi_User();
            Lebi_DT       dt              = new Lebi_DT();
            int           CommissionLevel = 3;

            if (Order.Supplier_id > 0)
            {
                Lebi_Supplier supplier = B_Lebi_Supplier.GetModel(Order.Supplier_id);
                if (supplier.IsSpread == 0)  //商家未开启
                {
                    SystemLog.Add("推广佣金-商家未开启");
                    return;
                }
            }
            if (Order.DT_id > 0)
            {
                Money_Product_Profit = Order.DT_Money;  //如果是分销商,利润为分销商佣金
                dt_agent             = B_Lebi_DT_Agent.GetModel("DT_id=" + Order.DT_id + "");
                dt = B_Lebi_DT.GetModel(Order.DT_id);
                if (dt != null)
                {
                    CommissionLevel = dt.CommissionLevel;
                }
                DT_User = B_Lebi_User.GetModel(dt.User_id);
                if (dt_agent.IsUsedAgent == 0)  //分销商未开启
                {
                    SystemLog.Add("推广佣金-分销商未开启");
                    return;
                }
                //  Money_Product_Profit = Order.DT_Money; ///zhangshijia注释,未找到DT_Money来源
                //List<Lebi_Order_Product> order_pro = B_Lebi_Order_Product.GetModel(" Order_id = " + Order.id + "");
                //foreach (Lebi_Order_Product op in order_pro)
                //{

                //}
            }
            yongjin1 = GetAngentCommission1(dt_agent, user1);
            decimal money = Money_Product_Profit * yongjin1 / 100;

            if (Order.DT_id > 0)
            {
                if (DT_User.Money < money)
                {
                    SystemLog.Add("推广佣金-分销商[" + DT_User.NickName + "-" + DT_User.id + "]金额不足,一级佣金生成失败");
                    return;
                }
            }
            AddMoney(money, user1, 391, 0, 0, 0);
            //SystemLog.Add("计算佣金" + user1.UserName + money.ToString());
            if (Order.DT_id > 0)
            {
                AddMoney(0 - money, DT_User, 391, 0, 0, 0);
            }
            //处理2级代理
            Lebi_User user2 = B_Lebi_User.GetModel(user1.User_id_parent);

            if (user2 == null)
            {
                user2 = new Lebi_User();
            }
            else
            {
                if (CommissionLevel >= 2)
                {
                    yongjin2 = GetAngentCommission2(dt_agent, user2);
                    money    = Money_Product_Profit * yongjin2 / 100;
                    if (Order.DT_id > 0)
                    {
                        if (DT_User.Money < money)
                        {
                            SystemLog.Add("推广佣金-分销商金额不足,二级佣金生成失败");
                            return;
                        }
                    }
                    AddMoney(money, user2, 391, 0, 0, 0);
                    if (Order.DT_id > 0)
                    {
                        AddMoney(0 - money, DT_User, 391, 0, 0, 0);
                    }
                }
            }
            //处理3级代理
            if (CommissionLevel == 2)
            {
                return;
            }
            Lebi_User user3 = B_Lebi_User.GetModel(user2.User_id_parent);

            if (user3 != null)
            {
                yongjin3 = GetAngentCommission3(dt_agent, user3);
                money    = Money_Product_Profit * yongjin3 / 100;
                if (Order.DT_id > 0)
                {
                    if (DT_User.Money < money)
                    {
                        SystemLog.Add("推广佣金-分销商金额不足,三级佣金生成失败");
                        return;
                    }
                }
                AddMoney(money, user3, 391, 0, 0, 0);
                if (Order.DT_id > 0)
                {
                    AddMoney(0 - money, DT_User, 391, 0, 0, 0);
                }
            }
            ////处理条件佣金,佣金历史达到X时,可获得下线,下下线Y%的佣金
            //decimal Angent_Commission_require = 0;
            //decimal.TryParse(bc.Angent_Commission_require, out Angent_Commission_require);
            //decimal yongjin3 = 0;//条件佣金比例
            //decimal.TryParse(bc.Angent_Commission, out yongjin3);
            //money = Money_Product_Profit * yongjin3 / 100;
            //if (user1.AgentMoney_history > Angent_Commission_require)
            //    AddMoney(money, user1, 395, 0, 0, 0);
            //if (user2.AgentMoney_history > Angent_Commission_require)
            //    AddMoney(money, user2, 395, 0, 0, 0);
        }