LeaderReserveRecordController.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.Threading.Tasks;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Microsoft.AspNetCore.Http;
  12. using Microsoft.Extensions.Logging;
  13. using Microsoft.Extensions.Options;
  14. using MySystem.Models;
  15. using Library;
  16. using LitJson;
  17. using MySystemLib;
  18. namespace MySystem.Areas.Admin.Controllers
  19. {
  20. [Area("Admin")]
  21. [Route("Admin/[controller]/[action]")]
  22. public class LeaderReserveRecordController : BaseController
  23. {
  24. public LeaderReserveRecordController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  25. {
  26. OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  27. }
  28. #region 盟主兑换机具券列表
  29. /// <summary>
  30. /// 根据条件查询盟主兑换机具券列表
  31. /// </summary>
  32. /// <returns></returns>
  33. public IActionResult Index(LeaderReserveRecord data, string right)
  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(LeaderReserveRecord data, string UserIdMakerCode, string SourceMakerCode, string RemarkSelect, string CreateDateData, int page = 1, int limit = 30)
  46. {
  47. Dictionary<string, string> Fields = new Dictionary<string, string>();
  48. Fields.Add("SeoKeyword", "1"); //订单编号
  49. string condition = " and Status>-1";
  50. //创客编号
  51. if (!string.IsNullOrEmpty(UserIdMakerCode))
  52. {
  53. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  54. }
  55. //购券创客
  56. if (!string.IsNullOrEmpty(SourceMakerCode))
  57. {
  58. condition += " and SourceUserId in (select UserId from UserForMakerCode where MakerCode='" + SourceMakerCode + "')";
  59. }
  60. //变动类型
  61. if (!string.IsNullOrEmpty(RemarkSelect))
  62. {
  63. condition += " and Remark='" + RemarkSelect + "'";
  64. }
  65. //创建时间
  66. if (!string.IsNullOrEmpty(CreateDateData))
  67. {
  68. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  69. string start = datelist[0];
  70. string end = datelist[1];
  71. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  72. }
  73. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("LeaderReserveRecord", Fields, "Id desc", "0", page, limit, condition);
  74. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  75. foreach (Dictionary<string, object> dic in diclist)
  76. {
  77. //创客
  78. int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
  79. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  80. UserAccount userAccount = db.UserAccount.FirstOrDefault(m => m.Id == UserId) ?? new UserAccount();
  81. dic["LeaderBalanceAmount"] = userAccount.LeaderBalanceAmount;
  82. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  83. dic["UserIdRealName"] = userid_Users.RealName;
  84. dic.Remove("UserId");
  85. //购券创客
  86. int SourceUserId = int.Parse(function.CheckInt(dic["SourceUserId"].ToString()));
  87. if (SourceUserId > 0)
  88. {
  89. Users sourceUser = db.Users.FirstOrDefault(m => m.Id == SourceUserId) ?? new Users();
  90. dic["SourceMakerCode"] = sourceUser.MakerCode;
  91. dic.Remove("SourceUserId");
  92. }
  93. // else
  94. // {
  95. // int OrderId = int.Parse(function.CheckInt(dic["OrderId"].ToString()));
  96. // var order = db.Orders.FirstOrDefault(m => m.Id == OrderId) ?? new Orders();
  97. // Users sourceUser = db.Users.FirstOrDefault(m => m.Id == order.UserId) ?? new Users();
  98. // dic["SourceMakerCode"] = sourceUser.MakerCode;
  99. // dic.Remove("OrderId");
  100. // }
  101. // //购券创客
  102. // int SourceUserId = int.Parse(function.CheckInt(dic["SourceUserId"].ToString()));
  103. // Users sourceUser = db.Users.FirstOrDefault(m => m.Id == SourceUserId) ?? new Users();
  104. // dic["SourceMakerCode"] = sourceUser.MakerCode;
  105. // dic.Remove("SourceUserId");
  106. // //订单来源创客
  107. // int OrderId = int.Parse(function.CheckInt(dic["OrderId"].ToString()));
  108. // var order = db.Orders.FirstOrDefault(m => m.Id == OrderId) ?? new Orders();
  109. // Users sourceOrderUser = db.Users.FirstOrDefault(m => m.Id == order.UserId) ?? new Users();
  110. // dic["SourceOrderMakerCode"] = sourceOrderUser.MakerCode;
  111. // dic.Remove("OrderId");
  112. //订单信息
  113. JsonData ApplyList = JsonMapper.ToObject(dic["SeoTitle"].ToString());//申请数据
  114. dic["dPosCoupons"] = "";
  115. dic["bPosCoupons"] = "";
  116. if (!string.IsNullOrEmpty(dic["SeoTitle"].ToString()))
  117. {
  118. for (int i = 0; i < ApplyList.Count; i++)
  119. {
  120. int num = Convert.ToInt32(ApplyList[i]["Num"].ToString());
  121. int type = Convert.ToInt32(ApplyList[i]["Type"].ToString());
  122. if (type == 1)
  123. {
  124. dic["dPosCoupons"] = num + "张";
  125. }
  126. else
  127. {
  128. dic["bPosCoupons"] = num + "张";
  129. }
  130. }
  131. }
  132. //券码
  133. int OrderId = int.Parse(function.CheckInt(dic["Id"].ToString()));
  134. if (OrderId >= 2300)
  135. {
  136. var info = db.UserSnDelayChange.Where(m => m.QueryCount == OrderId).ToList();
  137. var PosCoupons = "";
  138. foreach (var item in info)
  139. {
  140. PosCoupons += item.SnNo + ",";
  141. }
  142. dic["PosCoupons"] = PosCoupons;
  143. }
  144. else
  145. {
  146. dic["PosCoupons"] = dic["SeoDescription"].ToString();
  147. }
  148. }
  149. return Json(obj);
  150. }
  151. #endregion
  152. }
  153. }