Beispiel #1
0
        protected static string GetRemainTime(li_projects proj)
        {
            if (proj.publish_time == null)
            {
                return("");
            }

            var deadlineDay = proj.publish_time.Value.AddDays(proj.financing_day);

            var      match = new Regex(@"^(\d{1,2}):(\d{2}):(\d{2})$").Match(ConfigLoader.loadSiteConfig().systemTimerTriggerTime);
            TimeSpan remainTimeSpan;

            if (!match.Success)
            {
                remainTimeSpan = deadlineDay.Subtract(DateTime.Now);
            }
            else
            {
                remainTimeSpan =
                    deadlineDay.Date.AddHours(Convert.ToInt32(match.Groups[1].Value))
                    .AddMinutes(Convert.ToInt32(match.Groups[2].Value))
                    .AddSeconds(Convert.ToInt32(match.Groups[3].Value))
                    .Subtract(DateTime.Now);
            }
            var timeSpanNotNeg = new[] { remainTimeSpan, TimeSpan.Zero }.Max();

            return($"{timeSpanNotNeg.Days}天{timeSpanNotNeg.Hours}时{timeSpanNotNeg.Minutes}分");
        }
Beispiel #2
0
        /// <summary>
        /// 显示项目信息
        /// </summary>
        /// <param name="_project"></param>
        public virtual void ShowProjectInfo(li_projects _project)
        {
            spa_category.InnerText  = new article_category().GetTitle(_project.category_id);         //项目类别
            spa_type.InnerText      = Utils.GetAgp2pEnumDes((Agp2pEnums.LoanTypeEnum)_project.type); //借款主体
            spa_title.InnerText     = _project.title;
            spa_no.InnerText        = _project.no;
            spa_amount.InnerText    = _project.financing_amount.ToString();                                                         //借款金额
            spa_repayment.InnerText = _project.repayment_term_span_count +
                                      Utils.GetAgp2pEnumDes((Agp2pEnums.ProjectRepaymentTermSpanEnum)_project.repayment_term_span); //借款期限
            spa_repayment_type.InnerText = Utils.GetAgp2pEnumDes((Agp2pEnums.ProjectRepaymentTypeEnum)_project.repayment_type);     //还款方式
            spa_profit_rate.InnerText    = _project.profit_rate_year.ToString("N2");                                                //年化利率
            spa_bonus_rate.InnerText     = _project.bonus_rate == null ? "0" : ((decimal)_project.bonus_rate).ToString("N2");

            if (_project.tag != null)
            {
                spa_tag.InnerText = Utils.GetAgp2pEnumDes((Agp2pEnums.ProjectTagEnum)_project.tag);
            }
            spa_financing_day.InnerText  = _project.financing_day.ToString();
            spa_add_time.InnerText       = _project.add_time.ToString("yyyy-MM-dd HH:mm:ss");        //申请时间
            spa_publish_time.InnerText   = _project.publish_time?.ToString("yyyy-MM-dd HH:mm:ss");   //发布时间
            spa_make_loan_time.InnerText = _project.make_loan_time?.ToString("yyyy-MM-dd HH:mm:ss"); //放款时间
            spa_bond_fee.InnerText       = _project.bond_fee_rate?.ToString("N4");
            spa_loan_fee.InnerText       = _project.loan_fee_rate?.ToString("N4");
            spa_contact_no.InnerText     = _project.contract_no;

            ShowRiskInfo(_project);
        }
Beispiel #3
0
 //页面加载事件
 public virtual void Page_Load(object sender, EventArgs e)
 {
     this.ProjectId     = DTRequest.GetQueryInt("id");
     this.ProjectStatus = DTRequest.GetQueryInt("status");
     if (!Page.IsPostBack)
     {
         if (this.ProjectId == 0)
         {
             JscriptMsg("传输参数不正确!", "back", "Error");
             return;
         }
         li_projects project = LqContext.li_projects.FirstOrDefault(q => q.id == this.ProjectId);
         if (project == null)
         {
             JscriptMsg("项目不存在或已被删除!", "back", "Error");
             return;
         }
         Loan = new BLL.loan(LqContext);
         ShowProjectInfo(project);
         if (project.IsHuoqiProject())
         {
             ShowProfitingClaimInfo(project);
         }
         else
         {
             ShowClaimsInfo(project);
         }
         LoanType = project.type;
         ShowByStatus();
     }
 }
