public ActionResult GetAgentRelation(string ageId)
        {
            ListResult result = new ListResult();

            try
            {
                var list     = AgentRelationLogic.GetList().Where(f => f.c_parent_id == ageId).Select(f => f.c_child_id).ToList();
                var aList    = AgentLogic.GetList().Where(f => list.Contains(f.c_id)).ToList();
                var viewList = AgentHelper.getJsonListFromEntityList(aList);
                int firstGen = 1;
                foreach (var item in viewList)
                {
                    item.gender = "1 - " + firstGen.ToString();
                    firstGen++;
                }

                result.fistList = viewList;
                result.state    = ResultType.success.ToString();
                return(Content(result.ToJson()));
            }
            catch (Exception ex)
            {
                result.state   = ResultType.error.ToString();
                result.message = string.Format("提交失败({0})", ex.Message);
                return(Content(result.ToJson()));

                throw;
            }
        }
Exemplo n.º 2
0
        public ActionResult Register(string agentName, string username, string password, string recMobile, string savePath, string agentType)
        {
            LogEntity logEntity = new LogEntity();

            logEntity.F_ModuleName = "系统登录";
            logEntity.F_Type       = DbLogType.Login.ToString();
            try
            {
                int at = Convert.ToInt32(agentType);
                AgentLogic.CheckRegist(agentName, username, recMobile, password, savePath, at);
                return(Content(new AjaxResult {
                    state = ResultType.success.ToString(), message = "注册成功。"
                }.ToJson()));
            }
            catch (Exception ex)
            {
                logEntity.F_Account     = username;
                logEntity.F_NickName    = username;
                logEntity.F_Result      = false;
                logEntity.F_Description = "注册失败," + ex.Message;
                new LogApp().WriteDbLog(logEntity);
                return(Content(new AjaxResult {
                    state = ResultType.error.ToString(), message = ex.Message
                }.ToJson()));
            }
        }
Exemplo n.º 3
0
        private async void btnTim_Click(object sender, EventArgs e)
        {
            try
            {
                var obj = new
                {
                    id   = txtIDAgnt.Text == "" ? 0 : Convert.ToInt32(txtIDAgnt.Text),
                    name = txtNameAgent.Text
                };

                var data = await AgentLogic.FetchSearchAgent(obj);

                if (data != null && data.Count > 0)
                {
                    grd.DataSource = data;
                }
                else
                {
                    MessageBox.Show("Không tìm thấy thông tin !", "Thông báo");
                    grd.DataSource = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi tìm kiếm ! Có thể do nhập liệu không phù hợp.", "Thông báo");
                return;
            }
        }
Exemplo n.º 4
0
        public override ActionResult Index()
        {
            var lsit = AgentLogic.GetList();

            ViewBag.TotalCount = lsit.Count();
            ViewBag.TodayCount = lsit.Where(t => t.c_create_date >= DateTime.Now.Date).Count();
            return(View());
        }
Exemplo n.º 5
0
        private async void LoadAllAgents()
        {
            Agents = await AgentLogic.FetchAllAgent();

            var datatable = Agents.ToDataTable();

            gridAgent.AutoGenerateColumns = false;
            gridAgent.DataSource          = datatable;
        }
Exemplo n.º 6
0
        public ActionResult SubmitRevisePassword(string userPassword, string keyValue)
        {
            userLogOnApp.RevisePassword(userPassword, keyValue);
            Agent ag = AgentLogic.GetEnityById(keyValue);

            ag.c_login_pwd = userPassword;
            AgentLogic.UpdateEntity(ag);
            return(Success("重置密码成功。"));
        }
Exemplo n.º 7
0
        public ActionResult CheckLogin(string username, string password, string authCode)
        {
            LogEntity logEntity = new LogEntity();

            logEntity.F_ModuleName = "系统登录";
            logEntity.F_Type       = DbLogType.Login.ToString();
            try
            {
                if (Session["nfine_session_verifycode"].IsEmpty() || Md5.md5(authCode.ToLower(), 16) != Session["nfine_session_verifycode"].ToString())
                {
                    throw new Exception("验证码错误,请重新输入");
                }

                Agent user = AgentLogic.CheckLogin(username, password);
                //UserEntity userEntity = new UserApp().CheckLogin(model.Mobile, model.Password);
                if (user != null)
                {
                    OperatorModel operatorModel = new OperatorModel();
                    operatorModel.UserId   = user.c_id.ToString();
                    operatorModel.UserCode = user.c_mobile;
                    operatorModel.UserName = user.c_name;
                    //operatorModel.CompanyId = userEntity.F_OrganizeId;
                    //operatorModel.DepartmentId = userEntity.F_DepartmentId;
                    //operatorModel.RoleId = userEntity.F_RoleId;
                    operatorModel.LoginIPAddress     = Net.Ip;
                    operatorModel.LoginIPAddressName = Net.GetLocation(operatorModel.LoginIPAddress);
                    operatorModel.LoginTime          = DateTime.Now;
                    operatorModel.LoginToken         = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                    operatorModel.IsSystem           = false;

                    OperatorProvider.Provider.AddCurrent(operatorModel);
                    logEntity.F_Account     = user.c_mobile;
                    logEntity.F_NickName    = user.c_name;
                    logEntity.F_Result      = true;
                    logEntity.F_Description = "登录成功";
                    new LogApp().WriteDbLog(logEntity);
                }
                return(Content(new AjaxResult {
                    state = ResultType.success.ToString(), message = "登录成功。"
                }.ToJson()));
            }
            catch (Exception ex)
            {
                logEntity.F_Account     = username;
                logEntity.F_NickName    = username;
                logEntity.F_Result      = false;
                logEntity.F_Description = "登录失败," + ex.Message;
                new LogApp().WriteDbLog(logEntity);
                return(Content(new AjaxResult {
                    state = ResultType.error.ToString(), message = ex.Message
                }.ToJson()));
            }
        }
Exemplo n.º 8
0
        private async void btnSearch_Click(object sender, EventArgs e)
        {
            var searchCriteria = new AgentSearchCriteria()
            {
                Id       = txtId.Text,
                Name     = txtName.Text,
                Province = txtProvince.Text,
                District = txtDistrict.Text,
                IsActive = checkBox1.Checked
            };

            var agent = await AgentLogic.SearchAgent(searchCriteria);

            var tableSource = agent.ToDataTable();

            gridAgent.DataSource = tableSource;
        }
Exemplo n.º 9
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("审核成功。"));
        }
