OpenBankTableController.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.Extensions.Logging;
  7. using Microsoft.Extensions.Options;
  8. using Microsoft.AspNetCore.Authorization;
  9. using LitJson;
  10. using Library;
  11. using MySystem.Models.Main;
  12. using MySystem.Service.Main;
  13. namespace MySystem.Areas.Api.Controllers.v1
  14. {
  15. [Area("Api")]
  16. [Route("Api/v1/[controller]/[action]")]
  17. public class OpenBankTableController : BaseController
  18. {
  19. public OpenBankTableController(IHttpContextAccessor accessor) : base(accessor)
  20. {
  21. }
  22. #region 创客-首页-开户行查询
  23. // [Authorize]
  24. public JsonResult List(string value)
  25. {
  26. value = DesDecrypt(value);
  27. value = value.Replace("null", "\"\"");
  28. JsonData data = JsonMapper.ToObject(value);
  29. List<Dictionary<string, object>> dataList = ListDo(value);
  30. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  31. }
  32. public List<Dictionary<string, object>> ListDo(string value)
  33. {
  34. JsonData data = JsonMapper.ToObject(value);
  35. string SearchKey = data.getItem("SearchKey").ToString(); //搜索关键词
  36. int PageSize = int.Parse(function.CheckInt(data.getItem("PageSize").ToString()));
  37. int PageNum = int.Parse(function.CheckInt(data.getItem("PageNum").ToString()));
  38. string condition = ""; //查询条件
  39. if (value.Contains("\"Areas\""))
  40. {
  41. if (!string.IsNullOrEmpty(data["Areas"].ToString()))
  42. {
  43. string Areas = data["Areas"].ToString();
  44. if (Areas.Contains(","))
  45. {
  46. string[] AreasList = Areas.Split(',');
  47. if (AreasList.Length == 3)
  48. {
  49. string p = AreasList[0];
  50. string c = AreasList[1];
  51. string a = AreasList[2];
  52. condition += " and (BankChild like '%" + p + "%' or BankChild like '%" + c + "%' or BankChild like '%" + a + "%')";
  53. }
  54. else if (AreasList.Length == 2)
  55. {
  56. string p = AreasList[0];
  57. string c = AreasList[1];
  58. condition += " and (BankChild like '%" + p + "%' or BankChild like '%" + c + "%')";
  59. }
  60. else
  61. {
  62. condition += " and BankChild like '%" + Areas + "%'";
  63. }
  64. }
  65. else
  66. {
  67. condition += " and BankChild like '%" + Areas + "%'";
  68. }
  69. }
  70. }
  71. // if (value.Contains("\"BankName\""))
  72. // {
  73. // if (!string.IsNullOrEmpty(data["BankName"].ToString()))
  74. // {
  75. // string BankName = data["BankName"].ToString();
  76. // condition += " and BankChild like '%" + BankName + "%'";
  77. // }
  78. // }
  79. if (!string.IsNullOrEmpty(SearchKey))
  80. {
  81. condition += " and BankChild like '%" + SearchKey + "%'";
  82. }
  83. List<RelationData> relationData = new List<RelationData>();
  84. List<Dictionary<string, object>> list = OpenBankAllService.List(relationData, condition, PageNum, PageSize);
  85. foreach (Dictionary<string, object> dic in list)
  86. {
  87. dic["BankName"] = dic["BankChild"].ToString(); //开户行名称
  88. dic["BankCode"] = dic["BankChildNo"].ToString(); //联行号
  89. }
  90. // List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  91. // IQueryable<OpenBankTable> query = maindb.OpenBankTable;
  92. // if (value.Contains("\"Areas\""))
  93. // {
  94. // if (!string.IsNullOrEmpty(data["Areas"].ToString()))
  95. // {
  96. // string Areas = data["Areas"].ToString();
  97. // if (Areas.Contains(","))
  98. // {
  99. // string[] AreasList = Areas.Split(',');
  100. // if (AreasList.Length == 3)
  101. // {
  102. // string p = AreasList[0];
  103. // string c = AreasList[1];
  104. // string a = AreasList[2];
  105. // query = query.Where(m => (m.BankChild.Contains(p) || m.BankChild.Contains(c) || m.BankChild.Contains(a)));
  106. // }
  107. // else if (AreasList.Length == 2)
  108. // {
  109. // string p = AreasList[0];
  110. // string c = AreasList[1];
  111. // query = query.Where(m => (m.BankChild.Contains(p) || m.BankChild.Contains(c)));
  112. // }
  113. // else
  114. // {
  115. // query = query.Where(m => m.BankChild.Contains(Areas));
  116. // }
  117. // }
  118. // else
  119. // {
  120. // query = query.Where(m => m.BankChild.Contains(Areas));
  121. // }
  122. // }
  123. // }
  124. // if (value.Contains("\"BankName\""))
  125. // {
  126. // if (!string.IsNullOrEmpty(data["BankName"].ToString()))
  127. // {
  128. // string BankName = data["BankName"].ToString();
  129. // query = query.Where(m => m.BankChild.Contains(BankName));
  130. // }
  131. // }
  132. // if (!string.IsNullOrEmpty(SearchKey))
  133. // {
  134. // query = query.Where(m => m.BankChild.Contains(SearchKey));
  135. // }
  136. // query = query.Take(PageSize);
  137. // foreach (var subdata in query.ToList())
  138. // {
  139. // Dictionary<string, object> curData = new Dictionary<string, object>();
  140. // curData.Add("BankName", subdata.BankChild); //开户行名称
  141. // curData.Add("BankCode", subdata.BankChildNo); //联行号
  142. // dataList.Add(curData);
  143. // }
  144. return list;
  145. }
  146. #endregion
  147. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  148. /// <summary>
  149. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  150. /// </summary>
  151. /// <param name="value">请求的参数(json字符串)</param>
  152. /// <param name="signField">要签名的字段</param>
  153. /// <returns></returns>
  154. private string CheckSign(string value, string[] signField)
  155. {
  156. JsonData json = JsonMapper.ToObject(value);
  157. Dictionary<string, string> dic = new Dictionary<string, string>();
  158. for (int i = 0; i < signField.Length; i++)
  159. {
  160. dic.Add(signField[i], json[signField[i]].ToString());
  161. }
  162. string sign = json["sign"].ToString(); //客户端签名字符串
  163. return new Sign().sign(dic, sign);
  164. }
  165. #endregion
  166. }
  167. }