Beispiel #4
0
        public static void PublishProject(string projectName, int repayDays, decimal financingAmount, decimal profitingYearly)
        {
            var context = new Agp2pDataContext();
            var now     = DateTime.Now;

            var loaner      = context.li_loaners.Single(l => l.dt_users.real_name == "杨长岭");
            var ypbCategory = context.dt_article_category.Single(c => c.call_index == "ypb");
            var project     = new li_projects
            {
                li_risks = new li_risks
                {
                    last_update_time = now,
                    li_loaners       = loaner
                },
                category_id               = ypbCategory.id,
                type                      = (int)Agp2pEnums.LoanTypeEnum.Company,
                sort_id                   = 99,
                add_time                  = now,
                publish_time              = now,
                make_loan_time            = now,
                user_name                 = "admin",
                title                     = projectName,
                no                        = projectName,
                financing_amount          = financingAmount,
                repayment_term_span_count = repayDays,
                repayment_term_span       = (int)Agp2pEnums.ProjectRepaymentTermSpanEnum.Day,
                repayment_type            = (int)Agp2pEnums.ProjectRepaymentTypeEnum.DaoQi,
                profit_rate_year          = profitingYearly,
                status                    = (int)Agp2pEnums.ProjectStatusEnum.Financing,
            };

            context.li_projects.InsertOnSubmit(project);

            context.SubmitChanges();
        }
Beispiel #5
0
 /// <summary>
 /// 显示风险信息
 /// </summary>
 protected void ShowRiskInfo(li_projects _project)
 {
     if (_project.li_risks != null)
     {
         var risk = _project.li_risks;
         this.risk_id = risk.id;
         //借款人信息
         ddlLoaner.SelectedValue = risk.loaner.ToString();
         ShowLoanerInfo(risk.li_loaners);
         //债权人信息
         if (rbl_project_type.SelectedValue == ((int)Agp2pEnums.LoanTypeEnum.Creditor).ToString())
         {
             ddlCreditor.SelectedValue = risk.creditor.ToString();
             txtCreditorContent.Text   = risk.creditor_content;
         }
         if (risk.guarantor_id != null)
         {
             ddl_guarantor.SelectedValue = risk.guarantor_id.ToString();
         }
         //txtCreditRating.Text = risk.credit_rating;
         txtRepaymentSource.Text = risk.source_of_repayment; //还款来源
         txtLoanUse.Text         = risk.loan_usage;          //借款用途
         txtLoanerContent.Text   = risk.loaner_content;      //借款描述
         txtRiskContent.Value    = risk.risk_content;        //风控描述
         // 加载相册
         rptMortgageContracts.DataSource = risk.li_albums.Where(a => a.risk == risk.id && a.type == (int)Agp2pEnums.AlbumTypeEnum.MortgageContract);
         rptMortgageContracts.DataBind();
         rptLienCertificates.DataSource = risk.li_albums.Where(a => a.risk == risk.id && a.type == (int)Agp2pEnums.AlbumTypeEnum.LienCertificate);
         rptLienCertificates.DataBind();
         rptLoanAgreement.DataSource = risk.li_albums.Where(a => a.risk == risk.id && a.type == (int)Agp2pEnums.AlbumTypeEnum.LoanAgreement);
         rptLoanAgreement.DataBind();
     }
 }
