AmountRecordOperateController.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * 创客账户变动记录
  3. */
  4. using System;
  5. using System.Web;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.Data;
  10. using System.Threading.Tasks;
  11. using Microsoft.AspNetCore.Mvc;
  12. using Microsoft.AspNetCore.Http;
  13. using Microsoft.Extensions.Logging;
  14. using Microsoft.Extensions.Options;
  15. using MySystem.OpModels;
  16. using Library;
  17. using LitJson;
  18. using MySystemLib;
  19. namespace MySystem.Areas.Admin.Controllers
  20. {
  21. [Area("Admin")]
  22. [Route("Admin/[controller]/[action]")]
  23. public class AmountRecordOperateController : BaseController
  24. {
  25. public AmountRecordOperateController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  26. {
  27. }
  28. #region 运营中心额度变动明细记录列表
  29. /// <summary>
  30. /// 根据条件查询运营中心额度变动明细记录列表
  31. /// </summary>
  32. /// <returns></returns>
  33. public IActionResult Index(AmountRecord data, string right, int UserId = 0)
  34. {
  35. ViewBag.RightInfo = RightInfo;
  36. ViewBag.right = right;
  37. return View();
  38. }
  39. #endregion
  40. #region 根据条件查询运营中心额度变动明细记录列表
  41. /// <summary>
  42. /// 运营中心额度变动明细记录列表
  43. /// </summary>
  44. /// <returns></returns>
  45. public JsonResult IndexData(AmountRecord data, string MakerCode, string OpCode, string CreateDateData, int page = 1, int limit = 30)
  46. {
  47. Dictionary<string, string> Fields = new Dictionary<string, string>();
  48. string condition = condition = " and Status>-1";
  49. //创客编号
  50. if (!string.IsNullOrEmpty(MakerCode))
  51. {
  52. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  53. }
  54. //运营中心编号
  55. if (!string.IsNullOrEmpty(OpCode))
  56. {
  57. condition += " and UserId in (select UserId from SysAdmin where OpCode='" + OpCode + "')";
  58. }
  59. if (!string.IsNullOrEmpty(CreateDateData))
  60. {
  61. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  62. // string start = datelist[0];
  63. // string end = datelist[1];
  64. // condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  65. var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
  66. var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
  67. var check = opdb.AmountRecord.Any(m => m.CreateDate >= start);
  68. var checks = opdb.AmountRecord.Any(m => m.CreateDate <= end);
  69. if (check)
  70. {
  71. var sId = opdb.AmountRecord.Where(m => m.CreateDate >= start).Min(m => m.Id);
  72. condition += " and Id >=" + sId;
  73. }
  74. if (checks)
  75. {
  76. var eId = opdb.AmountRecord.Where(m => m.CreateDate <= end).Max(m => m.Id);
  77. condition += " and Id <=" + eId;
  78. }
  79. }
  80. else
  81. {
  82. var start = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
  83. var check = opdb.AmountRecord.Any(m => m.CreateDate >= start);
  84. if (check)
  85. {
  86. var minId = opdb.AmountRecord.Where(m => m.CreateDate >= start).Min(m => m.Id);
  87. var Info = function.ReadInstance("/WritePage/AmountRecordOperate/AmountRecordOperate.txt");
  88. if (string.IsNullOrEmpty(Info.ToString()))
  89. {
  90. function.WritePage("/WritePage/AmountRecordOperate/", "AmountRecordOperate.txt", minId.ToString());
  91. condition += " and Id >=" + minId;
  92. }
  93. else
  94. {
  95. condition += " and Id >=" + Convert.ToInt32(Info);
  96. }
  97. }
  98. else
  99. {
  100. condition += " and Id =0";
  101. }
  102. }
  103. Dictionary<string, object> obj = new AdminContentByConn(_accessor.HttpContext, PublicFunction.OpTables, OpConn).IndexData("AmountRecord", Fields, "Id desc", "0", page, limit, condition);
  104. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  105. foreach (Dictionary<string, object> dic in diclist)
  106. {
  107. int UId = int.Parse(dic["UserId"].ToString());
  108. SysAdmin sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.Id == UId) ?? new SysAdmin();
  109. dic["OpCode"] = sysAdmin.OpCode;
  110. dic["MakerCode"] = sysAdmin.MakerCode;
  111. dic["MakerName"] = sysAdmin.MakerName;
  112. int ProductType = int.Parse(dic["ProductType"].ToString());
  113. dic["ProductTypeName"] = RelationClass.GetKqProductBrandInfo(ProductType);
  114. int ChangeType = int.Parse(dic["ChangeType"].ToString());
  115. dic["ChangeTypeName"] = RelationClassForConst.GetChangeTypeInfo(ChangeType);
  116. //获得盟主5元奖励的机具Sn
  117. int SnId = int.Parse(dic["QueryCount"].ToString());
  118. var pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnId) ?? new Models.PosMachinesTwo();
  119. dic["PosSn"] = pos.PosSn;
  120. }
  121. return Json(obj);
  122. }
  123. #endregion
  124. }
  125. }