예제 #1
0
 public void SaveForm(string keyValue, Sxc_UserPaymentEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, Sxc_UserPaymentEntity entity, List <Sxc_CommissionRecordEntity> entryList)
 {
     try
     {
         service.SaveForm(keyValue, entity, entryList);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #3
0
 public void SaveForm(string keyValue, Sxc_UserPaymentEntity entity)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         entity.Modify(keyValue);
         this.BaseRepository(DbName).Update(entity);
     }
     else
     {
         entity.Create();
         entity.PaySN       = CommonHelper.CreateTimeRandomNo();
         entity.DistrAmount = entity.Amount;
         this.BaseRepository(DbName).Insert(entity);
     }
 }
예제 #4
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, Sxc_UserPaymentEntity entity, List <Sxc_CommissionRecordEntity> entryList)
        {
            IRepository db = this.BaseRepository(DbName).BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    //主表
                    entity.Modify(keyValue);
                    db.Update(entity);
                    //明细
                    db.Delete <Sxc_CommissionRecordEntity>(t => t.ID.Equals(keyValue));
                    foreach (Sxc_CommissionRecordEntity item in entryList)
                    {
                        item.Create();
                        item.ID = entity.ID;
                        db.Insert(item);
                    }
                }
                else
                {
                    //主表
                    entity.Create();
                    db.Insert(entity);
                    //明细
                    foreach (Sxc_CommissionRecordEntity item in entryList)
                    {
                        item.Create();
                        item.ID = entity.ID;
                        db.Insert(item);
                    }
                }
                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
