Example #1
0
 public FunongBaoDTO(Funongbao funongbao)
 {
     this.Id         = funongbao.Id;
     this.CreateDate = funongbao.CreateDate;
     //this.MpUserId = funongbao.MpUserId;
     //this.OpenId = funongbao.OpenId;
     //this.PassportNO = funongbao.PassportNO;
     //this.Name = funongbao.Name;
     //this.MobilePhone = funongbao.MobilePhone;
     //this.FunongbaoNO = funongbao.FunongbaoNO;
     //this.BankNO = funongbao.BankNO;
     //this.CurrentLimit = funongbao.CurrentLimit;
     //this.CurrentRates = funongbao.CurrentRates;
     //this.ApplyLimit = funongbao.ApplyLimit;
     //this.ApplyRates = funongbao.ApplyRates;
     //this.ChangedLimit = funongbao.ChangedLimit;
     //this.ChangedRates = funongbao.ChangedRates;
     //this.GroupNO = funongbao.GroupNO;
     //this.IsAuth = funongbao.IsAuth;
     //this.IsSignAgreement = funongbao.IsSignAgreement;
     //this.ProcessStatus = funongbao.ProcessStatus;
     //this.ProcessResult = funongbao.ProcessResult;
     //this.FinishDate = funongbao.FinishDate;
     //this.Subbranch = funongbao.Subbranch;
     //this.Marketer = funongbao.Marketer;
     //this.ChangeType = funongbao.ChangeType;
     //this.SuggestionLimit = funongbao.SuggestionLimit;
 }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            try
            {
                if (!string.IsNullOrEmpty(this.OpenID))
                {
                    CurrentFunongbao = _funongbaoService.GetFunongbaoByOpenid(this.OpenID);
                    Log4NetImpl.Write("CurrentFunongbao:");
                    if (CurrentFunongbao == null || CurrentFunongbao.IsAuth == 0)
                    {
                        filterContext.Result = new RedirectResult("/IdentAuth/Index?refUrl=" + this.Request.Url);
                    }
                    else
                    {
                        Log4NetImpl.Write("ViewBag.UserName:"******"MpUser:"******"先生" : "女士");
                            }
                            Log4NetImpl.Write("MpUser: end");
                        }
                        Log4NetImpl.Write("CurrentFunongbao:");
                    }
                }
            }
            catch (Exception ex) {
                Log4NetImpl.Write(ex.ToString());
                throw new OceanException(ex.Message);
            }
        }
