BusinessController.cs 5.8 KB

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