UserCashRecordForBusinessController.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 UserCashRecordForBusinessController : BaseController
  24. {
  25. public UserCashRecordForBusinessController(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(UserCashRecordForBusiness data, string right)
  35. {
  36. ViewBag.RightInfo = RightInfo;
  37. ViewBag.right = right;
  38. string Condition = "";
  39. Condition += "CashOrderNo:\"" + data.CashOrderNo + "\",";
  40. Condition += "TradeType:\"" + data.TradeType + "\",";
  41. if (!string.IsNullOrEmpty(Condition))
  42. {
  43. Condition = Condition.TrimEnd(',');
  44. Condition = ", where: {" + Condition + "}";
  45. }
  46. ViewBag.Condition = Condition;
  47. return View();
  48. }
  49. #endregion
  50. #region 根据条件查询提现记录列表
  51. /// <summary>
  52. /// 提现记录列表
  53. /// </summary>
  54. /// <returns></returns>
  55. public JsonResult IndexData(UserCashRecordForBusiness data, string MakerCode, string RealName, string StatusSelect, string QueryCountSelect, string CreateDateData, int page = 1, int limit = 30)
  56. {
  57. Dictionary<string, string> Fields = new Dictionary<string, string>();
  58. Fields.Add("CashOrderNo", "1"); //提现单号
  59. Fields.Add("TradeType", "0"); //交易类型
  60. string condition = " and Status>-1 and TradeType<3";
  61. //创客编号
  62. if (!string.IsNullOrEmpty(MakerCode))
  63. {
  64. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  65. }
  66. //创客名称
  67. if (!string.IsNullOrEmpty(RealName))
  68. {
  69. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  70. }
  71. //提现状态
  72. if (!string.IsNullOrEmpty(StatusSelect))
  73. {
  74. condition += " and Status=" + StatusSelect;
  75. }
  76. if (!string.IsNullOrEmpty(data.CashOrderNo))
  77. {
  78. condition += " and CashOrderNo='" + data.CashOrderNo + "'";
  79. }
  80. if (data.TradeType > 0)
  81. {
  82. condition += " and TradeType=" + data.TradeType;
  83. }
  84. //提交到代付状态
  85. if (!string.IsNullOrEmpty(QueryCountSelect))
  86. {
  87. if(QueryCountSelect == "0")
  88. {
  89. condition += " and QueryCount=" + QueryCountSelect;
  90. }
  91. else
  92. {
  93. condition += " and QueryCount>0";
  94. }
  95. }
  96. if (!string.IsNullOrEmpty(CreateDateData))
  97. {
  98. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  99. var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
  100. var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
  101. var check = db.UserCashRecord.Any(m => m.CreateDate >= start && m.TradeType < 3);
  102. var checks = db.UserCashRecord.Any(m => m.CreateDate <= end && m.TradeType < 3);
  103. if (check)
  104. {
  105. var sId = db.UserCashRecord.Where(m => m.CreateDate >= start && m.TradeType < 3).Min(m => m.Id);
  106. condition += " and Id >=" + sId;
  107. }
  108. if (checks)
  109. {
  110. var eId = db.UserCashRecord.Where(m => m.CreateDate <= end && m.TradeType < 3).Max(m => m.Id);
  111. condition += " and Id <=" + eId;
  112. }
  113. }
  114. else
  115. {
  116. var start = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
  117. var check = db.UserCashRecord.Any(m => m.CreateDate >= start && m.TradeType < 3);
  118. if (check)
  119. {
  120. var minId = db.UserCashRecord.Where(m => m.CreateDate >= start && m.TradeType < 3).Min(m => m.Id);
  121. var Info = function.ReadInstance("/WritePage/UserCashRecord/UserCashRecordForBusiness.txt");
  122. if (string.IsNullOrEmpty(Info.ToString()))
  123. {
  124. function.WritePage("/WritePage/UserCashRecord/", "UserCashRecordForBusiness.txt", minId.ToString());
  125. condition += " and Id >=" + minId;
  126. }
  127. else if (minId != int.Parse(Info))
  128. {
  129. function.WritePage("/WritePage/UserCashRecord/", "UserCashRecordForBusiness.txt", minId.ToString());
  130. condition += " and Id >=" + minId;
  131. }
  132. else
  133. {
  134. condition += " and Id >=" + Convert.ToInt32(Info);
  135. }
  136. }
  137. else
  138. {
  139. condition += " and Id =0";
  140. }
  141. }
  142. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserCashRecordForBusiness", Fields, "Id desc", "0", page, limit, condition);
  143. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  144. foreach (Dictionary<string, object> dic in diclist)
  145. {
  146. int UserId = int.Parse(dic["UserId"].ToString());
  147. Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  148. dic["MakerCode"] = user.MakerCode;
  149. dic["RealName"] = user.RealName;
  150. dic["TradeType"] = RelationClassForConst.GetTradeTypeInfo(int.Parse(dic["TradeType"].ToString()));
  151. int Status = int.Parse(dic["Status"].ToString());
  152. if (Status == 0) dic["StatusName"] = "处理中";
  153. if (Status == 1) dic["StatusName"] = "成功";
  154. if (Status == 2) dic["StatusName"] = "失败";
  155. int QueryCount = int.Parse(dic["QueryCount"].ToString());
  156. if (QueryCount == 0) dic["LockName"] = "待提交";
  157. if (QueryCount > 0) dic["LockName"] = "已提交";
  158. }
  159. return Json(obj);
  160. }
  161. #endregion
  162. #region 增加提现记录
  163. /// <summary>
  164. /// 增加或修改提现记录信息
  165. /// </summary>
  166. /// <returns></returns>
  167. public IActionResult Add(string right)
  168. {
  169. ViewBag.RightInfo = RightInfo;
  170. ViewBag.right = right;
  171. return View();
  172. }
  173. #endregion
  174. #region 增加提现记录
  175. /// <summary>
  176. /// 增加或修改提现记录信息
  177. /// </summary>
  178. /// <returns></returns>
  179. [HttpPost]
  180. public string Add(UserCashRecordForBusiness data)
  181. {
  182. Dictionary<string, object> Fields = new Dictionary<string, object>();
  183. Fields.Add("Remark", data.Remark); //备注
  184. Fields.Add("SeoTitle", data.SeoTitle);
  185. Fields.Add("SeoKeyword", data.SeoKeyword);
  186. Fields.Add("SeoDescription", data.SeoDescription);
  187. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("UserCashRecordForBusiness", Fields, 0);
  188. AddSysLog(data.Id.ToString(), "UserCashRecordForBusiness", "add");
  189. db.SaveChanges();
  190. return "success";
  191. }
  192. #endregion
  193. }
  194. }