MerchantDepositBackController.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 MySystem.MainModels;
  10. using LitJson;
  11. using Library;
  12. namespace MySystem.Areas.Api.Controllers.v1
  13. {
  14. [Area("Api")]
  15. [Route("/v1/qrcodeplatemain/[controller]/[action]")]
  16. public class MerchantDepositBackController : BaseController
  17. {
  18. public MerchantDepositBackController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  19. {
  20. }
  21. #region 商户激活-商户服务费退还
  22. [Authorize]
  23. public JsonResult AddMerchantDepositBack(string value)
  24. {
  25. value = DesDecrypt(value);
  26. JsonData data = JsonMapper.ToObject(value);
  27. AppResultJson result = AddMerchantDepositBackDo(value);
  28. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  29. }
  30. private AppResultJson AddMerchantDepositBackDo(string value)
  31. {
  32. JsonData data = JsonMapper.ToObject(value);
  33. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
  34. int ReturnWay = int.Parse(function.CheckInt(data["ReturnWay"].ToString())); //退还方式
  35. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  36. string ReturnNo = data["ReturnNo"].ToString(); //退还账号
  37. var info = MerchantDepositBackUtil.AddMerchantDepositBackDo(MerchantId, ReturnWay, MobileCode, ReturnNo);
  38. if (info == "success")
  39. {
  40. return new AppResultJson() { Status = "1", Info = info, Data = info };
  41. }
  42. else
  43. {
  44. return new AppResultJson() { Status = "-1", Info = info, Data = info };
  45. }
  46. }
  47. #endregion
  48. #region 商户激活-银行选项名称
  49. [Authorize]
  50. public JsonResult Options(string value)
  51. {
  52. value = DesDecrypt(value);
  53. JsonData data = JsonMapper.ToObject(value);
  54. List<Dictionary<string, object>> dataList = OptionsDo(value);
  55. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  56. }
  57. private List<Dictionary<string, object>> OptionsDo(string value)
  58. {
  59. JsonData data = JsonMapper.ToObject(value);
  60. int PageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
  61. int PageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
  62. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  63. var query = GetBanks();
  64. foreach (string key in query.Keys)
  65. {
  66. Dictionary<string, object> curData = new Dictionary<string, object>();
  67. curData.Add("text", query[key]); //文本
  68. curData.Add("value", key); //值
  69. dataList.Add(curData);
  70. }
  71. return dataList;
  72. }
  73. #endregion
  74. private Dictionary<string, string> GetBanks()
  75. {
  76. Dictionary<string, string> dic = new Dictionary<string, string>();
  77. dic.Add("工商银行", "工商银行");
  78. dic.Add("农业银行", "农业银行");
  79. dic.Add("邮储银行", "邮储银行");
  80. dic.Add("建设银行", "建设银行");
  81. dic.Add("招商银行", "招商银行");
  82. dic.Add("中国银行", "中国银行");
  83. dic.Add("交通银行", "交通银行");
  84. dic.Add("浦发银行", "浦发银行");
  85. dic.Add("广发银行", "广发银行");
  86. dic.Add("民生银行", "民生银行");
  87. dic.Add("平安银行", "平安银行");
  88. dic.Add("光大银行", "光大银行");
  89. dic.Add("兴业银行", "兴业银行");
  90. dic.Add("中信银行", "中信银行");
  91. dic.Add("上海银行", "上海银行");
  92. dic.Add("其他银行", "其他银行");
  93. return dic;
  94. }
  95. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  96. /// <summary>
  97. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  98. /// </summary>
  99. /// <param name="value">请求的参数(json字符串)</param>
  100. /// <param name="signField">要签名的字段</param>
  101. /// <returns></returns>
  102. private string CheckSign(string value, string[] signField)
  103. {
  104. JsonData json = JsonMapper.ToObject(value);
  105. Dictionary<string, string> dic = new Dictionary<string, string>();
  106. for (int i = 0; i < signField.Length; i++)
  107. {
  108. dic.Add(signField[i], json[signField[i]].ToString());
  109. }
  110. string sign = json["sign"].ToString(); //客户端签名字符串
  111. return new Sign().sign(dic, sign);
  112. }
  113. #endregion
  114. }
  115. }