WithdrawConfigController.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.CashModels;
  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 WithdrawConfigController : BaseController
  23. {
  24. public WithdrawConfigController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  25. {
  26. OtherMySqlConn.connstr = ConfigurationManager.AppSettings["CashSqlConnStr"].ToString();
  27. }
  28. #region 创客提现映射列表
  29. /// <summary>
  30. /// 根据条件查询创客提现映射列表
  31. /// </summary>
  32. /// <returns></returns>
  33. public IActionResult Index(WithdrawConfig 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(WithdrawConfig data, int page = 1, int limit = 30)
  46. {
  47. Dictionary<string, string> Fields = new Dictionary<string, string>();
  48. string condition = "";
  49. if(data.Id > 0)
  50. {
  51. condition += " and Id=" + data.Id;
  52. }
  53. if(data.QueryCount > 0)
  54. {
  55. condition += " and QueryCount=" + data.QueryCount;
  56. }
  57. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.CashTables).IndexData("WithdrawConfig", Fields, "Id desc", "0", page, limit, condition);
  58. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  59. foreach (Dictionary<string, object> dic in diclist)
  60. {
  61. //验证和同步账户
  62. int Id = int.Parse(dic["Id"].ToString());
  63. Models.Users user = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Models.Users();
  64. dic["MakerCode"] = user.MakerCode;
  65. dic["RealName"] = user.RealName;
  66. dic["Mobile"] = user.Mobile;
  67. int QueryCount = int.Parse(dic["QueryCount"].ToString());
  68. Models.Users touser = db.Users.FirstOrDefault(m => m.Id == QueryCount) ?? new Models.Users();
  69. dic["ToMakerCode"] = touser.MakerCode;
  70. dic["ToRealName"] = touser.RealName;
  71. dic["ToMobile"] = touser.Mobile;
  72. }
  73. return Json(obj);
  74. }
  75. #endregion
  76. #region 增加创客提现映射
  77. /// <summary>
  78. /// 增加或修改创客提现映射信息
  79. /// </summary>
  80. /// <returns></returns>
  81. public IActionResult Add(string right)
  82. {
  83. ViewBag.RightInfo = RightInfo;
  84. ViewBag.right = right;
  85. return View();
  86. }
  87. #endregion
  88. #region 增加创客提现映射
  89. /// <summary>
  90. /// 增加或修改创客提现映射信息
  91. /// </summary>
  92. /// <returns></returns>
  93. [HttpPost]
  94. public string Add(WithdrawConfig data)
  95. {
  96. Dictionary<string, object> Fields = new Dictionary<string, object>();
  97. Fields.Add("Id", data.Id); //创客编号
  98. Fields.Add("QueryCount", data.QueryCount); //创客名称
  99. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.CashTables).Add("WithdrawConfig", Fields, 0);
  100. AddSysLog(Id.ToString(), "WithdrawConfig", "add");
  101. cashdb.SaveChanges();
  102. return "success";
  103. }
  104. #endregion
  105. #region 删除创客提现映射信息
  106. /// <summary>
  107. /// 删除创客提现映射信息
  108. /// </summary>
  109. /// <returns></returns>
  110. public string Delete(string Id)
  111. {
  112. string[] idlist = Id.Split(new char[] { ',' });
  113. AddSysLog(Id, "WithdrawConfig", "del");
  114. foreach (string subid in idlist)
  115. {
  116. int id = int.Parse(subid);
  117. Dictionary<string, object> Fields = new Dictionary<string, object>();
  118. Fields.Add("Status", -1);
  119. new AdminContentOther(_accessor.HttpContext, PublicFunction.CashTables).Delete("WithdrawConfig", id);
  120. }
  121. cashdb.SaveChanges();
  122. return "success";
  123. }
  124. #endregion
  125. }
  126. }