Example #3
0
        private ActionResult ApplyRule(FunongbaoApply apply, decimal applyLimit, decimal applyRates)
        {
            apply.ApplyDate   = DateTime.Now;
            apply.ApplyLimit  = applyLimit;
            apply.ApplyRates  = applyRates;
            apply.ApplyStatus = 0;//默认为不能进行审批
            IList <Funongbao> funongbaoGroup = _funongbaoService.GetGroupByNo(CurrentFunongbao.GroupNO);

            Guid[] funongbaoIds = funongbaoGroup.Select(f => f.Id).ToArray();
            IList <FunongbaoApply> funongbaoApplyGroup = _funongbaoApplyService.GetByFunongbaoIds(funongbaoIds);
            //计算出当前组的总额度:--?此处疑问需再提问一次[1.如果原本有申请了50万,总额度]?
            decimal GropuLimitCount = funongbaoGroup.Sum(f => f.CurrentLimit);



            #region 升级额度情况
            if (applyLimit >= GropuLimitCount)
            {
                //if ((applyLimit > LimitRule.SingleLimitMax && funongbaoApplyGroup.Count <= 1) || (applyLimit > LimitRule.SingleLimitMax * 2 && funongbaoApplyGroup.Count <= 2))
                //{
                //    throw new OceanException("尊敬的"+this.Name+this.Sex+",您好!您申请的额度已经超过组的最大额度,请联系客户经理再开一张卡。");
                //}
                //else
                //{
                //获取满足条件的申请
                IList <FunongbaoApply> replationApplys = funongbaoApplyGroup.Where(f => f.ApplyLimit == apply.ApplyLimit && f.FunongbaoId != apply.FunongbaoId).ToList();
                //申请与现有的差值<当前申请卡的剩余额度-只需要当前申请-
                if (applyLimit - GropuLimitCount <= LimitRule.SingleLimitMax - CurrentFunongbao.CurrentLimit)
                {
                    apply.ChangedLimit = CurrentFunongbao.CurrentLimit + (applyLimit - GropuLimitCount);
                    apply.ChangedRates = apply.ApplyRates;
                    apply.ApplyStatus  = 1;
                    //_funongbaoApplyService.Update(apply);
                    _funongbaoApplyService.UpdateApllysNew(new FunongbaoApply[] { apply }, funongbaoApplyGroup.Where(fg => fg.Id != apply.Id));
                }
                //申请与现有的差值>当前申请卡的剩余额度-需要至少两张卡同时申请
                else
                {
                    //必须属性家庭组和申请必须大于1个
                    if (funongbaoGroup.Count > 1 && funongbaoApplyGroup.Count > 0 && replationApplys != null && replationApplys.Count() > 0)
                    {
                        //计算第二张卡的额度-最小值的那张
                        FunongbaoApply replationApply = replationApplys.Where(fa => funongbaoGroup.OrderBy(f => f.CurrentLimit).Where(f => fa.FunongbaoId == f.Id).Count() > 0).First();
                        Funongbao      replationFnb   = funongbaoGroup.Where(f => f.Id == replationApply.FunongbaoId).First();
                        //当前卡
                        decimal ChangeLimit = replationFnb.CurrentLimit + (applyLimit - GropuLimitCount - (LimitRule.SingleLimitMax - CurrentFunongbao.CurrentLimit));
                        apply.ChangedLimit = ChangeLimit > LimitRule.SingleLimitMax ? LimitRule.SingleLimitMax : ChangeLimit;
                        apply.ChangedRates = apply.ApplyRates;

                        if (ChangeLimit > LimitRule.SingleLimitMax)    //判断是否大最大限额
                        {
                            //需要三张卡同时申请
                            if (funongbaoGroup.Count > 2 && funongbaoApplyGroup.Count > 1 && replationApplys.Count() > 1)
                            {
                                //当前卡
                                apply.ChangedLimit = (applyLimit - LimitRule.SingleLimitMax * 2);
                                apply.ChangedRates = apply.ApplyRates;
                                apply.ApplyStatus  = 1;
                                //第二张卡
                                replationApply.ApplyStatus = 1;
                                //第三张卡|第三个申请
                                FunongbaoApply replationApply1 = replationApplys.Where(fa => funongbaoGroup.OrderBy(f => f.CurrentLimit).Where(f => fa.FunongbaoId == f.Id && fa.FunongbaoId != replationApply.FunongbaoId).Count() > 0).First();
                                Funongbao      replationFnb1   = funongbaoGroup.Where(f => f.Id == replationApply1.FunongbaoId).First();
                                replationApply1.ApplyStatus = 1;
                                //放入更新事务:
                                _funongbaoApplyService.UpdateApllysNew(new FunongbaoApply[] { apply, replationApply, replationApply1 }, null);
                            }
                            else
                            {
                                if (funongbaoApplyGroup.Count > 1)
                                {
                                    //判断有几个需的提醒的福农宝名称
                                    ViewBag.RelationNames = GetNoticeApplyNames(funongbaoGroup, apply, funongbaoApplyGroup);
                                    _funongbaoApplyService.Update(apply);
                                    ViewBag.ApplyStatus = 2;
                                    return(View("ApplyPost", apply));
                                }
                                else if (funongbaoApplyGroup.Count > 0)
                                {
                                    //判断有几个需的提醒的福农宝名称
                                    _funongbaoApplyService.Update(apply);
                                    ViewBag.RelationNames = GetNoticeApplyNames(funongbaoGroup, apply, funongbaoIds);
                                    if (ViewBag.RelationNames == "-1")
                                    {
                                        ViewBag.ApplyStatus = -1;
                                    }
                                    else
                                    {
                                        ViewBag.ApplyStatus = 2;
                                    }
                                    return(View("ApplyPost", apply));
                                }
                                else
                                {
                                    apply.ChangedLimit = LimitRule.SingleLimitMax;
                                    apply.ChangedRates = applyRates;
                                    _funongbaoApplyService.Update(apply);
                                    ViewBag.ApplyStatus = -1;
                                    return(View("ApplyPost", apply));
                                    //异常
                                    //throw new OceanException("尊敬的" + this.Name + this.Sex + ",您好!您申请的额度已经超过组的最大额度,请联系客户经理再开一张卡。");
                                }
                            }
                        }
                        else
                        {
                            //当前卡
                            apply.ApplyStatus = 1;
                            //第二张卡
                            replationApply.ApplyStatus = 1;
                            //放入更新事务:
                            _funongbaoApplyService.UpdateApllysNew(new FunongbaoApply[] { apply, replationApply }, funongbaoApplyGroup.Where(fg => fg.Id != apply.Id && fg.Id != replationApply.Id));
                        }
                    }
                    else
                    {
                        if (funongbaoApplyGroup.Count > 1)
                        {
                            //判断有几个需的提醒的福农宝名称
                            apply.ChangedLimit = LimitRule.SingleLimitMax;
                            apply.ChangedRates = applyRates;
                            _funongbaoApplyService.Update(apply);
                            ViewBag.RelationNames = GetNoticeApplyNames(funongbaoGroup, apply, funongbaoIds);
                            if (ViewBag.RelationNames == "-1")
                            {
                                ViewBag.ApplyStatus = -1;
                            }
                            else
                            {
                                ViewBag.ApplyStatus = 2;
                            }
                            return(View("ApplyPost", apply));
                        }
                        else
                        {
                            apply.ChangedLimit = LimitRule.SingleLimitMax;
                            apply.ChangedRates = applyRates;
                            _funongbaoApplyService.Update(apply);
                            ViewBag.ApplyStatus = -1;
                            return(View("ApplyPost", apply));
                            //异常
                            //throw new OceanException("尊敬的" + this.Name + this.Sex + ",您好!您申请的额度已经超过组的最大额度,请联系客户经理再开一张卡。");
                        }
                    }
                }
                //}
            }
            #endregion

            #region 降额情况
            else
            {
                //if (((CurrentFunongbao.CurrentLimit - (GropuLimitCount - applyLimit)) < 0 && funongbaoApplyGroup.Count <= 1))
                //{
                //    throw new OceanException("对不起,您申请的额度超出了限额,请联系客户经理联系(再开一张卡!)");
                //}
                //else
                //{
                apply.ApplyStatus = -1;
                //获取满足条件的申请
                IList <FunongbaoApply> replationApplys = funongbaoApplyGroup.Where(f => f.ApplyLimit == apply.ApplyLimit && f.FunongbaoId != apply.FunongbaoId).ToList();
                //申请与现有的差值<当前申请卡的剩余额度-只需要当前申请-
                if (CurrentFunongbao.CurrentLimit - (GropuLimitCount - applyLimit) >= 0)
                {
                    apply.ChangedLimit = CurrentFunongbao.CurrentLimit - (GropuLimitCount - applyLimit);
                    apply.ChangedRates = apply.ApplyRates;
                    apply.ApplyStatus  = 1;
                    //_funongbaoApplyService.Update(apply);
                    _funongbaoApplyService.UpdateApllysNew(new FunongbaoApply[] { apply }, funongbaoApplyGroup.Where(fg => fg.Id != apply.Id));
                }
                //申请与现有的差值>当前申请卡的剩余额度-需要至少两张卡同时申请
                else
                {
                    //必须属性家庭组和申请必须大于1个
                    if (funongbaoGroup.Count > 1 && funongbaoApplyGroup.Count > 0 && replationApplys != null && replationApplys.Count() > 0)
                    {
                        //计算第二张卡的额度-最小值的那张
                        FunongbaoApply replationApply = replationApplys.Where(fa => funongbaoGroup.OrderBy(f => f.CurrentLimit).Where(f => fa.FunongbaoId == f.Id).Count() > 0).First();
                        Funongbao      replationFnb   = funongbaoGroup.Where(f => f.Id == replationApply.FunongbaoId).First();
                        //当前卡
                        decimal ChangeLimit = CurrentFunongbao.CurrentLimit - ((GropuLimitCount - applyLimit) - replationFnb.CurrentLimit);
                        apply.ChangedLimit = (ChangeLimit < 0.00M ? 0.00M : ChangeLimit);
                        apply.ChangedRates = apply.ApplyRates;

                        if (ChangeLimit < 0)
                        {
                            //需要三张卡同时申请
                            if (funongbaoGroup.Count > 2 && funongbaoApplyGroup.Count > 1 && replationApplys.Count() > 1)
                            {
                                //第三张卡|第三个申请
                                FunongbaoApply replationApply1 = replationApplys.Where(fa => funongbaoGroup.OrderBy(f => f.CurrentLimit).Where(f => fa.FunongbaoId == f.Id && fa.FunongbaoId != replationApply.FunongbaoId).Count() > 0).First();
                                Funongbao      replationFnb1   = funongbaoGroup.Where(f => f.Id == replationApply1.FunongbaoId).First();
                                //当前卡
                                apply.ChangedLimit = (CurrentFunongbao.CurrentLimit - ((GropuLimitCount - applyLimit) - replationFnb1.CurrentLimit - replationFnb.CurrentLimit));
                                apply.ChangedRates = apply.ApplyRates;
                                apply.ApplyStatus  = 1;
                                //第二张卡
                                replationApply.ApplyStatus = 1;
                                //第三张卡
                                replationApply1.ApplyStatus = 1;
                                //放入更新事务:
                                _funongbaoApplyService.UpdateApllysNew(new FunongbaoApply[] { apply, replationApply, replationApply1 }, null);
                            }
                            else
                            {
                                if (funongbaoApplyGroup.Count > 1)
                                {
                                    //判断有几个需的提醒的福农宝名称
                                    ViewBag.RelationNames = GetNoticeApplyNames(funongbaoGroup, apply, funongbaoApplyGroup);
                                    _funongbaoApplyService.Update(apply);
                                    ViewBag.ApplyStatus = 3;
                                    return(View("ApplyPost", apply));
                                }
                                else if (funongbaoApplyGroup.Count > 0)
                                {
                                    //判断有几个需的提醒的福农宝名称
                                    _funongbaoApplyService.Update(apply);
                                    ViewBag.RelationNames = GetNoticeApplyNames(funongbaoGroup, apply, funongbaoIds);
                                    if (ViewBag.RelationNames == "-1")
                                    {
                                        ViewBag.ApplyStatus = -1;
                                    }
                                    else
                                    {
                                        ViewBag.ApplyStatus = 3;
                                    }
                                    return(View("ApplyPost", apply));
                                }
                                else
                                {
                                    apply.ChangedLimit = 0.00M;
                                    apply.ChangedRates = applyRates;
                                    _funongbaoApplyService.Update(apply);
                                    ViewBag.ApplyStatus = -1;
                                    return(View("ApplyPost", apply));
                                    //异常
                                    //throw new OceanException("尊敬的" + this.Name + this.Sex + ",您好!您申请的额度已经超过组的最大额度,请联系客户经理再开一张卡。");
                                }
                            }
                        }
                        else
                        {
                            //当前卡
                            apply.ApplyStatus = 1;
                            //第二张卡
                            replationApply.ApplyStatus = 1;
                            //放入更新事务:
                            _funongbaoApplyService.UpdateApllysNew(new FunongbaoApply[] { apply, replationApply }, funongbaoApplyGroup.Where(fg => fg.Id != apply.Id && fg.Id != replationApply.Id));
                        }
                    }
                    else
                    {
                        if (funongbaoApplyGroup.Count > 1)
                        {
                            //判断有几个需的提醒的福农宝名称
                            apply.ChangedLimit = 0.00M;
                            apply.ChangedRates = applyRates;
                            _funongbaoApplyService.Update(apply);
                            ViewBag.RelationNames = GetNoticeApplyNames(funongbaoGroup, apply, funongbaoIds);
                            if (ViewBag.RelationNames == "-1")
                            {
                                ViewBag.ApplyStatus = -1;
                            }
                            else
                            {
                                ViewBag.ApplyStatus = 3;
                            }
                            return(View("ApplyPost", apply));
                        }
                        else
                        {
                            apply.ChangedLimit = 0.00M;
                            apply.ChangedRates = applyRates;
                            _funongbaoApplyService.Update(apply);
                            ViewBag.ApplyStatus = -1;
                            return(View("ApplyPost", apply));
                            //异常
                            //throw new OceanException("尊敬的" + this.Name + this.Sex + ",您好!您申请的额度已经超过组的最大额度,请联系客户经理再开一张卡。");
                        }
                    }
                }
                //}
            }
            #endregion
            //申请成功
            ViewBag.ApplyStatus = 1;
            return(View("ApplyPost", apply));
        }
