ProfitRewardRecordController.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 System.Web;
  10. using MySystem.Models.Main;
  11. using LitJson;
  12. using Library;
  13. namespace MySystem.Areas.Api.Controllers.v1
  14. {
  15. [Area("Api")]
  16. [Route("Api/v1/[controller]/[action]")]
  17. public class ProfitRewardRecordController : BaseController
  18. {
  19. public ProfitRewardRecordController(IHttpContextAccessor accessor) : base(accessor)
  20. {
  21. }
  22. #region 首页-客小爽产品-收益查看-交易分润
  23. // [Authorize]
  24. public JsonResult TradeProfitList(string value)
  25. {
  26. value = DesDecrypt(value);
  27. value = value.Replace("null", "\"\"");
  28. JsonData data = JsonMapper.ToObject(value);
  29. List<Dictionary<string, object>> dataList = TradeProfitListDo(value);
  30. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  31. }
  32. public List<Dictionary<string, object>> TradeProfitListDo(string value)
  33. {
  34. JsonData data = JsonMapper.ToObject(value);
  35. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客
  36. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  37. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  38. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  39. IQueryable<ProfitRecord> query = maindb.ProfitRecord.Where(m => m.UserId == UserId).OrderByDescending(m => m.Id);
  40. if (PageNum == 1)
  41. {
  42. query = query.Take(PageSize);
  43. }
  44. else
  45. {
  46. int skipNum = PageSize * (PageNum - 1);
  47. query = query.Skip(skipNum).Take(PageSize);
  48. }
  49. foreach (var subdata in query.ToList())
  50. {
  51. Dictionary<string, object> curData = new Dictionary<string, object>();
  52. curData.Add("ProfitAmount", subdata.ProfitAmount); //交易分润
  53. curData.Add("ProfitMonth", subdata.SeoTitle.Substring(0, 4) + "年" + subdata.SeoTitle.Substring(4) + "月");
  54. curData.Add("ProfitDate", subdata.CreateDate.Value.ToString("yyyy-MM-dd"));
  55. dataList.Add(curData);
  56. }
  57. return dataList;
  58. }
  59. #endregion
  60. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  61. /// <summary>
  62. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  63. /// </summary>
  64. /// <param name="value">请求的参数(json字符串)</param>
  65. /// <param name="signField">要签名的字段</param>
  66. /// <returns></returns>
  67. private string CheckSign(string value, string[] signField)
  68. {
  69. JsonData json = JsonMapper.ToObject(value);
  70. Dictionary<string, string> dic = new Dictionary<string, string>();
  71. for (int i = 0; i < signField.Length; i++)
  72. {
  73. dic.Add(signField[i], json[signField[i]].ToString());
  74. }
  75. string sign = json["sign"].ToString(); //客户端签名字符串
  76. return new Sign().sign(dic, sign);
  77. }
  78. #endregion
  79. }
  80. }