SettlementCardChangeRecordController.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.Models;
  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 SettlementCardChangeRecordController : BaseController
  24. {
  25. public SettlementCardChangeRecordController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  26. {
  27. OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  28. }
  29. #region 结算卡变更记录
  30. /// <summary>
  31. /// 根据条件查询结算卡变更记录
  32. /// </summary>
  33. /// <returns></returns>
  34. public IActionResult Index(SettlementCardChangeRecord data, string right)
  35. {
  36. ViewBag.RightInfo = RightInfo;
  37. ViewBag.right = right;
  38. return View();
  39. }
  40. #endregion
  41. #region 根据条件查询结算卡变更记录
  42. /// <summary>
  43. /// 结算卡变更记录
  44. /// </summary>
  45. /// <returns></returns>
  46. public JsonResult IndexData(SettlementCardChangeRecord data, string CreateDateData, string MakerCode, string RealName, string BeforeCardNo, string AfterCardNo, int page = 1, int limit = 30)
  47. {
  48. Dictionary<string, string> Fields = new Dictionary<string, string>();
  49. string condition = " and Status>-1";
  50. //创建时间
  51. if (!string.IsNullOrEmpty(CreateDateData))
  52. {
  53. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  54. string start = datelist[0];
  55. string end = datelist[1];
  56. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  57. }
  58. //创客编号
  59. if (!string.IsNullOrEmpty(MakerCode))
  60. {
  61. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  62. }
  63. //创客名称
  64. if (!string.IsNullOrEmpty(RealName))
  65. {
  66. condition += " and Id in (select Id from Users where RealName='" + RealName + "')";
  67. }
  68. //变更前卡号
  69. if (!string.IsNullOrEmpty(BeforeCardNo))
  70. {
  71. condition += " and BeforeCardNo=" + BeforeCardNo;
  72. }
  73. //变更后卡号
  74. if (!string.IsNullOrEmpty(AfterCardNo))
  75. {
  76. condition += " and AfterCardNo=" + AfterCardNo;
  77. }
  78. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("SettlementCardChangeRecord", Fields, "Id desc", "0", page, limit, condition);
  79. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  80. foreach (Dictionary<string, object> dic in diclist)
  81. {
  82. int UserId = int.Parse(dic["UserId"].ToString());
  83. Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  84. dic["MakerCode"] = user.MakerCode;
  85. dic["RealName"] = user.RealName;
  86. }
  87. return Json(obj);
  88. }
  89. #endregion
  90. }
  91. }