MerchantAmountSummayController.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 MerchantAmountSummayController : BaseController
  17. {
  18. public MerchantAmountSummayController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  19. {
  20. }
  21. #region 已激活商户-达标信息列表
  22. [Authorize]
  23. public JsonResult List(string value)
  24. {
  25. value = DesDecrypt(value);
  26. JsonData data = JsonMapper.ToObject(value);
  27. List<Dictionary<string, object>> dataList = ListDo(value);
  28. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  29. }
  30. private List<Dictionary<string, object>> ListDo(string value)
  31. {
  32. JsonData data = JsonMapper.ToObject(value);
  33. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户
  34. int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
  35. int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
  36. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  37. dataList = MerchantAmountSummayUtil.ListDo(MerchantId, pageSize, pageNum);
  38. return dataList;
  39. }
  40. #endregion
  41. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  42. /// <summary>
  43. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  44. /// </summary>
  45. /// <param name="value">请求的参数(json字符串)</param>
  46. /// <param name="signField">要签名的字段</param>
  47. /// <returns></returns>
  48. private string CheckSign(string value, string[] signField)
  49. {
  50. JsonData json = JsonMapper.ToObject(value);
  51. Dictionary<string, string> dic = new Dictionary<string, string>();
  52. for (int i = 0; i < signField.Length; i++)
  53. {
  54. dic.Add(signField[i], json[signField[i]].ToString());
  55. }
  56. string sign = json["sign"].ToString(); //客户端签名字符串
  57. return new Sign().sign(dic, sign);
  58. }
  59. #endregion
  60. }
  61. }