using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Library; using LitJson; namespace MySystem.Controllers { public class HomeController : Controller { private readonly ILogger _logger; public HomeController(ILogger logger) { _logger = logger; } public IActionResult Index() { return View(); } public string test() { // testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/1", "bind_merchant"); // testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/8", "un_bind_merchant"); // testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/236", "change_bind_merchant"); // testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/4", "sim_charge"); testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/3", "service_fee"); testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/2", "trade"); return "ok"; } public string testReq(string requrl, string reqkind) { SortedList obj = new SortedList(); if(reqkind == "bind_merchant") obj = bind_merchant(); if(reqkind == "un_bind_merchant") obj = un_bind_merchant(); if(reqkind == "change_bind_merchant") obj = change_bind_merchant(); if(reqkind == "sim_charge") obj = sim_charge(); if(reqkind == "service_fee") obj = service_fee(); if(reqkind == "trade") obj = trade(); string content = EncryptHelper.Encrypt1(obj, "57yJ3T1Btz7LytyL"); obj = new SortedList(); obj.Add("type", reqkind); obj.Add("app_id", "KXS000001"); obj.Add("notice_id", Guid.NewGuid().ToString()); obj.Add("timestamp", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8)); obj.Add("content", content); string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(obj); function.WriteLog("请求地址:" + requrl); function.WriteLog("请求参数:" + requestJson); string result = function.PostWebRequest(requrl, requestJson, "application/json"); function.WriteLog("返回:" + result); function.WriteLog("\n\n\n"); return result; } private SortedList bind_merchant() { SortedList obj = new SortedList(); obj.Add("phone", "**********"); obj.Add("name", "杨洪江"); obj.Add("supplement_info", "533022********2015"); obj.Add("agent_id", "039034"); obj.Add("merch_no", "039331007177057"); obj.Add("pos_sn", "00005702280118855803"); obj.Add("device_model", "盒易付H版"); obj.Add("term_to", "00005702280118855803"); obj.Add("bind_time", "2023-12-14 16:32:38"); return obj; } private SortedList un_bind_merchant() { SortedList obj = new SortedList(); obj.Add("name", "张**"); obj.Add("supplement_info", "4307************48"); obj.Add("agent_id", "88880019"); obj.Add("merch_no", "LKB50009993529999"); obj.Add("pos_sn", "LKB1888888"); obj.Add("device_model", "N101"); obj.Add("bind_time", "2019-03-12 22:21:50"); return obj; } private SortedList change_bind_merchant() { SortedList obj = new SortedList(); obj.Add("name", "张**"); obj.Add("supplement_info", "4307************48"); obj.Add("agent_id", "88880019"); obj.Add("merch_no", "LKB50009993529999"); obj.Add("before_pos_sn", "LKB1888888"); obj.Add("after_pos_sn", "LKB1888888"); obj.Add("before_device_model", "N101"); obj.Add("after_device_model", "N102"); obj.Add("bind_time", "2019-03-12 22:21:50"); return obj; } private SortedList sim_charge() { SortedList obj = new SortedList(); obj.Add("merch_no", "LKB50009993529999"); obj.Add("agent_id", "88880019"); obj.Add("pos_sn", "LKB188FBMS78888"); obj.Add("amount", "9900"); obj.Add("order_id", "2004190320190312222130116680"); obj.Add("trans_time", "2019-03-12 22:23:02"); return obj; } private SortedList service_fee() { SortedList obj = new SortedList(); obj.Add("merch_no", "039331007177057"); obj.Add("agent_id", "039034"); obj.Add("pos_sn", "00005702280118855803"); obj.Add("order_id", "20231214H00040601976Y"); obj.Add("amount", "29900"); obj.Add("trans_time", "2023-12-14 16:39:43"); return obj; } private SortedList trade() { SortedList obj = new SortedList(); obj.Add("agent_id", "039034"); obj.Add("order_id", "20231214H00040608996Y"); obj.Add("trans_id", "20231214H00040608996Y"); obj.Add("merch_no", "039331007177057"); obj.Add("term_no", "00005702280118855803"); obj.Add("pos_sn", "00005702280118855803"); obj.Add("amount", "102500"); obj.Add("trans_time", "2023-12-14 16:54:17"); obj.Add("ret_code", "00"); obj.Add("ret_msg", "交易成功"); obj.Add("fee_amount", "615"); obj.Add("pay_type", "0"); obj.Add("card_type", "C"); obj.Add("trans_type", "31"); return obj; } public string push() { AliyunPushHelper.Instance.DoSomeThing("{\"Account\":\"14726006947\",\"Device\":\"ANDROID\",\"Title\":\"测试推送\",\"Body\":\"客小爽推送功能即将上线\"}"); AliyunPushHelper.Instance.DoSomeThing("{\"Account\":\"14726006947\",\"Device\":\"IOS\",\"Title\":\"测试推送\",\"Body\":\"客小爽推送功能即将上线\"}"); return "ok"; } } }