public static void DeleteEntity(string AgentRelationId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         AgentRelation DelAgentRelation = context.t_agent_relation.Find(AgentRelationId);
         context.t_agent_relation.Remove(DelAgentRelation);
         context.SaveChanges();
     }
 }
 public static void InsertNewEntiy(AgentRelation NewAgentRelation)
 {
     using (DistributionContext context = new DistributionContext())
     {
         NewAgentRelation.c_id = Guid.NewGuid().ToString();
         context.t_agent_relation.Add(NewAgentRelation);
         context.SaveChanges();
     }
 }
 public static void UpdateEntity(AgentRelation UpdateAgentRelation)
 {
     using (DistributionContext context = new DistributionContext())
     {
         AgentRelation ag = context.t_agent_relation.Find(UpdateAgentRelation.c_id);
         CommLogic.DeepClone <AgentRelation>(ag, UpdateAgentRelation);
         context.SaveChanges();
     }
 }
Exemple #4
0
        public ActionResult CheckApply(string keyValue)
        {
            ExpApplyEntity entity = entityApp.GetForm(keyValue);

            AgentApp    agApp = new AgentApp();
            AgentEntity ag    = agApp.GetForm(entity.c_agent_id);

            //更新申请表
            entity.c_apply_state = 1;
            entityApp.SubmitForm(entity, keyValue);

            //更新代理商表

            ag.c_agnet_type = (int)AgentType.Fran;
            agApp.SubmitForm(ag, null, ag.F_Id);

            #region 推荐奖励
            //积分奖励
            ScoreLogic.DealRewardScore(ag.F_Id, RewartType.Recommend);

            Agent ag2 = AgentLogic.GetEnityById(entity.c_agent_id);
            #endregion

            //扣减积分
            int score = Convert.ToInt32(CommConfigLogic.GetValueFromConfig((int)ConfigCategory.ScoreConfigCate, (int)RewardConfigKey.expLevelUpScore));
            ScoreDetailLogic.UpdateAgentScore(entity.c_agent_id, -score, "体验店升级扣除");

            //升级
            AgentRelation ar        = AgentRelationLogic.FindEntity(t => t.c_child_id == ag.F_Id);
            Agent         recomm_ag = AgentLogic.GetEnityById(ar.c_parent_id);
            LevelLogic.IsLevelUpWithCondition(recomm_ag);

            #region 生成代理商订单
            Order order = new Order();
            order.c_agent_id   = ag.F_Id;
            order.c_mobile     = ag.c_mobile;
            order.c_state      = (int)OrderState.NoDeliver;
            order.c_remark     = "代理商订单";
            order.c_order_num  = DateTime.Now.ToString("yyyyMMddHHmmss-") + Guid.NewGuid().ToString().Substring(0, 6);
            order.c_order_type = (int)OrderType.Agent;
            OrderLogic.InsertNewEntiy(order);
            #endregion


            return(Success("审核成功。"));
        }
Exemple #5
0
        public void TestRewardAndLevelUp()
        {
            #region 推荐奖励

            //被推荐人
            Agent ag = AgentLogic.GetEnityById("b21c7112-f859-4915-bfdf-3d92b17fea0e");

            //积分奖励
            //ScoreLogic.DealRewardScore(ag.c_id, RewartType.Recommend);
            //ScoreLogic.DealProvinceReward(ag);


            //升级
            AgentRelation ar        = AgentRelationLogic.FindEntity(t => t.c_child_id == ag.c_id);
            Agent         recomm_ag = AgentLogic.GetEnityById(ar.c_parent_id);
            LevelLogic.IsLevelUpWithCondition(recomm_ag);
            #endregion
        }
