Пример #1
0
        //计算投资次数
        public ActionResult CountInvestTime(int LoanID, BsgridPage bsgridPage)
        {
            try
            {
                B_LoanTable loan = (from tbloan in myModels.B_LoanTable
                                    where tbloan.LoanID == LoanID
                                    select tbloan).Single();

                var list = (from tbin in myModels.B_InvestTable
                            join tbuser in myModels.B_UserTable on tbin.UserID equals tbuser.UserID
                            join tbloan in myModels.B_LoanTable on tbin.LoanID equals tbloan.LoanID
                            join tbstate in myModels.S_StatusTable on tbin.StatusID equals tbstate.StatusID
                            where tbin.LoanID == loan.LoanID
                            select new InvestVo
                {
                    UserID = tbloan.UserID,
                    InvestID = tbin.InvestID,
                    InvestMoney = tbin.InvestMoney,
                    InvestTime = tbin.InvestTime,
                    StartTime = tbin.InvestTime.ToString(),
                    UserName = tbuser.UserName,
                    StatusName = tbstate.StatusName,
                }).Count();
                return(Json(list, JsonRequestBehavior.AllowGet));
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        //交易记录
        public ActionResult SelectJiaoYiRecord(int LoanID, BsgridPage bsgridPage)
        {
            try
            {
                B_LoanTable loan = (from tbloan in myModels.B_LoanTable
                                    where tbloan.LoanID == LoanID
                                    select tbloan).Single();

                var list = (from tbin in myModels.B_InvestTable
                            join tbuser in myModels.B_UserTable on tbin.UserID equals tbuser.UserID
                            join tbloan in myModels.B_LoanTable on tbin.LoanID equals tbloan.LoanID
                            join tbstate in myModels.S_StatusTable on tbin.StatusID equals tbstate.StatusID
                            where tbloan.LoanID == loan.LoanID
                            select new InvestVo
                {
                    UserID = tbloan.UserID,
                    InvestID = tbin.InvestID,
                    InvestMoney = tbin.InvestMoney,
                    InvestTime = tbin.InvestTime,
                    StartTime = tbin.InvestTime.ToString(),
                    UserName = tbuser.UserName,
                    StatusName = tbstate.StatusName,
                });
                int             TotaRow = list.Count();
                List <InvestVo> listT   = list.OrderBy(p => p.InvestID)
                                          .Skip(bsgridPage.GetStartIndex())
                                          .Take(bsgridPage.pageSize)
                                          .ToList();

                Bsgrid <InvestVo> bsgrid = new Bsgrid <InvestVo>();
                bsgrid.success   = true;
                bsgrid.totalRows = TotaRow;
                bsgrid.curPage   = bsgridPage.curPage;
                bsgrid.data      = listT;
                return(Json(bsgrid, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
        }
Пример #3
0
        //计算投资金额
        public ActionResult CountInvestMoney(int LoanID, BsgridPage bsgridPage)
        {
            try
            {
                B_LoanTable loan = (from tbloan in myModels.B_LoanTable
                                    where tbloan.LoanID == LoanID
                                    select tbloan).Single();

                var list = (from tbin in myModels.B_InvestTable
                            join tbuser in myModels.B_UserTable on tbin.UserID equals tbuser.UserID
                            join tbloan in myModels.B_LoanTable on tbin.LoanID equals tbloan.LoanID
                            join tbstate in myModels.S_StatusTable on tbin.StatusID equals tbstate.StatusID
                            where tbin.LoanID == loan.LoanID
                            select new InvestVo
                {
                    UserID = tbloan.UserID,
                    InvestID = tbin.InvestID,
                    InvestMoney = tbin.InvestMoney,
                    InvestTime = tbin.InvestTime,
                    StartTime = tbin.InvestTime.ToString(),
                    UserName = tbuser.UserName,
                    StatusName = tbstate.StatusName,
                }).ToList();
                decimal ZongE = 0;
                decimal ZE    = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    ZongE = Convert.ToDecimal(list[i].InvestMoney);
                    ZE   += ZongE;
                }

                return(Json(ZE.ToString(), JsonRequestBehavior.AllowGet));
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
        }
Пример #4
0
        public ActionResult selectjiekuanfullscale()
        {
            try
            {
                //判断VIP用户是否到期
                var vipUser = (from tbVIPuser in myDYXTEntities.B_VIPUserTable
                               select tbVIPuser).ToList();
                for (int i = 0; i < vipUser.Count; i++)
                {
                    DateTime nowTime = DateTime.Now;                           //当前时间
                    DateTime dtTime  = Convert.ToDateTime(vipUser[i].EndTime); //结束时间
                    if (nowTime > dtTime)
                    {
                        int         intuserID = Convert.ToInt32(vipUser[i].UserID);
                        B_UserTable varsuer   = (from tbUser in myDYXTEntities.B_UserTable
                                                 where tbUser.UserID == intuserID
                                                 select tbUser).Single();
                        varsuer.UserTypeID = 2;
                        myDYXTEntities.Entry(varsuer).State = System.Data.Entity.EntityState.Modified;
                        myDYXTEntities.SaveChanges();
                    }
                }


                var varstrloan = (from tbLoan in myDYXTEntities.B_LoanTable
                                  where tbLoan.StatusID == 7 || tbLoan.StatusID == 8 || tbLoan.StatusID == 9
                                  select tbLoan).ToList();
                try
                {
                    for (int i = 0; i < varstrloan.Count(); i++)
                    {
                        int         intloanID = varstrloan[i].LoanID;
                        B_LoanTable varloanll = (from tbloan in myDYXTEntities.B_LoanTable
                                                 where tbloan.LoanID == intloanID
                                                 select tbloan).Single();
                        DateTime loantime       = DateTime.Now;                                    //获取当前时间
                        DateTime valtiem        = Convert.ToDateTime(varstrloan[i].Endtime);       //获取到期是时间
                        DateTime Raistime       = Convert.ToDateTime(varstrloan[i].Raisestandard); //获取筹标时间
                        DateTime varsichuantime = Convert.ToDateTime(varstrloan[i].sichuantime);   //过期时间

                        if (Raistime >= loantime && varstrloan[i].Scheduleinvestment == Convert.ToDecimal("100"))
                        {
                            varloanll.StatusID = 28;//满标待审
                            myDYXTEntities.Entry(varloanll).State = System.Data.Entity.EntityState.Modified;
                            myDYXTEntities.SaveChanges();
                        }
                        else if (loantime > Raistime)
                        {
                            varloanll.StatusID    = 9;//已过期
                            varloanll.sichuantime = varloanll.Raisestandard.Value.AddDays(3);
                            myDYXTEntities.Entry(varloanll).State = System.Data.Entity.EntityState.Modified;
                            myDYXTEntities.SaveChanges();
                        }
                        if (varloanll.StatusID == 9 && loantime > varsichuantime && varstrloan[i].Scheduleinvestment < Convert.ToDecimal("100"))
                        {
                            varloanll.StatusID                    = 26;//流标
                            varloanll.RemoveTreetopTime           = DateTime.Now;
                            myDYXTEntities.Entry(varloanll).State = System.Data.Entity.EntityState.Modified;
                            myDYXTEntities.SaveChanges();

                            var varinves = (from tbinvest in myDYXTEntities.B_InvestTable
                                            where tbinvest.LoanID == varloanll.LoanID
                                            select tbinvest).ToList();
                            for (int j = 0; j < varinves.Count; j++)
                            {
                                int         VarUserID = Convert.ToInt32(varinves[j].UserID);
                                B_UserTable varsuer   = (from tbUser in myDYXTEntities.B_UserTable
                                                         where tbUser.UserID == VarUserID
                                                         select tbUser).Single();
                                varsuer.PropertyAmounts             = varsuer.PropertyAmounts + varinves[j].InvestMoney;
                                varsuer.UsableMoney                 = varsuer.UsableMoney + varinves[j].InvestMoney;
                                myDYXTEntities.Entry(varsuer).State = System.Data.Entity.EntityState.Modified;
                                myDYXTEntities.SaveChanges();
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                }


                //判断借款标是否逾期
                var varloan = (from tbLoan in myDYXTEntities.B_LoanTable
                               where tbLoan.StatusID == 10 || tbLoan.StatusID == 8 || tbLoan.StatusID == 11 || tbLoan.StatusID == 34
                               select tbLoan).ToList();

                for (int i = 0; i < varloan.Count; i++)
                {
                    DateTime nowTime = DateTime.Now;                           //当前时间
                    DateTime dtTime  = Convert.ToDateTime(varloan[i].Endtime); //结束时间

                    if (nowTime > dtTime && varloan[i].StatusID != 34)
                    {
                        TimeSpan           YuQitianshu    = nowTime - dtTime;
                        double             YQTS           = YuQitianshu.TotalDays;
                        int                yqts           = Convert.ToInt32(YQTS);                                                     //逾期天数
                        decimal            varrete        = Convert.ToDecimal(varloan[i].Rate) * Convert.ToDecimal(0.01);
                        decimal            demoney        = Convert.ToDecimal(varloan[i].LoanMoney) * varrete;                         //利息
                        decimal            strfx          = Convert.ToDecimal(varloan[i].LoanMoney) * Convert.ToDecimal(0.008) * yqts; //罚息
                        B_OverdueLoanTable strOverdueLoan = new B_OverdueLoanTable();
                        strOverdueLoan.LoanID                    = varloan[i].LoanID;
                        strOverdueLoan.PayableTime               = varloan[i].Endtime;
                        strOverdueLoan.OverdueDay                = yqts;
                        strOverdueLoan.PayablePrincipal          = varloan[i].LoanMoney + demoney + strfx;
                        strOverdueLoan.WebsiteWhetherPayStatusID = 33;
                        strOverdueLoan.StatusID                  = 31;
                        strOverdueLoan.RealityRepaymentTime      = varloan[i].Endtime;
                        myDYXTEntities.B_OverdueLoanTable.Add(strOverdueLoan);
                        myDYXTEntities.SaveChanges();

                        int intloan   = Convert.ToInt32(varloan[i].LoanID);
                        var varloanID = (from tbLoan in myDYXTEntities.B_LoanTable
                                         where tbLoan.LoanID == intloan
                                         select tbLoan).Single();
                        varloanID.StatusID                    = 34;
                        varloanID.RepayPrincipal              = strOverdueLoan.PayablePrincipal;
                        varloanID.ArrearagePrincipal          = strOverdueLoan.PayablePrincipal;
                        myDYXTEntities.Entry(varloanID).State = System.Data.Entity.EntityState.Modified;
                        myDYXTEntities.SaveChanges();
                    }
                    else if (nowTime > dtTime && varloan[i].StatusID == 34)
                    {
                        int intloan = Convert.ToInt32(varloan[i].LoanID);
                        B_OverdueLoanTable strOverdueLoan = (from tbOverdueLoan in myDYXTEntities.B_OverdueLoanTable
                                                             where tbOverdueLoan.LoanID == intloan
                                                             select tbOverdueLoan).Single();
                        TimeSpan YuQitianshu = nowTime - dtTime;
                        double   YQTS        = YuQitianshu.TotalDays;
                        int      yqts        = Convert.ToInt32(YQTS);//逾期天数

                        if (strOverdueLoan.OverdueDay != yqts)
                        {
                            decimal varrete = Convert.ToDecimal(varloan[i].Rate) * Convert.ToDecimal(0.01);
                            decimal demoney = Convert.ToDecimal(varloan[i].LoanMoney) * varrete;                         //利息
                            decimal strfx   = Convert.ToDecimal(varloan[i].LoanMoney) * Convert.ToDecimal(0.008) * yqts; //罚息
                            strOverdueLoan.OverdueDay                  = yqts;
                            strOverdueLoan.PayablePrincipal            = strOverdueLoan.PayablePrincipal + demoney + strfx;
                            myDYXTEntities.Entry(strOverdueLoan).State = System.Data.Entity.EntityState.Modified;
                            myDYXTEntities.SaveChanges();
                            int intloans  = Convert.ToInt32(varloan[i].LoanID);
                            var varloanID = (from tbLoan in myDYXTEntities.B_LoanTable
                                             where tbLoan.LoanID == intloans
                                             select tbLoan).Single();
                            varloanID.RepayPrincipal              = strOverdueLoan.PayablePrincipal;
                            varloanID.ArrearagePrincipal          = strOverdueLoan.PayablePrincipal;
                            myDYXTEntities.Entry(varloanID).State = System.Data.Entity.EntityState.Modified;
                            myDYXTEntities.SaveChanges();

                            try
                            {
                                B_WebsiteReceivableDetail varWebsiteReceivableDetail = (from tbWebsiteReceivableDetail in myDYXTEntities.B_WebsiteReceivableDetail
                                                                                        where tbWebsiteReceivableDetail.OverdueLoanID == strOverdueLoan.OverdueLoanID
                                                                                        select tbWebsiteReceivableDetail).Single();
                                varWebsiteReceivableDetail.ReceivableAccrual           = demoney + strfx;
                                varWebsiteReceivableDetail.OverdueDays                 = yqts;
                                myDYXTEntities.Entry(varWebsiteReceivableDetail).State = System.Data.Entity.EntityState.Modified;
                                myDYXTEntities.SaveChanges();
                            }
                            catch (Exception e)
                            {
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }

            return(Json(null, JsonRequestBehavior.AllowGet));
        }
Пример #5
0
        //认购页面
        public ActionResult SubscribeIndex(int LoanID, BsgridPage bsgridPage)
        {
            try
            {
                string         strUserId = Session["AccountID"].ToString();
                int            intUserId = Convert.ToInt32(strUserId);
                B_AccountTable accouunt  = (from tbAccountTable in myModels.B_AccountTable
                                            where tbAccountTable.AccountID == intUserId
                                            select tbAccountTable).Single();
                ViewBag.User = accouunt.User;

                B_LoanTable notice = (from tbloan in myModels.B_LoanTable
                                      join tbuser in myModels.B_UserTable on tbloan.UserID equals tbuser.UserID
                                      join tbLoanDeadline in myModels.S_LoanDeadlineTable on tbloan.LoanDeadlineID equals tbLoanDeadline.LoanDeadlineID
                                      join tbtree in myModels.S_Treetoptypetalbe on tbloan.TreetoptypeID equals tbtree.TreetoptypeID
                                      join tbRepaymentWayTable in myModels.S_RepaymentWayTable on tbloan.RepaymentWayID equals tbRepaymentWayTable.RepaymentWayID
                                      where tbloan.LoanID == LoanID
                                      select new LoanVo
                {
                    LoanID = tbloan.LoanID,
                    UserID = tbloan.UserID,
                    UserName = tbuser.UserName,
                    Loantitle = tbloan.Loantitle,
                    PaymentNumber = tbloan.PaymentNumber,
                    LoanMoney = tbloan.LoanMoney,
                    Rate = tbloan.Rate,
                    LoanDeadlineName = tbLoanDeadline.LoanDeadlineName,
                    RepaymentWayName = tbRepaymentWayTable.RepaymentWayName,
                    LowestTenderMoney = tbloan.LowestTenderMoney,
                    AlreadyLoan = tbloan.AlreadyLoan,
                    SurplusLoan = tbloan.SurplusLoan,
                    Scheduleinvestment = tbloan.Scheduleinvestment
                }).Single();
                ViewBag.notice = notice;

                B_LoanTable Loanxinix = (from tbloan in myModels.B_LoanTable
                                         where tbloan.LoanID == LoanID
                                         select tbloan).Single();
                int         userid    = Convert.ToInt32(Loanxinix.UserID);
                B_UserTable userxinxi = (from tbuser in myModels.B_UserTable
                                         where tbuser.UserID == userid
                                         select new UserVo
                {
                    UserName = tbuser.UserName,
                    Sex = tbuser.Sex,
                    MonthIncome = tbuser.MonthIncome,
                    ReleaseTimeStr = tbuser.BornDate.ToString(),
                    MarriageState = tbuser.MarriageState,
                    EducationalBackground = tbuser.EducationalBackground,
                    WhetherBuyCar = tbuser.WhetherBuyCar,
                    housingCondition = tbuser.housingCondition,
                    Issue = tbuser.Issue,
                    PropertyAmounts = tbuser.PropertyAmounts,
                    CompensatoryMoney = tbuser.CompensatoryMoney,
                }).Single();
                ViewBag.userxinxi = userxinxi;
                var vraloan = (from tbloan in myModels.B_LoanTable
                               where tbloan.UserID == userid
                               select tbloan).ToList();
                decimal rowloan = vraloan.Count;
                ViewBag.rowloan = rowloan;//发布借款
                var vraloanStatusID = (from tbloan in myModels.B_LoanTable
                                       where tbloan.UserID == userid && tbloan.StatusID == 10
                                       select tbloan).ToList();
                decimal varvraloanStatusID = vraloanStatusID.Count;
                ViewBag.varvraloanStatusID = varvraloanStatusID;//成功借款

                var vrastrloan = (from tbloanid in myModels.B_LoanTable
                                  where tbloanid.UserID == userid && (tbloanid.StatusID == 12 || tbloanid.StatusID == 13)
                                  select tbloanid).ToList();
                decimal rowvrastrloan = vrastrloan.Count;
                ViewBag.rowvrastrloan = rowvrastrloan;//还请笔数
            }
            catch (Exception e)
            {
            }

            return(View());
        }
Пример #6
0
        /// <summary>
        /// 确定认购
        /// </summary>
        /// <param name="bInvest"></param>
        /// <param name="Loantitle"></param>
        /// <param name="fenshu"></param>
        /// <param name="LowestTenderMoney"></param>
        /// <param name="Rate"></param>
        /// <param name="PayPassword"></param>
        /// <returns></returns>
        public ActionResult InsertLoan(B_InvestTable bInvest, string Loantitle, int fenshu, string LowestTenderMoney, string Rate, string PayPassword)
        {
            string      str            = "";
            int         loanid         = Convert.ToInt32(bInvest.LoanID);
            B_LoanTable varB_LoanTable = (from tbtbB_Loan in myModels.B_LoanTable
                                          where tbtbB_Loan.LoanID == loanid
                                          select tbtbB_Loan).Single();
            int         userid  = Convert.ToInt32(varB_LoanTable.UserID);
            B_UserTable varuser = (from tbuser in myModels.B_UserTable
                                   where tbuser.UserID == userid
                                   select tbuser).Single();
            string password = AESEncryptHelper.AESEncrypt(PayPassword);

            if (varuser.PayPassword.Trim().Equals(password))
            {
                int accountID = Convert.ToInt32(Session["AccountID"].ToString());
                var list      = (from tbuser in myModels.B_UserTable
                                 where tbuser.AccountID == accountID
                                 select tbuser).Single();
                bInvest.LoanTreetop = Loantitle;
                decimal intLowestTenderMoney = Convert.ToDecimal(LowestTenderMoney);
                bInvest.InvestMoney = fenshu * intLowestTenderMoney;                            //份数*最低投标金额

                decimal rate = Convert.ToDecimal(Rate.ToString().Trim());                       //年利率
                bInvest.ReceivableInterest = (bInvest.InvestMoney * rate) / 100;                //应收利息

                bInvest.ReceivablePrincipal = bInvest.InvestMoney + bInvest.ReceivableInterest; //应收本息

                bInvest.CountermandPrincipal = Convert.ToDecimal(0.00);                         //已收本息
                bInvest.NotRetrievePrincipal = bInvest.ReceivablePrincipal;                     //未收本息
                if (list.PropertyAmounts > bInvest.InvestMoney)
                {
                    if (bInvest.LoanID != null)
                    {
                        bInvest.InvestTime    = DateTime.Now;
                        bInvest.UserID        = list.UserID;
                        bInvest.StatusID      = 16;
                        bInvest.WhetherAttorn = false;
                        myModels.B_InvestTable.Add(bInvest);
                        myModels.SaveChanges();

                        //修改借款标表
                        B_LoanTable B_Loan = (from tbloan in myModels.B_LoanTable
                                              where tbloan.LoanID == bInvest.LoanID
                                              select tbloan).Single();
                        //B_Loan.LoanMoney = B_Loan.LoanMoney - bInvest.InvestMoney;//借款金额

                        int investTime;
                        investTime        = Convert.ToInt32(B_Loan.InvestTime.ToString());//投资次数
                        investTime        = investTime + 1;
                        B_Loan.InvestTime = Convert.ToInt32(investTime).ToString();



                        int grossscore;
                        grossscore = Convert.ToInt32(B_Loan.Grossscore); //总份数;
                        double scheduleinvestment;                       //进度
                        scheduleinvestment        = Convert.ToDouble(B_Loan.Scheduleinvestment);
                        scheduleinvestment        = Convert.ToDouble(Convert.ToDouble(fenshu) / Convert.ToDouble(grossscore)) * 100;
                        B_Loan.Scheduleinvestment = Convert.ToDecimal(scheduleinvestment + Convert.ToDouble(B_Loan.Scheduleinvestment));

                        int surplusLoan;//剩余份数
                        surplusLoan        = Convert.ToInt32(B_Loan.SurplusLoan);
                        surplusLoan        = (surplusLoan - fenshu);
                        B_Loan.SurplusLoan = Convert.ToDecimal(surplusLoan);

                        int alreadyLoan;//已被购买份数
                        alreadyLoan        = Convert.ToInt32(B_Loan.AlreadyLoan);
                        B_Loan.AlreadyLoan = Convert.ToInt32(alreadyLoan + fenshu);

                        myModels.Entry(B_Loan).State = System.Data.Entity.EntityState.Modified;
                        myModels.SaveChanges();
                        if (B_Loan.SurplusLoan == 0)
                        {
                            B_LoanTable bloan = (from tbloa in myModels.B_LoanTable
                                                 where tbloa.LoanID == bInvest.LoanID
                                                 select tbloa).Single();
                            bloan.StatusID = 28;
                            myModels.Entry(bloan).State = System.Data.Entity.EntityState.Modified;
                            myModels.SaveChanges();
                        }

                        //修改用户表的金额
                        B_UserTable listS = (from tbuser in myModels.B_UserTable
                                             where tbuser.AccountID == accountID
                                             select tbuser).Single();
                        //listS.PropertyAmounts = listS.PropertyAmounts - bInvest.InvestMoney;
                        listS.UsableMoney           = listS.UsableMoney - bInvest.InvestMoney;
                        listS.FreezeMoney           = listS.FreezeMoney + bInvest.InvestMoney;
                        myModels.Entry(listS).State = System.Data.Entity.EntityState.Modified;
                        myModels.SaveChanges();


                        B_CapitalrecordTable Capitalrecord = new B_CapitalrecordTable();
                        Capitalrecord.UserID          = list.UserID;
                        Capitalrecord.OperateTypeID   = 4;
                        Capitalrecord.OpFare          = Convert.ToDecimal(bInvest.InvestMoney);
                        Capitalrecord.Income          = Convert.ToDecimal(0);
                        Capitalrecord.Expend          = Convert.ToDecimal(bInvest.InvestMoney);
                        Capitalrecord.PropertyAmounts = list.PropertyAmounts;
                        Capitalrecord.Remarks         = "用户" + "[" + list.UserName.Trim() + "]" + ",投资成功,可用余额减少" + bInvest.InvestMoney + "元";
                        Capitalrecord.operatetime     = DateTime.Now;
                        myModels.B_CapitalrecordTable.Add(Capitalrecord);
                        myModels.SaveChanges();
                        str = "success";
                    }
                    else
                    {
                        str = "fail";
                    }
                }
            }
            else
            {
                str = "failPayPassword";
            }

            return(Json(str, JsonRequestBehavior.AllowGet));
        }