ConsumerProfitController.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.MainModels;
  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 ConsumerProfitController : BaseController
  18. {
  19. public ConsumerProfitController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  20. {
  21. }
  22. #region 消费者-分红记录
  23. [Authorize]
  24. public JsonResult List(string value)
  25. {
  26. value = DesDecrypt(value);
  27. JsonData data = JsonMapper.ToObject(value);
  28. List<Dictionary<string, object>> dataList = ListDo(value);
  29. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  30. }
  31. public List<Dictionary<string, object>> ListDo(string value)
  32. {
  33. JsonData data = JsonMapper.ToObject(value);
  34. int ConsumerId = int.Parse(function.CheckInt(data["ConsumerId"].ToString())); //消费者
  35. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  36. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  37. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  38. List<Dictionary<string, object>> query = new ConsumerProfitService().List(new List<FieldItem>(), " and ConsumerId=" + ConsumerId, PageNum, PageSize);
  39. foreach (var subdata in query)
  40. {
  41. MerchantInfo merchant = MerchantInfoDbconn.Instance.Get(int.Parse(subdata["MerchantId"].ToString())) ?? new MerchantInfo();
  42. Dictionary<string, object> curData = new Dictionary<string, object>();
  43. curData.Add("GetMoney", subdata["GetMoney"].ToString()); //分红金额
  44. curData.Add("Id", subdata["Id"].ToString()); //Id
  45. curData.Add("CreateDate", subdata["CreateDate"].ToString()); //CreateDate
  46. curData.Add("MerchantName", merchant.Name); //商户名称
  47. curData.Add("OrderNo", subdata["SeoTitle"].ToString()); //订单号
  48. dataList.Add(curData);
  49. }
  50. return dataList;
  51. }
  52. #endregion
  53. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  54. /// <summary>
  55. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  56. /// </summary>
  57. /// <param name="value">请求的参数(json字符串)</param>
  58. /// <param name="signField">要签名的字段</param>
  59. /// <returns></returns>
  60. private string CheckSign(string value, string[] signField)
  61. {
  62. JsonData json = JsonMapper.ToObject(value);
  63. Dictionary<string, string> dic = new Dictionary<string, string>();
  64. for (int i = 0; i < signField.Length; i++)
  65. {
  66. dic.Add(signField[i], json[signField[i]].ToString());
  67. }
  68. string sign = json["sign"].ToString(); //客户端签名字符串
  69. return new Sign().sign(dic, sign);
  70. }
  71. #endregion
  72. }
  73. }