Exemplo n.º 1
0
        public ActionResult BgLoans()
        {
            string outstr = "";

            ReLoans m = new ReLoans();

            m.CmdId         = DNTRequest.GetString("CmdId");
            m.RespCode      = DNTRequest.GetString("RespCode");
            m.RespDesc      = DNTRequest.GetString("RespDesc");
            m.MerCustId     = DNTRequest.GetString("MerCustId");
            m.OrdId         = DNTRequest.GetString("OrdId");
            m.OrdDate       = DNTRequest.GetString("OrdDate");
            m.OutCustId     = DNTRequest.GetString("OutCustId");
            m.OutAcctId     = DNTRequest.GetString("OutAcctId");
            m.TransAmt      = DNTRequest.GetString("TransAmt");
            m.Fee           = DNTRequest.GetString("Fee");
            m.InCustId      = DNTRequest.GetString("InCustId");
            m.InAcctId      = DNTRequest.GetString("InAcctId");
            m.SubOrdId      = DNTRequest.GetString("SubOrdId");
            m.SubOrdDate    = DNTRequest.GetString("SubOrdDate");
            m.FeeObjFlag    = DNTRequest.GetString("FeeObjFlag");
            m.IsDefault     = DNTRequest.GetString("IsDefault");
            m.IsUnFreeze    = DNTRequest.GetString("IsUnFreeze");
            m.UnFreezeOrdId = DNTRequest.GetString("UnFreezeOrdId");
            m.FreezeTrxId   = DNTRequest.GetString("FreezeTrxId");
            m.BgRetUrl      = DNTRequest.GetString("BgRetUrl");
            m.MerPriv       = DNTRequest.GetString("MerPriv");
            m.RespExt       = DNTRequest.GetString("RespExt");
            m.ChkValue      = DNTRequest.GetString("ChkValue");

            StringBuilder chkVal = new StringBuilder();

            chkVal.Append(m.CmdId);
            chkVal.Append(m.RespCode);
            chkVal.Append(m.MerCustId);
            chkVal.Append(m.OrdId);
            chkVal.Append(m.OrdDate);
            chkVal.Append(m.OutCustId);
            chkVal.Append(m.OutAcctId);
            chkVal.Append(m.TransAmt);
            chkVal.Append(m.Fee);
            chkVal.Append(m.InCustId);
            chkVal.Append(m.InAcctId);
            chkVal.Append(m.SubOrdId);
            chkVal.Append(m.SubOrdDate);
            chkVal.Append(m.FeeObjFlag);
            chkVal.Append(m.IsDefault);
            chkVal.Append(m.IsUnFreeze);
            chkVal.Append(m.UnFreezeOrdId);
            chkVal.Append(m.FreezeTrxId);
            chkVal.Append(m.BgRetUrl);
            chkVal.Append(m.MerPriv);
            chkVal.Append(m.RespExt);

            string msg = chkVal.ToString();

            //私钥文件的位置(这里是放在了站点的根目录下)
            string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
            //需要指定提交字符串的长度
            int           len        = Encoding.UTF8.GetBytes(msg).Length;
            StringBuilder sbChkValue = new StringBuilder(256);

            int ret = DllInterop.VeriSignMsg(merKeyFile, msg, msg.Length, m.ChkValue);


            LogInfo.WriteLog("验签:" + ret.ToString());

            if (ret == 0)
            {
                if (m.RespCode == "000")
                {
                    // M_borrowing_target m = new M_borrowing_target();
                    B_borrowing_target o = new B_borrowing_target();

                    B_member_table o1  = new B_member_table();
                    M_member_table p1  = new M_member_table();
                    M_member_table p2  = new M_member_table();
                    B_usercenter   BUC = new B_usercenter();


                    string cachename = m.OrdId + "Loans" + m.FreezeTrxId;

                    if (Utils.GeTThirdCache(cachename) == 0)
                    {
                        Utils.SetThirdCache(cachename);

                        M_Capital_account_water baw = new M_Capital_account_water(); //借款人流水对象


                        //标的id,借款人id,投资人id,投资记录bid,抵扣券金额
                        string   strings = m.MerPriv;
                        string[] sArray  = strings.Split('_');
                        if (sArray.Count() == 5)
                        {
                            p1 = o1.GetModel(int.Parse(sArray[1])); //借款人用户对象

                            LogInfo.WriteLog("sArray[1].ToString():" + sArray[1].ToString());
                            baw.membertable_registerid = p1.registerid;
                            baw.income      = decimal.Parse(m.TransAmt);
                            baw.expenditure = 0.00M;

                            baw.time_of_occurrence = DateTime.Now;

                            // decimal ff = p1.available_balance + decimal.Parse(retloan.TransAmt);
                            baw.account_balance = p1.available_balance;  //面要得么帐户余额

                            LogInfo.WriteLog("借款人余额:" + p1.available_balance);

                            baw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.借款转入.ToString());
                            baw.createtime    = DateTime.Now;
                            baw.keyid         = 0;
                            baw.remarks       = m.OrdId + "," + m.OrdDate;


                            M_Capital_account_water iaw = new M_Capital_account_water(); //投资人流水对象


                            p2 = o1.GetModel(int.Parse(sArray[2].ToString())); //投款人用户对象

                            iaw.membertable_registerid = p2.registerid;
                            iaw.income             = 0.00M;
                            iaw.expenditure        = decimal.Parse(m.TransAmt);
                            iaw.time_of_occurrence = DateTime.Now;
                            // decimal df=p1.available_balance - decimal.Parse(retloan.TransAmt);
                            iaw.account_balance = p2.available_balance;  //面要得么帐户余额
                            LogInfo.WriteLog("投资人余额:" + p2.ToString());

                            iaw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.项目投资.ToString());
                            iaw.createtime    = DateTime.Now;
                            iaw.keyid         = 0;
                            iaw.remarks       = m.OrdId + "," + m.OrdDate;

                            LogInfo.WriteLog("放款bid_records_id:" + sArray[3].ToString());


                            if (BUC.Loan_Successfully(m, baw, iaw, sArray[3].ToString(), decimal.Parse(sArray[4].ToString())) > 0)
                            {
                                //成功

                                outstr = "RECV_ORD_ID_" + m.OrdId;
                                LogInfo.WriteLog("后台主动通知操作成功:" + outstr);
                                return(Content(outstr));
                                //  Response.Redirect("/usercenter/index.html");
                            }
                        }
                    }
                }
            }



            return(Content(""));
        }