HomeController.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using Microsoft.AspNetCore.Mvc;
  7. using Microsoft.Extensions.Logging;
  8. using Library;
  9. using LitJson;
  10. namespace MySystem.Controllers
  11. {
  12. public class HomeController : Controller
  13. {
  14. private readonly ILogger<HomeController> _logger;
  15. public HomeController(ILogger<HomeController> logger)
  16. {
  17. _logger = logger;
  18. }
  19. public IActionResult Index()
  20. {
  21. return View();
  22. }
  23. public string test()
  24. {
  25. // testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/1", "bind_merchant");
  26. // testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/8", "un_bind_merchant");
  27. // testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/236", "change_bind_merchant");
  28. // testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/4", "sim_charge");
  29. testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/3", "service_fee");
  30. testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/2", "trade");
  31. return "ok";
  32. }
  33. public string testReq(string requrl, string reqkind)
  34. {
  35. SortedList<string, string> obj = new SortedList<string, string>();
  36. if(reqkind == "bind_merchant") obj = bind_merchant();
  37. if(reqkind == "un_bind_merchant") obj = un_bind_merchant();
  38. if(reqkind == "change_bind_merchant") obj = change_bind_merchant();
  39. if(reqkind == "sim_charge") obj = sim_charge();
  40. if(reqkind == "service_fee") obj = service_fee();
  41. if(reqkind == "trade") obj = trade();
  42. string content = EncryptHelper.Encrypt1(obj, "57yJ3T1Btz7LytyL");
  43. obj = new SortedList<string, string>();
  44. obj.Add("type", reqkind);
  45. obj.Add("app_id", "KXS000001");
  46. obj.Add("notice_id", Guid.NewGuid().ToString());
  47. obj.Add("timestamp", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8));
  48. obj.Add("content", content);
  49. string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
  50. function.WriteLog("请求地址:" + requrl);
  51. function.WriteLog("请求参数:" + requestJson);
  52. string result = function.PostWebRequest(requrl, requestJson, "application/json");
  53. function.WriteLog("返回:" + result);
  54. function.WriteLog("\n\n\n");
  55. return result;
  56. }
  57. private SortedList<string, string> bind_merchant()
  58. {
  59. SortedList<string, string> obj = new SortedList<string, string>();
  60. obj.Add("phone", "**********");
  61. obj.Add("name", "杨洪江");
  62. obj.Add("supplement_info", "533022********2015");
  63. obj.Add("agent_id", "039034");
  64. obj.Add("merch_no", "039331007177057");
  65. obj.Add("pos_sn", "00005702280118855803");
  66. obj.Add("device_model", "盒易付H版");
  67. obj.Add("term_to", "00005702280118855803");
  68. obj.Add("bind_time", "2023-12-14 16:32:38");
  69. return obj;
  70. }
  71. private SortedList<string, string> un_bind_merchant()
  72. {
  73. SortedList<string, string> obj = new SortedList<string, string>();
  74. obj.Add("name", "张**");
  75. obj.Add("supplement_info", "4307************48");
  76. obj.Add("agent_id", "88880019");
  77. obj.Add("merch_no", "LKB50009993529999");
  78. obj.Add("pos_sn", "LKB1888888");
  79. obj.Add("device_model", "N101");
  80. obj.Add("bind_time", "2019-03-12 22:21:50");
  81. return obj;
  82. }
  83. private SortedList<string, string> change_bind_merchant()
  84. {
  85. SortedList<string, string> obj = new SortedList<string, string>();
  86. obj.Add("name", "张**");
  87. obj.Add("supplement_info", "4307************48");
  88. obj.Add("agent_id", "88880019");
  89. obj.Add("merch_no", "LKB50009993529999");
  90. obj.Add("before_pos_sn", "LKB1888888");
  91. obj.Add("after_pos_sn", "LKB1888888");
  92. obj.Add("before_device_model", "N101");
  93. obj.Add("after_device_model", "N102");
  94. obj.Add("bind_time", "2019-03-12 22:21:50");
  95. return obj;
  96. }
  97. private SortedList<string, string> sim_charge()
  98. {
  99. SortedList<string, string> obj = new SortedList<string, string>();
  100. obj.Add("merch_no", "LKB50009993529999");
  101. obj.Add("agent_id", "88880019");
  102. obj.Add("pos_sn", "LKB188FBMS78888");
  103. obj.Add("amount", "9900");
  104. obj.Add("order_id", "2004190320190312222130116680");
  105. obj.Add("trans_time", "2019-03-12 22:23:02");
  106. return obj;
  107. }
  108. private SortedList<string, string> service_fee()
  109. {
  110. SortedList<string, string> obj = new SortedList<string, string>();
  111. obj.Add("merch_no", "039331007177057");
  112. obj.Add("agent_id", "039034");
  113. obj.Add("pos_sn", "00005702280118855803");
  114. obj.Add("order_id", "20231214H00040601976Y");
  115. obj.Add("amount", "29900");
  116. obj.Add("trans_time", "2023-12-14 16:39:43");
  117. return obj;
  118. }
  119. private SortedList<string, string> trade()
  120. {
  121. SortedList<string, string> obj = new SortedList<string, string>();
  122. obj.Add("agent_id", "039034");
  123. obj.Add("order_id", "20231214H00040608996Y");
  124. obj.Add("trans_id", "20231214H00040608996Y");
  125. obj.Add("merch_no", "039331007177057");
  126. obj.Add("term_no", "00005702280118855803");
  127. obj.Add("pos_sn", "00005702280118855803");
  128. obj.Add("amount", "102500");
  129. obj.Add("trans_time", "2023-12-14 16:54:17");
  130. obj.Add("ret_code", "00");
  131. obj.Add("ret_msg", "交易成功");
  132. obj.Add("fee_amount", "615");
  133. obj.Add("pay_type", "0");
  134. obj.Add("card_type", "C");
  135. obj.Add("trans_type", "31");
  136. return obj;
  137. }
  138. public string push()
  139. {
  140. AliyunPushHelper.Instance.DoSomeThing("{\"Account\":\"14726006947\",\"Device\":\"ANDROID\",\"Title\":\"测试推送\",\"Body\":\"客小爽推送功能即将上线\"}");
  141. AliyunPushHelper.Instance.DoSomeThing("{\"Account\":\"14726006947\",\"Device\":\"IOS\",\"Title\":\"测试推送\",\"Body\":\"客小爽推送功能即将上线\"}");
  142. return "ok";
  143. }
  144. }
  145. }