BusinessController.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. using System.Data;
  14. using MySystem.Service.Main;
  15. namespace MySystem.Areas.Api.Controllers.v1
  16. {
  17. [Area("Api")]
  18. [Route("/v1/[controller]/[action]")]
  19. public class BusinessController : BaseController
  20. {
  21. public BusinessController(IHttpContextAccessor accessor) : base(accessor)
  22. {
  23. }
  24. #region 经营数据-经营数据记录(月)
  25. // [Authorize]
  26. public JsonResult BussinessRecordForMonth(string value)
  27. {
  28. value = DesDecrypt(value);
  29. value = value.Replace("null", "\"\"");
  30. JsonData data = JsonMapper.ToObject(value);
  31. List<Dictionary<string, object>> dataList = BussinessRecordForMonthDo(value);
  32. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  33. }
  34. private List<Dictionary<string, object>> BussinessRecordForMonthDo(string value)
  35. {
  36. JsonData data = JsonMapper.ToObject(value);
  37. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
  38. string TradeMonth = data["TradeMonth"].ToString(); //月份
  39. int pageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  40. int pageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  41. var dataList = BusinessUtil.BussinessRecordForMonth(MerchantId, TradeMonth, pageSize, pageNum);
  42. return dataList;
  43. }
  44. #endregion
  45. #region 经营数据-经营数据记录(半年)
  46. // [Authorize]
  47. public JsonResult BussinessRecordForHalfYear(string value)
  48. {
  49. value = DesDecrypt(value);
  50. value = value.Replace("null", "\"\"");
  51. JsonData data = JsonMapper.ToObject(value);
  52. List<Dictionary<string, object>> dataList = BussinessRecordForHalfYearDo(value);
  53. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  54. }
  55. private List<Dictionary<string, object>> BussinessRecordForHalfYearDo(string value)
  56. {
  57. JsonData data = JsonMapper.ToObject(value);
  58. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
  59. int pageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  60. int pageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  61. var dataList = BusinessUtil.BussinessRecordForHalfYear(MerchantId, pageSize, pageNum);
  62. return dataList;
  63. }
  64. #endregion
  65. #region 经营数据-经营数据记录-经营详情列表
  66. // [Authorize]
  67. public JsonResult DayDetailList(string value)
  68. {
  69. value = DesDecrypt(value);
  70. value = value.Replace("null", "\"\"");
  71. JsonData data = JsonMapper.ToObject(value);
  72. List<Dictionary<string, object>> dataList = DayDetailListDo(value);
  73. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  74. }
  75. private List<Dictionary<string, object>> DayDetailListDo(string value)
  76. {
  77. JsonData data = JsonMapper.ToObject(value);
  78. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
  79. string TradeDate = data["TradeDate"].ToString(); //日期
  80. int pageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  81. int pageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  82. string condition = " and Status>=1";
  83. if (!string.IsNullOrEmpty(data["MerchantId"].ToString()))
  84. {
  85. condition += " and MerchantId=" + MerchantId;
  86. }
  87. if (!string.IsNullOrEmpty(data["TradeDate"].ToString()))
  88. {
  89. var start = TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2) + " 00:00:00";
  90. var end = TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2) + " 23:59:59";
  91. condition += " and CreateDate>='" + start + "' and CreateDate<='" + end + "'";
  92. }
  93. var dataList = BusinessUtil.DayDetailList(condition, pageSize, pageNum);
  94. return dataList;
  95. }
  96. #endregion
  97. #region 经营数据-经营数据记录-交易详情
  98. // [Authorize]
  99. public JsonResult OrderDetail(string value)
  100. {
  101. value = DesDecrypt(value);
  102. value = value.Replace("null", "\"\"");
  103. JsonData data = JsonMapper.ToObject(value);
  104. Dictionary<string, object> dataList = OrderDetailDo(value);
  105. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  106. }
  107. private Dictionary<string, object> OrderDetailDo(string value)
  108. {
  109. JsonData data = JsonMapper.ToObject(value);
  110. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
  111. int OrderId = int.Parse(function.CheckInt(data["OrderId"].ToString())); //订单Id
  112. string condition = " and Status>=1";
  113. if (!string.IsNullOrEmpty(data["OrderId"].ToString()))
  114. {
  115. condition += " and Id=" + OrderId;
  116. }
  117. if (!string.IsNullOrEmpty(data["MerchantId"].ToString()))
  118. {
  119. condition += " and MerchantId=" + MerchantId;
  120. }
  121. var obj = BusinessUtil.OrderDetail(condition);
  122. return obj;
  123. }
  124. #endregion
  125. }
  126. }