HomeController.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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", "LDN7HDQM024111927716");
  146. obj.Add("merch_no", "015110108481518");
  147. obj.Add("agent_id", "0000001");
  148. obj.Add("supplement_info", "");
  149. obj.Add("name", "中投国信(北京)科技发展有限公司");
  150. obj.Add("phone", "");
  151. obj.Add("request_id", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8));
  152. obj.Add("device_model", "好哒扫码通M837");
  153. obj.Add("term_to", "好哒扫码通M837");
  154. obj.Add("bind_time", "2025-01-15 20:02:00");
  155. obj.Add("credit_code", "91110108756029022Y"); //统一社会信用代码
  156. jm(obj, "bind");
  157. // SortedList<string, string> obj = new SortedList<string, string>();
  158. // obj.Add("agent_id","0000001");
  159. // obj.Add("busi_type","");
  160. // obj.Add("busi_sub_type","");
  161. // obj.Add("order_id","G1241227C03142143729");
  162. // obj.Add("trans_id","G1241227C03142143729");
  163. // obj.Add("merch_no","015330849562900");
  164. // obj.Add("term_no","");
  165. // obj.Add("pos_sn","LDN7HDQM365548961135");
  166. // obj.Add("refer_no","");
  167. // obj.Add("card_no","");
  168. // obj.Add("amount","48.00");
  169. // obj.Add("trans_time","2024-12-27 00:00:27");
  170. // obj.Add("longitude","0");
  171. // obj.Add("latitude","0");
  172. // obj.Add("ret_code","00");
  173. // obj.Add("ret_msg","交易成功");
  174. // obj.Add("area_code","");
  175. // obj.Add("fee_amount","0");
  176. // obj.Add("pay_type","");
  177. // jm(obj, "trade");
  178. return "ok";
  179. }
  180. public string jm(SortedList<string, string> obj, string type)
  181. {
  182. // string NoticeUrl = "https://sy.sic-credit.com:9091/prod-api/space/open/api/commerce/offline/business/data"; //测试
  183. string NoticeUrl = "https://cxsls.cniot-credit.com:9091/prod-api/space/open/api/commerce/offline/business/data"; //正式
  184. string PushData = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
  185. LogHelper.Instance.WriteLog("原始数据:" + PushData, "推送数据日志");
  186. string content = EncryptHelper.Encrypt1(obj, "KTVpzn70n3Bv7w04");
  187. LogHelper.Instance.WriteLog("加密数据:" + content, "推送数据日志");
  188. obj = new SortedList<string, string>();
  189. obj.Add("type", type);
  190. obj.Add("notice_id", Guid.NewGuid().ToString());
  191. obj.Add("timestamp", function.getTimeStamp());
  192. obj.Add("content", content);
  193. string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
  194. string PushDataEncrypt = requestJson;
  195. LogHelper.Instance.WriteLog("请求参数:" + PushDataEncrypt, "推送数据日志");
  196. LogHelper.Instance.WriteLog("请求地址:" + NoticeUrl, "推送数据日志");
  197. string result = function.PostWebRequest(NoticeUrl, requestJson, "application/json");
  198. LogHelper.Instance.WriteLog("返回报文:" + result + "\n\n", "推送数据日志");
  199. return result;
  200. }
  201. public string push3()
  202. {
  203. string[] list = function.ReadInstance("9.txt").Split('\n');
  204. foreach(string sub in list)
  205. {
  206. PosPushHelper.Instance.DoSomeThing(sub);
  207. }
  208. return "ok";
  209. }
  210. public string push2()
  211. {
  212. // List<string> list = new List<string>();
  213. string[] list = function.ReadInstance("9.txt").Split('\n');
  214. string result = ",";
  215. foreach(string sub in list)
  216. {
  217. function.WriteLog(sub);
  218. result += function.GetWebRequest("https://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_PRIZE_MALL_CONFIG_DIVISION&m=" + sub + "&ids=14");
  219. }
  220. return result;
  221. }
  222. }
  223. }