Beispiel #6
0
        /// <summary>
        /// 项目信息赋值
        /// </summary>
        /// <param name="project"></param>
        private void SetProjectModel(li_projects project)
        {
            project.seo_title       = txtSeoTitle.Text.Trim();
            project.seo_keywords    = txtSeoKeywords.Text.Trim();
            project.seo_description = txtSeoDescription.Text.Trim();
            project.sort_id         = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            project.click           = Utils.StrToInt(txtClick.Text.Trim(), 0);
            project.img_url         = txtImgUrl.Text.Trim();
            project.add_time        = string.IsNullOrEmpty(txtAddTime.Text.Trim()) ? DateTime.Now : Utils.StrToDateTime(txtAddTime.Text.Trim());
            project.user_name       = GetAdminInfo().user_name;
            project.category_id     = Utils.StrToInt(ddlCategoryId.SelectedValue, 0);
            project.title           = txtTitle.Text.Trim();
            project.type            = Utils.StrToInt(rbl_project_type.SelectedValue, 10);
            project.no = txt_project_no.Text.Trim();
            project.financing_amount          = Utils.StrToInt(txt_project_amount.Text.Trim(), 0);
            project.repayment_term_span_count = Utils.StrToInt(txt_project_repayment_number.Text.Trim(), 0);
            project.repayment_term_span       = Utils.StrToInt(txt_project_repayment_term.SelectedValue, 20);
            project.repayment_type            = Utils.StrToInt(txt_project_repayment_type.SelectedValue, 10);
            project.profit_rate_year          = Utils.StrToDecimal(txt_project_profit_rate.Text.Trim(), 0);
            project.bonus_rate    = Utils.StrToDecimal(txt_project_bonus_rate.Text.Trim(), 0);
            project.bond_fee_rate = Utils.StrToDecimal(txt_bond_fee_rate.Text.Trim(), 0) / 100;
            project.loan_fee_rate = Utils.StrToDecimal(txt_loan_fee_rate.Text.Trim(), 0) / 100;
            project.contract_no   = txt_contact_no.Text.Trim();

            //提交操作则状态为待初审
            project.status = save_only ? (int)Agp2pEnums.ProjectStatusEnum.FinancingApplicationUncommitted : (int)Agp2pEnums.ProjectStatusEnum.FinancingApplicationChecking;
        }
Beispiel #7
0
        //页面加载事件
        public virtual void Page_Load(object sender, EventArgs e)
        {
            this.action     = DTRequest.GetQueryString("action");
            this.project_id = DTRequest.GetQueryInt("id");
            this.Loan       = new BLL.loan(LqContext);

            if (!Page.IsPostBack)
            {
                CategoryDDLBind(this.channel_id);
                BindControls();

                if (!string.IsNullOrEmpty(action) && (action == DTEnums.ActionEnum.Edit.ToString() || action == DTEnums.ActionEnum.Copy.ToString()))
                {
                    if (this.project_id == 0)
                    {
                        JscriptMsg("传输参数不正确!", "back", "Error");
                        return;
                    }
                    LqContext = new Agp2pDataContext();
                    li_projects project = LqContext.li_projects.FirstOrDefault(q => q.id == this.project_id);
                    if (project == null)
                    {
                        JscriptMsg("项目不存在或已被删除!", "back", "Error");
                        return;
                    }
                    ShowInfo(project);
                }
                SetLoanType();
            }
        }