예제 #5
0
        public void DistrCommission(IRepository db, Sxc_UserPaymentEntity entity)
        {
            entity.State     = 1;
            entity.DistrTime = DateTime.Now;

            var agent = db.FindEntity <Sxc_AgentEntity>(t => t.ID == entity.UserID);

            //&& agent.IsValid.Value 不需要本身是有效代理
            if (agent.Type == 1)
            {
                if (agent.PID.HasValue)
                {
                    var agent1 = db.FindEntity <Sxc_AgentEntity>(t => t.ID == agent.PID);

                    var per1 = GetZxsPercent(agent1.Level);

                    var amount1 = entity.DistrAmount * per1;

                    entity.Commission += amount1;
                    agent1.Commission += amount1;

                    var record1 = new Sxc_CommissionRecordEntity
                    {
                        AgentID       = agent1.ID,
                        CreateTime    = DateTime.Now,
                        State         = 0,
                        UserPaymentID = entity.ID,
                        Commission    = amount1
                    };

                    db.Insert(record1);
                    db.Update(agent1);

                    if (agent1.PID.HasValue)
                    {
                        var agent2 = db.FindEntity <Sxc_AgentEntity>(t => t.ID == agent1.PID);

                        var per2 = GetZxsPercent(agent2.Level);

                        if (per2 > per1)
                        {
                            per2 = per2 - per1;
                        }
                        else
                        {
                            per2 = 0.05m;
                        }

                        var amount2 = entity.DistrAmount * per2;

                        entity.Commission += amount2;
                        agent2.Commission += amount2;

                        var record2 = new Sxc_CommissionRecordEntity
                        {
                            AgentID       = agent2.ID,
                            CreateTime    = DateTime.Now,
                            State         = 0,
                            UserPaymentID = entity.ID,
                            Commission    = amount2
                        };

                        db.Insert(record2);
                        db.Update(agent2);
                    }
                }
            }

            //&& agent.IsValid.Value
            if (agent.Type == 2)
            {
                if (agent.PID.HasValue)
                {
                    var agent1 = db.FindEntity <Sxc_AgentEntity>(t => t.ID == agent.PID);

                    //var amount1 = GetFzxsCommission(agent1.Level);
                    var amount1 = entity.DistrAmount * GetFzxsCommission(agent1.Level);

                    entity.Commission += amount1;
                    agent1.Commission += amount1;

                    var record1 = new Sxc_CommissionRecordEntity
                    {
                        AgentID       = agent1.ID,
                        CreateTime    = DateTime.Now,
                        State         = 0,
                        UserPaymentID = entity.ID,
                        Commission    = amount1
                    };

                    db.Insert(record1);
                    db.Update(agent1);

                    if (agent1.PID.HasValue)
                    {
                        var agent2 = db.FindEntity <Sxc_AgentEntity>(t => t.ID == agent1.PID);

                        //var amount2 = 1000;
                        var amount2 = entity.DistrAmount * 0.05m;

                        entity.Commission += amount2;
                        agent2.Commission += amount2;

                        var record2 = new Sxc_CommissionRecordEntity
                        {
                            AgentID       = agent2.ID,
                            CreateTime    = DateTime.Now,
                            State         = 0,
                            UserPaymentID = entity.ID,
                            Commission    = amount2
                        };

                        db.Insert(record2);
                        db.Update(agent2);

                        List <Sxc_AgentEntity> SupAgents = new List <Sxc_AgentEntity>();

                        GetSupAgents(db, agent2, SupAgents);

                        foreach (var sup in SupAgents)
                        {
                            //var amountsup = 1000;
                            var amountsup = entity.DistrAmount * 0.05m;

                            entity.Commission += amountsup;
                            sup.Commission    += amountsup;

                            var recordsup = new Sxc_CommissionRecordEntity
                            {
                                AgentID       = sup.ID,
                                CreateTime    = DateTime.Now,
                                State         = 0,
                                UserPaymentID = entity.ID,
                                Commission    = amountsup
                            };

                            db.Insert(recordsup);
                            db.Update(sup);
                        }
                    }
                }
            }
            //直属
            if (agent.Type == 3)
            {
                if (agent.PID.HasValue)
                {
                    var agent1 = db.FindEntity <Sxc_AgentEntity>(t => t.ID == agent.PID);

                    //公司直招
                    if (agent1.Level < 4)
                    {
                        var distrAmount = entity.DistrAmount * 0.3m;
                        var amount1     = distrAmount * GetFzxsCommission(agent1.Level);

                        entity.Commission += amount1;
                        agent1.Commission += amount1;

                        var record1 = new Sxc_CommissionRecordEntity
                        {
                            AgentID       = agent1.ID,
                            CreateTime    = DateTime.Now,
                            State         = 0,
                            UserPaymentID = entity.ID,
                            Commission    = amount1
                        };

                        db.Insert(record1);
                        db.Update(agent1);

                        List <Sxc_AgentEntity> SupAgents = new List <Sxc_AgentEntity>();
                        GetSupAgents(db, agent1, SupAgents);

                        foreach (var sup in SupAgents)
                        {
                            var amountsup = distrAmount * 0.15m;
                            entity.Commission += amountsup;
                            sup.Commission    += amountsup;

                            var recordsup = new Sxc_CommissionRecordEntity
                            {
                                AgentID       = sup.ID,
                                CreateTime    = DateTime.Now,
                                State         = 0,
                                UserPaymentID = entity.ID,
                                Commission    = amountsup
                            };

                            db.Insert(recordsup);
                            db.Update(sup);
                        }
                    }
                    //学员发展
                    //level=4
                    else
                    {
                        var amount1 = entity.DistrAmount * GetFzxsCommission(agent1.Level);

                        entity.Commission += amount1;
                        agent1.Commission += amount1;

                        var record1 = new Sxc_CommissionRecordEntity
                        {
                            AgentID       = agent1.ID,
                            CreateTime    = DateTime.Now,
                            State         = 0,
                            UserPaymentID = entity.ID,
                            Commission    = amount1
                        };

                        db.Insert(record1);
                        db.Update(agent1);

                        if (agent1.PID.HasValue)
                        {
                            var agent2 = db.FindEntity <Sxc_AgentEntity>(t => t.ID == agent1.PID);

                            var amount2 = entity.DistrAmount * 0.05m;

                            entity.Commission += amount2;
                            agent2.Commission += amount2;

                            var record2 = new Sxc_CommissionRecordEntity
                            {
                                AgentID       = agent2.ID,
                                CreateTime    = DateTime.Now,
                                State         = 0,
                                UserPaymentID = entity.ID,
                                Commission    = amount2
                            };

                            db.Insert(record2);
                            db.Update(agent2);
                        }
                    }
                }
            }

            entity.FinalAmount = entity.Amount - entity.Commission;
        }
 public ActionResult SavePayForm(string keyValue, Sxc_UserPaymentEntity entity)
 {
     sxc_userpaymentbll.SaveForm(keyValue, entity);
     return(Success("操作成功。"));
 }