FluxProfitSummaryController.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.pos
  14. {
  15. [Area("Api")]
  16. [Route("Api/v1/pos/[controller]/[action]")]
  17. public class FluxProfitSummaryController : BaseController
  18. {
  19. public FluxProfitSummaryController(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 UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客
  35. int BrandId = int.Parse(function.CheckInt(data["ProductType"].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<FluxProfitSummary> query = maindb.FluxProfitSummary.Where(m => m.UserId == UserId && m.BrandId == BrandId).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. string TradeMonth = subdata.TradeMonth;
  52. Dictionary<string, object> curData = new Dictionary<string, object>();
  53. curData.Add("TradeMonth", TradeMonth.Substring(0, 4) + "-" + TradeMonth.Substring(4, 2)); //交易月
  54. curData.Add("TradeMonthValue", TradeMonth);
  55. curData.Add("FluxProfitAmt", subdata.FluxProfitAmt); //流量分润总金额
  56. dataList.Add(curData);
  57. }
  58. return dataList;
  59. }
  60. #endregion
  61. #region 首页-客小爽产品-收益查看-流量卡分佣详细
  62. [Authorize]
  63. public JsonResult ByDate(string value)
  64. {
  65. value = DesDecrypt(value);
  66. JsonData data = JsonMapper.ToObject(value);
  67. List<Dictionary<string, object>> dataList = ByDateDo(value);
  68. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  69. }
  70. public List<Dictionary<string, object>> ByDateDo(string value)
  71. {
  72. JsonData data = JsonMapper.ToObject(value);
  73. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客
  74. int ProductType = int.Parse(function.CheckInt(data["ProductType"].ToString())); //产品类型
  75. string TradeMonth = data["TradeMonth"].ToString();
  76. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  77. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  78. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  79. IQueryable<FluxProfitDetail> query = maindb.FluxProfitDetail.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.BrandId == ProductType);
  80. if (PageNum == 1)
  81. {
  82. query = query.Take(PageSize);
  83. }
  84. else
  85. {
  86. int skipNum = PageSize * (PageNum - 1);
  87. query = query.Skip(skipNum).Take(PageSize);
  88. }
  89. foreach (var subdata in query.ToList())
  90. {
  91. Dictionary<string, object> curData = new Dictionary<string, object>();
  92. string TradeDate = subdata.TradeDate;
  93. curData.Add("TradeDate", TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2)); //交易日
  94. curData.Add("FluxProfitAmt", subdata.FluxProfitAmt); //流量分润总金额
  95. PosMerchantInfo merchant = PosMerchantInfoDbconn.Instance.Get(subdata.MerchantId) ?? new PosMerchantInfo();
  96. string MerchantName = merchant.MerchantName;
  97. if (ProductType == 2)
  98. {
  99. if (MerchantName.Contains("-"))
  100. {
  101. MerchantName = MerchantName.Split('-')[1];
  102. }
  103. else if (MerchantName.Contains("_"))
  104. {
  105. MerchantName = MerchantName.Split('_')[1];
  106. }
  107. }
  108. curData.Add("RealName", MerchantName); //姓名
  109. curData.Add("Mobile", merchant.MerchantMobile); //手机号
  110. dataList.Add(curData);
  111. }
  112. return dataList;
  113. }
  114. #endregion
  115. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  116. /// <summary>
  117. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  118. /// </summary>
  119. /// <param name="value">请求的参数(json字符串)</param>
  120. /// <param name="signField">要签名的字段</param>
  121. /// <returns></returns>
  122. private string CheckSign(string value, string[] signField)
  123. {
  124. JsonData json = JsonMapper.ToObject(value);
  125. Dictionary<string, string> dic = new Dictionary<string, string>();
  126. for (int i = 0; i < signField.Length; i++)
  127. {
  128. dic.Add(signField[i], json[signField[i]].ToString());
  129. }
  130. string sign = json["sign"].ToString(); //客户端签名字符串
  131. return new Sign().sign(dic, sign);
  132. }
  133. #endregion
  134. }
  135. }