Beispiel #8
0
        private bool DoAdd()
        {
            var project = new li_projects();
            var risk    = new li_risks();

            project.li_risks = risk;
            SetRiskModel(risk);
            SetProjectModel(project);
            BindMortgages(risk);
            //项目编号
            var latestProject = LqContext.li_projects.Where(p => p.category_id == project.category_id && !p.title.Equals("")).OrderByDescending(p => p.id).FirstOrDefault();
            int prjectCount   = latestProject == null ? 0 : Utils.StrToInt(latestProject.title.Substring(latestProject.title.Length - 5), 0);

            project.title += new BLL.article_category().GetModel(project.category_id).call_index.ToUpper() + (prjectCount + 1).ToString("00000");

            LqContext.li_risks.InsertOnSubmit(risk);
            LqContext.li_projects.InsertOnSubmit(project);
            try
            {
                LqContext.SubmitChanges();
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加项目成功!"); //记录日志
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(true);
        }
        public static DateTime GetStatusChangingTime(this li_projects project)
        {
            var status = (Agp2pEnums.ProjectStatusEnum)project.status;

            if (status < Agp2pEnums.ProjectStatusEnum.Financing)
            {
                return(project.add_time);
            }
            else if (status < Agp2pEnums.ProjectStatusEnum.FinancingSuccess)
            {
                return(project.publish_time.Value);
            }
            else if (status < Agp2pEnums.ProjectStatusEnum.ProjectRepaying)
            {
                return(project.invest_complete_time.Value);
            }
            else if (status < Agp2pEnums.ProjectStatusEnum.RepayCompleteIntime)
            {
                return(project.make_loan_time.Value);
            }
            else
            {
                return(project.complete_time.Value);
            }
        }
Beispiel #10
0
        /// <summary>
        /// 显示项目信息
        /// </summary>
        /// <param name="_project"></param>
        public virtual void ShowInfo(li_projects _project)
        {
            ddlCategoryId.SelectedValue = _project.category_id.ToString(); //项目类别
            BindDDlCategory();
            rbl_project_type.SelectedValue = _project.type.ToString();     //借款主体

            txtSeoTitle.Text                         = _project.seo_title;
            txtSeoKeywords.Text                      = _project.seo_keywords;
            txtSeoDescription.Text                   = _project.seo_description;
            txtSortId.Text                           = _project.sort_id.ToString();
            txtClick.Text                            = _project.click.ToString();
            txtImgUrl.Text                           = _project.img_url;
            txtTitle.Text                            = action == DTEnums.ActionEnum.Copy.ToString() ? "" : _project.title;
            txt_project_no.Text                      = _project.no;
            txt_project_amount.Text                  = _project.financing_amount.ToString();                                                                                                            //借款金额
            txt_project_repayment_number.Text        = _project.repayment_term_span_count.ToString();                                                                                                   //借款期限
            txt_project_repayment_term.SelectedValue = _project.repayment_term_span.ToString();                                                                                                         //借款期限单位
            txt_project_repayment_type.Text          = _project.repayment_type.ToString();                                                                                                              //还款方式
            txt_project_profit_rate.Text             = _project.profit_rate_year.ToString("N2");                                                                                                        //年化利率
            txt_project_bonus_rate.Text              = _project.bonus_rate == null ? "0" : ((decimal)_project.bonus_rate).ToString("N2");                                                               //额外奖励利率
            txtAddTime.Text                          = action == DTEnums.ActionEnum.Copy.ToString() ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : _project.add_time.ToString("yyyy-MM-dd HH:mm:ss"); //申请时间
            txt_bond_fee_rate.Text                   = ((decimal)(_project.bond_fee_rate * 100)).ToString("F2");
            txt_loan_fee_rate.Text                   = ((decimal)(_project.loan_fee_rate * 100)).ToString("F2");
            txt_contact_no.Text                      = _project.contract_no;

            ShowRiskInfo(_project);
        }
Beispiel #11
0
 /// <summary>
 /// 显示风险信息
 /// </summary>
 protected void ShowRiskInfo(li_projects _project)
 {
     if (_project.li_risks != null)
     {
         var risk = _project.li_risks;
         //借款人信息
         ShowLoanerInfo(risk.li_loaners, risk.id);
         //债权人信息
         if (_project.type == (int)Agp2pEnums.LoanTypeEnum.Creditor)
         {
             spa_creditor.InnerText        = risk.li_creditors.dt_users.real_name;
             spa_creditorContent.InnerText = risk.creditor_content;
         }
         //风控信息
         spa_loanerContent.InnerText   = risk.loaner_content;      //借款描述
         spa_loanUse.InnerText         = risk.loan_usage;          //借款用途
         spa_repaymentSource.InnerText = risk.source_of_repayment; //还款来源
         spa_txtRiskContent.InnerHtml  = risk.risk_content;        //风控描述
         // 加载相册
         rptMortgageContracts.DataSource = risk.li_albums.Where(a => a.type == (int)Agp2pEnums.AlbumTypeEnum.MortgageContract);
         rptMortgageContracts.DataBind();
         rptLienCertificates.DataSource = risk.li_albums.Where(a => a.type == (int)Agp2pEnums.AlbumTypeEnum.LienCertificate);
         rptLienCertificates.DataBind();
         rptLoanAgreement.DataSource = risk.li_albums.Where(a => a.type == (int)Agp2pEnums.AlbumTypeEnum.LoanAgreement);
         rptLoanAgreement.DataBind();
     }
 }
Beispiel #12
0
 protected bool IsProjectCanRepayToday(li_projects pro)
 {
     return
         (pro.li_repayment_tasks.Any(
              r =>
              (r.status == (int)Agp2pEnums.RepaymentStatusEnum.Unpaid ||
               r.status == (int)Agp2pEnums.RepaymentStatusEnum.OverTime) &&
              r.should_repay_time.Date <= DateTime.Today));
 }
Beispiel #13
0
 private static decimal QueryInvestAmount(li_projects proj, int userId)
 {
     return(proj.li_project_transactions.Where(
                ptr =>
                ptr.investor == userId &&
                ptr.type == (int)Agp2pEnums.ProjectTransactionTypeEnum.Invest &&
                ptr.status == (int)Agp2pEnums.ProjectTransactionStatusEnum.Success)
            .Sum(ptr => ptr.principal));
 }
Beispiel #14
0
 /// <summary>
 /// 获取募集进度
 /// </summary>
 /// <param name="projectId"></param>
 /// <returns></returns>
 protected string getInvestmentProgress(li_projects pro)
 {
     return
         (pro.GetInvestmentProgress(
              (total, projectAmount) =>
              new BasePage.ProjectInvestmentProgress {
         total = total, projectAmount = projectAmount
     })
          .GetInvestmentProgress() + "%");
 }
        protected string QueryRepaymentProgress(li_projects pro)
        {
            if (pro.status < (int)Agp2pEnums.ProjectStatusEnum.ProjectRepaying)
            {
                return("未开始还款");
            }
            var repayments = pro.li_repayment_tasks.Select(r => r.status).ToList();

            return(string.Format("{0}/{1}", repayments.Count(r => r != (int)Agp2pEnums.RepaymentStatusEnum.Unpaid && r != (int)Agp2pEnums.RepaymentStatusEnum.OverTime), repayments.Count));
        }
Beispiel #16
0
 private void PublishProject(li_projects project, bool publishdelay)
 {
     ChkAdminLevel("loan_financing", DTEnums.ActionEnum.Add.ToString());
     if (!string.IsNullOrEmpty(rblTag.SelectedValue))
     {
         project.tag = Utils.StrToInt(rblTag.SelectedValue, 0);
     }
     project.status       = publishdelay ? (int)Agp2pEnums.ProjectStatusEnum.FinancingAtTime : (int)Agp2pEnums.ProjectStatusEnum.Financing;
     project.publish_time = string.IsNullOrEmpty(txtPublishTime.Text.Trim())
         ? DateTime.Now
         : DateTime.Parse(txtPublishTime.Text.Trim());
     project.financing_day = Convert.ToInt16(txt_financing_day.Text.Trim());
     LqContext.SubmitChanges();
 }
Beispiel #17
0
 public static bool IsTicketProject(this li_projects p)
 {
     return(p.dt_article_category.call_index == "ypb" || p.dt_article_category.call_index == "ypl");
 }
 protected string CalcProjectProgress(li_projects project)
 {
     return((project.investment_amount / project.financing_amount).ToString("P2"));
 }
Beispiel #19
0
 public static bool IsNewbieProject1(this li_projects p)
 {
     return(p.dt_article_category.call_index == "newbie");
 }
Beispiel #20
0
 public static bool IsHuoqiProject(this li_projects p)
 {
     return(p.dt_article_category.call_index == "huoqi");
 }
Beispiel #21
0
 private void ShowProfitingClaimInfo(li_projects project)
 {
     isHuoqiProject          = true;
     rptClaimList.DataSource = project.li_claims_profiting.AsEnumerable();
     rptClaimList.DataBind();
 }
Beispiel #22
0
 private void ShowClaimsInfo(li_projects project)
 {
     isHuoqiProject          = false;
     rptClaimList.DataSource = project.li_claims.AsEnumerable();
     rptClaimList.DataBind();
 }
Beispiel #23
0
        public static string ApplyLoan(string loanerContent, string loanUsage, string sourceOfRepayment, decimal amount)
        {
            var context  = new Agp2pDataContext();
            var userInfo = GetUserInfoByLinq(context);

            HttpContext.Current.Response.TrySkipIisCustomErrors = true;
            if (userInfo == null)
            {
                HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                return("请先登录");
            }

            var project = context.li_projects.FirstOrDefault(p => p.li_risks.li_loaners.dt_users.id == userInfo.id &&
                                                             p.status < (int)Agp2pEnums.ProjectStatusEnum.FinancingApplicationChecking);

            if (project != null)
            {
                project.li_risks.loaner_content      = loanerContent;
                project.li_risks.loan_usage          = loanUsage;
                project.li_risks.source_of_repayment = sourceOfRepayment;
                project.financing_amount             = amount;
                project.status = (int)Agp2pEnums.ProjectStatusEnum.FinancingApplicationUncommitted;

                context.SubmitChanges();
                return("ok");
            }

            try
            {
                var risk = new li_risks()
                {
                    loaner              = userInfo.li_loaners.Single().id,
                    loaner_content      = loanerContent,
                    loan_usage          = loanUsage,
                    source_of_repayment = sourceOfRepayment,
                    last_update_time    = DateTime.Now
                };
                project = new li_projects()
                {
                    li_risks         = risk,
                    category_id      = 61,
                    financing_amount = amount,
                    user_name        = userInfo.user_name,
                    add_time         = DateTime.Now,
                    status           = (int)Agp2pEnums.ProjectStatusEnum.FinancingApplicationUncommitted,
                    repayment_type   = (int)Agp2pEnums.ProjectRepaymentTypeEnum.DengEr,
                    no   = "",
                    type = (int)Agp2pEnums.LoanTypeEnum.Personal
                };
                //项目编号
                var latestProject = context.li_projects.Where(p => p.category_id == project.category_id).OrderByDescending(p => p.id).FirstOrDefault();
                int prjectCount   = latestProject == null ? 0 : Utils.StrToInt(latestProject.title.Substring(latestProject.title.Length - 5), 0);
                project.title += new BLL.article_category().GetModel(project.category_id).call_index.ToUpper() + (prjectCount + 1).ToString("00000");
                context.li_risks.InsertOnSubmit(risk);
                context.li_projects.InsertOnSubmit(project);
                context.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return("ok");
        }
Beispiel #24
0
        void Page_Init(object sender, EventArgs e)
        {
            var user = GetUserInfoByLinq();

            if (user == null)
            {
                step = LoanApplyStep.Unlogin;
            }
            else
            {
                user_id   = user.id;
                user_name = user.user_name;
                //查看是否已为借款人
                Agp2pDataContext context = new Agp2pDataContext();
                loaner = context.li_loaners.SingleOrDefault(l => l.user_id == user.id);
                if (loaner == null)
                {
                    step          = LoanApplyStep.UnApplyAsLoaner;
                    loaner_name   = user.real_name;
                    loaner_mobile = user.mobile;
                }
                else
                {
                    //借款人信息
                    loaner_id  = loaner.id;
                    loaner_age = loaner.age.ToString();
                    loaner_educational_background = loaner.educational_background;
                    loaner_income          = loaner.income;
                    loaner_job             = loaner.job;
                    loaner_marital_status  = loaner.marital_status.ToString();
                    loaner_mobile          = loaner.dt_users.mobile;
                    loaner_name            = loaner.dt_users.real_name;
                    loaner_native_place    = loaner.native_place;
                    loaner_working_at      = loaner.working_at;
                    loaner_working_company = loaner.working_company;

                    if (loaner.status != (int)Agp2pEnums.LoanerStatusEnum.Normal)
                    {
                        step = LoanApplyStep.ApplyAsLoanerAuditting;
                        return;
                    }

                    //查看是否有在审批中的借款申请
                    project = context.li_projects.FirstOrDefault(p => p.li_risks.li_loaners.dt_users.id == user.id &&
                                                                 p.status <= (int)Agp2pEnums.ProjectStatusEnum.FinancingApplicationChecking);
                    if (project != null)
                    {
                        step = LoanApplyStep.ProjectAuditting; //显示正在审批步骤
                        project_category_id         = project.category_id;
                        project_amount              = (int)project.financing_amount;
                        project_loan_usage          = project.li_risks.loan_usage;
                        project_source_of_repayment = project.li_risks.source_of_repayment;
                        project_loaner_content      = project.li_risks.loaner_content;
                        quota_use = loaner.quota - (int)project.financing_amount;
                    }
                    else
                    {
                        //查询已审核通过的借款
                        var projectAll = context.li_projects.Where(p =>
                                                                   p.li_risks.li_loaners.dt_users.id == user.id &&
                                                                   (int)Agp2pEnums.ProjectStatusEnum.FinancingApplicationSuccess <= p.status &&
                                                                   p.status != (int)Agp2pEnums.ProjectStatusEnum.FinancingFail);
                        //查询可用额度
                        if (projectAll.Any())
                        {
                            step      = LoanApplyStep.ProjectApplyCompleted;
                            quota_use = loaner.quota - (int)projectAll.Sum(p => p.financing_amount);
                        }
                        else
                        {
                            step      = LoanApplyStep.UnApplyProject;
                            quota_use = loaner.quota;
                        }
                    }
                }
            }
        }
 protected DateTime GetRepaymentCompleteTime(li_projects liProjects)
 {
     return(liProjects.li_repayment_tasks.Max(r => r.should_repay_time));
 }
Beispiel #26
0
 /// <summary>
 /// 获取项目进度参数
 /// </summary>
 /// <param name="projectId"></param>
 /// <returns></returns>
 protected static ProjectInvestmentProgress GetProjectInvestmentProgress(li_projects pro)
 {
     return(pro.GetInvestmentProgress((total, projectAmount) => new ProjectInvestmentProgress {
         total = total, projectAmount = projectAmount
     }));
 }
Beispiel #27
0
        /// <summary>
        /// 重写虚方法,此方法将在Init事件前执行
        /// </summary>
        protected override void ShowPage()
        {
            Init += Project_Init; //加入IInit事件

            project_id = DTRequest.GetQueryInt("project_id");
            page       = Math.Max(1, DTRequest.GetQueryInt("page"));
            buyClaimId = DTRequest.GetQueryInt("buyClaimId");

            if (project_id <= 0)
            {
                return;
            }
            projectModel = context.li_projects.FirstOrDefault(p => p.id == project_id);
            if (projectModel == null)
            {
                //HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")));
                HttpContext.Current.Response.Redirect(linkurl("404"));
                return;
            }
            li_claims preBuyClaim = null;

            if (buyClaimId != 0)
            {
                preBuyClaim = context.li_claims.SingleOrDefault(c => c.id == buyClaimId);
                if (preBuyClaim == null)
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")));
                    return;
                }
            }
            Investable = new Investable {
                NeedTransferClaim = preBuyClaim, Project = projectModel
            };

            // 浏览次数 + 1
            projectModel.click += 1;
            context.SubmitChanges();

            var pr = GetProjectInvestmentProgress(projectModel);

            //剩余金额
            investmentBalance = pr.GetInvestmentBalance();
            //风控信息
            risk = projectModel.li_risks;
            //借款人
            loaner = risk.li_loaners;
            //借款人企业
            loaner_company = risk.li_loaners?.li_loaner_companies;
            //抵押物
            mortgages = projectModel.li_risks.li_risk_mortgage.Select(rm => rm.li_mortgages).ToList();

            invsetorCount      = projectModel.GetInvestedUserCount();
            projectSum         = projectModel.financing_amount;
            projectDescription = projectModel.title;

            //还款计划
            repayment_tasks = projectModel.li_repayment_tasks
                              .Where(task => task.only_repay_to == null)
                              .OrderBy(rt => rt.should_repay_time)
                              .ToList();

            if (Investable.NeedTransferClaim != null)
            {
                var ratio = Investable.NeedTransferClaim.principal / projectModel.financing_amount;
                repayment_tasks = repayment_tasks.Select(src => new li_repayment_tasks
                {
                    repay_principal = Math.Round(src.repay_principal * ratio, 2),
                    repay_interest  = Investable.NeedTransferClaim.Parent.GetProfitingSectionDays(src,
                                                                                                  (claimBeforeProfitingDays, claimProfitingDays, claimInvalidDays) =>
                                                                                                  Math.Round(src.repay_interest * ratio * claimInvalidDays / (claimBeforeProfitingDays + claimProfitingDays + claimInvalidDays), 2)),
                    should_repay_time = src.should_repay_time,
                    term = src.term
                }).ToList();
            }
        }