HomeController.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. // string content = "{\"data_type\":\"bind\",\"data_content\":{\"pos_sn\":\"1014BS0023511\",\"mer_no\":\"15608798003\",\"id_card\":null,\"mer_name\":\"15608798003\",\"mer_mobile\":\"15608798003\",\"request_id\":\"2024102310381200098289115\",\"bind_time\":\"2024-10-23 10:38:12\",\"brand\":\"23\"}}";
  143. // PosPushHelper.Instance.DoSomeThing(content);
  144. // SortedList<string, string> obj = new SortedList<string, string>();
  145. // obj.Add("pos_sn", "LDN7HDQM365548961135");
  146. // obj.Add("mer_no", "015330849562900");
  147. // obj.Add("id_card", "");
  148. // obj.Add("mer_name", "");
  149. // obj.Add("mer_mobile", "");
  150. // obj.Add("request_id", "ac76801a7b0773063ac20ece3f8ca6dc");
  151. // obj.Add("bind_time", "2024-12-27 10:16:10");
  152. // obj.Add("brand", "29");
  153. // jm(obj, "bind");
  154. // SortedList<string, string> obj = new SortedList<string, string>();
  155. // obj.Add("pos_sn", "LDN7HDQM365548961135");
  156. // obj.Add("mer_no", "015330849562900");
  157. // obj.Add("request_id", "7440225443200e5c52d1a502074915ab");
  158. // obj.Add("deposit_amount", "299.00");
  159. // obj.Add("trade_time", "2024-12-27 10:17:11");
  160. // obj.Add("card_type", "1");
  161. // obj.Add("brand", "29");
  162. // jm(obj, "deposit");
  163. SortedList<string, string> obj = new SortedList<string, string>();
  164. obj.Add("pos_sn","LDN7HDQM365548961135");
  165. obj.Add("mer_no","015330849562900");
  166. obj.Add("request_id","G1241227C03142143729");
  167. obj.Add("trade_amount","48.00");
  168. obj.Add("trade_time","2024-12-27 00:00:27");
  169. obj.Add("brand","29");
  170. obj.Add("is_act","0");
  171. obj.Add("card_type","1");
  172. obj.Add("qr_pay_flag","0");
  173. obj.Add("fee_rate","0.63");
  174. obj.Add("fee_amt","3");
  175. jm(obj, "trade");
  176. return "ok";
  177. }
  178. public string jm(SortedList<string, string> obj, string type)
  179. {
  180. string NoticeUrl = "http://61.189.43.58:9092/prod-api/space/open/api/commerce/offline/business/data";
  181. string PushData = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
  182. LogHelper.Instance.WriteLog("原始数据:" + PushData, "推送数据日志");
  183. string content = EncryptHelper.Encrypt1(obj, "KTVpzn70n3Bv7w04");
  184. LogHelper.Instance.WriteLog("加密数据:" + content, "推送数据日志");
  185. obj = new SortedList<string, string>();
  186. obj.Add("type", type);
  187. obj.Add("notice_id", Guid.NewGuid().ToString());
  188. obj.Add("timestamp", function.getTimeStamp());
  189. obj.Add("content", content);
  190. string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
  191. string PushDataEncrypt = requestJson;
  192. LogHelper.Instance.WriteLog("请求参数:" + PushDataEncrypt, "推送数据日志");
  193. LogHelper.Instance.WriteLog("请求地址:" + NoticeUrl, "推送数据日志");
  194. string result = function.PostWebRequest(NoticeUrl, requestJson, "application/json");
  195. LogHelper.Instance.WriteLog("返回报文:" + result + "\n\n", "推送数据日志");
  196. return result;
  197. }
  198. public string push2()
  199. {
  200. // List<string> list = new List<string>();
  201. string[] list = function.ReadInstance("9.txt").Split('\n');
  202. string result = ",";
  203. foreach(string sub in list)
  204. {
  205. function.WriteLog(sub);
  206. string[] data = sub.Split('|');
  207. result += function.GetWebRequest("https://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=" + data[1] + "&m=" + data[0] + "&ids=" + data[2]) + ",";
  208. }
  209. return result;
  210. }
  211. }
  212. }