public ActionResult CashProcessingMore(string str) { string json = ""; if (string.IsNullOrEmpty(str)) { json = @"{""ret"":0,""msg"":""参数错误""}"; } string strCount = ""; string bid = str; string[] s = bid.Split(new char[] { ',' }); string sqllist = ""; for (int i = 0; i < s.Length; i++) { sqllist = sqllist + "'" + s[i] + "',"; } if (sqllist.Contains(",")) { bid = Utils.ClearLastChar(sqllist); } int orstate = 1; sqllist = " select registerid,UserCashId,OrdId,OrdIdState,TransAmt,BankName,OpenBankId,OpenAcctId,UsrCustId,realname,Reason,Remarks,available_balance from V_UserCash_Bank "; sqllist += " where UserCashId in (" + bid + ")"; DataTable dt = DbHelperSQL.GET_DataTable_List(sqllist); int succ = 0, lost = 0; for (int i = 0; i < dt.Rows.Count; i++) { M_CashAudit mc = new M_CashAudit(); mc.Version = "10"; mc.CmdId = "CashAudit"; mc.MerCustId = Utils.GetMerCustID(); mc.OrdId = dt.Rows[i]["OrdId"].ToString(); mc.UsrCustId = dt.Rows[i]["UsrCustId"].ToString(); mc.TransAmt = dt.Rows[i]["TransAmt"].ToString(); //判定用户在审核期间内把卡号 移除或取消绑定 或 绑定 状态等于0 string bindCardSql = " SELECT * FROM hx_UsrBindCardC WHERE UsrCustId='{0}' AND OpenAcctId='{1}' "; bindCardSql = string.Format(bindCardSql, dt.Rows[i]["UsrCustId"].ToString(), dt.Rows[i]["OpenAcctId"].ToString()); DataTable bcDt = DbHelperSQL.GET_DataTable_List(bindCardSql); if (bcDt == null || bcDt.Rows.Count == 0) { orstate = 4; } if (orstate == 4) { mc.AuditFlag = "R"; } else { mc.AuditFlag = "S"; } // mc.BgRetUrl = ""; mc.BgRetUrl = Utils.GetRe_url("admin/Thirdparty/BgCashProcessing"); mc.MerPriv = "chuanglitou"; StringBuilder chkVal = new StringBuilder(); chkVal.Append(mc.Version); chkVal.Append(mc.CmdId); chkVal.Append(mc.MerCustId); chkVal.Append(mc.OrdId); chkVal.Append(mc.UsrCustId); chkVal.Append(mc.TransAmt); chkVal.Append(mc.AuditFlag); // chkVal.Append(mc.RetUrl); chkVal.Append(mc.BgRetUrl); chkVal.Append(mc.MerPriv); string chkv = chkVal.ToString(); LogInfo.WriteLog("批量取现审核chkv字符:" + chkv); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetMerPr(); //需要指定提交字符串的长度 int len = Encoding.UTF8.GetBytes(chkv).Length; StringBuilder sbChkValue = new StringBuilder(256); //加签 int strer = DllInterop.SignMsg(Utils.GetMerId(), merKeyFile, chkv, len, sbChkValue); mc.ChkValue = sbChkValue.ToString(); LogInfo.WriteLog("批量取现审核提交信息:" + FastJSON.toJOSN(mc)); using (var client = new WebClient()) { var values = new NameValueCollection(); values.Add("Version", mc.Version); values.Add("CmdId", mc.CmdId); values.Add("MerCustId", mc.MerCustId); values.Add("OrdId", mc.OrdId); values.Add("UsrCustId", mc.UsrCustId); values.Add("TransAmt", mc.TransAmt); values.Add("AuditFlag", mc.AuditFlag); values.Add("BgRetUrl", mc.BgRetUrl); values.Add("MerPriv", mc.MerPriv); values.Add("ChkValue", mc.ChkValue); string url = Utils.GetChinapnrUrl(); //同步发送form表单请求 byte[] result = client.UploadValues(url, "POST", values); var retStr = Encoding.UTF8.GetString(result); // Response.Write(retStr); // LogInfo.WriteLog("批量取现审同步form表单请求" + retStr); ReCashAudit ReCa = new ReCashAudit(); var Re = (ReCashAudit)FastJSON.ToObject(retStr, ReCa); LogInfo.WriteLog("批量取现审返回报文:" + FastJSON.toJOSN(Re)); StringBuilder builder = new StringBuilder(); builder.Append(Re.CmdId); builder.Append(Re.RespCode); builder.Append(Re.MerCustId); builder.Append(Re.OrdId); builder.Append(Re.UsrCustId); builder.Append(Re.TransAmt); builder.Append(Re.OpenAcctId); builder.Append(Re.OpenBankId); builder.Append(Re.AuditFlag); builder.Append(HttpUtility.UrlDecode(Re.BgRetUrl)); builder.Append(Re.MerPriv); var msg = builder.ToString(); LogInfo.WriteLog("批量取现审验签文明:" + 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) { //更新数据库 string sql = ""; if (orstate == 1) { sql = "update hx_td_UserCash set Remarks='' where UserCashId=" + dt.Rows[i]["UserCashId"].ToString(); DbHelperSQL.RunSql(sql); } else if (orstate == 3) { sql = "update hx_td_UserCash set Remarks='',OrdIdState=3 ,OperTime='" + DateTime.Now.ToString() + "' where UserCashId=" + dt.Rows[i]["UserCashId"].ToString(); DbHelperSQL.RunSql(sql); } else if (orstate == 4) { // sql = "update hx_td_UserCash set Remarks='" + Utils.CheckSQLHtml(model.Remarks) + "', Reason='" + Utils.CheckSQLHtml(model.Reason) + "',OrdIdState=4 ,OperTime='" + DateTime.Now.ToString() + "' where UserCashId=" + UserCashId.ToString(); // sql += ";update hx_member_table set available_balance=available_balance+" + dt.Rows[0]["TransAmt"].ToString() + ",frozen_sum=frozen_sum-" + dt.Rows[0]["TransAmt"].ToString() + " where registerid=" + dt.Rows[0]["registerid"].ToString(); // DbHelperSQL.RunSql(sql); // return Content(StringAlert.Alert("取现未通过,金额已退还!", "/admin/UserCash/CashProcessing?UserCashId=" + model.UserCashId)); } if (Re.RespCode == "000" || Re.RespCode == "999" || Re.RespCode == "406") { string cachename = Re.OrdId + "Cash" + Re.UsrCustId + Re.TransAmt.ToString(); if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); //提现成功后,得多事务处理账户金额,流水等 B_usercenter BUC = new B_usercenter(); M_Capital_account_water aw = new M_Capital_account_water(); if (BUC.Su_CashProcessing(Re, aw) > 0) { strCount += Re.OrdId + " 取款审核成功<br /> "; LogInfo.WriteLog("后台取款审核成功:" + str); succ = succ + 1; } else { lost = lost + 1; strCount += Re.OrdId + " 取款审核失败<br /> "; LogInfo.WriteLog("后台取款审核事误操作失败"); } } } else { lost = lost + 1; strCount += Re.OrdId + " 取款审核失败 (" + Re.RespCode + ")<br /> "; LogInfo.WriteLog("后台提现失败" + Re.RespCode); } } else { // Response.Write(Re.UsrCustId + "取款审核验签失败 原因: " + Re.RespDesc + " <br>"); } } } json = @"{""ret"":1,""msg"":""<div style='margin: 9px;line-height:20px;'>批量复核操作成功 RR</div>"" }"; string sfd = succ.ToString() + "笔成功, " + lost.ToString() + "失败<br />" + strCount + " "; json = json.Replace("RR", sfd); return(Content(json, "text/json")); }
public ActionResult BgCashProcessing() { // Response.BufferOutput = true; // System.Threading.Thread.Sleep(1000); string str = ""; ReCashAudit m = new ReCashAudit(); 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.AuditFlag = DNTRequest.GetString("AuditFlag"); 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.MerPriv = HttpUtility.UrlDecode(DNTRequest.GetString("MerPriv")); 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.AuditFlag); 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); LogInfo.WriteLog("后台验签返回参数:" + ret.ToString()); #region 核验签结果 if (ret == 0) { if (m.RespCode == "000" || m.RespCode == "999" || m.RespCode == "406") { System.Threading.Thread.Sleep(500); string cachename = m.OrdId + "Cash" + m.UsrCustId + m.TransAmt.ToString(); if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); //提现成功后,得多事务处理账户金额,流水等 B_usercenter BUC = new B_usercenter(); M_Capital_account_water aw = new M_Capital_account_water(); if (BUC.Su_CashProcessing(m, aw) > 0) { str = "RECV_ORD_ID_" + m.OrdId; LogInfo.WriteLog("后台取款审核成功" + str); } else { LogInfo.WriteLog("后台取款审核事误操作失败"); } } str = "RECV_ORD_ID_" + m.OrdId; } else { LogInfo.WriteLog("后台提现失败"); } } else { LogInfo.WriteLog("后台验签失败"); } #endregion return(Content(str)); }
/// <summary> /// 汇付回调逻辑 /// </summary> /// <param name="m"></param> public static void RePostCashHelper(ReCashAudit m) { string str = ""; 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.AuditFlag); 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); LogInfo.WriteLog("前台取现复核验签返回参数:" + ret.ToString()); #region 核验签成功 if (ret == 0) { //在406取现失败后,再次复核申请时会变成415 if (m.RespCode == "000" || m.RespCode == "999" || m.RespCode == "406") { string cachename = m.OrdId + "Cash" + m.UsrCustId + m.TransAmt.ToString(); if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); //提现成功后,得多事务处理账户金额,流水等 B_usercenter BUC = new B_usercenter(); M_Capital_account_water aw = new M_Capital_account_water(); if (BUC.Su_CashProcessing(m, aw) > 0) { str = "RECV_ORD_ID_" + m.OrdId; LogInfo.WriteLog("后台取款审核成功" + str); } else { LogInfo.WriteLog("后台取款审核事误操作失败"); } } } else { LogInfo.WriteLog("后台提现失败"); } } else { LogInfo.WriteLog("后台验签失败"); } #endregion }