/// <summary> /// 投资合同 /// </summary> /// <returns></returns> public ActionResult InvestmentContract(int targetId) { ContractLogic _logic = new ContractLogic(); M_Contract_management model = _logic.GetContractListForApp(targetId).FirstOrDefault(); StringBuilder sb = new StringBuilder(model.contract_money); sb = sb.Replace("#loan_number#", model.loan_number.ToString()); //手机号*号处理 if (!string.IsNullOrEmpty(model.borrower_username) && model.borrower_username.Length == 11) { model.borrower_username = model.borrower_username.Substring(0, 3) + "****" + model.borrower_username.Substring(7); } sb = sb.Replace("#borrower_username#", model.borrower_username); //姓名 名字*号处理 if (!string.IsNullOrEmpty(model.borrower_name)) { model.borrower_name = model.borrower_name.Substring(0, 1) + "**"; } sb = sb.Replace("#borrower_name#", model.borrower_name); sb = sb.Replace("#borrower_id_card#", model.borrower_id_card); sb = sb.Replace("#lender_username#", model.lender_username); sb = sb.Replace("#lender_name#", model.lender_name); sb = sb.Replace("#lender_id_card#", model.lender_id_card); sb = sb.Replace("#surety_company_name#", model.surety_company_name); sb = sb.Replace("#guarantor_agent_usernqme#", model.guarantor_agent_usernqme); sb = sb.Replace("#contract_amount#", RMB.GetDecimal(model.contract_amount, 2, true).ToString()); BorrowLogic _borrowLogic = new BorrowLogic(); BorrowEntity borrowEntity = _borrowLogic.SelectBorrowDetail(targetId); sb = sb.Replace("#annual_interest_rate#", decimal.Parse(borrowEntity.annual_interest_rate.ToString()).ToString("0.00")); DateTime date1 = DateTime.Parse(borrowEntity.release_date.ToString()); DateTime date2 = DateTime.Parse(borrowEntity.repayment_date.ToString()); sb = sb.Replace("#release_date#", date1.ToString("yyyy-MM-dd")); sb = sb.Replace("#repayment_date#", date2.ToString("yyyy-MM-dd")); sb = sb.Replace("#days#", Utils.DateDiff("Day", date1, date2).ToString()); model.contract_money = sb.ToString(); //ViewBag.loan_number = model.loan_number; //ViewBag.borrower_username = model.borrower_username; //ViewBag.borrower_name = model.borrower_name; //ViewBag.guarantee_legal_representative = model.guarantee_legal_representative; //ViewBag.surety_company_name = model.surety_company_name; //ViewBag.StartTime = model.Start_Time; //ViewBag.EndTime = model.End_Time; //ViewBag.DurationDays = model.DurationTime; return(View(model)); }
public RMBTest() { _rmb = new RMB(machine.CPU); }
public ActionResult GetInvestList(int arp = 0, int repayment = 0, int account = 0, int schedule = 0, int status = 0, int project = 0, int sort = 0, int Page = 1, int pageSize = 12) { string TableName = "V_borrowing_target_addlist"; string strFields = "targetid,loan_number,borrowing_title,borrowing_thumbnail,annual_interest_rate,borrowing_balance,life_of_loan,unit_day,release_date,month_payment_date,repayment_date,end_time,minimum,company_name,guarantee_way_name,fundraising_amount,tender_state,start_time,sys_time,IsUse,companyid,indexorder,payment_options "; string fldName = "tender_state asc,indexorder desc,targetid desc"; switch (sort) { case 1: //期 限 fldName = "unit_day asc,life_of_loan desc,indexorder desc,tender_state asc,targetid desc"; break; case 2: //发标时间 fldName = "start_time desc,indexorder desc,tender_state asc,targetid desc"; break; case 3: //预期年化收益 fldName = "annual_interest_rate desc,indexorder desc,tender_state asc,targetid desc"; break; default: break; } string strWhere = " targetid >0 and tender_state>=2 and annual_interest_rate<=15 AND project_type_id!=6 ";//显示利率小于15 类型不是新手标的项目 DataTable dt = new DataTable(); if (arp > 0) { string[] sta = getarray(arp); if (sta.Length > 0) { if (sta[1].ToString() == "0") { strWhere += " and tender_state =" + sta[0].ToString() + " "; } else { strWhere += " and annual_interest_rate between " + sta[0].ToString() + " and " + sta[1].ToString() + " "; } } } else { strWhere += " and tender_state between 2 and 5 "; } if (repayment > 0) { string[] sta = getarray(repayment); if (sta.Length > 0) { //strWhere += " and DATEDIFF(MONTH,release_date,repayment_date) between " + sta[0].ToString() + " and " + sta[1].ToString() + " "; if (repayment == 5)//3个月以下 { strWhere += " AND (life_of_loan BETWEEN " + sta[0].ToString() + " AND " + sta[1].ToString() + " AND unit_day=1 OR life_of_loan <90 AND unit_day=3) "; } else { strWhere += " AND life_of_loan BETWEEN " + sta[0].ToString() + " AND " + sta[1].ToString() + " AND unit_day=1 "; } } } if (account > 0) { string[] sta = getarray(account); if (sta.Length > 0) { strWhere += " and borrowing_balance between " + int.Parse(sta[0].ToString()) * 10000 + " and " + int.Parse(sta[1].ToString()) * 10000 + " "; } } if (schedule > 0) { string[] sta = getarray(schedule); if (sta.Length > 0) { strWhere += " and fundraising_amount/borrowing_balance*100 between " + sta[0].ToString() + " and " + sta[1].ToString() + " "; } } if (status > 0) { string[] sta = getarray(status); if (sta.Length > 0) { strWhere += " and tender_state =" + sta[0].ToString() + " "; } } if (project > 0) { strWhere += " and project_type_id =" + project.ToString() + " "; } int RecordCount = 0; B_PublicPageList o = new B_PublicPageList(); dt = o.GetListByPage(TableName, strFields, fldName, pageSize, Page, strWhere, out RecordCount); //计算总页数 var pagecount = RecordCount / pageSize; if ((RecordCount % pageSize) > 0) { pagecount++; } StringBuilder json = new StringBuilder(); json.Append("{"); json.AppendFormat("\"ret\":1,\"pagecount\":{0},\"data\":[", pagecount); int _index = 0; if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { if (_index > 0) { json.Append(","); } _index++; json.Append("{"); json.AppendFormat("\"targetid\":{0}", dr["targetid"].ToString()); json.AppendFormat(",\"borrowing_title\":\"{0}\"", dr["borrowing_title"].ToString()); json.AppendFormat(",\"companyid\":\"{0}\"", dr["companyid"].ToString()); json.AppendFormat(",\"company_name\":\"{0}\"", dr["company_name"].ToString()); json.AppendFormat(",\"borrowing_thumbnail\":\"{0}\"", dr["borrowing_thumbnail"].ToString()); json.AppendFormat(",\"annual_interest_rate\":\"{0}\" ", decimal.Parse(dr["annual_interest_rate"].ToString()).ToString("0.0")); json.AppendFormat(",\"tender_state\":{0}", dr["tender_state"].ToString()); json.AppendFormat(",\"IsUse\":{0}", Convert.ToInt32(dr["IsUse"].ToString())); //借款期限 DateTime rpdt = DateTime.Parse(dr["repayment_date"].ToString()); DateTime rest = DateTime.Parse(dr["release_date"].ToString()); long diffdays = Utils.DateDiff("Day", DateTime.Parse(rest.ToString("yyyy-MM-dd")), DateTime.Parse(rpdt.ToString("yyyy-MM-dd"))); int unit_day = dr["unit_day"].ToInt(); json.AppendFormat(",\"jkqx\":\"{0}\"", dr["life_of_loan"].ToString()); if (unit_day == 3) { json.AppendFormat(",\"jkday\":\"天\""); } else if (unit_day == 1) { json.AppendFormat(",\"jkday\":\"个月\""); } //else if (diffdays < 60) //{ // int daysr = int.Parse(diffdays.ToString()); // if (daysr == 30 || daysr == 31) // { // json.AppendFormat(",\"jkday\":\"天\"", Utils.GetLife_of_loans(dr["life_of_loan"].ToString(), dr["unit_day"].ToString())); // } // else // { // json.AppendFormat(",\"jkqx\":\"{0}天\"", daysr); // } //} //else //{ // json.AppendFormat(",\"jkqx\":\"{0}\"", Utils.GetLife_of_loans(dr["life_of_loan"].ToString(), dr["unit_day"].ToString())); //} string str1 = ""; string str2 = ""; if (int.Parse(dr["tender_state"].ToString()) > 2) { str1 = Utils.Getpayment_options(int.Parse(dr["payment_options"].ToString())); } else { str2 = DateTime.Parse(dr["repayment_date"].ToString()).ToString("yyyy-MM-dd"); } json.AppendFormat(",\"payment_options\":\"{0}\"", str1); //还款方式 json.AppendFormat(",\"repayment_date\":\"{0}\"", str2); //还款日期 json.AppendFormat(",\"borrowing_balance\":\"{0}\"", RMB.GetWebConvertdisp(decimal.Parse(dr["borrowing_balance"].ToString()), 2, true)); decimal borrowing_balance = decimal.Parse(dr["borrowing_balance"].ToString()); decimal fundraising_amount = decimal.Parse(dr["fundraising_amount"].ToString()); decimal Percentage = fundraising_amount / borrowing_balance * 100; if (Percentage > 100.00M) { Percentage = 100.00M; } decimal Difference = borrowing_balance - fundraising_amount; if (Difference < 0.00M) { Percentage = 0.00M; } //还需金额 var needMoney = "0"; if (dr["tender_state"].ToString() == "2") { needMoney = RMB.GetWebConvertdisp(Difference, 2, true); } json.AppendFormat(",\"needMoney\":\"{0}\"", needMoney); json.AppendFormat(",\"Percentage\":\"{0}\"", Percentage.ToString("0.00")); //融资进度 json.AppendFormat(",\"minimum\":\"{0}\"", decimal.Parse(dr["minimum"].ToString()).ToString("0")); DateTime Endtime = DateTime.Parse(dr["end_time"].ToString()); DateTime Stime = DateTime.Parse(dr["start_time"].ToString()); DateTime online = DateTime.Parse(dr["sys_time"].ToString()); json.AppendFormat(",\"systime\":\"{0}\"", online.ToString("yyyy-MM-dd HH:mm:ss")); int operState = 0; if (dr["tender_state"].ToString() == "2") { if (Stime <= online && online > DateTime.Now) { //str.Append("<a href=\"javascript:void(0);\" class=\"grey_btn\">未开始</a>"); operState = 11; } else { if (DateTime.Compare(Endtime, DateTime.Now) <= 0 && Percentage < 100.00M) { //str.Append("<a href=\"javascript:void(0);\" class=\"grey_btn\">项目已结束</a>"); operState = 12; } else if (Percentage >= 100.00M) { //str.Append("<a href=\"javascript:void(0);\" class=\"grey_btn\">满标</a>"); operState = 13; } else { //str.Append("<a href=\"invest_borrow_" + dt.Rows[i]["targetid"].ToString() + ".html\" title=\"" + dt.Rows[i]["borrowing_title"].ToString() + "\">立即投资</a>"); operState = 14; } } } else if (dr["tender_state"].ToString() == "3") { //str.Append("<a href=\"invest_borrow_" + dt.Rows[i]["targetid"].ToString() + ".html\" title=\"" + dt.Rows[i]["borrowing_title"].ToString() + "\" class=\"grey_btn\">满标</a>"); operState = 3; } else if (dr["tender_state"].ToString() == "4") { //str.Append("<a href=\"invest_borrow_" + dt.Rows[i]["targetid"].ToString() + ".html\" title=\"" + dt.Rows[i]["borrowing_title"].ToString() + "\" class=\"grey_btn\">还款中</a>"); operState = 4; } else if (dr["tender_state"].ToString() == "5") { //str.Append("<a href=\"invest_borrow_" + dt.Rows[i]["targetid"].ToString() + ".html\" title=\"" + dt.Rows[i]["borrowing_title"].ToString() + "\" class=\"grey_btn\">已还清</a>"); operState = 5; } json.AppendFormat(",\"operState\":\"{0}\"", operState); var actFanXian = ef.hx_ActivityTable.Where(c => c.ActName == "12月投资立得返现奖励").OrderByDescending(c => c.ActEndtime).FirstOrDefault(); bool isShow = actFanXian == null ? false : TActivity_Luck.GetCurJiaoBiao(Convert.ToDateTime(actFanXian.ActStarttime), Convert.ToDateTime(actFanXian.ActEndtime), online, Convert.ToInt32(dr["tender_state"]), Convert.ToDateTime(dr["end_time"])); json.AppendFormat(",\"isShowJiaoBiao\":\"{0}\"", isShow); json.Append("}"); } } json.Append("]}"); return(Content(json.ToString(), "text/json")); }
//用户查看pdf(我的投资列表---合同 ---查看) 增加权限判断 //waitfor 将多处生成合同代码整合复用 public JsonResult MakePdf(int id) { string contractpath = ""; hx_Bid_records hbr = ef.hx_Bid_records.Where(p => p.bid_records_id == id).FirstOrDefault(); int uid = Utils.checkloginsessiontop(); if (hbr != null && hbr.investor_registerid == uid) { contractpath = hbr.contractpath; } else { return(Json(new PdfDetail { Path = "" }, JsonRequestBehavior.AllowGet)); } try { if (string.IsNullOrEmpty(contractpath) || !System.IO.File.Exists(Server.MapPath(contractpath))) { #region 生成合同 //生成用户合同 LogInfo.WriteLog("生成用户合同响应"); var sql = " SELECT targetid,loan_number, borrower_registerid,borrowing_title,annual_interest_rate,payment_options,borrowing_balance,life_of_loan,unit_day,release_date,month_payment_date,repayment_date,end_time,companyid,company_name,agent_name,agent_id_card,username,realname,iD_number,usertypes,CopName from V_borrowing_target_bonding where targetid=" + hbr.targetid; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { var str = UserContactText(Convert.ToInt32(hbr.targetid)); B_member_table ub = new B_member_table(); M_member_table up = new M_member_table(); // int uid = Utils.checkloginsessiontop(); // int uid = Convert.ToInt32(hbr.investor_registerid); string OrdId = hbr.OrdId.ToString(); LogInfo.WriteLog("是否有接收到信息: OrdId=" + OrdId + " uc:" + uid); //if (uid <= 0) //{ // Response.End(); //} up = ub.GetModel(uid); string fileName = "U_" + up.registerid.ToString() + "_" + dt.Rows[0]["targetid"].ToString() + "_" + dt.Rows[0]["loan_number"].ToString() + "_" + Utils.RndNum(3); string path = "/PDF/" + fileName + ".pdf"; M_Contract_management p = new M_Contract_management(); B_Contract_management o = new B_Contract_management(); sql = "select top 1 bid_records_id,investment_amount,value_date,investment_maturity from hx_Bid_records where targetid=" + hbr.targetid.ToString() + " and investor_registerid=" + uid.ToString() + " and OrdId ='" + OrdId + "' order by bid_records_id desc"; DataTable dtbid = DbHelperSQL.GET_DataTable_List(sql); DateTime dte = DateTime.Now; p.loan_number = decimal.Parse(dt.Rows[0]["loan_number"].ToString()); p.targetid = id; p.bid_records_id = int.Parse(dtbid.Rows[0]["bid_records_id"].ToString()); p.lender_username = up.username; p.lender_name = up.realname; p.lender_registerid = uid; p.lender_id_card = up.iD_number; p.lenders_account_name = ""; p.lender_bank_account = ""; p.lender_bank = ""; p.lenders_telephone = up.mobile; p.lenders_email = up.email; p.lendres_date_contract = dte; p.borrower_registerid = int.Parse(dt.Rows[0]["borrower_registerid"].ToString()); p.borrower_name = dt.Rows[0]["realname"].ToString(); if (dt.Rows[0]["usertypes"].ToString() == "2") { p.borrower_username = dt.Rows[0]["CopName"].ToString(); } else { p.borrower_username = dt.Rows[0]["username"].ToString(); } p.borrower_id_card = dt.Rows[0]["iD_number"].ToString(); p.borrower_account_name = dt.Rows[0]["realname"].ToString(); p.borrower_bank_account = ""; p.borrower_date_contract = dte.ToString(); p.borrower_bank = ""; p.surety_company_name = dt.Rows[0]["company_name"].ToString(); p.guarantor_agent = dt.Rows[0]["agent_name"].ToString(); p.guarantor_agent_usernqme = dt.Rows[0]["agent_name"].ToString(); p.guarantor_companyid = int.Parse(dt.Rows[0]["companyid"].ToString()); p.guarantor_agent_idate_contract = dte; p.witness_date_contract = dte; p.contract_money = str; p.contract_amount = decimal.Parse(dtbid.Rows[0]["investment_amount"].ToString()); p.createtime = dte; p.mode_payment = Utils.Getpayment_options(int.Parse(dt.Rows[0]["payment_options"].ToString())); p.contract_type = 1; StringBuilder sb = new StringBuilder(str); sb = sb.Replace("#loan_number#", p.loan_number.ToString()); sb = sb.Replace("#borrower_username#", p.borrower_username); sb = sb.Replace("#borrower_name#", p.borrower_name); sb = sb.Replace("#borrower_id_card#", p.borrower_id_card); sb = sb.Replace("#lender_username#", p.lender_username); sb = sb.Replace("#lender_name#", p.lender_name); sb = sb.Replace("#lender_id_card#", p.lender_id_card); sb = sb.Replace("#surety_company_name#", p.surety_company_name); sb = sb.Replace("#guarantor_agent_usernqme#", p.guarantor_agent_usernqme); sb = sb.Replace("#contract_amount#", RMB.GetDecimal(p.contract_amount, 2, true).ToString()); sb = sb.Replace("#annual_interest_rate#", decimal.Parse(dt.Rows[0]["annual_interest_rate"].ToString()).ToString("0.00")); DateTime date1 = DateTime.Parse(dtbid.Rows[0]["value_date"].ToString()); DateTime date2 = DateTime.Parse(dtbid.Rows[0]["investment_maturity"].ToString()); sb = sb.Replace("#release_date#", date1.ToString("yyyy-MM-dd")); sb = sb.Replace("#repayment_date#", date2.ToString("yyyy-MM-dd")); sb = sb.Replace("#days#", Utils.DateDiff("Day", date1, date2).ToString()); p.contract_money = sb.ToString(); p.contractpath = path; int cid = o.Add(p); if (cid > 0) { sql = "update hx_Bid_records set contractid=" + cid + ",contractpath= '" + p.contractpath + "' where bid_records_id=" + p.bid_records_id; DbHelperSQL.ExecuteSql(sql); if (HTMLToPDF(sb.ToString(), fileName)) { return(Json(new PdfDetail { Path = p.contractpath }, JsonRequestBehavior.AllowGet)); } } } #endregion } else { return(Json(new PdfDetail { Path = contractpath }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new PdfDetail { Path = "" }, JsonRequestBehavior.AllowGet)); } return(Json(new PdfDetail { Path = contractpath }, JsonRequestBehavior.AllowGet)); }
// GET: pdf public ActionResult Index() { string str = "pdf"; string sql = ""; int id = DNTRequest.GetInt("data", 0); string action = Utils.CheckSQLHtml(DNTRequest.GetString("action")); if (action == "PDF" && id > 0) {//生成某项目借款合同范本 sql = " SELECT targetid,loan_number, borrower_registerid,borrowing_title,annual_interest_rate,payment_options,borrowing_balance,life_of_loan,unit_day,release_date,month_payment_date,repayment_date,end_time,companyid,company_name,agent_name,agent_id_card,username,realname,iD_number,legal_representative,usertypes,CopName from V_borrowing_target_bonding where targetid=" + id; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { if (dt.Rows[0]["companyid"].ToString() == "6") { str = ContractText(6); } else { str = ContractText(1); } string fileName = "template" + dt.Rows[0]["targetid"].ToString() + dt.Rows[0]["loan_number"].ToString(); string path = "/PDF/" + fileName + ".pdf"; M_Contract_management p = new M_Contract_management(); B_Contract_management o = new B_Contract_management(); DateTime dte = DateTime.Parse(dt.Rows[0]["release_date"].ToString()); p.loan_number = decimal.Parse(dt.Rows[0]["loan_number"].ToString()); p.targetid = id; p.lender_username = ""; p.lender_registerid = 0; p.lender_id_card = ""; p.lenders_account_name = ""; p.lender_bank_account = ""; p.lender_bank = ""; p.lenders_telephone = ""; p.lenders_email = ""; p.lendres_date_contract = dte; p.borrower_registerid = int.Parse(dt.Rows[0]["borrower_registerid"].ToString()); p.borrower_name = dt.Rows[0]["realname"].ToString(); if (dt.Rows[0]["usertypes"].ToString() == "2") { p.borrower_username = dt.Rows[0]["CopName"].ToString(); } else { p.borrower_username = dt.Rows[0]["username"].ToString(); } p.borrower_id_card = dt.Rows[0]["iD_number"].ToString(); p.borrower_account_name = dt.Rows[0]["realname"].ToString(); p.borrower_bank_account = ""; p.borrower_date_contract = dte.ToString(); p.borrower_bank = ""; p.surety_company_name = dt.Rows[0]["company_name"].ToString(); p.guarantor_agent = dt.Rows[0]["agent_name"].ToString(); p.guarantor_companyid = int.Parse(dt.Rows[0]["companyid"].ToString()); p.guarantor_agent_idate_contract = dte; p.guarantor_agent_usernqme = dt.Rows[0]["legal_representative"].ToString(); p.witness_date_contract = dte; p.contract_money = str; p.contract_amount = decimal.Parse(dt.Rows[0]["borrowing_balance"].ToString()); p.createtime = dte; p.mode_payment = Utils.Getpayment_options(int.Parse(dt.Rows[0]["payment_options"].ToString())); p.contract_type = 0; sql = "select contract,targetid from Contract_management where contract_type=0 and targetid=" + id; DataTable dt1 = DbHelperSQL.GET_DataTable_List(sql); if (dt1.Rows.Count > 0) { p.contract = int.Parse(dt1.Rows[0]["contract"].ToString()); o.Update(p); } else { o.Add(p); } StringBuilder sb = new StringBuilder(str); sb = sb.Replace("#loan_number#", p.loan_number.ToString()); sb = sb.Replace("#borrower_username#", p.borrower_username); sb = sb.Replace("#borrower_name#", p.borrower_name); sb = sb.Replace("#borrower_id_card#", p.borrower_id_card); sb = sb.Replace("#lender_username#", p.lender_username); sb = sb.Replace("#lender_name#", p.lender_name); sb = sb.Replace("#lender_id_card#", p.lender_id_card); sb = sb.Replace("#surety_company_name#", p.surety_company_name); sb = sb.Replace("#guarantor_agent_usernqme#", p.guarantor_agent_usernqme); sb = sb.Replace("#contract_amount#", RMB.GetDecimal(p.contract_amount, 2, true).ToString()); sb = sb.Replace("#annual_interest_rate#", decimal.Parse(dt.Rows[0]["annual_interest_rate"].ToString()).ToString("0.00")); DateTime date1 = DateTime.Parse(dt.Rows[0]["release_date"].ToString()); DateTime date2 = DateTime.Parse(dt.Rows[0]["repayment_date"].ToString()); sb = sb.Replace("#release_date#", date1.ToString("yyyy-MM-dd")); sb = sb.Replace("#repayment_date#", date2.ToString("yyyy-MM-dd")); sb = sb.Replace("#days#", Utils.DateDiff("Day", date1, date2).ToString()); /* * * string expr = @"#+([a-zA-Z0-9_\u4e00-\u9fa5]*)+#"; * MatchCollection mc = Regex.Matches(sb.ToString(), expr); * * string[] array = new string[mc.Count]; * array.SetValue(p.loan_number.ToString(), 0); * array.SetValue(p.borrower_username, 1); * array.SetValue(p.borrower_name, 2); * array.SetValue(p.borrower_id_card, 3); * array.SetValue(p.lender_username, 4); * array.SetValue(p.lender_name, 5); * array.SetValue(p.lender_id_card, 6); * array.SetValue(p.surety_company_name, 7); * array.SetValue(p.guarantor_agent_usernqme, 8); * array.SetValue("", 9); * array.SetValue(dt.Rows[0]["annual_interest_rate"].ToString(), 10); * DateTime date1 = DateTime.Parse(dt.Rows[0]["release_date"].ToString()); * DateTime date2 = DateTime.Parse(dt.Rows[0]["repayment_date"].ToString()); * array.SetValue(date1.ToString("yyyy-MM-dd"), 11); * array.SetValue(date2.ToString("yyyy-MM-dd"), 12); * array.SetValue(Utils.DateDiff("Day",date1,date2).ToString(), 13); * * array.SetValue(p.borrower_name, 14); * array.SetValue(p.borrower_id_card, 15); * array.SetValue("", 16); * array.SetValue("", 17); * array.SetValue(p.surety_company_name, 18); * array.SetValue(p.guarantor_agent_usernqme, 19); * * for (int i = 0; i < mc.Count; i++) * { * sb = sb.Replace(mc[i].ToString(), array[i].ToString()); * } */ if (HTMLToPDF(sb.ToString(), fileName)) { json = @" {""rs"" : ""y"", ""datainfo"" : ""add""}"; json = json.Replace("add", path); Response.Write(json); Response.End(); } else { json = @" {""rs"" : ""n"", ""datainfo"" : ""PDF合同生成失败""}"; Response.Write(json); Response.End(); } } return(Content(str)); //return View(); } else if (action == "UserPDF" && id > 0) { //生成用户合同 sql = " SELECT targetid,loan_number, borrower_registerid,borrowing_title,annual_interest_rate,payment_options,borrowing_balance,life_of_loan,unit_day,release_date,month_payment_date,repayment_date,end_time,companyid,company_name,agent_name,agent_id_card,username,realname,iD_number,usertypes,CopName from V_borrowing_target_bonding where targetid=" + id; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { str = UserContactText(id); B_member_table ub = new B_member_table(); M_member_table up = new M_member_table(); int uid = Utils.checkloginsessiontop(); //int uid = 9; if (uid <= 0) { Response.Redirect("/login.html"); Response.End(); } up = ub.GetModel(uid); string fileName = "U_" + up.registerid.ToString() + "_" + dt.Rows[0]["targetid"].ToString() + "_" + dt.Rows[0]["loan_number"].ToString() + "_" + Utils.RndNum(3); string path = "/PDF/" + fileName + ".pdf"; M_Contract_management p = new M_Contract_management(); B_Contract_management o = new B_Contract_management(); sql = "select top 1 bid_records_id,investment_amount,value_date,investment_maturity from hx_Bid_records where targetid=" + id.ToString() + " and investor_registerid=" + uid.ToString() + " order by bid_records_id desc"; DataTable dtbid = DbHelperSQL.GET_DataTable_List(sql); DateTime dte = DateTime.Now; p.loan_number = decimal.Parse(dt.Rows[0]["loan_number"].ToString()); p.targetid = id; p.bid_records_id = int.Parse(dtbid.Rows[0]["bid_records_id"].ToString()); p.lender_username = up.username; p.lender_name = up.realname; p.lender_registerid = uid; p.lender_id_card = up.iD_number; p.lenders_account_name = ""; p.lender_bank_account = ""; p.lender_bank = ""; p.lenders_telephone = up.mobile; p.lenders_email = up.email; p.lendres_date_contract = dte; p.borrower_registerid = int.Parse(dt.Rows[0]["borrower_registerid"].ToString()); p.borrower_name = dt.Rows[0]["realname"].ToString(); if (dt.Rows[0]["usertypes"].ToString() == "2") { p.borrower_username = dt.Rows[0]["CopName"].ToString(); } else { p.borrower_username = dt.Rows[0]["username"].ToString(); } p.borrower_id_card = dt.Rows[0]["iD_number"].ToString(); p.borrower_account_name = dt.Rows[0]["realname"].ToString(); p.borrower_bank_account = ""; p.borrower_date_contract = dte.ToString(); p.borrower_bank = ""; p.surety_company_name = dt.Rows[0]["company_name"].ToString(); p.guarantor_agent = dt.Rows[0]["agent_name"].ToString(); p.guarantor_agent_usernqme = dt.Rows[0]["agent_name"].ToString(); p.guarantor_companyid = int.Parse(dt.Rows[0]["companyid"].ToString()); p.guarantor_agent_idate_contract = dte; p.witness_date_contract = dte; p.contract_money = str; p.contract_amount = decimal.Parse(dtbid.Rows[0]["investment_amount"].ToString()); p.createtime = dte; p.mode_payment = Utils.Getpayment_options(int.Parse(dt.Rows[0]["payment_options"].ToString())); p.contract_type = 1; StringBuilder sb = new StringBuilder(str); sb = sb.Replace("#loan_number#", p.loan_number.ToString()); sb = sb.Replace("#borrower_username#", p.borrower_username); sb = sb.Replace("#borrower_name#", p.borrower_name); sb = sb.Replace("#borrower_id_card#", p.borrower_id_card); sb = sb.Replace("#lender_username#", p.lender_username); sb = sb.Replace("#lender_name#", p.lender_name); sb = sb.Replace("#lender_id_card#", p.lender_id_card); sb = sb.Replace("#surety_company_name#", p.surety_company_name); sb = sb.Replace("#guarantor_agent_usernqme#", p.guarantor_agent_usernqme); sb = sb.Replace("#contract_amount#", RMB.GetDecimal(p.contract_amount, 2, true).ToString()); sb = sb.Replace("#annual_interest_rate#", decimal.Parse(dt.Rows[0]["annual_interest_rate"].ToString()).ToString("0.00")); DateTime date1 = DateTime.Parse(dtbid.Rows[0]["value_date"].ToString()); DateTime date2 = DateTime.Parse(dtbid.Rows[0]["investment_maturity"].ToString()); sb = sb.Replace("#release_date#", date1.ToString("yyyy-MM-dd")); sb = sb.Replace("#repayment_date#", date2.ToString("yyyy-MM-dd")); sb = sb.Replace("#days#", Utils.DateDiff("Day", date1, date2).ToString()); p.contract_money = sb.ToString(); p.contractpath = path; int cid = o.Add(p); if (cid > 0) { sql = "update hx_Bid_records set contractid=" + cid + ",contractpath= '" + p.contractpath + "' where bid_records_id=" + p.bid_records_id; DbHelperSQL.ExecuteSql(sql); if (HTMLToPDF(sb.ToString(), fileName)) { json = @" {""rs"" : ""y"", ""datainfo"" : ""/usercenter/myinvest.html""}"; Response.Write(json); Response.End(); } else { json = @" {""rs"" : ""n"", ""datainfo"" : ""PDF合同生成失败""}"; Response.Write(json); Response.End(); } } } } else if (action == "MUserPDF" && id > 0) { //生成用户合同 LogInfo.WriteLog("生成用户合同响应"); sql = " SELECT targetid,loan_number, borrower_registerid,borrowing_title,annual_interest_rate,payment_options,borrowing_balance,life_of_loan,unit_day,release_date,month_payment_date,repayment_date,end_time,companyid,company_name,agent_name,agent_id_card,username,realname,iD_number,usertypes,CopName from V_borrowing_target_bonding where targetid=" + id; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { str = UserContactText(id); B_member_table ub = new B_member_table(); M_member_table up = new M_member_table(); // int uid = Utils.checkloginsessiontop(); int uid = DNTRequest.GetInt("uc", 0); string OrdId = DNTRequest.GetString("OrdId"); LogInfo.WriteLog("是否有接收到信息: OrdId=" + OrdId + " uc:" + uid); //int uid = 9; if (uid <= 0) { Response.End(); } up = ub.GetModel(uid); string fileName = "U_" + up.registerid.ToString() + "_" + dt.Rows[0]["targetid"].ToString() + "_" + dt.Rows[0]["loan_number"].ToString() + "_" + Utils.RndNum(3); string path = "/PDF/" + fileName + ".pdf"; M_Contract_management p = new M_Contract_management(); B_Contract_management o = new B_Contract_management(); sql = "select top 1 bid_records_id,investment_amount,value_date,investment_maturity from hx_Bid_records where targetid=" + id.ToString() + " and investor_registerid=" + uid.ToString() + " and OrdId ='" + OrdId + "' order by bid_records_id desc"; DataTable dtbid = DbHelperSQL.GET_DataTable_List(sql); DateTime dte = DateTime.Now; p.loan_number = decimal.Parse(dt.Rows[0]["loan_number"].ToString()); p.targetid = id; p.bid_records_id = int.Parse(dtbid.Rows[0]["bid_records_id"].ToString()); p.lender_username = up.username; p.lender_name = up.realname; p.lender_registerid = uid; p.lender_id_card = up.iD_number; p.lenders_account_name = ""; p.lender_bank_account = ""; p.lender_bank = ""; p.lenders_telephone = up.mobile; p.lenders_email = up.email; p.lendres_date_contract = dte; p.borrower_registerid = int.Parse(dt.Rows[0]["borrower_registerid"].ToString()); p.borrower_name = dt.Rows[0]["realname"].ToString(); if (dt.Rows[0]["usertypes"].ToString() == "2") { p.borrower_username = dt.Rows[0]["CopName"].ToString(); } else { p.borrower_username = dt.Rows[0]["username"].ToString(); } p.borrower_id_card = dt.Rows[0]["iD_number"].ToString(); p.borrower_account_name = dt.Rows[0]["realname"].ToString(); p.borrower_bank_account = ""; p.borrower_date_contract = dte.ToString(); p.borrower_bank = ""; p.surety_company_name = dt.Rows[0]["company_name"].ToString(); p.guarantor_agent = dt.Rows[0]["agent_name"].ToString(); p.guarantor_agent_usernqme = dt.Rows[0]["agent_name"].ToString(); p.guarantor_companyid = int.Parse(dt.Rows[0]["companyid"].ToString()); p.guarantor_agent_idate_contract = dte; p.witness_date_contract = dte; p.contract_money = str; p.contract_amount = decimal.Parse(dtbid.Rows[0]["investment_amount"].ToString()); p.createtime = dte; p.mode_payment = Utils.Getpayment_options(int.Parse(dt.Rows[0]["payment_options"].ToString())); p.contract_type = 1; StringBuilder sb = new StringBuilder(str); sb = sb.Replace("#loan_number#", p.loan_number.ToString()); sb = sb.Replace("#borrower_username#", p.borrower_username); sb = sb.Replace("#borrower_name#", p.borrower_name); sb = sb.Replace("#borrower_id_card#", p.borrower_id_card); sb = sb.Replace("#lender_username#", p.lender_username); sb = sb.Replace("#lender_name#", p.lender_name); sb = sb.Replace("#lender_id_card#", p.lender_id_card); sb = sb.Replace("#surety_company_name#", p.surety_company_name); sb = sb.Replace("#guarantor_agent_usernqme#", p.guarantor_agent_usernqme); sb = sb.Replace("#contract_amount#", RMB.GetDecimal(p.contract_amount, 2, true).ToString()); sb = sb.Replace("#annual_interest_rate#", decimal.Parse(dt.Rows[0]["annual_interest_rate"].ToString()).ToString("0.00")); DateTime date1 = DateTime.Parse(dtbid.Rows[0]["value_date"].ToString()); DateTime date2 = DateTime.Parse(dtbid.Rows[0]["investment_maturity"].ToString()); sb = sb.Replace("#release_date#", date1.ToString("yyyy-MM-dd")); sb = sb.Replace("#repayment_date#", date2.ToString("yyyy-MM-dd")); sb = sb.Replace("#days#", Utils.DateDiff("Day", date1, date2).ToString()); p.contract_money = sb.ToString(); p.contractpath = path; int cid = o.Add(p); if (cid > 0) { sql = "update hx_Bid_records set contractid=" + cid + ",contractpath= '" + p.contractpath + "' where bid_records_id=" + p.bid_records_id; DbHelperSQL.ExecuteSql(sql); if (HTMLToPDF(sb.ToString(), fileName)) { json = @" {""rs"" : ""y"", ""datainfo"" : ""/usercenter/myinvest.html""}"; Response.Write(json); Response.End(); } else { json = @" {""rs"" : ""n"", ""datainfo"" : ""PDF合同生成失败""}"; Response.Write(json); Response.End(); } } } } return(Content(str));//权限? //return View(); }
/// <summary> /// 讲系统标签格式化 /// </summary> /// <param name="specialData"></param> /// <param name="strWithMark"></param> /// <returns></returns> public string DoWithSystemMark(object specialData, string strWithMark) { string text = ""; string text2 = ""; if (!string.IsNullOrEmpty(strWithMark)) { if (specialData != null && specialData.GetType() == typeof(string) && specialData.ToString().StartsWith("/Date(") && specialData.ToString().EndsWith(")/")) { string s = specialData.ToString().Substring(6, specialData.ToString().Length - 8); specialData = new DateTime(1970, 1, 1).AddMilliseconds((double)long.Parse(s)).ToLocalTime(); } if (string.Compare(strWithMark, "visual", true) == 0) { text = (string.IsNullOrEmpty(ObjectExtensions.ToStr(specialData)) ? "display:none;" : ""); } else if (string.Compare(strWithMark, "yn", true) == 0) { text = ((ObjectExtensions.ToInt(specialData) == 1) ? "是" : "否"); } else if (string.Compare(strWithMark, "bar", true) == 0) { text = Server.UrlEncode(specialData.ToString()); } else if (string.Compare(strWithMark, "qr", true) == 0) { text = Server.UrlEncode(specialData.ToString()); } else if (string.Compare(strWithMark, "img", true) == 0) { if (specialData == null) { return(""); } string text3 = ObjectExtensions.ToStr(specialData); if (!text3.StartsWith("/")) { text3 = "/" + text3; } text = "<img src='" + text3 + "' />"; } else if (string.Compare(strWithMark, "rmb", true) == 0) { text = RMB.Convert(DataHelper.ConvertValue <double>(specialData)); } else if (strWithMark.Length == 2 && strWithMark[0] == 'C' && !string.IsNullOrEmpty(text2)) { strWithMark = "N" + strWithMark[1]; text = text2 + string.Format("{0:" + strWithMark + "}", specialData); } else { text = string.Format("{0:" + strWithMark + "}", specialData); } } else { text = ObjectExtensions.ToStr(specialData); } return(text); }