using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Threading.Tasks; using CZFW.Core; using CZFW.Core.Security; using CZKJ.GBRS2.Model; using CZKJ.GBRS2.ViewModel; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Reflection; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Http; using CZKJ.GBRS2.Interface; using System.Net; namespace CZKJ.GBRS2.WebMVC.Controllers { public class QueryController : Controller { ICustomerQuery _logic; public QueryController(ICustomerQuery logic) { _logic = logic; } public IActionResult HuaWeiToekn() { string str = _logic.GetHuaWeiToken("1010100005153469999").Result; HuaWeiDownLoadModel downLoadModel = JsonConvert.DeserializeObject(str); if (downLoadModel.Code == 500) { return Content("该保单无法下载"); } HttpWebRequest request; request = WebRequest.Create(downLoadModel.Data.v4TemporarySignatureResponse.signedUrl) as HttpWebRequest; request.Method = "GET"; //request.ContentType = "application/x-www-form-urlencoded"; request.Accept = "*/*"; request.Timeout = 15000; request.AllowAutoRedirect = false; var response = request.GetResponse(); return File(response.GetResponseStream(), "application/x-jpg", "保单详情.jpg"); } public IActionResult HuaWei() { string getToeknUrl = $"{ConfigHelper.GetValue("HuaWei:Url")}/cloud/api/apply/token?appId={ConfigHelper.GetValue("HuaWei:AppId")}&appKey={ConfigHelper.GetValue("HuaWei:AppKey")}"; var responseString = HttpHelper.HttpPostAsync(getToeknUrl).Result; return Content(responseString); } public IActionResult PolicyDetail(string contNo) { return View( _logic.QueryReprot(ConfigHelper.GetValue("CoreQuery:ConNo"))); } //public IActionResult MyPolicy(string userId = "0000000706") //{ // var jobJect = JObject.Parse(_logic.GetListByUserId(userId))["TransData"]["ContentData"]; // List ContNos = new List(); // List ReportList = new List(); // if (jobJect != null) // { // ContNos = JsonConvert.DeserializeObject(jobJect.ToString()).ContNos; // } // if (ContNos.Count > 0) // { // ReportList = _logic.GetReportNoList(ContNos); // } // return View(ContNos); //} public IActionResult Comprehensive(string ContNo) { SentParams para = new SentParams(); TransData model = new TransData(); model.ContentData = new ContentData { BusinessNo= "1010100005153469999", BusinessType="1",PrintType="1" }; model.HeadData = new HeadData { REQ_APP_ID = "2", RESP_APP_ID = "1", ID = Utility.GetUnixTimeTick().ToString() /*configuration.GetValue("TransId")*/, TRANS_ID = "QRY033", TRANS_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff", new CultureInfo("en-US")) }; para.TransData = model; string sign = DesEncrypt.JavaMD5(JsonConvert.SerializeObject(para) + ConfigHelper.GetValue("CoreQuery:Key")); string url = $"http://{ConfigHelper.GetValue("CoreQuery:IP")}/officialWebsiteHttpServer?sign=" + sign; var res = HttpHelper.HttpPost2(url, JsonConvert.SerializeObject(para)).Result; return Content(res); } #region /// /// 保单号查询保单信息 /// /// /// //public IActionResult GetInfoByConNo(string ContNo) //{ // //if (string.IsNullOrWhiteSpace(ContNo)) // //{ // // return Content("保单号不可为空!"); // //} // SentParams para = new SentParams(); // TransData model = new TransData(); // model.ContentData = new ContentData { ContNo = ConfigHelper.GetValue("CoreQuery:ConNo") }; // model.HeadData = new HeadData { REQ_APP_ID = "2", RESP_APP_ID = "1", ID = Utility.GetUnixTimeTick().ToString() /*configuration.GetValue("TransId")*/, TRANS_ID = "QRY004", TRANS_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff", new CultureInfo("en-US")) }; // para.TransData = model; // string sign = DesEncrypt.JavaMD5(JsonConvert.SerializeObject(para) + ConfigHelper.GetValue("CoreQuery:Key")); // string url = $"http://{ConfigHelper.GetValue("CoreQuery:IP")}/officialWebsiteHttpServer?sign=" + sign; // var res = HttpHelper.HttpPost2(url, JsonConvert.SerializeObject(para)); // var res2 = JObject.Parse(res)["TransData"]["ContentData"]; // var res1 = JObject.Parse(res)["TransData"]["ContentData"].ToString(); // InsurancePolicyModel viewModel = JsonConvert.DeserializeObject(JObject.Parse(res)["TransData"]["ContentData"].ToString()); // return Content(res); //} ///// ///// 查询客户名下保单列表 ///// ///// ///// //public IActionResult GetListbyUserId(string userId) //{ // //if (string.IsNullOrWhiteSpace(userId)) // //{ // // return Content("用户Id不可为空!"); // //} // SentParams para = new SentParams(); // TransData model = new TransData(); // model.ContentData = new ContentData { CustomerNo = ConfigHelper.GetValue("CoreQuery:CustomerNo"), CustomerType = ConfigHelper.GetValue("CoreQuery:CustomerType") }; // model.HeadData = new HeadData { REQ_APP_ID = "2", RESP_APP_ID = "1", ID = Utility.GetUnixTimeTick().ToString() /*configuration.GetValue("TransId")*/, TRANS_ID = "QRY003", TRANS_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff", new CultureInfo("en-US")) }; // para.TransData = model; // string sign = DesEncrypt.JavaMD5(JsonConvert.SerializeObject(para) + ConfigHelper.GetValue("CoreQuery:Key")); // string url = $"http://{ConfigHelper.GetValue("CoreQuery:IP")}/officialWebsiteHttpServer?sign=" + sign; // var res = HttpHelper.HttpPost2(url, JsonConvert.SerializeObject(para)); // return Content(res); //} //public IActionResult Comprehensive(string ContNo) //{ // SentParams para = new SentParams(); // TransData model = new TransData(); // model.ContentData = new ContentData { ContNo = ConfigHelper.GetValue("CoreQuery:CustomerNo"), CustomerType = ConfigHelper.GetValue("CoreQuery:CustomerType") }; // model.HeadData = new HeadData { REQ_APP_ID = "2", RESP_APP_ID = "1", ID = Utility.GetUnixTimeTick().ToString() /*configuration.GetValue("TransId")*/, TRANS_ID = "QRY008", TRANS_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff", new CultureInfo("en-US")) }; // para.TransData = model; // string sign = DesEncrypt.JavaMD5(JsonConvert.SerializeObject(para) + ConfigHelper.GetValue("CoreQuery:Key")); // string url = $"http://{ConfigHelper.GetValue("CoreQuery:IP")}/officialWebsiteHttpServer?sign=" + sign; // var res = HttpHelper.HttpPost2(url, JsonConvert.SerializeObject(para)); // return Content(res); //} //public IActionResult GetPolNo() //{ // SentParams para = new SentParams(); // TransData model = new TransData(); // model.ContentData = new ContentData { ContNo = ConfigHelper.GetValue("CoreQuery:CustomerNo") }; // model.HeadData = new HeadData { REQ_APP_ID = "2", RESP_APP_ID = "1", ID = Utility.GetUnixTimeTick().ToString() /*configuration.GetValue("TransId")*/, TRANS_ID = "QRY005", TRANS_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff", new CultureInfo("en-US")) }; // para.TransData = model; // string sign = DesEncrypt.JavaMD5(JsonConvert.SerializeObject(para) + ConfigHelper.GetValue("CoreQuery:Key")); // string url = $"http://{ConfigHelper.GetValue("CoreQuery:IP")}/officialWebsiteHttpServer?sign=" + sign; // var res = HttpHelper.HttpPost2(url, JsonConvert.SerializeObject(para)); // return Content(res); //} //public IActionResult Test() //{ // var res= _logic.QueryReprot("201000000001500"); // return Json(res); //} #endregion } }