示例#1
0
        public DataTable GetByUserForUserActivity(int userId)
        {
            BorrowLogic   borrowLogic = new BorrowLogic();
            List <Borrow> borrowList  = borrowLogic.getByUserForUserActivity(userId);


            return(AppUtil.ToDataTable(borrowList));
        }
示例#2
0
        public DataTable GetAllReserved()
        {
            BorrowLogic   borrowLogic = new BorrowLogic();
            List <Borrow> borrowList  = borrowLogic.getAllReserved();


            return(AppUtil.ToDataTable(borrowList));
        }
示例#3
0
        /// <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));
        }
示例#4
0
        public DataTable deleteBorrowItem(int borrowId)
        {
            BorrowLogic borrowLogic = new BorrowLogic();
            bool        result      = borrowLogic.deleteBorrowItem(borrowId);

            IdAndValue x = createBoolIdAndValue(result);

            //sneaky list IdAndValue of 1 item
            List <IdAndValue> idValList = new List <IdAndValue>();

            idValList.Add(x);

            return(AppUtil.ToDataTable(idValList));
        }
示例#5
0
        public DataTable updateMediaForReturn(int borrowId, int lateFee)
        {
            BorrowLogic borrowLogic = new BorrowLogic();
            bool        result      = borrowLogic.updateMediaForReturn(borrowId, lateFee);

            IdAndValue x = createBoolIdAndValue(result);

            //sneaky list IdAndValue of 1 item
            List <IdAndValue> idValList = new List <IdAndValue>();

            idValList.Add(x);

            return(AppUtil.ToDataTable(idValList));
        }
示例#6
0
        public DataTable insertForCheckOutMedia(int userId, int mediaId)
        {
            BorrowLogic borrowLogic = new BorrowLogic();
            bool        result      = borrowLogic.insertForCheckOutMedia(userId, mediaId);

            IdAndValue x = createBoolIdAndValue(result);

            //sneaky list IdAndValue of 1 item
            List <IdAndValue> idValList = new List <IdAndValue>();

            idValList.Add(x);

            return(AppUtil.ToDataTable(idValList));
        }
示例#7
0
        public DataTable getMediaExistsBorrowLogic(int mediaId)
        {
            BorrowLogic borrowLogic = new BorrowLogic();
            bool        result      = borrowLogic.getMediaExists(mediaId);

            IdAndValue x = createBoolIdAndValue(result);

            //sneaky list IdAndValue of 1 item
            List <IdAndValue> idValList = new List <IdAndValue>();

            idValList.Add(x);

            return(AppUtil.ToDataTable(idValList));
        }
示例#8
0
 //Initialize Global Variables
 public TabViewControl(UserModel user)
 {
     InitializeComponent();
     localDate    = DateTime.Now;
     currentTime  = localDate.GetDateTimeFormats()[0].ToString().Replace("/", "-");
     userID       = user.userID;
     userLevel    = user.userLevel;
     dataSet      = new DataSet();
     adminLogic   = new AdminLogic();
     search       = new SearchLogic();
     borrowLogic  = new BorrowLogic();
     reserveLogic = new ReserveLogic();
     returnLogic  = new ReturnLogic();
     defaultBook  = new BookModel();
     //user Level has being passed from the login screen
     changeVisibilityDependingOnThe(userLevel);
 }
示例#9
0
 public BorrowController(BorrowLogic logic)
 {
     _logic = logic;
 }
