/// <summary> ///生成站内信 系统消息(发放奖励) /// </summary> ///<param name="registerid">用户id</param> ///<param name="MTitle">消息标题</param> ///<param name="MContext">消息内容</param> ///<param name="Mtye">消息类型 0系统消息 1投资通知 2收益通知 3提现 4充值 5系统通知</param> protected bool AddSytemMessage(int registerid, string MTitle, string MContext, int Mtype = 5) { DateTime dtiff = DateTime.Now; M_td_System_message pm2 = new M_td_System_message(); pm2.MReg = registerid; pm2.Mstate = 0; pm2.MTitle = MTitle; pm2.MContext = MContext; pm2.PubTime = dtiff; pm2.Mtype = Mtype; B_usercenter.AddMessage(pm2); return(true); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(M_td_System_message model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update hx_td_System_message set "); strSql.Append("MTitle=@MTitle,"); strSql.Append("PubTime=@PubTime,"); strSql.Append("MContext=@MContext,"); strSql.Append("Mstate=@Mstate,"); strSql.Append("MUrl=@MUrl,"); strSql.Append("MReg=@MReg"); strSql.Append(" where Messageid=@Messageid"); SqlParameter[] parameters = { new SqlParameter("@MTitle", SqlDbType.VarChar, 255), new SqlParameter("@PubTime", SqlDbType.DateTime), new SqlParameter("@MContext", SqlDbType.VarChar, 800), new SqlParameter("@Mstate", SqlDbType.Int, 4), new SqlParameter("@MUrl", SqlDbType.VarChar, 255), new SqlParameter("@MReg", SqlDbType.Int, 4), new SqlParameter("@Messageid", SqlDbType.Int, 4) }; parameters[0].Value = model.MTitle; parameters[1].Value = model.PubTime; parameters[2].Value = model.MContext; parameters[3].Value = model.Mstate; parameters[4].Value = model.MUrl; parameters[5].Value = model.MReg; parameters[6].Value = model.Messageid; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(M_td_System_message model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into hx_td_System_message("); strSql.Append("MTitle,PubTime,MContext,Mstate,MUrl,MReg,Mtype)"); strSql.Append(" values ("); strSql.Append("@MTitle,@PubTime,@MContext,@Mstate,@MUrl,@MReg,@Mtype)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MTitle", SqlDbType.VarChar, 255), new SqlParameter("@PubTime", SqlDbType.DateTime), new SqlParameter("@MContext", SqlDbType.VarChar, 800), new SqlParameter("@Mstate", SqlDbType.Int, 4), new SqlParameter("@MUrl", SqlDbType.VarChar, 255), new SqlParameter("@MReg", SqlDbType.Int, 4), new SqlParameter("@Mtype", SqlDbType.Int, 4) }; parameters[0].Value = model.MTitle; parameters[1].Value = model.PubTime; parameters[2].Value = model.MContext; parameters[3].Value = model.Mstate; parameters[4].Value = model.MUrl; parameters[5].Value = model.MReg; parameters[6].Value = model.Mtype; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public M_td_System_message DataRowToModel(DataRow row) { M_td_System_message model = new M_td_System_message(); if (row != null) { if (row["Messageid"] != null && row["Messageid"].ToString() != "") { model.Messageid = int.Parse(row["Messageid"].ToString()); } if (row["MTitle"] != null) { model.MTitle = row["MTitle"].ToString(); } if (row["PubTime"] != null && row["PubTime"].ToString() != "") { model.PubTime = DateTime.Parse(row["PubTime"].ToString()); } if (row["MContext"] != null) { model.MContext = row["MContext"].ToString(); } if (row["Mstate"] != null && row["Mstate"].ToString() != "") { model.Mstate = int.Parse(row["Mstate"].ToString()); } if (row["MUrl"] != null) { model.MUrl = row["MUrl"].ToString(); } if (row["MReg"] != null && row["MReg"].ToString() != "") { model.MReg = int.Parse(row["MReg"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public M_td_System_message GetModel(int Messageid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Messageid,MTitle,PubTime,MContext,Mstate,MUrl,MReg from hx_td_System_message "); strSql.Append(" where Messageid=@Messageid"); SqlParameter[] parameters = { new SqlParameter("@Messageid", SqlDbType.Int, 4) }; parameters[0].Value = Messageid; M_td_System_message model = new M_td_System_message(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public ActionResult Su_Repayment() { Utils.SetSYSDateTimeFormat(); chuangtouEntities ef = new chuangtouEntities(); string str = ""; ReRepayment Re = new ReRepayment(); Re.CmdId = DNTRequest.GetString("CmdId"); Re.RespCode = DNTRequest.GetString("RespCode"); Re.MerCustId = DNTRequest.GetString("MerCustId"); Re.ProId = DNTRequest.GetString("ProId"); Re.OrdId = DNTRequest.GetString("OrdId"); Re.OrdDate = DNTRequest.GetString("OrdDate"); Re.OutCustId = DNTRequest.GetString("OutCustId"); Re.SubOrdId = DNTRequest.GetString("SubOrdId"); Re.SubOrdDate = DNTRequest.GetString("SubOrdDate"); Re.OutAcctId = DNTRequest.GetString("OutAcctId"); Re.TransAmt = DNTRequest.GetString("TransAmt"); Re.PrincipalAmt = DNTRequest.GetString("PrincipalAmt"); Re.InterestAmt = DNTRequest.GetString("InterestAmt"); Re.Fee = DNTRequest.GetString("Fee"); Re.InCustId = DNTRequest.GetString("InCustId"); Re.InAcctId = DNTRequest.GetString("InAcctId"); Re.FeeObjFlag = DNTRequest.GetString("FeeObjFlag"); Re.DzObject = DNTRequest.GetString("DzObject"); Re.BgRetUrl = DNTRequest.GetString("BgRetUrl"); Re.MerPriv = DNTRequest.GetString("MerPriv"); Re.RespExt = DNTRequest.GetString("RespExt"); LogInfo.WriteLog("后台还款返回报文:" + FastJSON.toJOSN(Re)); string version = "20"; if (string.IsNullOrEmpty(Re.TransAmt) || Re.TransAmt == "0.00") { version = "30"; } StringBuilder builder = new StringBuilder(); builder.Append(Re.CmdId); builder.Append(Re.RespCode); builder.Append(Re.MerCustId); if (version == "30") { builder.Append(Re.ProId); } builder.Append(Re.OrdId); builder.Append(Re.OrdDate); builder.Append(Re.OutCustId); builder.Append(Re.SubOrdId); builder.Append(Re.SubOrdDate); builder.Append(Re.OutAcctId); if (version == "30") { builder.Append(Re.PrincipalAmt); builder.Append(Re.InterestAmt); } else { builder.Append(Re.TransAmt); } builder.Append(Re.Fee); builder.Append(Re.InCustId); builder.Append(Re.InAcctId); builder.Append(Re.FeeObjFlag); if (version == "30") { builder.Append(Re.DzObject); } builder.Append(HttpUtility.UrlDecode(Re.BgRetUrl)); builder.Append(Re.MerPriv); builder.Append(HttpUtility.UrlDecode(Re.RespExt)); // builder.Append(Re.ChkValue); var msg = builder.ToString(); if (version == "30") { msg = Utils.MD5(msg); } string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); int ret = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, Re.ChkValue); LogInfo.WriteLog("后台验签 ret= " + ret.ToString()); if (ret == 0) { if (Re.RespCode == "000" || Re.TransAmt == "0.00") { string cachename = "Repayment" + Re.OrdId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); B_member_table o = new B_member_table(); M_member_table p = new M_member_table(); M_member_table p2 = new M_member_table(); M_Capital_account_water baw = new M_Capital_account_water(); V_borrowing_Bid_records_income_statement item = new V_borrowing_Bid_records_income_statement(); int income_statement_id = int.Parse(Re.MerPriv); item = ef.V_borrowing_Bid_records_income_statement.AsNoTracking().Where(ps => ps.income_statement_id == income_statement_id).FirstOrDefault(); p = o.GetModel(int.Parse(item.borrower_registerid.ToString())); //借款人用户对象 baw.membertable_registerid = p.registerid; baw.income = 0.00M; baw.expenditure = decimal.Parse(Re.TransAmt); baw.time_of_occurrence = DateTime.Now; baw.account_balance = p.available_balance - baw.expenditure; //面要得么帐户余额 baw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.还款.ToString()); baw.createtime = DateTime.Now; baw.keyid = 0; baw.remarks = Re.OrdId + "," + Re.OrdDate; M_Capital_account_water iaw = new M_Capital_account_water(); //投资人流水对象 p2 = o.GetModel(int.Parse(item.investor_registerid.ToString())); //投资人用户对象 iaw.membertable_registerid = p2.registerid; iaw.income = decimal.Parse(Re.TransAmt); iaw.expenditure = 0.00M; iaw.time_of_occurrence = DateTime.Now; iaw.account_balance = p2.available_balance + iaw.income; //面要得么帐户余额 iaw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.借款人还款.ToString()); iaw.createtime = DateTime.Now; iaw.keyid = 0; iaw.remarks = Re.OrdId + "," + Re.OrdDate; int targetid = int.Parse(item.targetid.ToString()); //判断是否为最后一期还款,并进行相应状态处理 hx_repayment_plan plan = (from a in ef.hx_repayment_plan where a.targetid == targetid select a).OrderByDescending(a => a.current_period).Take(1).FirstOrDefault(); var lastcur = plan.current_period; //判断是否是最后一期,如果是对本金处理。得直接用最后一期还款金额减去本金,这样就解决多出本金问题 bool lastrepamt = false; if (item.current_investment_period.ToString() == lastcur.ToString()) { lastrepamt = true; } //需要更新投资记录表已还款金额 B_usercenter BUC = new B_usercenter(); decimal PrincipalInterest = decimal.Parse(item.Principal.ToString()) + decimal.Parse(item.interestpayment.ToString()); //本金加利息 decimal PInterest = decimal.Parse(item.interestpayment.ToString()); //利息 Re.MerPriv = DateTime.Parse(item.interest_payment_date.ToString()).ToString("yyyy-MM-dd"); //传入还款日期 int bucd = BUC.Repayment_Successfully(Re, baw, iaw, lastrepamt, PrincipalInterest, PInterest); if (bucd > 0) { // 尊敬#UserName#,您投资的第#PID#号标第#ORDER#期还款已到帐,本次已成功还款#MONEY#元.欢迎继续投资!【创利投】 #region 短信通知 //短信通知 string contxt = Utils.GetMSMEmailContext(11, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", item.username.ToString()); sbsms = sbsms.Replace("#PID#", item.targetid.ToString()); sbsms = sbsms.Replace("#ORDER#", item.current_investment_period.ToString()); sbsms = sbsms.Replace("#MONEY#", item.repayment_amount.ToString()); string mobile = item.mobile.ToString(); M_td_SMS_record psms = new M_td_SMS_record(); B_td_SMS_record osms = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资回款.ToString()); psms.phone_number = mobile; psms.sendtime = DateTime.Now; psms.senduserid = int.Parse(item.investor_registerid.ToString()); psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); #endregion #region 系统消息 //系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(item.investor_registerid.ToString()); pm.Mstate = 0; pm.MTitle = "投资回款"; // pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + dt.Rows[0]["investment_amount"].ToString() + "。如有问题可咨询创利投的客服!谢谢!"; pm.MContext = sbsms.ToString(); pm.PubTime = dti; pm.Mtype = 2; B_usercenter.AddMessage(pm); #endregion #region 更新标的状态为还还清 ///更新标的状态为还还清 if (item.current_investment_period.ToString() == lastcur.ToString()) { //更新标的状态为还还清 string sql = "update hx_borrowing_target set tender_state=5 where targetid=" + item.targetid.ToString() + ""; DbHelperSQL.ExecuteSql(sql); sql = "update hx_Bid_records set payment_status =1 where bid_records_id=" + item.bid_records_id.ToString(); DbHelperSQL.ExecuteSql(sql); } #endregion //Response.Write("还款验签成功!"); } else { //Response.Write("还款更新失败!" + bucd.ToString()); } } str = "RECV_ORD_ID_" + Re.OrdId; LogInfo.WriteLog(str + "后台还款成功"); } else { string cc = Utils.GetReturnCode(Int32.Parse(Re.RespCode)); if (cc.Contains("还款金额超过还款总额") || cc.Contains("重复的还款请求")) { B_member_table o = new B_member_table(); M_member_table p = new M_member_table(); M_member_table p2 = new M_member_table(); M_Capital_account_water baw = new M_Capital_account_water(); V_borrowing_Bid_records_income_statement item = new V_borrowing_Bid_records_income_statement(); int income_statement_id = int.Parse(Re.MerPriv); item = ef.V_borrowing_Bid_records_income_statement.AsNoTracking().Where(ps => ps.income_statement_id == income_statement_id).FirstOrDefault(); p = o.GetModel(int.Parse(item.borrower_registerid.ToString())); //借款人用户对象 baw.membertable_registerid = p.registerid; baw.income = 0.00M; baw.expenditure = decimal.Parse(Re.TransAmt); baw.time_of_occurrence = DateTime.Now; baw.account_balance = p.available_balance - baw.expenditure; //面要得么帐户余额 baw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.还款.ToString()); baw.createtime = DateTime.Now; baw.keyid = 0; baw.remarks = Re.OrdId + "," + Re.OrdDate; M_Capital_account_water iaw = new M_Capital_account_water(); //投资人流水对象 p2 = o.GetModel(int.Parse(item.investor_registerid.ToString())); //投资人用户对象 iaw.membertable_registerid = p2.registerid; iaw.income = decimal.Parse(Re.TransAmt); iaw.expenditure = 0.00M; iaw.time_of_occurrence = DateTime.Now; iaw.account_balance = p2.available_balance + iaw.income; //面要得么帐户余额 iaw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.借款人还款.ToString()); iaw.createtime = DateTime.Now; iaw.keyid = 0; iaw.remarks = Re.OrdId + "," + Re.OrdDate; int targetid = int.Parse(item.targetid.ToString()); //判断是否为最后一期还款,并进行相应状态处理 hx_repayment_plan plan = (from a in ef.hx_repayment_plan where a.targetid == targetid select a).OrderByDescending(a => a.current_period).Take(1).FirstOrDefault(); var lastcur = plan.current_period; //判断是否是最后一期,如果是对本金处理。得直接用最后一期还款金额减去本金,这样就解决多出本金问题 bool lastrepamt = false; if (item.current_investment_period.ToString() == lastcur.ToString()) { lastrepamt = true; } //需要更新投资记录表已还款金额 B_usercenter BUC = new B_usercenter(); decimal PrincipalInterest = decimal.Parse(item.Principal.ToString()) + decimal.Parse(item.interestpayment.ToString()); //本金加利息 decimal PInterest = decimal.Parse(item.interestpayment.ToString()); //利息 Re.MerPriv = DateTime.Parse(item.interest_payment_date.ToString()).ToString("yyyy-MM-dd"); //传入还款日期 int bucd = BUC.Repayment_Successfully(Re, baw, iaw, lastrepamt, PrincipalInterest, PInterest); if (bucd > 0) { // 尊敬#UserName#,您投资的第#PID#号标第#ORDER#期还款已到帐,本次已成功还款#MONEY#元.欢迎继续投资!【创利投】 #region 短信通知 //短信通知 string contxt = Utils.GetMSMEmailContext(11, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", item.username.ToString()); sbsms = sbsms.Replace("#PID#", item.targetid.ToString()); sbsms = sbsms.Replace("#ORDER#", item.current_investment_period.ToString()); sbsms = sbsms.Replace("#MONEY#", item.repayment_amount.ToString()); string mobile = item.mobile.ToString(); M_td_SMS_record psms = new M_td_SMS_record(); B_td_SMS_record osms = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资回款.ToString()); psms.phone_number = mobile; psms.sendtime = DateTime.Now; psms.senduserid = int.Parse(item.investor_registerid.ToString()); psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); #endregion #region 系统消息 //系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(item.investor_registerid.ToString()); pm.Mstate = 0; pm.MTitle = "投资回款"; // pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + dt.Rows[0]["investment_amount"].ToString() + "。如有问题可咨询创利投的客服!谢谢!"; pm.MContext = sbsms.ToString(); pm.PubTime = dti; pm.Mtype = 2; B_usercenter.AddMessage(pm); #endregion #region 更新标的状态为还还清 ///更新标的状态为还还清 if (item.current_investment_period.ToString() == lastcur.ToString()) { //更新标的状态为还还清 string sql = "update hx_borrowing_target set tender_state=5 where targetid=" + item.targetid.ToString() + ""; DbHelperSQL.ExecuteSql(sql); sql = "update hx_Bid_records set payment_status =1 where bid_records_id=" + item.bid_records_id.ToString(); DbHelperSQL.ExecuteSql(sql); } #endregion //Response.Write("还款验签成功!"); } else { //Response.Write("还款更新失败!" + bucd.ToString()); } } //Response.Write("出现错误! " + Utils.GetReturnCode(Int32.Parse(Re.RespCode))); /* * string cc = Utils.GetReturnCode(Int32.Parse(Re.RespCode)); * * * if (cc.Contains("还款金额超过还款总额") || cc.Contains("重复的还款请求")) * { * * B_member_table o = new B_member_table(); * M_member_table p = new M_member_table(); * M_member_table p2 = new M_member_table(); * M_Capital_account_water baw = new M_Capital_account_water(); * V_borrowing_Bid_records_income_statement item = new V_borrowing_Bid_records_income_statement(); * int income_statement_id = int.Parse(Re.MerPriv); * item = ef.V_borrowing_Bid_records_income_statement.AsNoTracking().Where(ps => ps.income_statement_id == income_statement_id).FirstOrDefault(); * p = o.GetModel(int.Parse(item.borrower_registerid.ToString())); //借款人用户对象 * * * int ic = ef.hx_income_statement.Where(c => c.bid_records_id == item.bid_records_id && c.targetid == item.targetid && c.orderid== Re.OrdId).Update(c => new hx_income_statement { payment_status = 1, repayment_period = DateTime.Now }); * * if (ic > 0) * { * int userid = int.Parse(item.borrower_registerid.ToString()); * UserInfoData ud = new UserInfoData(); * ReQueryBalanceBg retloan = ud.Querybalance(userid); * * if (retloan.RespCode == "000") * { * // sql = "update hx_member_table set available_balance=" + decimal.Parse(retloan.AvlBal) + " ,frozen_sum=" + decimal.Parse(retloan.FrzBal) + " where registerid=" + userid.ToString() + ""; * * //sql = "update hx_member_table set available_balance=" + decimal.Parse(retloan.AvlBal) + " where registerid=" + userid.ToString() + ""; * * //DbHelperSQL.RunSql(sql); * B_usercenter bu = new B_usercenter(); * bu.DataSync(retloan, userid.ToString()); * * * * * } * } */ } } return(Content(str)); }
public bool SendCash(int actID, int Registerid) { bool t = false; chuangtouEntities ef = new chuangtouEntities(); hx_ActivityTable hat = new ActFacade().GetActivityModel(actID); //GetActTableInfo(ActTypeId, ActUser, 1); if (hat != null) { //判是否过期 if (hat.ActStarttime <= DateTime.Now && DateTime.Now <= hat.ActEndtime) { string ActRule = hat.ActRule; List <MAmtList> mlist = new List <MAmtList>(); JavaScriptSerializer js = new JavaScriptSerializer(); //MActCash mc = new MActCash(); Mcoupon mcp = new Mcoupon(); mcp = js.Deserialize <Mcoupon>(ActRule); //mlist = js.Deserialize<List<MAmtList>>(ActRule); //检查分发奖励是否超过顶限,如果超过直接跳过 //int TopNum = B_usercenter.GetTopNum(hat.ActID); //项目已经发放的金额 //decimal totalAmt = B_usercenter.GetTopAmtCount(hat.ActID); //第一次投资获取对应奖励 decimal actamt = mcp.cash;//GetActAmt(mc, InvestAmt, TopNum); //if (mc.TopAmt > totalAmt && mc.TopNum > TopNum) //{ t = true; if (actamt > 0)//大于 0里写入对应的奖励数据 { hx_UserAct hua = new hx_UserAct(); hua.ActTypeId = hat.ActTypeId; hua.registerid = Registerid; hua.RewTypeID = hat.RewTypeID; hua.ActID = hat.ActID; hua.Amt = actamt; hua.Uselower = 0.00M; hua.Usehight = 0.00M; hua.AmtEndtime = DateTime.Parse(hat.ActEndtime.ToString()).AddMonths(1); hua.AmtUses = 1; //没指定情况下默认为单独使用 hua.UseState = 5; //现金未转账 hua.UseTime = DateTime.Now; hua.AmtProid = 0; //未使用默认为0 hua.ISSmsOne = 0; hua.IsSmsThree = 0; hua.isSmsFifteen = 0; hua.IsSmsSeven = 0; hua.isSmsSixteen = 0; hua.OrderID = decimal.Parse(Utils.Createcode()); hua.Createtime = DateTime.Now; hua.Title = hat.ActName; hua.UseLifeLoan = ""; ef.hx_UserAct.Add(hua); int i = ef.SaveChanges(); if (i > 0) { //录入成功,后进行转账操作 //1.获取用户对向 M_member_table p = new M_member_table(); B_member_table o = new B_member_table(); p = o.GetModel(Registerid); if (p != null) { //2.调用商户向用户转账接口 Transfer tf = new Transfer(); ReTransfer retf = tf.ToUserTransfer(p.UsrCustId, actamt, hua.OrderID.ToString(), hua.ActID.ToString(), "/Thirdparty/ToUserTransfer"); if (retf != null) { if (retf.RespCode == "000") { //3.事务处理操作账户及插入流水 #region 验签缓存处理 string cachename = retf.OrdId + "ToUserTransfer" + retf.InCustId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); B_usercenter BUC = new B_usercenter(); int ic = BUC.UpateActToUserTransfer(retf, 0); //用户余更新 if (ic > 0) { string sql = "SELECT registerid,username,mobile from hx_member_table where UsrCustId='" + retf.InCustId + "'"; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { /*短信接口*/ #region 流水信息 B_usercenter ors = new B_usercenter(); decimal di = ors.GetUsridAvailable_balance(int.Parse(dt.Rows[0]["registerid"].ToString())); // di = di + decimal.Parse(hua.Amt.ToString()); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into hx_Capital_account_water("); strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)"); strSql.Append(" values ("); strSql.Append("" + int.Parse(dt.Rows[0]["registerid"].ToString()) + "," + decimal.Parse(hua.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.现金奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + "现金奖励" + "')"); DbHelperSQL.RunSql(strSql.ToString()); strSql.Clear(); #endregion #region 奖励流水 M_bonus_account_water mbaw = new M_bonus_account_water(); B_bonus_account_water bbaw = new B_bonus_account_water(); DateTime dte = DateTime.Now; mbaw.bonus_account_id = int.Parse(hua.ActID.ToString()); mbaw.membertable_registerid = int.Parse(dt.Rows[0]["registerid"].ToString()); mbaw.income = decimal.Parse(retf.TransAmt); mbaw.expenditure = 0.00M; mbaw.time_of_occurrence = DateTime.Now; mbaw.award_description = hat.ActName + "奖励已汇入个人账户"; mbaw.water_type = 0; bbaw.Add(mbaw); #endregion #region MyRegion 系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(dt.Rows[0]["registerid"].ToString()); pm.Mstate = 0; pm.MTitle = hat.ActName; pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功" + hat.ActName + ",现金奖励 " + retf.TransAmt + "元。如有问题可咨询创利投的客服!"; pm.PubTime = dti; B_usercenter.AddMessage(pm); #endregion } } t = true; } #endregion } } } } } //} } } return(t); }
public ActionResult PostGENERALAmt() { //显示于页面给汇付 string str = string.Empty; //日志变量 string log = string.Empty; //响应通知加签的状态码 int ret = -1; //业务的sql语句变量 string sql = string.Empty; ReCash m = ChinapnrFacade.CashCallBack(out ret); if (m != null) { //提现成功后,得多事务处理账户金额,流水及冻结金额等 if (m.RespCode == "000") { string cachename = m.OrdId + "Cash" + m.UsrCustId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); B_usercenter BUC = new B_usercenter(); M_ReqExt mre = JsonConvert.DeserializeObject <M_ReqExt>(m.RespExt.Replace("[", "").Replace("]", "")); int CashOp = BUC.CashTran(m.OpenAcctId, m.OpenBankId, m.OrdId, m.RealTransAmt, m.UsrCustId, m.FeeAmt, mre.FeeObjFlag, mre.CashChl); if (CashOp > 0) { sql = "select registerid,username,mobile,UsrCustId,available_balance from hx_member_table where UsrCustId='" + m.UsrCustId + "'"; LogInfo.WriteLog("审请取现成功短信sql:" + sql); DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { //短信通知 //尊敬的#USERANEM#,您已成功提现#MONEY#元,账户余额#MONEY1#.请注意查收!【创利投】 string contxt = Utils.GetMSMEmailContext(12, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#MONEY#", m.TransAmt); decimal amt = decimal.Parse(dt.Rows[0]["available_balance"].ToString()) - decimal.Parse(m.TransAmt); sbsms = sbsms.Replace("#MONEY1#", amt.ToString()); string mobile = dt.Rows[0]["mobile"].ToString(); M_td_SMS_record psms = new M_td_SMS_record(); B_td_SMS_record osms = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.取现成功.ToString()); psms.phone_number = mobile; psms.sendtime = DateTime.Now; psms.senduserid = int.Parse(dt.Rows[0]["registerid"].ToString()); psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(dt.Rows[0]["registerid"].ToString()); pm.Mstate = 0; pm.MTitle = "提现"; pm.MContext = sbsms.ToString(); pm.PubTime = dti; pm.Mtype = 3; B_usercenter.AddMessage(pm); } string cashChl = Enum.GetName(typeof(EnumCommon.E_hx_td_UserCash.EnumCashChl), (int)EnumCommon.E_hx_td_UserCash.EnumCashChl.IMMEDIATE); if (mre.CashChl == cashChl && decimal.Parse(m.TransAmt) <= 200000M) { string retUrl = Utils.GetRe_url("admin/UserCash/RePostCashProcessing"); string bgRetUrl = Utils.GetRe_url("admin/Thirdparty/BgCashProcessing"); BusinessLogicHelper.AutoCheckCash(m.UsrCustId, retUrl, bgRetUrl); } } } } } return(View(m)); }
/// <summary> /// 12月份元旦活动转账专用 获取活动信息 短信通知部分需要更改 /// </summary> /// <param name="mc"></param> /// <param name="TrAMT"></param> /// <param name="TransAmt"></param> public void YuandaiToUserTransfer(M_CashAwards mc, decimal TrAMT, decimal TransAmt) { M_Transfer m = new M_Transfer(); m.Version = "10"; m.CmdId = "Transfer"; // m.OrdId = Utils.Createcode(); m.OrdId = mc.OrdId.ToString(); m.OutCustId = Utils.GetMerCustID(); m.OutAcctId = "MDT000001"; m.TransAmt = mc.Amounts.ToString("0.00"); m.InCustId = mc.UsrCustId; m.BgRetUrl = Utils.GetRe_url("Thirdparty/ToUserTransfer.aspx"); m.MerPriv = mc.proid.ToString(); StringBuilder chkVal = new StringBuilder(); chkVal.Append(m.Version); chkVal.Append(m.CmdId); chkVal.Append(m.OrdId); chkVal.Append(m.OutCustId); chkVal.Append(m.OutAcctId); chkVal.Append(m.TransAmt); chkVal.Append(m.InCustId); chkVal.Append(m.RetUrl); chkVal.Append(m.BgRetUrl); chkVal.Append(m.MerPriv); string chkv = chkVal.ToString(); LogInfo.WriteLog("12月份元旦活动平台向用户活动转账加签chkv字符:" + chkv); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetMerPr(); //需要指定提交字符串的长度 int len = Encoding.UTF8.GetBytes(chkv).Length; StringBuilder sbChkValue = new StringBuilder(256); //加签 int str = DllInterop.SignMsg(Utils.GetMerId(), merKeyFile, chkv, len, sbChkValue); LogInfo.WriteLog("12月份元旦活动平台向用户活动转账加签字符:" + str.ToString()); m.ChkValue = sbChkValue.ToString(); LogInfo.WriteLog("12月份元旦活动平台向用户活动转账提交信息:" + FastJSON.toJOSN(m)); LogInfo.WriteLog("ChkValue:" + m.ChkValue); using (var client = new WebClient()) { var values = new NameValueCollection(); values.Add("Version", m.Version); values.Add("CmdId", m.CmdId); values.Add("OrdId", m.OrdId); values.Add("OutCustId", m.OutCustId); values.Add("OutAcctId", m.OutAcctId); values.Add("TransAmt", m.TransAmt); values.Add("InCustId", m.InCustId); values.Add("InAcctId", m.InAcctId); values.Add("RetUrl", m.RetUrl); values.Add("BgRetUrl", m.BgRetUrl); values.Add("MerPriv", m.MerPriv); values.Add("ChkValue", m.ChkValue); string url = Utils.GetChinapnrUrl(); //同步发送form表单请求 byte[] result = client.UploadValues(url, "POST", values); var retStr = Encoding.UTF8.GetString(result); // Response.Write(retStr); LogInfo.WriteLog("12月份元旦活动自动扣款转账(商户用)返回报文" + retStr); ReTransfer reg = new ReTransfer(); var retloan = (ReTransfer)FastJSON.ToObject(retStr, reg); StringBuilder builder = new StringBuilder(); builder.Append(retloan.CmdId); builder.Append(retloan.RespCode); builder.Append(retloan.OrdId); builder.Append(retloan.OutCustId); builder.Append(retloan.OutAcctId); builder.Append(retloan.TransAmt); builder.Append(retloan.InCustId); builder.Append(retloan.InAcctId); builder.Append(HttpUtility.UrlDecode(retloan.RetUrl)); builder.Append(HttpUtility.UrlDecode(retloan.BgRetUrl)); builder.Append(retloan.MerPriv); var msg = builder.ToString(); LogInfo.WriteLog("12月份元旦活动平台向用户活动转账返回参数:" + msg); //验签 string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); int ret = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, retloan.ChkValue); LogInfo.WriteLog("12月份元旦活动平台向用户活动转账验签ret:" + ret.ToString()); if (ret == 0) { if (retloan.RespCode == "000") { /* * string sql = "update hx_CashAwards set OrdIdstate=3 where OrdIdstate=1 and OrdId=" + retloan.OrdId + " and proid =" + retloan.MerPriv; * DbHelperSQL.RunSql(sql); * LogInfo.WriteLog("平台向用户活动转账验签更新"+ sql); */ // Response.Write(retloan.RespCode + " <br> "); B_usercenter BUC = new B_usercenter(); int dint = BUC.UpateAwa(retloan); LogInfo.WriteLog("12月份元旦活动事务执行返回:" + dint.ToString()); if (dint > 0) { B_member_table dmt = new B_member_table(); string sql = "SELECT registerid,username,mobile from hx_member_table where UsrCustId='" + retloan.InCustId + "'"; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { //活动奖历 M_Activity_schedule ma = new M_Activity_schedule(); B_Activity_schedule ba = new B_Activity_schedule(); B_bonus_account bb = new B_bonus_account(); M_bonus_account mb = new M_bonus_account(); M_bonus_account_water mbaw = new M_bonus_account_water(); B_bonus_account_water bbaw = new B_bonus_account_water(); DateTime dte = DateTime.Now; // ma = ba.GetModel(16); //测试平台 ma = ba.GetModel(15); //获取奖励对象 mb.activity_schedule_id = ma.activity_schedule_id; mb.membertable_registerid = int.Parse(dt.Rows[0]["registerid"].ToString()); mb.activity_schedule_name = ma.activity_schedule_name; mb.amount_of_reward = decimal.Parse(retloan.TransAmt); mb.use_lower_limit = ma.use_lower_limit; mb.reward = ma.reward; mb.start_date = dte; mb.end_date = dte; mb.entry_time = dte; mb.reward_state = 3; int bbid = bb.Add(mb); if (bbid > 0) //奖励记录成功后插入明细记录 { mbaw.bonus_account_id = bbid; mbaw.membertable_registerid = mb.membertable_registerid; mbaw.income = mb.amount_of_reward; mbaw.expenditure = 0.00M; mbaw.time_of_occurrence = mb.entry_time; // mbaw. mbaw.award_description = "已汇入个人账户"; mbaw.water_type = 0; bbaw.Add(mbaw); //短信通知 #region MyRegion //短信通知 string contxt = Utils.GetMSMEmailContext(20, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#MONEY#", TrAMT.ToString("0.00")); sbsms = sbsms.Replace("#AMTM#", TransAmt.ToString("0.00")); string mobile = dt.Rows[0]["mobile"].ToString(); M_td_SMS_record psms = new M_td_SMS_record(); B_td_SMS_record osms = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.活动奖励.ToString()); psms.phone_number = mobile; psms.sendtime = DateTime.Now; psms.senduserid = int.Parse(dt.Rows[0]["registerid"].ToString()); psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); #endregion } #region MyRegion 系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(dt.Rows[0]["registerid"].ToString()); pm.Mstate = 0; pm.MTitle = "投资成功现金奖励"; pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目,现金奖励 " + retloan.TransAmt + "元。如有问题可咨询创利投的客服!"; pm.PubTime = dti; B_usercenter.AddMessage(pm); #endregion } LogInfo.WriteLog("12月份元旦活动 平台向用户活动转账验签更新成功,需要写入消息"); } } else { //Response.Write(HttpUtility.UrlDecode(retloan.)); } } } }
public ActionResult Changepass() { string json = ""; string tel1 = Utils.CheckSQLHtml(DNTRequest.GetString("t")); string rid1 = Utils.CheckSQLHtml(DNTRequest.GetString("key")); string vcode1 = Utils.CheckSQLHtml(DNTRequest.GetString("c")); string pcode1 = Utils.CheckSQLHtml(DNTRequest.GetString("p")); string rid = ""; if (rid1 != "") { rid = DESEncrypt.Decrypt(rid1, ConfigurationManager.AppSettings["webp"].ToString()); } string tel = ""; if (tel1 != "") { tel = DESEncrypt.Decrypt(tel1, ConfigurationManager.AppSettings["webp"].ToString()); } string vcode = ""; if (vcode1 != "") { vcode = DESEncrypt.Decrypt(vcode1, ConfigurationManager.AppSettings["webp"].ToString()); } string pcode = ""; if (pcode1 != "") { pcode = DESEncrypt.Decrypt(pcode1, ConfigurationManager.AppSettings["webp"].ToString()); } string pass = ""; string sql = ""; if (pcode == "gettel") { sql = "select top 1 smscontext,phone_number from hx_td_SMS_record where ( smstype=8 or smstype=7) and phone_number='" + tel + "' and vcode='" + vcode + "' and DATEDIFF(MINUTE,sendtime,getDate())<3 order by sms_record_id desc"; DataTable dtc = DbHelperSQL.GET_DataTable_List(sql); var ts = true; if (Settings.Instance.SiteDomain.IndexOf(PublicURL.NewPCUrl) >= 0) { ts = false; } if (dtc.Rows.Count > 0 || ts) { sql = "select registerid,mobile from hx_member_table where registerid=" + rid + " and mobile='" + tel + "' "; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { pass = DESEncrypt.Encrypt(Utils.CheckSQLHtml(DNTRequest.GetString("userpassword")), ConfigurationManager.AppSettings["webp"].ToString()); sql = "update hx_member_table set password='******' where registerid=" + rid; if (DbHelperSQL.ExecuteSql(sql) > 0) { DateTime dti = DateTime.Now; M_td_System_message p = new M_td_System_message(); p.MReg = int.Parse(dt.Rows[0]["registerid"].ToString()); p.Mstate = 0; p.MTitle = "安全提示"; p.MContext = "您在" + dti.ToString("yyyy-MM-dd HH:mm:ss") + "使用手机进行了密码找回操作,如非本人操作请联系客服"; p.PubTime = dti; B_usercenter.AddMessage(p); M_td_SMS_record pm = new M_td_SMS_record(); B_td_SMS_record om = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.修改密码.ToString()); string smscontxt = Utils.GetMSMEmailContext(17, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(smscontxt); string mobile = tel; sbsms = sbsms.Replace("#DATATIME#", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); pm.phone_number = mobile; pm.sendtime = DateTime.Now; pm.senduserid = int.Parse(dt.Rows[0]["registerid"].ToString()); pm.smstype = smstype; pm.smscontext = sbsms.ToString(); // p.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); pm.orderid = SendSMS.Send_Audio(mobile, smscontxt); pm.vcode = ""; om.Add(pm); json = @" {""rs"": ""y"", ""info"": ""新密码设置成功!"",""url"":""/""}"; return(Content(json)); } else { json = @" {""rs"": ""n"", ""info"": ""新密码设置失败!""}"; return(Content(json)); } } else { json = @" {""rs"": ""n"", ""info"": ""数据异常!""}"; return(Content(json)); } } else { json = @" {""rs"": ""n"", ""info"": ""验证码无效,或已经过期,请重新获取!""}"; return(Content(json)); } } return(Content(json)); }
/// <summary> /// 汇付主动通知页面 /// </summary> /// <returns></returns> public ActionResult CashBgCallback() { string str1 = ""; ReCash m = new ReCash(); m.CmdId = DNTRequest.GetString("CmdId"); m.RespCode = DNTRequest.GetString("RespCode"); m.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); m.MerCustId = DNTRequest.GetString("MerCustId"); m.OrdId = DNTRequest.GetString("OrdId"); m.UsrCustId = DNTRequest.GetString("UsrCustId"); m.TransAmt = DNTRequest.GetString("TransAmt"); m.OpenAcctId = DNTRequest.GetString("OpenAcctId"); m.OpenBankId = DNTRequest.GetString("OpenBankId"); m.FeeAmt = DNTRequest.GetString("FeeAmt"); m.FeeCustId = DNTRequest.GetString("FeeCustId"); m.FeeAcctId = DNTRequest.GetString("FeeAcctId"); m.ServFee = DNTRequest.GetString("ServFee"); m.ServFeeAcctId = DNTRequest.GetString("ServFeeAcctId"); m.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); m.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); m.MerPriv = DNTRequest.GetString("MerPriv"); m.RespExt = HttpUtility.UrlDecode(DNTRequest.GetString("RespExt")); m.ChkValue = DNTRequest.GetString("ChkValue"); m.RealTransAmt = DNTRequest.GetString("RealTransAmt"); LoggerHelper.Info("后台取现返回报文:" + JsonHelper.Entity2Json(m)); //验签 StringBuilder chkVal = new StringBuilder(); chkVal.Append(m.CmdId); chkVal.Append(m.RespCode); chkVal.Append(m.MerCustId); chkVal.Append(m.OrdId); chkVal.Append(m.UsrCustId); chkVal.Append(m.TransAmt); chkVal.Append(m.OpenAcctId); chkVal.Append(m.OpenBankId); chkVal.Append(m.FeeAmt); chkVal.Append(m.FeeCustId); chkVal.Append(m.FeeAcctId); chkVal.Append(m.ServFee); chkVal.Append(m.ServFeeAcctId); chkVal.Append(m.RetUrl); chkVal.Append(m.BgRetUrl); chkVal.Append(m.MerPriv); chkVal.Append(m.RespExt); string msg = chkVal.ToString(); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.PgPubk; //需要指定提交字符串的长度 int len = Encoding.UTF8.GetBytes(msg).Length; StringBuilder sbChkValue = new StringBuilder(256); int ret = DllInterop.VeriSignMsg(merKeyFile, msg, msg.Length, m.ChkValue); // LoggerHelper.Info("验签返回参数:" + ret.ToString()); StringBuilder str = new StringBuilder(); if (ret == 0) { //提现成功后,得多事务处理账户金额,流水及冻结金额等 if (m.RespCode == "000") { string cachename = m.OrdId + "Cash" + m.UsrCustId; if (Settings.Instance.GeTThirdCache(cachename) == 0) { Settings.Instance.SetThirdCache(cachename); B_usercenter BUC = new B_usercenter(); M_ReqExt mr = new M_ReqExt(); mr = FastJSON.ToObject <M_ReqExt>(m.RespExt.Replace("[", "").Replace("]", "")); int CashOp = BUC.CashTran(m.OpenAcctId, m.OpenBankId, m.OrdId, m.RealTransAmt, m.UsrCustId, m.FeeAmt, mr.FeeObjFlag, mr.CashChl); if (CashOp > 0) { string sql = "select registerid,username,mobile,UsrCustId,available_balance from hx_member_table where UsrCustId='" + m.UsrCustId + "'"; LoggerHelper.Info("后台审请取现成功短信sql:" + sql); DataTable dt = DbHelper.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { //短信通知 //尊敬的#USERANEM#,您已成功提现#MONEY#元,账户余额#MONEY1#.请注意查收!【创利投】 MemberLogic _logic = new MemberLogic(); var ebt = _logic.GetSmsEmailEntity(1, 12); // 获取内容 string contxt = ebt.SEContext; StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#MONEY#", m.TransAmt); decimal amt = decimal.Parse(dt.Rows[0]["available_balance"].ToString()) - decimal.Parse(m.TransAmt); sbsms = sbsms.Replace("#MONEY1#", amt.ToString()); string mobile = dt.Rows[0]["mobile"].ToString(); M_td_SMS_record psms = new M_td_SMS_record(); B_td_SMS_record osms = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.取现成功.ToString()); psms.phone_number = mobile; psms.sendtime = DateTime.Now; psms.senduserid = int.Parse(dt.Rows[0]["registerid"].ToString()); psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(dt.Rows[0]["registerid"].ToString()); pm.Mstate = 0; pm.MTitle = "投现成功"; pm.MContext = sbsms.ToString(); pm.PubTime = dti; pm.Mtype = 3; B_usercenter.AddMessage(pm); //即时提现,提现金额小于等于20万自动审核,高于20万人工审核 string cashChl = Enum.GetName(typeof(EnumCommon.E_hx_td_UserCash.EnumCashChl), (int)EnumCommon.E_hx_td_UserCash.EnumCashChl.IMMEDIATE); if (mr.CashChl == cashChl && decimal.Parse(m.TransAmt) <= 200000) { string retUrl = Settings.Instance.ImagesDomain + "/admin/UserCash/RePostCashProcessing"; string bgRetUrl = Settings.Instance.ImagesDomain + "/admin/Thirdparty/BgCashProcessing"; BusinessLogicHelper.AutoCheckCash(m.UsrCustId, retUrl, bgRetUrl); } } } } str1 = "RECV_ORD_ID_" + m.OrdId; } } return(Content(str1)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(M_td_System_message model) { return(dal.Add(model)); }
/// <summary> /// 投资成功,汇付后台主动通知 /// </summary> /// <returns></returns> public ActionResult CallbackBgRetUrl() { int id = 0; string srt = ""; ReInitiativeTender p = new ReInitiativeTender(); B_usercenter BUC = new B_usercenter(); string OrdId = ""; int useridc = 0; string targetid = "0"; id = DNTRequest.GetInt("id", 0); LoggerHelper.Info("主动通知后台有响应成功!"); p.CmdId = DNTRequest.GetString("CmdId"); p.RespCode = DNTRequest.GetString("RespCode"); p.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); p.MerCustId = DNTRequest.GetString("MerCustId"); p.OrdId = DNTRequest.GetString("OrdId"); p.OrdDate = DNTRequest.GetString("OrdDate"); p.TransAmt = DNTRequest.GetString("TransAmt"); p.UsrCustId = DNTRequest.GetString("UsrCustId"); p.TrxId = DNTRequest.GetString("TrxId"); p.IsFreeze = DNTRequest.GetString("IsFreeze"); p.FreezeOrdId = DNTRequest.GetString("FreezeOrdId"); p.FreezeTrxId = DNTRequest.GetString("FreezeTrxId"); p.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); p.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); string merp = DNTRequest.GetString("MerPriv"); if (merp.Length > 0) { p.MerPriv = HttpUtility.UrlDecode(merp); } else { p.MerPriv = merp; } p.RespExt = HttpUtility.UrlDecode(DNTRequest.GetString("RespExt")); p.ChkValue = DNTRequest.GetString("ChkValue"); StringBuilder chkVal = new StringBuilder(); chkVal.Append(p.CmdId); chkVal.Append(p.RespCode); chkVal.Append(p.MerCustId); chkVal.Append(p.OrdId); chkVal.Append(p.OrdDate); chkVal.Append(p.TransAmt); chkVal.Append(p.UsrCustId); chkVal.Append(p.TrxId); chkVal.Append(p.IsFreeze); chkVal.Append(p.FreezeOrdId); chkVal.Append(p.FreezeTrxId); chkVal.Append(p.RetUrl); chkVal.Append(p.BgRetUrl); chkVal.Append(p.MerPriv); chkVal.Append(p.RespExt); string chkv = chkVal.ToString(); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.PgPubk; int ret = DllInterop.VeriSignMsg(merKeyFile, chkv, chkv.Length, p.ChkValue); LoggerHelper.Info("投标后台主动投标返回报文:" + JsonHelper.Entity2Json(p)); string sql = ""; merp = p.MerPriv; string deviceKey = PickoutDeviceFlag(ref merp);//pick out device code from comment field p.MerPriv = merp; int invcount = 0; //记录用户是否是首次投资 #region 验签 if (ret == 0) { if (p.RespCode == "000" || p.RespCode == "534" || p.RespCode == "360" || p.RespCode == "099")//p.RespCode == "322" || { string cachename = p.OrdId + "Invest" + p.UsrCustId; if (Settings.Instance.GeTThirdCache(cachename) == 0) { Settings.Instance.SetThirdCache(cachename); if (p.FreezeTrxId != "") { sql = "select ordstate from hx_Bid_records where ordstate =0 and OrdId='" + p.OrdId + "'"; LoggerHelper.Info("CallbackBgRetUrl===p.OrdId:" + p.OrdId); LoggerHelper.Info("sql :" + sql); DataTable dts = DbHelper.Query(sql).Tables[0]; if (dts.Rows.Count > 0) { //同步处理用户金额 int d = BUC.ReInvest_success(p.UsrCustId, p.FreezeOrdId, p.TransAmt, p.FreezeTrxId, p.OrdId, p.MerPriv); LoggerHelper.Info("后台投标:id" + id.ToString() + "返回唯一冻结标识:" + p.FreezeTrxId + "事务执行结果:" + d.ToString()); if (d > 0) { sql = "select targetid,bid_records_id, borrowing_title,investor_registerid ,username,mobile,invitationcode,investment_amount,life_of_loan,unit_day,borrowing_balance,bonusAmt from V_hx_Bid_records_borrowing_target where OrdId='" + p.OrdId + "'"; DataTable dt = DbHelper.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { decimal invdesc = decimal.Parse(dt.Rows[0]["investment_amount"].ToString()); OrdId = p.OrdId; useridc = int.Parse(dt.Rows[0]["investor_registerid"].ToString()); targetid = dt.Rows[0]["targetid"].ToString(); LoggerHelper.Info(" /*此处加入活动*/:" + targetid); //参与所有活动规则 if (!string.IsNullOrWhiteSpace(deviceKey)) { using (ActFacade actFacade = new ActFacade()) { actFacade.SendBonusAfterInvest(dt, Utils.GetDevicePlatformCode(deviceKey)); } } #region MyRegion 邀请注册奖历 投资成功奖励 --已过期 //invcount = B_usercenter.GetIsNews(useridc); //ActTable act = new ActTable(); //#region 首次投资活动奖励 //if (invcount == 1) //{ // //首次投资活动奖励 // act.UsrFirstInvest(useridc, decimal.Parse(p.TransAmt), 3, 1); //} /////续投用户 //if (invcount >= 2) //{ // act.UsrFirstInvest(useridc, decimal.Parse(p.TransAmt), 3, 6); //} //#region 所有用户 ////所有用户 //act.UsrFirstInvest(useridc, decimal.Parse(p.TransAmt), 3, 5); //#endregion //#region 投标最大的用户 ////投标最大的用户 //decimal borrowing_balance = decimal.Parse(dt.Rows[0]["borrowing_balance"].ToString()); //DataTable dmax = B_usercenter.Topinvestor(int.Parse(targetid)); //if (dmax.Rows.Count > 0) //{ // decimal amtc = decimal.Parse(dmax.Rows[0]["InvCount_Amt"].ToString()); // if (borrowing_balance == amtc) // { // act.UsrFirstInvest(int.Parse(dmax.Rows[0]["investor_registerid"].ToString()), decimal.Parse(dmax.Rows[0]["maxamt"].ToString()), 3, 4); // } //} //#endregion //#region 每标首投用户 ////每标首投用户 //if (B_usercenter.TopNum(targetid) == 1) //{ // act.UsrFirstInvest(useridc, decimal.Parse(p.TransAmt), 3, 3); //} //#endregion //#endregion //#region 渠道合作 第一投标调用接口 //B_member_table bmt = new B_member_table(); //M_member_table mmt = new M_member_table(); //mmt = bmt.GetModel(int.Parse(dt.Rows[0]["investor_registerid"].ToString())); //if (mmt.Tid != null && mmt.Channelsource == 1) //{ // if (B_usercenter.GetIsNews(mmt.registerid) == 1) // { // string ret3 = Utils.GetCoopAPI(mmt.Tid, invdesc.ToString("0.00"), 2); // LoggerHelper.Info("渠道合作第一次返回结果:" + ret3 + " 用户id:" + mmt.registerid + " 订单id " + p.OrdId); // } //} //#endregion /*此处注册奖励业务*/ ////注册奖历 //B_bonus_account bb = new B_bonus_account(); //M_bonus_account mb = new M_bonus_account(); //M_bonus_account_water mbaw = new M_bonus_account_water(); //B_bonus_account_water bbaw = new B_bonus_account_water(); //string invcode = dt.Rows[0]["invitationcode"].ToString(); //string uid = dt.Rows[0]["investor_registerid"].ToString(); //LoggerHelper.Info(" /*验证码*/:" + invcode); //if (invcode != null && invcode != "") //{ // DateTime dte = DateTime.Now; // string codesql = "SELECT invcode,Invpeopleid,invpersonid from hx_td_Userinvitation where invcode='" + invcode + "' and invpersonid=" + uid + " ";//查询本人是否已经被邀请注册过 // LoggerHelper.Info("codesql2:" + codesql); // DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql); // if (dtcode.Rows.Count > 0) // { // int uuid = int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()); //邀请用户id // B_member_table oy = new B_member_table(); // M_member_table py = new M_member_table(); // //获取 邀请用户身份渠道用户不执行 // py = oy.GetModel(uuid); // if (py.useridentity != 4) // { // //受邀好友首次成功投资 // #region 首次投资活动奖励 // ACTInvitation aci = new ACTInvitation(); // #region 受邀好友首次成功投资给予活动奖励 // if (invcount == 1) //受邀好友首次成功投资给予活动奖励 // { // hx_UserAct hut = aci.YaoAmtAct(uuid, int.Parse(dtcode.Rows[0]["invpersonid"].ToString()), -1, 4, 1, 1, 0, 5); // if (hut != null) // { // mbaw.bonus_account_id = hut.UserAct; // mbaw.membertable_registerid = uuid; // mbaw.income = decimal.Parse(hut.Amt.ToString()); // mbaw.expenditure = 0.00M; // mbaw.time_of_occurrence = DateTime.Now; // mbaw.award_description = "邀请好友首次投资成功" + hut.Amt.ToString() + "元奖励"; // mbaw.water_type = 0; // bbaw.Add(mbaw); // } // } // #endregion // #region 受邀用户续投奖励 // ///受邀用户续投奖励 // if (invcount >= 2) // { // if (py.LostInvitation == 0) // { // //这里需要取出受邀用户奖总数 // int biyaoUsrid = int.Parse(dt.Rows[0]["invpersonid"].ToString()); // decimal totAmt = B_usercenter.GetInviUserTotalAmt(uuid, biyaoUsrid); // hx_UserAct hut = aci.YaoAmtAct(uuid, biyaoUsrid, decimal.Parse(p.TransAmt), 4, 2, 1, totAmt, 5); // if (hut != null) // { // mbaw.bonus_account_id = hut.UserAct; // mbaw.membertable_registerid = uuid; // mbaw.income = decimal.Parse(hut.Amt.ToString()); // mbaw.expenditure = 0.00M; // mbaw.time_of_occurrence = DateTime.Now; // mbaw.award_description = "受邀用户续投奖励" + hut.Amt.ToString() + "元奖励"; // mbaw.water_type = 0; // bbaw.Add(mbaw); // } // } // } // #endregion // /* // int bbid = bb.Add(mb); // if (bbid > 0) //奖励记录成功后插入明细记录 // { // mbaw.bonus_account_id = bbid; // mbaw.membertable_registerid = uuid; // mbaw.income = mb.amount_of_reward; // mbaw.expenditure = 0.00M; // mbaw.time_of_occurrence = mb.entry_time; // // mbaw. // mbaw.award_description = "邀请投资成功10元奖励"; // mbaw.water_type = 0; // bbaw.Add(mbaw); // DbHelperSQL.RunSql(" update hx_td_Userinvitation set InvitesStates=1 where invcode='" + invcode + "' and invpersonid=" + uid + " and InvitesStates=2 "); // LoggerHelper.Info(" 后台更新数据邀请状态 update hx_td_Userinvitation set InvitesStates=1 where invcode='" + invcode + "' and invpersonid=" + uid + " and InvitesStates=2 "); // }*/ // } // } //} //#endregion #endregion #region MyRegion 系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(dt.Rows[0]["investor_registerid"].ToString()); pm.Mstate = 0; pm.MTitle = "投资成功"; pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + dt.Rows[0]["investment_amount"].ToString() + "。如有问题可咨询创利投的客服!谢谢!"; pm.PubTime = dti; pm.Mtype = 1; B_usercenter.AddMessage(pm); #endregion #region MyRegion//短信通知 MemberLogic _logic = new MemberLogic(); var smsEntity = _logic.GetSmsEmailEntity(1, 15); // 短信通知 StringBuilder sbsms = new StringBuilder(smsEntity.SEContext); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#PID#", dt.Rows[0]["targetid"].ToString()); sbsms = sbsms.Replace("#MONEY#", dt.Rows[0]["investment_amount"].ToString()); string mobile = dt.Rows[0]["mobile"].ToString(); M_td_SMS_record psms = new M_td_SMS_record(); B_td_SMS_record osms = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资成功.ToString()); psms.phone_number = mobile; psms.sendtime = DateTime.Now; psms.senduserid = int.Parse(dt.Rows[0]["investor_registerid"].ToString()); psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); #endregion } //远程调用生成合同 //var values = new NameValueCollection //{ // {"action","MUserPDF"}, // {"data",targetid}, // {"uc",useridc.ToString()}, // {"OrdId",OrdId} //}; //HttpHelper.Post(Settings.Instance.SiteDomain + "/pdf", values); } } else { } srt = "RECV_ORD_ID_" + p.OrdId; } }/*缓存检查结束位置*/ } else { } } #endregion return(Content(srt)); }
/// <summary> /// 投资成功,汇付回调页面 /// </summary> /// <returns></returns> public ActionResult CallbackRetUrl() { ViewBag.UserId = 0; ReInitiativeTender p = new ReInitiativeTender(); B_usercenter BUC = new B_usercenter(); string OrdId = "", sql = ""; int useridc = 0; string targetid = "0"; p.CmdId = DNTRequest.GetString("CmdId"); p.RespCode = DNTRequest.GetString("RespCode"); p.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); p.MerCustId = DNTRequest.GetString("MerCustId"); p.OrdId = DNTRequest.GetString("OrdId"); p.OrdDate = DNTRequest.GetString("OrdDate"); p.TransAmt = DNTRequest.GetString("TransAmt"); p.UsrCustId = DNTRequest.GetString("UsrCustId"); p.TrxId = DNTRequest.GetString("TrxId"); p.IsFreeze = DNTRequest.GetString("IsFreeze"); p.FreezeOrdId = DNTRequest.GetString("FreezeOrdId"); p.FreezeTrxId = DNTRequest.GetString("FreezeTrxId"); p.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); p.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); string merp = DNTRequest.GetString("MerPriv"); if (merp.Length > 0) { p.MerPriv = HttpUtility.UrlDecode(merp); } else { p.MerPriv = merp; } p.RespExt = HttpUtility.UrlDecode(DNTRequest.GetString("RespExt")); p.ChkValue = DNTRequest.GetString("ChkValue"); StringBuilder chkVal = new StringBuilder(); chkVal.Append(p.CmdId); chkVal.Append(p.RespCode); chkVal.Append(p.MerCustId); chkVal.Append(p.OrdId); chkVal.Append(p.OrdDate); chkVal.Append(p.TransAmt); chkVal.Append(p.UsrCustId); chkVal.Append(p.TrxId); chkVal.Append(p.IsFreeze); chkVal.Append(p.FreezeOrdId); chkVal.Append(p.FreezeTrxId); chkVal.Append(p.RetUrl); chkVal.Append(p.BgRetUrl); chkVal.Append(p.MerPriv); chkVal.Append(p.RespExt); // LoggerHelper.Info("投标RespCode" + p.RespCode + "RespExt:" + p.RespExt); string chkv = chkVal.ToString(); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.PgPubk; int ret = DllInterop.VeriSignMsg(merKeyFile, chkv, chkv.Length, p.ChkValue); // LoggerHelper.Info("验签:" + ret.ToString()); LoggerHelper.Info("前台主动投标返回报文:" + JsonHelper.Entity2Json(p)); int invcount = 0; //记录用户是否为首次投资,汲及到邀请人的操作 merp = p.MerPriv; string deviceKey = PickoutDeviceFlag(ref merp);//pick out device code from comment field p.MerPriv = merp; int registerid = 0; #region 验签 if (ret == 0) { if (p.RespCode == "000" || p.RespCode == "534" || p.RespCode == "360" || p.RespCode == "099")//p.RespCode == "322" || { string cachename = p.OrdId + "Invest" + p.UsrCustId; //LoggerHelper.Info("cachename:" + cachename); if (Settings.Instance.GeTThirdCache(cachename) == 0) { Settings.Instance.SetThirdCache(cachename); if (p.FreezeTrxId != "") { sql = "select ordstate from hx_Bid_records where ordstate =0 and OrdId='" + p.OrdId + "'"; LoggerHelper.Info("CallbackRetUrl===p.OrdId:" + p.OrdId); DataTable dts = DbHelper.Query(sql).Tables[0]; if (dts.Rows.Count > 0) { //同步处理用户金额 int d = BUC.ReInvest_success(p.UsrCustId, p.FreezeOrdId, p.TransAmt, p.FreezeTrxId, p.OrdId, p.MerPriv); LoggerHelper.Info("返回唯一冻结标识:" + p.FreezeTrxId + "事务执行结果:" + d); if (d > 0) { sql = "select targetid,bid_records_id, borrowing_title,investor_registerid ,username,mobile,invitationcode,investment_amount,life_of_loan,unit_day,borrowing_balance,bonusAmt,registerid from V_hx_Bid_records_borrowing_target where OrdId='" + p.OrdId + "'"; DataTable dt = DbHelper.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { decimal invdesc = decimal.Parse(dt.Rows[0]["investment_amount"].ToString()); OrdId = p.OrdId; useridc = int.Parse(dt.Rows[0]["investor_registerid"].ToString()); targetid = dt.Rows[0]["targetid"].ToString(); registerid = Convert.ToInt32(dt.Rows[0]["registerid"]); LoggerHelper.Info(" /*此处加入活动*/:" + targetid + " DeviceKey:" + deviceKey); //参与所有活动规则 if (!string.IsNullOrWhiteSpace(deviceKey)) { using (ActFacade actFacade = new ActFacade()) { actFacade.SendBonusAfterInvest(dt, Utils.GetDevicePlatformCode(deviceKey)); } } ViewBag.UserId = Convert.ToInt32(dt.Rows[0]["registerid"]); #region MyRegion 系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(dt.Rows[0]["investor_registerid"].ToString()); pm.Mstate = 0; pm.MTitle = "投资成功"; pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + dt.Rows[0]["investment_amount"].ToString() + "。如有问题可咨询创利投的客服!谢谢!"; pm.PubTime = dti; pm.Mtype = 1; B_usercenter.AddMessage(pm); #endregion #region MyRegion//短信通知 MemberLogic _logic = new MemberLogic(); var smsEntity = _logic.GetSmsEmailEntity(1, 15); // 短信通知 StringBuilder sbsms = new StringBuilder(smsEntity.SEContext); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#PID#", dt.Rows[0]["targetid"].ToString()); sbsms = sbsms.Replace("#MONEY#", dt.Rows[0]["investment_amount"].ToString()); string mobile = dt.Rows[0]["mobile"].ToString(); M_td_SMS_record psms = new M_td_SMS_record(); B_td_SMS_record osms = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资成功.ToString()); psms.phone_number = mobile; psms.sendtime = DateTime.Now; psms.senduserid = int.Parse(dt.Rows[0]["investor_registerid"].ToString()); psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); #endregion } } } } } }/*缓存检查结束位置*/ } #endregion return(View(p)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(M_td_System_message model) { return(dal.Update(model)); }
/// <summary> /// 无效投资标的处理 /// </summary> /// <param name="investor_registerid">投资用户id</param> /// <param name="bid_records_id">投资记录id</param> /// <param name="OrdId">投资订单号</param> /// <param name="OrdDate">投资订单日期</param> /// <param name="UsrCustId">客户号</param> /// <param name="FreezeOrdId">冻结订单号</param> /// <param name="TransAmt">交易金额</param> /// <param name="FreezeTrxId">冻结唯一标识</param> /// <param name="MerPriv">优惠券字符串</param> /// <param name="QueryTransType">查询类型 LOANS:放款交易查询 REPAYMENT:还款交易查询 TENDER:投标交易查询 CASH:取现交易查询 FREEZE:冻结解冻交易查询 </param> public void setRecords_Lost(string investor_registerid, string bid_records_id, string OrdId, string OrdDate, string UsrCustId, string FreezeOrdId, string TransAmt, string FreezeTrxId, string MerPriv, string QueryTransType = "TENDER") { TransStat ts = new TransStat(); bool d = ts.checktrans(OrdId, OrdDate, QueryTransType); if (d == false) { string sql = "update hx_UserAct set UseState=0,AmtProid=0 where UseState=3 and AmtProid=" + bid_records_id + "and registerid=" + investor_registerid; DbHelperSQL.RunSql(sql); sql = "delete hx_Bid_records where OrdId ='" + OrdId + "' and ordstate=0 and bid_records_id=" + bid_records_id; DbHelperSQL.RunSql(sql); } else {//TODO 此处有bug,自动查询的更新冻结表时缺少 FreezeTrxId 值,放款时没有该值会报错。 考虑注释该逻辑,等待汇付异步回调???? B_usercenter BUC = new B_usercenter(); //取得投标记录使用的优惠券 string AmtProid = BUC.GetBid_AmtProid(int.Parse(bid_records_id)); int de = BUC.ReInvest_success(UsrCustId, FreezeOrdId, TransAmt, FreezeTrxId, OrdId, AmtProid); if (de > 0) { string sql = "select targetid,bid_records_id, borrowing_title,investor_registerid ,username,mobile,invitationcode,investment_amount,life_of_loan,unit_day,borrowing_balance,bonusAmt from V_hx_Bid_records_borrowing_target where OrdId='" + OrdId + "'"; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { decimal investAmt = decimal.Parse(dt.Rows[0]["investment_amount"].ToString()); int registerid = int.Parse(dt.Rows[0]["investor_registerid"].ToString()); string targetid = dt.Rows[0]["targetid"].ToString(); #region 待提取为公共方法 #region MyRegion 系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = registerid; pm.Mstate = 0; pm.MTitle = "投资成功"; pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + investAmt + "。如有问题可咨询创利投的客服!谢谢!"; pm.PubTime = dti; pm.Mtype = 1; B_usercenter.AddMessage(pm); #endregion #region MyRegion //短信通知 string contxt = Utils.GetMSMEmailContext(15, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#PID#", targetid); sbsms = sbsms.Replace("#MONEY#", investAmt.ToString()); string mobile = dt.Rows[0]["mobile"].ToString(); M_td_SMS_record psms = new M_td_SMS_record(); B_td_SMS_record osms = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资成功.ToString()); psms.phone_number = mobile; psms.sendtime = DateTime.Now; psms.senduserid = registerid; psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); #endregion #region 远程调用生成合同??? 稍后替换为本地方法调用 微信端可远程调用 string postString = "action=MUserPDF&data=" + targetid.ToString() + "&uc=" + registerid.ToString() + "&OrdId=" + OrdId; string sr = Utils.PostWebRequest(Utils.GetRemote_url("pdf/index"), postString, Encoding.UTF8); #endregion #region 道合作 第一投标调用接口??? B_member_table bmt = new B_member_table(); M_member_table mmt = new M_member_table(); mmt = bmt.GetModel(registerid); if (mmt.Tid != null && mmt.Channelsource == 1) { if (B_usercenter.GetInvestCountByUserid(mmt.registerid) == 1) { string ret3 = Utils.GetCoopAPI(mmt.Tid, investAmt.ToString("0.00"), 2); LogInfo.WriteLog("前台渠道合作第一次返回结果:" + ret3 + " 用户id:" + mmt.registerid + " 订单id " + OrdId); } } #endregion #endregion 待提取为公共方法 //发放奖励 ActFacade act = new ActFacade(); act.SendBonusAfterInvest(dt, EnumCommon.E_hx_ActivityTable.E_ActTargetPlatform.web); } } } }
/// <summary> /// 活动企业向用户转账 /// </summary> /// <returns></returns> public ActionResult ToUserTransfer() { // Thread.Sleep(6000); string str = ""; ReTransfer p = new ReTransfer(); p.CmdId = DNTRequest.GetString("CmdId"); p.RespCode = DNTRequest.GetString("RespCode"); p.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); p.OrdId = DNTRequest.GetString("OrdId"); p.OutCustId = DNTRequest.GetString("OutCustId"); p.OutAcctId = DNTRequest.GetString("OutAcctId"); p.TransAmt = DNTRequest.GetString("TransAmt"); p.InCustId = DNTRequest.GetString("InCustId"); p.InAcctId = DNTRequest.GetString("InAcctId"); p.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); p.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); p.MerPriv = DNTRequest.GetString("MerPriv"); p.ChkValue = DNTRequest.GetString("ChkValue"); StringBuilder builder = new StringBuilder(); builder.Append(p.CmdId); builder.Append(p.RespCode); builder.Append(p.OrdId); builder.Append(p.OutCustId); builder.Append(p.OutAcctId); builder.Append(p.TransAmt); builder.Append(p.InCustId); builder.Append(p.InAcctId); builder.Append(HttpUtility.UrlDecode(p.RetUrl)); builder.Append(HttpUtility.UrlDecode(p.BgRetUrl)); builder.Append(p.MerPriv); string chkv = builder.ToString(); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); int ret = DllInterop.VeriSignMsg(merKeyFile, chkv, chkv.Length, p.ChkValue); string log = "后台平台向用户活动转账后"; log += "<br>1台验签:" + ret.ToString(); log += "<br>1台主动投标返回报文:" + FastJSON.toJOSN(p); LogInfo.WriteLog(log); if (ret == 0) { if (p.RespCode == "000") { #region 验签缓存处理 string cachename = p.OrdId + "ToUserTransfer" + p.InCustId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); B_usercenter BUC = new B_usercenter(); int bid_records_id = DbHelperSQL.Execint(" select amtproid from hx_UserAct where OrderID='" + p.OrdId + "' and UseState=5"); int ic = BUC.UpateActToUserTransfer(p, bid_records_id); if (ic > 0) { string sql = "SELECT registerid,username,mobile from hx_member_table where UsrCustId='" + p.InCustId + "'"; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { int ActID = int.Parse(p.MerPriv); hx_ActivityTable hat = ef.hx_ActivityTable.Where(c => c.ActID == ActID).FirstOrDefault(); #region 流水信息 /* * B_usercenter ors = new B_usercenter(); * decimal di = ors.GetUsridAvailable_balance(int.Parse(dt.Rows[0]["registerid"].ToString())); * // di = di + decimal.Parse(hua.Amt.ToString()); * StringBuilder strSql = new StringBuilder(); * strSql.Append("insert into hx_Capital_account_water("); * strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)"); * strSql.Append(" values ("); * strSql.Append("" + int.Parse(dt.Rows[0]["registerid"].ToString()) + "," + decimal.Parse(p.TransAmt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.现金奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + "现金奖励" + "')"); * * DbHelperSQL.RunSql(strSql.ToString()); * * strSql.Clear(); */ #endregion #region 奖励流水 M_bonus_account_water mbaw = new M_bonus_account_water(); B_bonus_account_water bbaw = new B_bonus_account_water(); DateTime dte = DateTime.Now; mbaw.bonus_account_id = int.Parse(hat.ActID.ToString()); mbaw.membertable_registerid = int.Parse(dt.Rows[0]["registerid"].ToString()); mbaw.income = decimal.Parse(p.TransAmt); mbaw.expenditure = 0.00M; mbaw.time_of_occurrence = DateTime.Now; mbaw.award_description = hat.ActName + "奖励已汇入个人账户"; mbaw.water_type = 0; bbaw.Add(mbaw); #endregion #region MyRegion 系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(dt.Rows[0]["registerid"].ToString()); pm.Mstate = 0; pm.MTitle = hat.ActName; pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目,现金奖励 " + p.TransAmt + "元。如有问题可咨询创利投的客服!"; pm.PubTime = dti; pm.Mtype = 2; B_usercenter.AddMessage(pm); #endregion } } } #endregion str = "RECV_ORD_ID_" + p.OrdId.ToString(); } else { } } return(Content(str)); }
/// <summary> /// 投资成功,汇付后台主动通知 /// </summary> /// <returns></returns> public ActionResult BG_investment_success() { int id = 0; string srt = ""; ReInitiativeTender p = new ReInitiativeTender(); id = DNTRequest.GetInt("id", 0); string log = ""; log += "主动通知后台有响应成功!接收到的项目id=" + id; p.CmdId = DNTRequest.GetString("CmdId"); p.RespCode = DNTRequest.GetString("RespCode"); p.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); p.MerCustId = DNTRequest.GetString("MerCustId"); p.OrdId = DNTRequest.GetString("OrdId"); p.OrdDate = DNTRequest.GetString("OrdDate"); p.TransAmt = DNTRequest.GetString("TransAmt"); p.UsrCustId = DNTRequest.GetString("UsrCustId"); p.TrxId = DNTRequest.GetString("TrxId"); p.IsFreeze = DNTRequest.GetString("IsFreeze"); p.FreezeOrdId = DNTRequest.GetString("FreezeOrdId"); p.FreezeTrxId = DNTRequest.GetString("FreezeTrxId"); p.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); p.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); string merp = DNTRequest.GetString("MerPriv"); if (merp.Length > 0) { p.MerPriv = HttpUtility.UrlDecode(merp); } else { p.MerPriv = merp; } p.RespExt = HttpUtility.UrlDecode(DNTRequest.GetString("RespExt")); p.ChkValue = DNTRequest.GetString("ChkValue"); StringBuilder chkVal = new StringBuilder(); chkVal.Append(p.CmdId); chkVal.Append(p.RespCode); chkVal.Append(p.MerCustId); chkVal.Append(p.OrdId); chkVal.Append(p.OrdDate); chkVal.Append(p.TransAmt); chkVal.Append(p.UsrCustId); chkVal.Append(p.TrxId); chkVal.Append(p.IsFreeze); chkVal.Append(p.FreezeOrdId); chkVal.Append(p.FreezeTrxId); chkVal.Append(p.RetUrl); chkVal.Append(p.BgRetUrl); chkVal.Append(p.MerPriv); chkVal.Append(p.RespExt); string chkv = chkVal.ToString(); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); int ret = DllInterop.VeriSignMsg(merKeyFile, chkv, chkv.Length, p.ChkValue); log += "<br>投标后台主动投标返回报文:" + FastJSON.toJOSN(p); string sql = ""; int invcount = 0; //记录用户是否是首次投资 #region 验签 if (ret == 0) { if (p.RespCode == "000" || p.RespCode == "322" || p.RespCode == "534" || p.RespCode == "360" || p.RespCode == "099") { string cachename = p.OrdId + "InvestWeb" + p.UsrCustId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); if (p.FreezeTrxId != "") { sql = "select ordstate from hx_Bid_records where ordstate =0 and OrdId='" + p.OrdId + "'"; DataTable dts = DbHelperSQL.GET_DataTable_List(sql); if (dts.Rows.Count > 0) { //同步处理用户金额 B_usercenter BUC = new B_usercenter(); int d = BUC.ReInvest_success(p.UsrCustId, p.FreezeOrdId, p.TransAmt, p.FreezeTrxId, p.OrdId, p.MerPriv); log += "<br>后台投标:id" + id.ToString() + "返回唯一冻结标识:" + p.FreezeTrxId + "事务执行结果:" + d.ToString(); if (d > 0) { sql = "select targetid,bid_records_id, borrowing_title,investor_registerid ,username,mobile,invitationcode,investment_amount,life_of_loan,unit_day,borrowing_balance,bonusAmt from V_hx_Bid_records_borrowing_target where OrdId='" + p.OrdId + "'"; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { decimal investAmt = decimal.Parse(dt.Rows[0]["investment_amount"].ToString()); string OrdId = p.OrdId; int registerid = int.Parse(dt.Rows[0]["investor_registerid"].ToString()); ViewBag.userid = registerid; string targetid = dt.Rows[0]["targetid"].ToString(); #region 待提取为公共方法 #region MyRegion 系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = registerid; pm.Mstate = 0; pm.MTitle = "投资成功"; pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + investAmt + "。如有问题可咨询创利投的客服!谢谢!"; pm.PubTime = dti; pm.Mtype = 1; B_usercenter.AddMessage(pm); #endregion #region MyRegion //短信通知 string contxt = Utils.GetMSMEmailContext(15, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#PID#", targetid); sbsms = sbsms.Replace("#MONEY#", investAmt.ToString()); string mobile = dt.Rows[0]["mobile"].ToString(); M_td_SMS_record psms = new M_td_SMS_record(); B_td_SMS_record osms = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资成功.ToString()); psms.phone_number = mobile; psms.sendtime = DateTime.Now; psms.senduserid = registerid; psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); #endregion #region 远程调用生成合同??? 稍后替换为本地方法调用 微信端可远程调用 string postString = "action=MUserPDF&data=" + targetid.ToString() + "&uc=" + registerid.ToString() + "&OrdId=" + OrdId; string sr = Utils.PostWebRequest(Utils.GetRemote_url("pdf/index"), postString, Encoding.UTF8); #endregion #region 道合作 第一投标调用接口??? B_member_table bmt = new B_member_table(); M_member_table mmt = new M_member_table(); mmt = bmt.GetModel(registerid); if (mmt.Tid != null && mmt.Channelsource == 1) { if (B_usercenter.GetInvestCountByUserid(mmt.registerid) == 1) { string ret3 = Utils.GetCoopAPI(mmt.Tid, investAmt.ToString("0.00"), 2); log += "<br>前台渠道合作第一次返回结果:" + ret3 + " 用户id:" + mmt.registerid + " 订单id " + OrdId; } } #endregion #endregion 待提取为公共方法 //发放奖励 ActFacade act = new ActFacade(); act.SendBonusAfterInvest(dt, EnumCommon.E_hx_ActivityTable.E_ActTargetPlatform.web); #region 线 投资六月专享标一元抢Iphone 2016年9月11日 9点 至2016年9月30日 if (false) { DateTime nowdate = DateTime.Now; DateTime startdate = new DateTime(2016, 09, 11, 9, 00, 00); DateTime enddate = new DateTime(2016, 09, 30, 23, 59, 59); if (nowdate > startdate && nowdate < enddate) { log += "<br>PC端【一元抢Iphone】"; log += "<br>标的期限:" + dt.Rows[0]["life_of_loan"].ToString(); if (dt.Rows[0]["unit_day"].ToString() == "1" && dt.Rows[0]["life_of_loan"].ToString() == "6")//是否六月标 { log += "<br>用户注册时间:" + mmt.Registration_time.ToString(); if (mmt.Registration_time > new DateTime(2016, 09, 11, 0, 0, 0)) { B_GrabIphone gi = new B_GrabIphone(); bool isCount = gi.Exists(mmt.registerid);//查询是否存在该用户 log += "<br> 用户ID:" + mmt.registerid + ";查询是否存在该用户:" + isCount; if (isCount != true) { M_GrabIphone model = new M_GrabIphone(); model.RegrsterID = mmt.registerid; model.Color = ""; model.Addtime = nowdate; model.LuckDrawState = 0; model.WinningState = 0; model.WinningTime = nowdate; model.TargetID = int.Parse(dt.Rows[0]["targetid"].ToString()); model.BidRecordsID = int.Parse(dt.Rows[0]["bid_records_id"].ToString()); model.InvestmentAmount = dt.Rows[0]["investment_amount"].ToString(); gi.Add(model); //增加一条数据 int ljcount = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["GrabIphone"].ToString()); //获取启动抽奖人数 List <M_GrabIphone> giList = gi.GetModelList(ljcount, "LuckDrawState=0", "ID"); //获取当前阶段投资人数 if (giList != null) { log += "<br>当前阶段投资人数:" + giList.Count; if (giList.Count >= ljcount) { bool bo = gi.UpdateLuckDrawState();//批量更新抽奖状态 log += "<br> 批量更新抽奖状态:" + bo; if (bo == true) { int count = giList.Count; int index = new Random().Next(count); M_GrabIphone randowitem = giList[index]; if (randowitem != null) { log += "<br> 获奖用户ID:" + randowitem.RegrsterID; bool co = gi.Update("", 1, DateTime.Now, randowitem.RegrsterID);//更新中奖用户状态 log += "<br> 更新中奖用户状态:" + co; } } } } } } } } } #endregion } } } srt = "RECV_ORD_ID_" + p.OrdId; } }/*缓存检查结束位置*/ } } LogInfo.WriteLog(log); #endregion return(Content(srt)); }
/// <summary> /// 普通提现汇付后台主动通知 /// </summary> /// <returns></returns> public ActionResult PostGENERALAmt() { string str1 = ""; ReCash m = new ReCash(); m.CmdId = DNTRequest.GetString("CmdId"); m.RespCode = DNTRequest.GetString("RespCode"); m.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); m.MerCustId = DNTRequest.GetString("MerCustId"); m.OrdId = DNTRequest.GetString("OrdId"); m.UsrCustId = DNTRequest.GetString("UsrCustId"); m.TransAmt = DNTRequest.GetString("TransAmt"); m.OpenAcctId = DNTRequest.GetString("OpenAcctId"); m.OpenBankId = DNTRequest.GetString("OpenBankId"); m.FeeAmt = DNTRequest.GetString("FeeAmt"); m.FeeCustId = DNTRequest.GetString("FeeCustId"); m.FeeAcctId = DNTRequest.GetString("FeeAcctId"); m.ServFee = DNTRequest.GetString("ServFee"); m.ServFeeAcctId = DNTRequest.GetString("ServFeeAcctId"); m.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); m.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); m.MerPriv = DNTRequest.GetString("MerPriv"); m.RespExt = HttpUtility.UrlDecode(DNTRequest.GetString("RespExt")); m.ChkValue = DNTRequest.GetString("ChkValue"); LogInfo.WriteLog("后台取现返回报文:" + FastJSON.toJOSN(m)); //验签 StringBuilder chkVal = new StringBuilder(); chkVal.Append(m.CmdId); chkVal.Append(m.RespCode); chkVal.Append(m.MerCustId); chkVal.Append(m.OrdId); chkVal.Append(m.UsrCustId); chkVal.Append(m.TransAmt); chkVal.Append(m.OpenAcctId); chkVal.Append(m.OpenBankId); chkVal.Append(m.FeeAmt); chkVal.Append(m.FeeCustId); chkVal.Append(m.FeeAcctId); chkVal.Append(m.ServFee); chkVal.Append(m.ServFeeAcctId); chkVal.Append(m.RetUrl); 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()); StringBuilder str = new StringBuilder(); if (ret == 0) { //提现成功后,得多事务处理账户金额,流水及冻结金额等 if (m.RespCode == "000") { string cachename = m.OrdId + "Cash" + m.UsrCustId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); B_usercenter BUC = new B_usercenter(); M_ReqExt mre = JsonConvert.DeserializeObject <M_ReqExt>(m.RespExt.Replace("[", "").Replace("]", "")); int CashOp = BUC.CashTran(m.OpenAcctId, m.OpenBankId, m.OrdId, m.TransAmt, m.UsrCustId, m.FeeAmt, mre.FeeObjFlag, mre.CashChl); //int CashOp = BUC.CashTran(m.OpenAcctId, m.OpenBankId, m.OrdId, m.TransAmt, m.UsrCustId); if (CashOp > 0) { string sql = "select registerid,username,mobile,UsrCustId,available_balance from hx_member_table where UsrCustId='" + m.UsrCustId + "'"; LogInfo.WriteLog("后台审请取现成功短信sql:" + sql); DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { //短信通知 //尊敬的#USERANEM#,您已成功提现#MONEY#元,账户余额#MONEY1#.请注意查收!【创利投】 string contxt = Utils.GetMSMEmailContext(12, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#MONEY#", m.TransAmt); decimal amt = decimal.Parse(dt.Rows[0]["available_balance"].ToString()) - decimal.Parse(m.TransAmt); sbsms = sbsms.Replace("#MONEY1#", amt.ToString()); string mobile = dt.Rows[0]["mobile"].ToString(); M_td_SMS_record psms = new M_td_SMS_record(); B_td_SMS_record osms = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.取现成功.ToString()); psms.phone_number = mobile; psms.sendtime = DateTime.Now; psms.senduserid = int.Parse(dt.Rows[0]["registerid"].ToString()); psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(dt.Rows[0]["registerid"].ToString()); pm.Mstate = 0; pm.MTitle = "提现成功"; pm.MContext = sbsms.ToString(); pm.PubTime = dti; pm.Mtype = 3; B_usercenter.AddMessage(pm); if (mre.CashChl == "IMMEDIATE" && decimal.Parse(m.TransAmt) <= 200000M) { string retUrl = Utils.GetRe_url("admin/UserCash/RePostCashProcessing"); string bgRetUrl = Utils.GetRe_url("admin/Thirdparty/BgCashProcessing"); BusinessLogicHelper.AutoCheckCash(m.UsrCustId, retUrl, bgRetUrl); } } } } str1 = "RECV_ORD_ID_" + m.OrdId; } } return(Content(str1)); }
/// <summary> /// 充值汇付后台主动通知 /// </summary> /// <returns></returns> public ActionResult ReQPNetSave() { string str1 = ""; Utils.SetSYSDateTimeFormat(); ReQPNetSave m = new ReQPNetSave(); m.CmdId = DNTRequest.GetString("CmdId"); m.RespCode = DNTRequest.GetString("RespCode"); m.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); m.MerCustId = DNTRequest.GetString("MerCustId"); m.UsrCustId = DNTRequest.GetString("UsrCustId"); m.OrdId = DNTRequest.GetString("OrdId"); m.OrdDate = DNTRequest.GetString("OrdDate"); m.TransAmt = DNTRequest.GetString("TransAmt"); m.TrxId = DNTRequest.GetString("TrxId"); m.GateBusiId = DNTRequest.GetString("GateBusiId"); m.GateBankId = DNTRequest.GetString("GateBankId"); m.FeeAmt = DNTRequest.GetString("FeeAmt"); m.FeeCustId = DNTRequest.GetString("FeeCustId"); m.FeeAcctId = DNTRequest.GetString("FeeAcctId"); m.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); m.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); m.CardId = DNTRequest.GetString("CardId"); m.MerPriv = HttpUtility.UrlDecode(DNTRequest.GetString("MerPriv")); // m.MerPriv = DESEncrypt.Decrypt(DNTRequest.GetString("MerPriv"), ConfigurationManager.AppSettings["webp"].ToString()); m.ChkValue = DNTRequest.GetString("ChkValue"); StringBuilder chkVal = new StringBuilder(); chkVal.Append(m.CmdId); chkVal.Append(m.RespCode); chkVal.Append(m.MerCustId); chkVal.Append(m.UsrCustId); chkVal.Append(m.OrdId); chkVal.Append(m.OrdDate); chkVal.Append(m.TransAmt); chkVal.Append(m.TrxId); chkVal.Append(m.RetUrl); chkVal.Append(m.BgRetUrl); chkVal.Append(m.MerPriv); 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); // Response.Write("验签:" + ret.ToString()); LogInfo.WriteLog("快充接口后台验签:ret=" + ret.ToString() + " RespCode:" + m.RespCode + m.RespDesc); LogInfo.WriteLog("快充接口后台充值返回报文:" + FastJSON.toJOSN(m)); StringBuilder str = new StringBuilder(); string sql = ""; if (ret == 0) { if (m.RespCode == "000") { string MerPrivTemp = DESEncrypt.Decrypt(m.MerPriv, ConfigurationManager.AppSettings["webp"].ToString()); string[] arr = Utils.SplitString(MerPrivTemp, "_"); //第一位是用户id 二是 记录id int userid = int.Parse(arr[0]); int reid = int.Parse(arr[1]); string cachename = m.OrdId + userid.ToString() + reid.ToString(); if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); sql = "select recharge_condition from hx_Recharge_history where recharge_condition=0 and recharge_history_id=" + reid + " and order_No='" + m.OrdId + "'"; DataTable dtr = DbHelperSQL.GET_DataTable_List(sql); if (dtr.Rows.Count > 0) { LogInfo.WriteLog("快充接口后台充值数据没有写入情况下操作>>>>>>>>>>>>>>>>>>>>>>>"); M_Recharge_history rh = new M_Recharge_history(); M_Capital_account_water aw = new M_Capital_account_water(); B_member_table o = new B_member_table(); M_member_table p = new M_member_table(); p = o.GetModel(userid); rh.membertable_registerid = userid; rh.recharge_amount = decimal.Parse(m.TransAmt); rh.recharge_time = DateTime.Now; rh.account_amount = decimal.Parse(m.TransAmt); rh.order_No = m.OrdId; rh.recharge_condition = 1; //1表示充值成功 rh.recharge_bank = m.GateBankId; // 得接口返回; rh.recharge_history_id = reid; //本值提交里存的充值id aw.membertable_registerid = userid; aw.income = decimal.Parse(m.TransAmt); aw.expenditure = 0.00M; aw.time_of_occurrence = rh.recharge_time; aw.account_balance = p.available_balance + aw.income; //要得么帐户余额 aw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.充值.ToString()); aw.createtime = DateTime.Now; aw.keyid = 0; aw.remarks = m.OrdId; B_usercenter BUC = new B_usercenter(); int bucrec = BUC.rechargeTran(rh, aw); #region MyRegion 系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = p.registerid; pm.Mstate = 0; pm.MTitle = "充值成功"; pm.MContext = "尊敬的用户" + p.username + ":您好!恭喜您充值成功,充值金额是:" + rh.recharge_amount.ToString() + "。如有问题可咨询创利投的客服!谢谢!"; pm.PubTime = dti; pm.Mtype = 4; B_usercenter.AddMessage(pm); #endregion LogInfo.WriteLog("后台充值事务操作返回码小于=0 操作失败:" + bucrec.ToString()); if (m.GateBusiId == "QP") { sql = "select UsrBindCardID from hx_UsrBindCardC where UsrCustId='" + m.UsrCustId + "' and OpenAcctId='" + m.CardId + "'"; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { sql = "update hx_UsrBindCardC set BindCardType =1 where UsrCustId='" + m.UsrCustId + "' and OpenAcctId='" + m.CardId + "' "; DbHelperSQL.RunSql(sql); } else { sql = "INSERT INTO hx_UsrBindCardC (UsrCustId,OpenAcctId,OpenBankId,defCard,BindCardType) VALUES ('" + m.UsrCustId + "','" + m.CardId + "','" + m.GateBankId + "',1,1)"; DbHelperSQL.RunSql(sql); sql = "update hx_member_table set isbankcard=1 where registerid=" + userid.ToString(); DbHelperSQL.RunSql(sql); } } } } str1 = "RECV_ORD_ID_" + m.TrxId; } } return(Content(str1)); }