Exemple #6
0
        public ActionResult EnabledAccount(string keyValue)
        {
            bool        hadReward  = agentApp.hadReward(keyValue);
            AgentEntity userEntity = new AgentEntity();

            userEntity.F_Id         = keyValue;
            userEntity.c_state      = 1;//0:未审核   1:审核通过
            userEntity.c_had_reward = true;
            agentApp.UpdateForm(userEntity);

            Agent ag = AgentLogic.GetEnityById(keyValue);

            //升级
            AgentRelation ar        = AgentRelationLogic.FindEntity(t => t.c_child_id == ag.c_id);
            Agent         recomm_ag = AgentLogic.GetEnityById(ar.c_parent_id);

            LevelLogic.IsLevelUpWithCondition(recomm_ag);
            if (!hadReward)
            {
                #region 推荐奖励
                //积分奖励
                ScoreLogic.DealRewardScore(ag.c_id, RewartType.Recommend);

                #endregion

                if (ag.c_agnet_type != (int)AgentType.Exp)//体验店计算上下级奖励即可
                {
                    #region 生成代理商订单
                    Order order = new Order();
                    order.c_agent_id   = ag.c_id;
                    order.c_mobile     = ag.c_mobile;
                    order.c_state      = (int)OrderState.NoDeliver;
                    order.c_remark     = "代理商订单";
                    order.c_order_num  = DateTime.Now.ToString("yyyyMMddHHmmss-") + Guid.NewGuid().ToString().Substring(0, 6);
                    order.c_order_type = (int)OrderType.Agent;
                    OrderLogic.InsertNewEntiy(order);
                    #endregion
                }
            }


            return(Success("审核成功。"));
        }
        public static bool CheckRegist(string reg_Name, string reg_Mobile, string reco_Mobile, string pwd, string voucherPath, int agentType)
        {
            bool  result = true;
            Agent rec_ag = FindEntity(t => t.c_mobile == reco_Mobile);

            if (rec_ag == null)
            {
                throw new Exception("未找到推荐人,请输入正确的推荐人手机号码");
            }
            Agent reg_ag = FindEntity(t => t.c_mobile == reg_Mobile);

            if (reg_ag != null)
            {
                throw new Exception("该手机已被注册,请输入正确的手机号码或联系管理员");
            }
            reg_ag                = new Agent();
            reg_ag.c_name         = reg_Name;
            reg_ag.c_mobile       = reg_Mobile;
            reg_ag.c_login_pwd    = pwd;
            reg_ag.c_levle        = 1;
            reg_ag.c_state        = 0;
            reg_ag.c_create_date  = DateTime.Now;
            reg_ag.c_score        = 0;
            reg_ag.c_agent_level  = 1;
            reg_ag.c_voucher_path = voucherPath;
            reg_ag.c_agnet_type   = agentType;
            if (agentType == (int)AgentType.Exp)
            {
                reg_ag.c_exp_state = 0;
            }
            InsertNewEntiy(reg_ag);

            AgentRelation ar = new AgentRelation();

            ar.c_parent_id   = rec_ag.c_id;
            ar.c_child_id    = reg_ag.c_id;
            ar.c_create_date = DateTime.Now;
            AgentRelationLogic.InsertNewEntiy(ar);
            return(result);
        }
        public BasicController()
        {
            var UserInfo = NFine.Code.OperatorProvider.Provider.GetCurrent();

            ViewBag.UserId = "";
            ViewBag.User   = "";
            if (agentInfo == null)
            {
                agentInfo = new AgentInfoModel();
                if (UserInfo != null)
                {
                    ViewBag.UserId = UserInfo.UserId;
                    ViewBag.User   = UserInfo.UserCode;
                    Agent ag = AgentLogic.GetEnityById(UserInfo.UserId);
                    if (ag == null)
                    {
                        return;
                    }
                    agentInfo.agent = ag;
                    AgentRelation ar = AgentRelationLogic.FindEntity(t => t.c_child_id == ag.c_id);
                    if (ag.c_levle != null)
                    {
                        agentInfo.Level = CommConfigLogic.GetValueFromConfig(1, ag.c_levle);
                    }
                    if (ag.c_agent_level != null)
                    {
                        agentInfo.AgLevel = CommConfigLogic.GetValueFromConfig(2, ag.c_agent_level);
                    }
                    if (ar != null)
                    {
                        agentInfo.RecomAgentName = AgentLogic.GetEnityById(ar.c_parent_id).c_name;
                    }
                    int totalScore = ScoreDetailLogic.GetTotalScore(ag.c_id);
                    int fisrtCount = 0, secondCount = 0, otherCount = 0, expCount = 0;
                    var readSessionAgent = OperatorProvider.Provider.GetAgentInfo(agentInfo.agent.c_id);
                    if (readSessionAgent != null)
                    {
                        fisrtCount  = readSessionAgent.FirstCount;
                        secondCount = readSessionAgent.SecondCount;
                        otherCount  = readSessionAgent.DeptCount;
                        expCount    = readSessionAgent.ExpCount;
                    }
                    else
                    {
                        fisrtCount = AgentRelationLogic.GetFirstCount(ag.c_id, out secondCount, out otherCount, out expCount);
                        AgentInfo sInfo = new AgentInfo();
                        sInfo.AgeId       = agentInfo.agent.c_id;
                        sInfo.FirstCount  = fisrtCount;
                        sInfo.SecondCount = secondCount;
                        sInfo.DeptCount   = otherCount;
                        sInfo.ExpCount    = expCount;
                        OperatorProvider.Provider.AddCurrentAgentInfo(sInfo, agentInfo.agent.c_id);
                    }
                    agentInfo.FirstCount  = fisrtCount;
                    agentInfo.SecondCount = secondCount;
                    agentInfo.OtherCount  = otherCount;
                    agentInfo.ExpCount    = expCount;
                    agentInfo.TotalScore  = totalScore.ToString();
                    int dealingScore = ScoreCashLogic.GetTotalCashScoreByState(ag.c_id, CashScoreState.Dealing);
                    agentInfo.CanCashScore    = ((int)agentInfo.agent.c_score - dealingScore);
                    agentInfo.expLevelUpScore = Convert.ToInt32(CommConfigLogic.GetValueFromConfig((int)ConfigCategory.ScoreConfigCate, (int)RewardConfigKey.expLevelUpScore));;
                    agentInfo.prodStartAmount = Convert.ToInt32(CommConfigLogic.GetValueFromConfig((int)ConfigCategory.ScoreConfigCate, (int)RewardConfigKey.productAmount));
                }
            }
        }