示例#10
0
        public ActionResult Index(RequestParam <RequestTender> reqst)
        {
            LoggerHelper.Info(JsonHelper.Entity2Json(reqst));
            ResultInfo <string> res = new ResultInfo <string>("99999");
            var usrId    = ConvertHelper.ParseValue(reqst.body.userId, 0);
            var targetId = ConvertHelper.ParseValue(reqst.body.targetId, 0);
            var bds      = string.Empty;

            B_borrowing_target b_borrowing_target = new B_borrowing_target();
            var            m_borrowing_target     = b_borrowing_target.GetModel(targetId);
            B_member_table b_member_table         = new B_member_table();
            var            m_member_table         = b_member_table.GetModel(usrId);


            if (m_borrowing_target == null || m_member_table == null)
            {
                res.code    = "1000000010";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            if (!string.IsNullOrWhiteSpace(reqst.body.bonusIds))
            {
                bds = reqst.body.bonusIds;
            }
            if (!string.IsNullOrWhiteSpace(reqst.body.addRateIds))
            {
                if (!string.IsNullOrWhiteSpace(bds))
                {
                    bds += ",";
                }
                bds = reqst.body.addRateIds;
            }
            var         investAmount = ConvertHelper.ParseValue(reqst.body.investAmount, 0M);
            BorrowLogic _logic       = new BorrowLogic();
            var         ent          = _logic.SelectBorrowDetail(targetId);

            if (usrId <= 0)
            {
                res.code    = "1000000015";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            if (targetId <= 0)
            {
                res.code    = "1000000014";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            if (investAmount < 100)
            {
                res.code    = "2000000000";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            if (m_borrowing_target.minimum > 0 && investAmount < m_borrowing_target.minimum)
            {
                res.code    = "2000000008";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            if (m_borrowing_target.maxmum > 0 && investAmount > m_borrowing_target.maxmum)
            {
                res.code    = "2000000009";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }

            if (reqst.body.typeId == 6)//新手标判定
            {
                if (!string.IsNullOrWhiteSpace(bds))
                {
                    res.code    = "2000000010";
                    res.message = Settings.Instance.GetErrorMsg(res.code);
                    return(View(res));
                }
                if (m_member_table.useridentity != 5)
                {
                    if (Convert.ToDateTime(m_member_table.Registration_time.ToString("yyyy-MM-dd")).AddDays(30) < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")))
                    {
                        res.code    = "2000000011";
                        res.message = Settings.Instance.GetErrorMsg(res.code);
                        return(View(res));
                    }
                    B_Bid_records b_Bid_records = new B_Bid_records();
                    int           investedCount = b_Bid_records.GetInvestCount(reqst.body.userId, reqst.body.targetId);
                    if (investedCount >= 3)
                    {
                        res.code    = "2000000012";
                        res.message = Settings.Instance.GetErrorMsg(res.code);
                        return(View(res));
                    }
                    if (ent.start_time != null && ent.start_time.Value < Convert.ToDateTime("2016-12-01 00:00:00"))
                    {
                        res.code    = "2999999999";
                        res.message = Settings.Instance.GetErrorMsg(res.code);
                        return(View(res));
                    }
                    if (ent.project_type_id != null && ent.project_type_id.Value != 6)
                    {
                        res.code    = "2999999999";
                        res.message = Settings.Instance.GetErrorMsg(res.code);
                        return(View(res));
                    }
                }
            }
            try
            {
                decimal        vocheramttemp = GetUseRewards(bds, usrId);
                B_member_table b             = new B_member_table();
                M_member_table user          = new M_member_table();
                user = b.GetModel(reqst.body.userId);
                InvestmentParameters mp = new InvestmentParameters
                {
                    Amount            = investAmount,
                    Circle            = ConvertHelper.ParseValue(ent.life_of_loan, 0),
                    CircleType        = ConvertHelper.ParseValue(ent.unit_day, 0),
                    NominalYearRate   = ConvertHelper.ParseValue(ent.annual_interest_rate, 0D),
                    OverheadsRate     = 0f,
                    RepaymentMode     = ConvertHelper.ParseValue(ent.payment_options, 0),
                    RewardRate        = 0f,
                    IsThirtyDayMonth  = false,
                    InvestDate        = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")),
                    ReleaseDate       = DateTime.Parse(ent.release_date.ToString()).ToString("yyyy-MM-dd"),
                    Investmentenddate = DateTime.Parse(DateTime.Parse(ent.repayment_date.ToString()).ToString("yyyy-MM-dd")),
                    Payinterest       = ConvertHelper.ParseValue(ent.month_payment_date, 0),
                    InvestObject      = 1
                };
                //追加  加息券
                if (!string.IsNullOrWhiteSpace(bds))
                {
                    B_UserAct bUserAct     = new B_UserAct();
                    var       addRateModel = bUserAct.GetAddRateModel(bds);
                    if (addRateModel != null)// add rate of year
                    {
                        mp.NominalYearRate = mp.NominalYearRate + Convert.ToDouble(addRateModel.Amt.Value);
                    }
                }
                List <InvestmentReceiveRecordInfo> records = InvestCalculator.CalculateReceiveRecord(mp);
                StringBuilder sb = new StringBuilder("");
                if (records != null && records.Any())
                {
                    int i = 1;
                    foreach (var item in records)
                    {
                        sb.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7}|", i, item.interestvalue_date, item.NominalReceiveDate, item.Balance, item.Interest, item.Principal, item.TotalInstallments, item.TotalDays);
                        i = i + 1;
                    }
                }
                var     orderId      = Settings.Instance.OrderCode;
                var     frozenidNo   = Settings.Instance.OrderCode;
                decimal frozenAmount = 0.00M;

                var xf = ((records != null && records.Any()) ? records.Sum(t => t.Interest) : 0M);
                //LoggerHelper.Error("利息:" + xf + " ------- " + JsonHelper.Entity2Json(records));
                string invitationCode = string.Empty;
                using (InvitationLogic invitationLogic = new InvitationLogic())
                {
                    var invitationModel = invitationLogic.GetUserInvited(usrId);
                    if (invitationModel != null)
                    {
                        invitationCode = invitationModel.invcode;
                    }
                }
                var resVal = _logic.SubmitTender(usrId, targetId, investAmount, bds, invitationCode, orderId
                                                 , xf, frozenidNo
                                                 , investAmount - frozenAmount
                                                 , ((records != null && records.Any()) ? records.Count : 0), sb.ToString());
                if (resVal < 200)
                {
                    switch (resVal)
                    {
                    case -100:
                    {
                        res.code = "2000000001";
                    }
                    break;

                    case -101:
                    {
                        res.code = "2000000008";
                    }
                    break;

                    case -200:
                    {
                        res.code = "2000000002";
                    }
                    break;

                    case -300:
                    {
                        res.code = "2000000003";
                    }
                    break;

                    case -400:
                    {
                        res.code = "2000000004";
                    }
                    break;

                    case -500:
                    {
                        res.code = "2000000007";
                    }
                    break;

                    case -600:
                    {
                        res.code = "2000000006";
                    }
                    break;
                    }
                }
                else
                {
                    LoggerHelper.Error("SubmitTender!!!!!!!!!!!!!!!投资开始");
                    LoggerHelper.Info("投资开始");
                    #region 投资成功
                    M_InitiativeTender Mt = new M_InitiativeTender();
                    Mt.Version       = "20";
                    Mt.CmdId         = "InitiativeTender";
                    Mt.MerCustId     = Settings.Instance.MerCustId;
                    Mt.OrdId         = orderId;
                    Mt.OrdDate       = mp.InvestDate.ToString("yyyyMMdd");
                    Mt.TransAmt      = investAmount.ToString("0.00");
                    Mt.UsrCustId     = user.UsrCustId;
                    Mt.MaxTenderRate = "0.20";

                    TenderJosnPro mtp = new TenderJosnPro();
                    mtp.BorrowerCustId = b.GetModel(ConvertHelper.ParseValue(ent.borrower_registerid, 0)).UsrCustId;
                    mtp.BorrowerAmt    = investAmount.ToString("0.00");

                    // mtp.BorrowerRate = decimal.Parse( dt.Rows[0]["loan_management_fee"].ToString()).ToString("0.00");

                    mtp.BorrowerRate = "1.00"; //风控范围

                    mtp.ProId = targetId.ToString();

                    Mt.BorrowerDetails = "[" + FastJSON.toJOSN(mtp) + "]";

                    #region 此处判断优惠类型

                    #endregion
                    Mt.IsFreeze = "Y";

                    Mt.FreezeOrdId = frozenidNo;

                    Mt.RetUrl = Settings.Instance.GetCallbackUrl("/MemberCenter/InvestSubmit/CallbackRetUrl");

                    Mt.BgRetUrl = Settings.Instance.GetCallbackUrl("/MemberCenter/InvestSubmit/CallbackBgRetUrl");

                    if (!string.IsNullOrWhiteSpace(reqst.body.bonusIds))
                    {
                        Mt.MerPriv = bds;
                        TenderAccPro ret = new TenderAccPro();
                        ret.AcctId    = ChuanglitouP2P.Common.Utils.GetMERDT();
                        ret.VocherAmt = vocheramttemp.ToString("0.00");
                        Mt.ReqExt     = "{" + "\"Vocher\":" + FastJSON.toJOSN(ret) + "}";
                    }
                    else
                    {
                        Mt.MerPriv = reqst.body.addRateIds;
                    }

                    //append device code to comment fields for make sure it be transfered back
                    string temp = Mt.MerPriv;
                    AppendDeviceFlag(reqst.header.appId.ToString(), ref temp);
                    Mt.MerPriv = temp;

                    LoggerHelper.Info("优惠券使用的id:" + bds);
                    StringBuilder chkVal = new StringBuilder();
                    chkVal.Append(Mt.Version);
                    chkVal.Append(Mt.CmdId);
                    chkVal.Append(Mt.MerCustId);
                    chkVal.Append(Mt.OrdId);
                    chkVal.Append(Mt.OrdDate);
                    chkVal.Append(Mt.TransAmt);
                    chkVal.Append(Mt.UsrCustId);
                    chkVal.Append(Mt.MaxTenderRate);
                    chkVal.Append(Mt.BorrowerDetails);
                    chkVal.Append(Mt.IsFreeze);
                    chkVal.Append(Mt.FreezeOrdId);
                    chkVal.Append(Mt.RetUrl);
                    chkVal.Append(Mt.BgRetUrl);
                    chkVal.Append(Mt.MerPriv);
                    chkVal.Append(Mt.ReqExt);

                    string chkv = chkVal.ToString();
                    LoggerHelper.Info("投资:" + chkv);
                    //私钥文件的位置(这里是放在了站点的根目录下)
                    string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.MerPr;
                    //需要指定提交字符串的长度
                    int           len        = Encoding.UTF8.GetBytes(chkv).Length;
                    StringBuilder sbChkValue = new StringBuilder(256);
                    //加签
                    int str = DllInterop.SignMsg(Settings.Instance.MerId, merKeyFile, chkv, len, sbChkValue);

                    LoggerHelper.Info(str);

                    Mt.ChkValue = sbChkValue.ToString();
                    if (str == 0)
                    {
                        var strz = new StringBuilder();

                        strz.Append(" <form id=\"formauto\" name=\"formauto\"  action=\"" + Settings.Instance.ChinapnrUrl + "\" method=\"post\">");

                        strz.Append("<input id=\"Version\"  name=\"Version\"  type=\"hidden\"  value=\"" + Mt.Version + "\" />");

                        strz.Append("<input id=\"CmdId\"  name=\"CmdId\"    type=\"hidden\"  value=\"" + Mt.CmdId + "\" />");

                        strz.Append("<input id=\"MerCustId\" name=\"MerCustId\"   type=\"hidden\"  value=\"" + Mt.MerCustId + "\" />");

                        strz.Append("<input id=\"OrdId\" name=\"OrdId\" type=\"hidden\"  value=\"" + Mt.OrdId + "\" />");

                        strz.Append("<input id=\"OrdDate\" name=\"OrdDate\" type=\"hidden\"  value=\"" + Mt.OrdDate + "\" />");

                        strz.Append("<input id=\"TransAmt\" name=\"TransAmt\" type=\"hidden\"  value=\"" + Mt.TransAmt + "\" />");

                        strz.Append("<input id=\"UsrCustId\"  name=\"UsrCustId\" type=\"hidden\"  value=\"" + Mt.UsrCustId + "\" />");

                        strz.Append("<input id=\"MaxTenderRate\"   name=\"MaxTenderRate\" type=\"hidden\"  value=\"" + Mt.MaxTenderRate + "\" />");

                        strz.Append("<input id=\"BorrowerDetails\" name=\"BorrowerDetails\" type=\"hidden\"  value=" + Mt.BorrowerDetails + " />");

                        strz.Append("<input id=\"IsFreeze\" name=\"IsFreeze\" type=\"hidden\"  value=\"" + Mt.IsFreeze + "\" />");
                        strz.Append("<input id=\"FreezeOrdId\" name=\"FreezeOrdId\" type=\"hidden\"  value=\"" + Mt.FreezeOrdId + "\" />");
                        strz.Append("<input id=\"RetUrl\" name=\"RetUrl\" type=\"hidden\"  value=\"" + Mt.RetUrl + "\" />");
                        strz.Append("<input id=\"BgRetUrl\" name=\"BgRetUrl\" type=\"hidden\"  value=\"" + Mt.BgRetUrl + "\" />");
                        strz.Append("<input id=\"MerPriv\" name=\"MerPriv\" type=\"hidden\"  value=\"" + Mt.MerPriv + "\" />");
                        strz.Append("<input id=\"ReqExt\" name=\"ReqExt\" type=\"hidden\"  value=" + Mt.ReqExt + " >");
                        strz.Append("<input id=\"ChkValue\" name=\"ChkValue\" type=\"hidden\"  value=\"" + Mt.ChkValue + "\" />");
                        strz.Append(" </form>");
                        strz.Append("<script type=\"text/javascript\">document.getElementById('formauto').submit();</script>");

                        LoggerHelper.Info("投资表单:" + strz.ToString());
                        res.code = "1";
                        res.body = strz.ToString();
                    }
                    else
                    {
                        res.code = "5000000000";
                    }
                    #endregion
                }
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(ex.ToString());
                LoggerHelper.Error(JsonHelper.Entity2Json(reqst));
                res.code    = "500";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
        }