Exemplo n.º 10
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
        }
Exemplo n.º 11
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("审核成功。"));
        }
Exemplo n.º 12
0
        // GET: Product
        public ActionResult Index(CustRelationModel model)
        {
            var UserInfo = NFine.Code.OperatorProvider.Provider.GetCurrent();

            if (UserInfo == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            CustRelationModel viewModel = new CustRelationModel();

            if (base.agentInfo != null)
            {
                CommLogic.DeepClone <AgentInfoModel>(viewModel, agentInfo);
            }
            var totalArList = AgentRelationLogic.GetList();
            var agList      = AgentLogic.GetList();
            var list        = totalArList.Where(f => f.c_parent_id == UserInfo.UserId).Select(f => f.c_child_id).ToList();
            var aList       = agList.Where(f => list.Contains(f.c_id)).ToList();
            var viewList    = AgentHelper.getJsonListFromEntityList(aList);
            int firstGen    = 1;

            foreach (var item in viewList)
            {
                item.gender = "1 - " + firstGen.ToString();
                var sList      = totalArList.Where(t => t.c_parent_id == item.id).Select(f => f.c_child_id).ToList();
                var sAgentList = agList.Where(f => sList.Contains(f.c_id)).ToList();
                var sViewList  = AgentHelper.getJsonListFromEntityList(sAgentList);
                item.secondList = sViewList;
                int seconGen = 1;
                foreach (var second in item.secondList)
                {
                    second.gender = item.gender + " - " + seconGen.ToString();
                    seconGen++;
                }

                firstGen++;
            }
            viewModel.fistList = viewList;
            return(View(viewModel));
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            AgentDao agentDao = new AgentDao();

            AgentLogic agentLogic = new AgentLogic(agentDao);

            Agent agent1 = new Agent(111, "khdkfhsk", "8908789796");

            agentLogic.Add(agent1);

            foreach (var agent in agentLogic.GetAll())
            {
                Console.WriteLine(agent.IdAgent + " " + agent.Fio + " " + agent.PhoneNumber);
            }

            agentLogic.Delete(111);

            Console.WriteLine("_____________________________________________");

            foreach (var agent in agentLogic.GetAll())
            {
                Console.WriteLine(agent.IdAgent + " " + agent.Fio + " " + agent.PhoneNumber);
            }
        }
Exemplo n.º 14
0
        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));
                }
            }
        }