diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/ReceiveSendFeeManagement/Controllers/FinaChargeStuYearController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/ReceiveSendFeeManagement/Controllers/FinaChargeStuYearController.cs index cf348c360..fd990b47d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/ReceiveSendFeeManagement/Controllers/FinaChargeStuYearController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/ReceiveSendFeeManagement/Controllers/FinaChargeStuYearController.cs @@ -15,6 +15,9 @@ using Learun.Util.Operat; using Newtonsoft.Json; using ThoughtWorks.QRCode.Codec; using System.Threading.Tasks; +using System.Net.NetworkInformation; +using System.Net; +using System.Net.Http; namespace Learun.Application.Web.Areas.ReceiveSendFeeManagement.Controllers { @@ -96,7 +99,7 @@ namespace Learun.Application.Web.Areas.ReceiveSendFeeManagement.Controllers return Success(new { success = "1" }); } else - return Success(new { success = "0",info= "当前不在缴费时间范围" }); + return Success(new { success = "0", info = "当前不在缴费时间范围" }); } [HttpGet] @@ -206,8 +209,8 @@ namespace Learun.Application.Web.Areas.ReceiveSendFeeManagement.Controllers { finaChargeStuYearIBLL.DeleteEntity(keyValue); return Success("删除成功!"); - } - + } + [HttpPost] [AjaxOnly] public ActionResult SetUnInvoiceHandleByFSYID(string keyValue) @@ -215,7 +218,7 @@ namespace Learun.Application.Web.Areas.ReceiveSendFeeManagement.Controllers //触发开具发票任务 //通过调用digitalschoolapi的接口实现任务触发 string excelInvoice = Config.GetValue("ExcelInvoiceTwo"); - Task.Run(() => HttpMethods.Post(excelInvoice+ "?FSYID="+keyValue)); + Task.Run(() => HttpMethods.Post(excelInvoice + "?FSYID=" + keyValue)); return Success("操作成功!"); } /// @@ -260,62 +263,107 @@ namespace Learun.Application.Web.Areas.ReceiveSendFeeManagement.Controllers FinaChargeStuYearEntity entity = strEntity.ToObject(); List list = detailList.ToObject>(); var imgUrl = ""; - Random ran = new Random(); - string merchantid = "105000082201406";//商户号 - string posid = "043724806";//商户柜台代码 - string branchid = "510000000";//分行代码 - string orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); - string payment = entity.PayMoney.ToString(); - string curcode = "01"; - string txcode = "530550"; - string remark1 = entity.StuNo; - string remark2 = entity.FSYear.ToString(); - string returntype = "3"; - string timeout = DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"); - string pub32tr2 = "40d987faa793a0a27e7a86ef020111"; - string bankURL = "https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6"; - string tmp = "MERCHANTID=" + merchantid + "&POSID=" + posid + "&BRANCHID=" + branchid + "&ORDERID=" + orderid; - tmp += "&PAYMENT=" + payment + "&CURCODE=" + curcode + "&TXCODE=" + txcode + "&REMARK1=" + remark1; - tmp += "&REMARK2=" + remark2 + "&RETURNTYPE=" + returntype + "&TIMEOUT=" + timeout; - MD5 md5 = MD5.Create(); - string tmp1 = tmp; - tmp += "&PUB=" + pub32tr2; - byte[] buffer = Encoding.Default.GetBytes(tmp); - byte[] md5Buffer = md5.ComputeHash(buffer); - string strMd5 = ""; - //hdnOrderId.Value = orderid; - foreach (byte item in md5Buffer) - { - strMd5 += item.ToString("x2"); - } - String url = bankURL + "&" + tmp1 + "&MAC=" + strMd5; - string reJson = HttpMethods.Post(url); - LogEntity logEntity = new LogEntity(); - logEntity.F_CategoryId = 121; - logEntity.F_ExecuteResultJson = reJson; - logEntity.WriteLog(); - //HttpConnect conn = new HttpConnect(); - //string reJson = conn.Post(url, ""); - JsonBean MemberInfoList = JsonConvert.DeserializeObject(reJson); - if (MemberInfoList.SUCCESS.Equals("true")) + + //访问学校财务服务器 + string payresulturl = Config.GetValue("payresulturl"); + string par = "requestXml="; + Encoding encoding = Encoding.GetEncoding("gb2312"); + byte[] payload = encoding.GetBytes(par); + HttpClient httpClient = new HttpClient(); + HttpContent content = new ByteArrayContent(payload); + try { - string imgCode = HttpMethods.Post(MemberInfoList.PAYURL); - logEntity.F_CategoryId = 121; - logEntity.F_ExecuteResultJson = imgCode; - logEntity.WriteLog(); - MemberInfoList = JsonConvert.DeserializeObject(imgCode); - if (MemberInfoList.SUCCESS.Equals("true")) + var result = httpClient.PostAsync(payresulturl, content); + //LogEntity logEntity2 = new LogEntity(); + //logEntity2.F_CategoryId = 121; + //logEntity2.F_SourceObjectId = "preaccess"; + //logEntity2.F_SourceContentJson = "成功"; + //logEntity2.F_ExecuteResultJson = result.ToString(); + //logEntity2.WriteLog(); + + try + { + Random ran = new Random(); + string merchantid = "105000082201406";//商户号 + string posid = "043724806";//商户柜台代码 + string branchid = "510000000";//分行代码 + string orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); + string payment = entity.PayMoney.ToString(); + string curcode = "01"; + string txcode = "530550"; + string remark1 = entity.StuNo; + string remark2 = entity.FSYear.ToString(); + string returntype = "3"; + string timeout = DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"); + string pub32tr2 = "40d987faa793a0a27e7a86ef020111"; + string bankURL = "https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6"; + string tmp = "MERCHANTID=" + merchantid + "&POSID=" + posid + "&BRANCHID=" + branchid + "&ORDERID=" + orderid; + tmp += "&PAYMENT=" + payment + "&CURCODE=" + curcode + "&TXCODE=" + txcode + "&REMARK1=" + remark1; + tmp += "&REMARK2=" + remark2 + "&RETURNTYPE=" + returntype + "&TIMEOUT=" + timeout; + MD5 md5 = MD5.Create(); + string tmp1 = tmp; + tmp += "&PUB=" + pub32tr2; + byte[] buffer = Encoding.Default.GetBytes(tmp); + byte[] md5Buffer = md5.ComputeHash(buffer); + string strMd5 = ""; + //hdnOrderId.Value = orderid; + foreach (byte item in md5Buffer) + { + strMd5 += item.ToString("x2"); + } + String url = bankURL + "&" + tmp1 + "&MAC=" + strMd5; + string reJson = HttpMethods.Post(url); + LogEntity logEntity = new LogEntity(); + logEntity.F_CategoryId = 121; + logEntity.F_SourceObjectId = "qrcode"; + logEntity.F_SourceContentJson = "成功"; + logEntity.F_ExecuteResultJson = reJson; + logEntity.WriteLog(); + //HttpConnect conn = new HttpConnect(); + //string reJson = conn.Post(url, ""); + JsonBean MemberInfoList = JsonConvert.DeserializeObject(reJson); + if (MemberInfoList.SUCCESS.Equals("true")) + { + string imgCode = HttpMethods.Post(MemberInfoList.PAYURL); + logEntity.F_CategoryId = 121; + logEntity.F_SourceObjectId = "qrcode"; + logEntity.F_SourceContentJson = "成功"; + logEntity.F_ExecuteResultJson = imgCode; + logEntity.WriteLog(); + MemberInfoList = JsonConvert.DeserializeObject(imgCode); + if (MemberInfoList.SUCCESS.Equals("true")) + { + imgUrl = CreateQRImg(MemberInfoList.QRURL, orderid); + } + } + + if (!string.IsNullOrEmpty(imgUrl)) + { + entity.orderid = orderid; + finaChargeStuOrderIbll.SaveOrderData(entity, list); + } + } + catch (Exception e) { - imgUrl = CreateQRImg(MemberInfoList.QRURL, orderid); + LogEntity logEntity = new LogEntity(); + logEntity.F_CategoryId = 121; + logEntity.F_SourceObjectId = "qrcode"; + logEntity.F_SourceContentJson = "失败"; + logEntity.F_ExecuteResultJson = e.Message; + logEntity.WriteLog(); } } - - if (!string.IsNullOrEmpty(imgUrl)) + catch (Exception e) { - entity.orderid = orderid; - finaChargeStuOrderIbll.SaveOrderData(entity, list); + LogEntity logEntity = new LogEntity(); + logEntity.F_CategoryId = 121; + logEntity.F_SourceObjectId = "preaccess"; + logEntity.F_SourceContentJson = "失败"; + logEntity.F_ExecuteResultJson = e.Message; + logEntity.WriteLog(); + return Fail("缴费机器暂停缴费!"); } - + return Success(imgUrl); } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config index 03b51b1c9..d67fe1707 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config @@ -181,6 +181,7 @@ + \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/ReceiveSendFeeManagement/FinaChargeStuYearApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/ReceiveSendFeeManagement/FinaChargeStuYearApi.cs index 28c0596ee..03836c1dc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/ReceiveSendFeeManagement/FinaChargeStuYearApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/ReceiveSendFeeManagement/FinaChargeStuYearApi.cs @@ -17,6 +17,7 @@ using Learun.Application.TwoDevelopment.Ask; using Learun.Application.TwoDevelopment.ReceiveSendFeeManagement; using Newtonsoft.Json; using ThoughtWorks.QRCode.Codec; +using System.Net.Http; namespace Learun.Application.WebApi.Modules { @@ -106,62 +107,107 @@ namespace Learun.Application.WebApi.Modules FinaChargeStuYearEntity entity = parameter.strEntity.ToObject(); List list = parameter.detailList.ToObject>(); var imgUrl = ""; - Random ran = new Random(); - string merchantid = "105000082201406";//商户号 - string posid = "043724806";//商户柜台代码 - string branchid = "510000000";//分行代码 - string orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); - string payment = entity.PayMoney.ToString(); - string curcode = "01"; - string txcode = "530550"; - string remark1 = entity.StuNo; - string remark2 = entity.FSYear.ToString(); - string returntype = "3"; - string timeout = DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"); - string pub32tr2 = "40d987faa793a0a27e7a86ef020111"; - string bankURL = "https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6"; - string tmp = "MERCHANTID=" + merchantid + "&POSID=" + posid + "&BRANCHID=" + branchid + "&ORDERID=" + orderid; - tmp += "&PAYMENT=" + payment + "&CURCODE=" + curcode + "&TXCODE=" + txcode + "&REMARK1=" + remark1; - tmp += "&REMARK2=" + remark2 + "&RETURNTYPE=" + returntype + "&TIMEOUT=" + timeout; - MD5 md5 = MD5.Create(); - string tmp1 = tmp; - tmp += "&PUB=" + pub32tr2; - byte[] buffer = Encoding.Default.GetBytes(tmp); - byte[] md5Buffer = md5.ComputeHash(buffer); - string strMd5 = ""; - //hdnOrderId.Value = orderid; - foreach (byte item in md5Buffer) - { - strMd5 += item.ToString("x2"); - } - String url = bankURL + "&" + tmp1 + "&MAC=" + strMd5; - string reJson = HttpMethods.Post(url); - LogEntity logEntity = new LogEntity(); - logEntity.F_CategoryId = 121; - logEntity.F_ExecuteResultJson = reJson; - logEntity.WriteLog(); - //HttpConnect conn = new HttpConnect(); - //string reJson = conn.Post(url, ""); - JsonBean MemberInfoList = JsonConvert.DeserializeObject(reJson); - if (MemberInfoList.SUCCESS.Equals("true")) + + //访问学校财务服务器 + string payresulturl = Config.GetValue("payresulturl"); + string par = "requestXml="; + Encoding encoding = Encoding.GetEncoding("gb2312"); + byte[] payload = encoding.GetBytes(par); + HttpClient httpClient = new HttpClient(); + HttpContent content = new ByteArrayContent(payload); + try { - string imgCode = HttpMethods.Post(MemberInfoList.PAYURL); - logEntity.F_CategoryId = 121; - logEntity.F_ExecuteResultJson = imgCode; - logEntity.WriteLog(); - MemberInfoList = JsonConvert.DeserializeObject(imgCode); - if (MemberInfoList.SUCCESS.Equals("true")) + var result = httpClient.PostAsync(payresulturl, content); + //LogEntity logEntity2 = new LogEntity(); + //logEntity2.F_CategoryId = 121; + //logEntity2.F_SourceObjectId = "preaccess"; + //logEntity2.F_SourceContentJson = "成功"; + //logEntity2.F_ExecuteResultJson = result.ToString(); + //logEntity2.WriteLog(); + + try { - imgUrl = CreateQRImg(MemberInfoList.QRURL, orderid); + Random ran = new Random(); + string merchantid = "105000082201406";//商户号 + string posid = "043724806";//商户柜台代码 + string branchid = "510000000";//分行代码 + string orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); + string payment = entity.PayMoney.ToString(); + string curcode = "01"; + string txcode = "530550"; + string remark1 = entity.StuNo; + string remark2 = entity.FSYear.ToString(); + string returntype = "3"; + string timeout = DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"); + string pub32tr2 = "40d987faa793a0a27e7a86ef020111"; + string bankURL = "https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6"; + string tmp = "MERCHANTID=" + merchantid + "&POSID=" + posid + "&BRANCHID=" + branchid + "&ORDERID=" + orderid; + tmp += "&PAYMENT=" + payment + "&CURCODE=" + curcode + "&TXCODE=" + txcode + "&REMARK1=" + remark1; + tmp += "&REMARK2=" + remark2 + "&RETURNTYPE=" + returntype + "&TIMEOUT=" + timeout; + MD5 md5 = MD5.Create(); + string tmp1 = tmp; + tmp += "&PUB=" + pub32tr2; + byte[] buffer = Encoding.Default.GetBytes(tmp); + byte[] md5Buffer = md5.ComputeHash(buffer); + string strMd5 = ""; + //hdnOrderId.Value = orderid; + foreach (byte item in md5Buffer) + { + strMd5 += item.ToString("x2"); + } + String url = bankURL + "&" + tmp1 + "&MAC=" + strMd5; + string reJson = HttpMethods.Post(url); + LogEntity logEntity = new LogEntity(); + logEntity.F_CategoryId = 121; + logEntity.F_SourceObjectId = "qrcode"; + logEntity.F_SourceContentJson = "成功"; + logEntity.F_ExecuteResultJson = reJson; + logEntity.WriteLog(); + //HttpConnect conn = new HttpConnect(); + //string reJson = conn.Post(url, ""); + JsonBean MemberInfoList = JsonConvert.DeserializeObject(reJson); + if (MemberInfoList.SUCCESS.Equals("true")) + { + string imgCode = HttpMethods.Post(MemberInfoList.PAYURL); + logEntity.F_CategoryId = 121; + logEntity.F_SourceObjectId = "qrcode"; + logEntity.F_SourceContentJson = "成功"; + logEntity.F_ExecuteResultJson = imgCode; + logEntity.WriteLog(); + MemberInfoList = JsonConvert.DeserializeObject(imgCode); + if (MemberInfoList.SUCCESS.Equals("true")) + { + imgUrl = CreateQRImg(MemberInfoList.QRURL, orderid); + } + } + + if (!string.IsNullOrEmpty(imgUrl)) + { + entity.orderid = orderid; + finaChargeStuOrderIbll.SaveOrderData(entity, list); + } + } + catch (Exception e) + { + LogEntity logEntity = new LogEntity(); + logEntity.F_CategoryId = 121; + logEntity.F_SourceObjectId = "qrcode"; + logEntity.F_SourceContentJson = "失败"; + logEntity.F_ExecuteResultJson = e.Message; + logEntity.WriteLog(); } } - - if (!string.IsNullOrEmpty(imgUrl)) + catch (Exception e) { - entity.orderid = orderid; - finaChargeStuOrderIbll.SaveOrderData(entity, list); + LogEntity logEntity = new LogEntity(); + logEntity.F_CategoryId = 121; + logEntity.F_SourceObjectId = "preaccess"; + logEntity.F_SourceContentJson = "失败"; + logEntity.F_ExecuteResultJson = e.Message; + logEntity.WriteLog(); + return Fail("缴费机器暂停缴费!"); } - + var backimgUrl = new { imgUrl }; return Success(backimgUrl); } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/XmlConfig/system.config b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/XmlConfig/system.config index a0013c63b..5530cb9f6 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/XmlConfig/system.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/XmlConfig/system.config @@ -108,5 +108,6 @@ + \ No newline at end of file