Example #4
0
        public ActionResult Index()
        {
            if (!string.IsNullOrEmpty(this.OpenID))
            {
                Funongbao fnb = _funongbaoService.GetFunongbaoByOpenid(this.OpenID);
                if (fnb != null)
                {
                    return(new RedirectResult("/funongbao/apply"));
                }
            }

            Funongbao funongbao = new Funongbao();

            if (WebHelper.IsPost())
            {
                ViewBag.AuthStatus = 0;
                TryUpdateModel <Funongbao>(funongbao);
                int useCount = _mobileCodeService.GetMobileCodeCount(this.MpUserID, 1);//当天使用次数
                if (useCount <= 5)
                {
                    MobileCode lastCode = _mobileCodeService.GetMobileCode(this.MpUserID, 1);//是否存在未使用的证码
                    if (lastCode != null)
                    {
                        MobileCode checkCode = _mobileCodeService.GetMobileCode(funongbao.MobilePhone, WebHelper.GetString("Code"), this.MpUserID, 1);//检查验证码
                        if (checkCode != null)
                        {
                            TimeSpan ts = DateTime.Now.Subtract(checkCode.CreateDate).Duration();
                            if (ts.Minutes > 10)
                            {
                                checkCode.Time  += 1;
                                checkCode.Status = 1;
                                _mobileCodeService.Update(lastCode);
                                ViewBag.CodeError = "验证码已经失效,请重新获取!";
                            }
                            else
                            {
                                Funongbao authFnb    = null;
                                int       authStatus = _funongbaoService.IdentAuth2(funongbao, out authFnb);
                                if (authStatus == -1)
                                {
                                    ViewBag.CodeError = "对不起,该客户已经被绑定了,您无法再次绑定!";
                                }
                                else
                                {
                                    if (authStatus == 1)
                                    {
                                        //更新用户认证并更新cookie
                                        MpUser user = _mpUserservice.GetById(this.MpUserID);
                                        user.Name        = funongbao.Name;
                                        user.PassportNO  = funongbao.PassportNO;
                                        user.MobilePhone = funongbao.MobilePhone;
                                        user.IsAuth      = 1;
                                        //更新当前验证码失败
                                        checkCode.Status = 1;//已用
                                        //更新福农保信息
                                        authFnb.IsAuth          = 1;
                                        authFnb.IsSignAgreement = WebHelper.GetInt("IsSignAgreement", 1);
                                        authFnb.MpUserId        = this.MpUserID;
                                        authFnb.OpenId          = this.OpenID;
                                        try
                                        {
                                            Log4NetImpl.Write("测试事务写入");
                                            _funongbaoService.BeginTransaction();
                                            _mpUserservice.Update(user);
                                            _mobileCodeService.Update(checkCode);
                                            _funongbaoService.Update(authFnb);
                                            _funongbaoService.Commit();
                                            WriteMpUserCookie(user);
                                            Log4NetImpl.Write("测试获取cookie");
                                            var a = MpUserArr;
                                            if (!string.IsNullOrEmpty(WebHelper.GetString("refUrl")))
                                            {
                                                return(Redirect(WebHelper.GetString("refUrl")));
                                            }
                                            else
                                            {
                                                return(RedirectToAction("index", "funongbao"));
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            _funongbaoService.Rollback();
                                            Log4NetImpl.Write(ex.ToString());
                                            throw new OceanException("对不起,系统异常,身份认证失败!", ex);
                                        }
                                    }
                                    else
                                    {
                                        ViewBag.AuthStatus = authStatus;
                                    }
                                }
                            }
                        }
                        else
                        {
                            lastCode.Time += 1;
                            _mobileCodeService.Update(lastCode);
                            ViewBag.CodeError = "对不起,验证码有误,请检查!";
                        }
                    }
                    else
                    {
                        ViewBag.CodeError = "对不起,您还未点击发送验证码!";
                    }
                }
                else
                {
                    ViewBag.CodeError = "对不起,您今天最多只能发起5次验证码";
                }
            }
            return(View(funongbao));
        }