UserAccountRecordController.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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 UserAccountRecordController : BaseController
  24. {
  25. public UserAccountRecordController(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(UserAccountRecord data, string right, int UserId = 0)
  35. {
  36. ViewBag.RightInfo = RightInfo;
  37. ViewBag.right = right;
  38. ViewBag.UserId = UserId.ToString();
  39. List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
  40. ViewBag.TopUsers = TopUsers;
  41. List<KqProducts> Brands = db.KqProducts.OrderBy(m => m.Id).ToList();
  42. ViewBag.Brands = Brands;
  43. return View();
  44. }
  45. #endregion
  46. #region 根据条件查询创客账户变动记录列表
  47. /// <summary>
  48. /// 创客账户变动记录列表
  49. /// </summary>
  50. /// <returns></returns>
  51. public JsonResult IndexData(UserAccountRecord data, int ChangeType, int ProductType, string TransRecordNo, string MakerCode, string RealName, int TopUserId, string CreateDateData, int UserId = 0, int page = 1, int limit = 30)
  52. {
  53. Dictionary<string, string> Fields = new Dictionary<string, string>();
  54. // Fields.Add("ChangeType", "1"); //交易类型
  55. // Fields.Add("ProductType", "1"); //产品类型
  56. // Fields.Add("TransRecordNo", "3"); //交易流水编号
  57. string condition = " and Status>-1";
  58. //创客编号
  59. if (!string.IsNullOrEmpty(MakerCode))
  60. {
  61. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  62. }
  63. //创客名称
  64. if (!string.IsNullOrEmpty(RealName))
  65. {
  66. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  67. }
  68. //顶级创客
  69. if (TopUserId > 0)
  70. {
  71. condition += " and UserId in (select Id from Users where ParentNav like '," + TopUserId + ",%')";
  72. }
  73. if (UserId > 0)
  74. {
  75. condition += " and UserId=" + UserId;
  76. }
  77. if (!string.IsNullOrEmpty(CreateDateData))
  78. {
  79. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  80. var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
  81. var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
  82. var check = db.UserAccountRecord.Any(m => m.CreateDate >= start);
  83. var checks = db.UserAccountRecord.Any(m => m.CreateDate <= end);
  84. if (check)
  85. {
  86. var sId = db.UserAccountRecord.Where(m => m.CreateDate >= start).Min(m => m.Id);
  87. condition += " and Id >=" + sId;
  88. }
  89. if (checks)
  90. {
  91. var eId = db.UserAccountRecord.Where(m => m.CreateDate <= end).Max(m => m.Id);
  92. condition += " and Id <=" + eId;
  93. }
  94. }
  95. else
  96. {
  97. var start = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
  98. var check = db.UserAccountRecord.Any(m => m.CreateDate >= start);
  99. if (check)
  100. {
  101. var minId = db.UserAccountRecord.Where(m => m.CreateDate >= start).Min(m => m.Id);
  102. var Info = function.ReadInstance("/WritePage/UsersAccountRecord/UsersAccountRecord.txt");
  103. if (string.IsNullOrEmpty(Info.ToString()))
  104. {
  105. function.WritePage("/WritePage/UsersAccountRecord/", "UsersAccountRecord.txt", minId.ToString());
  106. condition += " and Id >=" + minId;
  107. }
  108. else
  109. {
  110. condition += " and Id >=" + Convert.ToInt32(Info);
  111. }
  112. }
  113. else
  114. {
  115. condition += " and Id =0";
  116. }
  117. }
  118. if (ChangeType > 0)
  119. {
  120. if (ChangeType == 1)
  121. {
  122. condition += " and (ChangeType=" + ChangeType + " or (ChangeType in(112,1) and ProductType=101))";
  123. }
  124. else if (ChangeType == 30)
  125. {
  126. condition += " and ChangeType=31 and Remark='开机抢红包活动'";
  127. }
  128. else if (ChangeType == 31)
  129. {
  130. condition += " and (ChangeType=" + ChangeType + " and (Remark!='开机抢红包活动' or Remark IS NULL))";
  131. }
  132. else
  133. {
  134. condition += " and ChangeType=" + ChangeType;
  135. }
  136. }
  137. if (ProductType > 0)
  138. {
  139. condition += " and ProductType=" + ProductType;
  140. }
  141. if (!string.IsNullOrEmpty(TransRecordNo))
  142. {
  143. condition += " and TransRecordNo='" + TransRecordNo + "'";
  144. }
  145. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserAccountRecord", Fields, "Id desc", "0", page, limit, condition);
  146. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  147. foreach (Dictionary<string, object> dic in diclist)
  148. {
  149. int UId = int.Parse(dic["UserId"].ToString());
  150. Users user = db.Users.FirstOrDefault(m => m.Id == UId) ?? new Users();
  151. dic["MakerCode"] = user.MakerCode;
  152. dic["RealName"] = user.RealName;
  153. if (!string.IsNullOrEmpty(user.ParentNav))
  154. {
  155. int TopId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  156. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  157. dic["TopMakerCode"] = tuser.MakerCode;
  158. dic["TopRealName"] = tuser.RealName;
  159. }
  160. int ProductTypes = int.Parse(dic["ProductType"].ToString());
  161. dic["ProductTypeName"] = RelationClass.GetKqProductBrandInfo(ProductTypes);
  162. int ChangeTypes = int.Parse(dic["ChangeType"].ToString());
  163. dic["ChangeTypeName"] = RelationClassForConst.GetChangeTypeInfo(ChangeTypes);
  164. //获得盟主5元奖励的机具Sn
  165. int SnId = int.Parse(dic["QueryCount"].ToString());
  166. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnId) ?? new PosMachinesTwo();
  167. dic["PosSn"] = pos.PosSn;
  168. }
  169. Dictionary<string, object> other = new Dictionary<string, object>();
  170. // string ChangeTypeAmount0 = "0.00", ChangeTypeAmount1 = "0.00", ChangeTypeAmount2 = "0.00", ChangeTypeAmount3 = "0.00", ChangeTypeAmount4 = "0.00", ChangeTypeAmount5 = "0.00", ChangeTypeAmount6 = "0.00", ChangeTypeAmount61 = "0.00", ChangeTypeAmount62 = "0.00", ChangeTypeAmount63 = "0.00", ChangeTypeAmount64 = "0.00", ChangeTypeAmount50 = "0.00", ChangeTypeAmount111 = "0.00", ChangeTypeAmount112 = "0.00", ChangeTypeAmount60 = "0.00", ChangeTypeAmount31 = "0.00", ChangeTypeAmount31s = "0.00", ChangeTypeAmount124 = "0.00", ChangeTypeAmount125 = "0.00";
  171. // DataTable dt = OtherMySqlConn.dtable("select sum(if(ChangeType=0, ChangeAmount, 0)),sum(if(ChangeType=1 and ProductType!=101, ChangeAmount, 0)) + sum(if(ChangeType in(112,1) and ProductType=101, ChangeAmount, 0)),sum(if(ChangeType=2, ChangeAmount, 0)),sum(if(ChangeType=6, ChangeAmount, 0)),sum(if(ChangeType=61, ChangeAmount, 0)),sum(if(ChangeType=62, ChangeAmount, 0)),sum(if(ChangeType=63, ChangeAmount, 0)),sum(if(ChangeType=64, ChangeAmount, 0)),sum(if(ChangeType=50, ChangeAmount, 0)),sum(if(ChangeType=111, ChangeAmount, 0)),sum(if(ChangeType=112 and ProductType!=101, ChangeAmount, 0)),sum(if(ChangeType=60, ChangeAmount, 0)),sum(if(ChangeType=31 and Remark='开机抢红包活动', ChangeAmount, 0)),sum(if(ChangeType=3, ChangeAmount, 0)),sum(if(ChangeType=4, ChangeAmount, 0)),sum(if(ChangeType=5, ChangeAmount, 0)),sum(if(ChangeType=124, ChangeAmount, 0)),sum(if(ChangeType=125, ChangeAmount, 0)),sum(if(ChangeType=31 and (Remark!='开机抢红包活动' or Remark IS NULL), ChangeAmount, 0)) from UserAccountRecord where 1=1" + condition);
  172. // if (dt.Rows.Count > 0)
  173. // {
  174. // ChangeTypeAmount0 = dt.Rows[0][0].ToString();
  175. // ChangeTypeAmount1 = dt.Rows[0][1].ToString();
  176. // ChangeTypeAmount2 = dt.Rows[0][2].ToString();
  177. // ChangeTypeAmount3 = dt.Rows[0][13].ToString();
  178. // ChangeTypeAmount4 = dt.Rows[0][14].ToString();
  179. // ChangeTypeAmount5 = dt.Rows[0][15].ToString();
  180. // ChangeTypeAmount6 = dt.Rows[0][3].ToString();
  181. // ChangeTypeAmount61 = dt.Rows[0][4].ToString();
  182. // ChangeTypeAmount62 = dt.Rows[0][5].ToString();
  183. // ChangeTypeAmount63 = dt.Rows[0][6].ToString();
  184. // ChangeTypeAmount64 = dt.Rows[0][7].ToString();
  185. // ChangeTypeAmount50 = dt.Rows[0][8].ToString();
  186. // ChangeTypeAmount111 = dt.Rows[0][9].ToString();
  187. // ChangeTypeAmount112 = dt.Rows[0][10].ToString();
  188. // ChangeTypeAmount60 = dt.Rows[0][11].ToString();
  189. // ChangeTypeAmount31 = dt.Rows[0][12].ToString();
  190. // ChangeTypeAmount124 = dt.Rows[0][16].ToString();
  191. // ChangeTypeAmount125 = dt.Rows[0][17].ToString();
  192. // ChangeTypeAmount31s = dt.Rows[0][18].ToString();
  193. // }
  194. // other.Add("ChangeTypeAmount0", ChangeTypeAmount0); //激活奖励
  195. // other.Add("ChangeTypeAmount1", ChangeTypeAmount1); //交易分润
  196. // other.Add("ChangeTypeAmount2", ChangeTypeAmount2); //提现申请
  197. // other.Add("ChangeTypeAmount3", ChangeTypeAmount3); //提现代付
  198. // other.Add("ChangeTypeAmount4", ChangeTypeAmount4); //提现手续费
  199. // other.Add("ChangeTypeAmount5", ChangeTypeAmount5); //提现税点扣除
  200. // other.Add("ChangeTypeAmount6", ChangeTypeAmount6); //提现失败,解冻
  201. // other.Add("ChangeTypeAmount61", ChangeTypeAmount61); //人工冻结
  202. // other.Add("ChangeTypeAmount62", ChangeTypeAmount62); //人工解冻
  203. // other.Add("ChangeTypeAmount63", ChangeTypeAmount63); //人工扣减
  204. // other.Add("ChangeTypeAmount64", ChangeTypeAmount64); //人工增加
  205. // other.Add("ChangeTypeAmount50", ChangeTypeAmount50); //开机奖励
  206. // other.Add("ChangeTypeAmount111", ChangeTypeAmount111); //分润补贴
  207. // other.Add("ChangeTypeAmount112", ChangeTypeAmount112); //推荐奖励
  208. // other.Add("ChangeTypeAmount60", ChangeTypeAmount60); //流量卡分佣
  209. // other.Add("ChangeTypeAmount31", ChangeTypeAmount31); //红包奖励
  210. // other.Add("ChangeTypeAmount31s", ChangeTypeAmount31s); //活动奖励
  211. // other.Add("ChangeTypeAmount124", ChangeTypeAmount124); //机具过期
  212. // other.Add("ChangeTypeAmount125", ChangeTypeAmount125); //软件服务费
  213. string ChangeTypeAmount0 = "0.00", ChangeTypeAmount1 = "0.00", ChangeTypeAmount2 = "0.00", ChangeTypeAmount3 = "0.00", ChangeTypeAmount4 = "0.00", ChangeTypeAmount5 = "0.00", ChangeTypeAmount6 = "0.00", ChangeTypeAmount12 = "0.00", ChangeTypeAmount20 = "0.00", ChangeTypeAmount31 = "0.00", ChangeTypeAmount50 = "0.00", ChangeTypeAmount60 = "0.00", ChangeTypeAmount61 = "0.00", ChangeTypeAmount62 = "0.00", ChangeTypeAmount63 = "0.00", ChangeTypeAmount64 = "0.00", ChangeTypeAmount111 = "0.00", ChangeTypeAmount112 = "0.00", ChangeTypeAmount114 = "0.00", ChangeTypeAmount115 = "0.00", ChangeTypeAmount116 = "0.00", ChangeTypeAmount119 = "0.00", ChangeTypeAmount121 = "0.00", ChangeTypeAmount122 = "0.00", ChangeTypeAmount123 = "0.00", ChangeTypeAmount128And120 = "0.00", ChangeTypeAmount124 = "0.00", ChangeTypeAmount125 = "0.00", ChangeTypeAmount126 = "0.00", ChangeTypeAmount127 = "0.00", ChangeTypeAmount202 = "0.00", ChangeTypeAmount30 = "0.00";
  214. DataTable dt = OtherMySqlConn.dtable("select sum(if(ChangeType=0, ChangeAmount, 0)) + sum(if(ChangeType=12, ChangeAmount, 0)),sum(if(ChangeType=1 and ProductType!=101, ChangeAmount, 0)) + sum(if(ChangeType in(112,1) and ProductType=101, ChangeAmount, 0)),sum(if(ChangeType=2, ChangeAmount, 0)),sum(if(ChangeType=3, ChangeAmount, 0)),sum(if(ChangeType=4, ChangeAmount, 0)),sum(if(ChangeType=5, ChangeAmount, 0)),sum(if(ChangeType=6, ChangeAmount, 0)),sum(if(ChangeType=12, ChangeAmount, 0)),sum(if(ChangeType=20, ChangeAmount, 0)),sum(if(ChangeType=31 and (Remark!='开机抢红包活动' or Remark IS NULL), ChangeAmount, 0)),sum(if(ChangeType=50, ChangeAmount, 0)),sum(if(ChangeType=60, ChangeAmount, 0)),sum(if(ChangeType=61, ChangeAmount, 0)),sum(if(ChangeType=62, ChangeAmount, 0)),sum(if(ChangeType=63, ChangeAmount, 0)),sum(if(ChangeType=64, ChangeAmount, 0)),sum(if(ChangeType=111, ChangeAmount, 0)),sum(if(ChangeType=112 and ProductType=0, ChangeAmount, 0)),sum(if(ChangeType=114, ChangeAmount, 0)),sum(if(ChangeType=115, ChangeAmount, 0)),sum(if(ChangeType=116, ChangeAmount, 0)),sum(if(ChangeType=119, ChangeAmount, 0)),sum(if(ChangeType=121, ChangeAmount, 0)),sum(if(ChangeType=118 or ChangeType=120, ChangeAmount, 0)),sum(if(ChangeType=122, ChangeAmount, 0)),sum(if(ChangeType=123, ChangeAmount, 0)),sum(if(ChangeType=124, ChangeAmount, 0)),sum(if(ChangeType=125, ChangeAmount, 0)),sum(if(ChangeType=126, ChangeAmount, 0)),sum(if(ChangeType=127, ChangeAmount, 0)),sum(if(ChangeType=202, ChangeAmount, 0)),sum(if(ChangeType=31 and Remark='开机抢红包活动', ChangeAmount, 0)) from UserAccountRecord where 1=1" + condition);
  215. if (dt.Rows.Count > 0)
  216. {
  217. ChangeTypeAmount0 = dt.Rows[0][0].ToString();
  218. ChangeTypeAmount1 = dt.Rows[0][1].ToString();
  219. ChangeTypeAmount2 = dt.Rows[0][2].ToString();
  220. ChangeTypeAmount3 = dt.Rows[0][3].ToString();
  221. ChangeTypeAmount4 = dt.Rows[0][4].ToString();
  222. ChangeTypeAmount5 = dt.Rows[0][5].ToString();
  223. ChangeTypeAmount6 = dt.Rows[0][6].ToString();
  224. ChangeTypeAmount12 = dt.Rows[0][7].ToString();
  225. ChangeTypeAmount20 = dt.Rows[0][8].ToString();
  226. ChangeTypeAmount31 = dt.Rows[0][9].ToString();
  227. ChangeTypeAmount50 = dt.Rows[0][10].ToString();
  228. ChangeTypeAmount60 = dt.Rows[0][11].ToString();
  229. ChangeTypeAmount61 = dt.Rows[0][12].ToString();
  230. ChangeTypeAmount62 = dt.Rows[0][13].ToString();
  231. ChangeTypeAmount63 = dt.Rows[0][14].ToString();
  232. ChangeTypeAmount64 = dt.Rows[0][15].ToString();
  233. ChangeTypeAmount111 = dt.Rows[0][16].ToString();
  234. ChangeTypeAmount112 = dt.Rows[0][17].ToString();
  235. ChangeTypeAmount114 = dt.Rows[0][18].ToString();
  236. ChangeTypeAmount115 = dt.Rows[0][19].ToString();
  237. ChangeTypeAmount116 = dt.Rows[0][20].ToString();
  238. ChangeTypeAmount119 = dt.Rows[0][21].ToString();
  239. ChangeTypeAmount121 = dt.Rows[0][22].ToString();
  240. ChangeTypeAmount122 = dt.Rows[0][23].ToString();
  241. ChangeTypeAmount123 = dt.Rows[0][24].ToString();
  242. ChangeTypeAmount128And120 = dt.Rows[0][25].ToString();
  243. ChangeTypeAmount124 = dt.Rows[0][26].ToString();
  244. ChangeTypeAmount125 = dt.Rows[0][27].ToString();
  245. ChangeTypeAmount126 = dt.Rows[0][28].ToString();
  246. ChangeTypeAmount127 = dt.Rows[0][29].ToString();
  247. ChangeTypeAmount202 = dt.Rows[0][30].ToString();
  248. ChangeTypeAmount30 = dt.Rows[0][31].ToString();
  249. }
  250. other.Add("ChangeTypeAmount0", ChangeTypeAmount0); //激活奖励
  251. other.Add("ChangeTypeAmount1", ChangeTypeAmount1); //交易分润
  252. other.Add("ChangeTypeAmount2", ChangeTypeAmount2); //提现申请
  253. other.Add("ChangeTypeAmount3", ChangeTypeAmount3); //提现代付
  254. other.Add("ChangeTypeAmount4", ChangeTypeAmount4); //提现手续费
  255. other.Add("ChangeTypeAmount5", ChangeTypeAmount5); //提现税点扣除
  256. other.Add("ChangeTypeAmount6", ChangeTypeAmount6); //提现失败,解冻
  257. other.Add("ChangeTypeAmount12", ChangeTypeAmount12); //交易奖励
  258. other.Add("ChangeTypeAmount20", ChangeTypeAmount20); //余额支付
  259. other.Add("ChangeTypeAmount31", ChangeTypeAmount31); //活动奖励
  260. other.Add("ChangeTypeAmount50", ChangeTypeAmount50); //开机奖励
  261. other.Add("ChangeTypeAmount60", ChangeTypeAmount60); //流量卡分佣
  262. other.Add("ChangeTypeAmount61", ChangeTypeAmount61); //人工冻结
  263. other.Add("ChangeTypeAmount62", ChangeTypeAmount62); //人工解冻
  264. other.Add("ChangeTypeAmount63", ChangeTypeAmount63); //系统扣减(人工扣减)
  265. other.Add("ChangeTypeAmount64", ChangeTypeAmount64); //系统奖励(人工增加)
  266. other.Add("ChangeTypeAmount111", ChangeTypeAmount111); //分润补贴
  267. other.Add("ChangeTypeAmount112", ChangeTypeAmount112); //推荐奖励
  268. other.Add("ChangeTypeAmount114", ChangeTypeAmount114); //私董会分红
  269. other.Add("ChangeTypeAmount115", ChangeTypeAmount115); //分仓奖励
  270. other.Add("ChangeTypeAmount116", ChangeTypeAmount116); //大盟主奖励
  271. other.Add("ChangeTypeAmount119", ChangeTypeAmount119); //分仓临时额度退还
  272. other.Add("ChangeTypeAmount121", ChangeTypeAmount121); //运营中心奖励
  273. other.Add("ChangeTypeAmount122", ChangeTypeAmount122); //推荐大盟主奖励
  274. other.Add("ChangeTypeAmount123", ChangeTypeAmount123); //推荐小盟主奖励
  275. other.Add("ChangeTypeAmount128And120", ChangeTypeAmount128And120); //购机奖励(118盟主奖励(购机奖励) 120运营中心(购机奖励))
  276. other.Add("ChangeTypeAmount124", ChangeTypeAmount124); //扣机具货款
  277. other.Add("ChangeTypeAmount125", ChangeTypeAmount125); //软件服务费
  278. other.Add("ChangeTypeAmount126", ChangeTypeAmount126); //机具货款退还
  279. other.Add("ChangeTypeAmount127", ChangeTypeAmount127); //运营中心分仓奖励
  280. other.Add("ChangeTypeAmount202", ChangeTypeAmount202); //创客预扣款
  281. other.Add("ChangeTypeAmount30", ChangeTypeAmount30); //红包奖励
  282. obj.Add("other", other);
  283. return Json(obj);
  284. }
  285. #endregion
  286. #region 增加创客账户变动记录
  287. /// <summary>
  288. /// 增加或修改创客账户变动记录信息
  289. /// </summary>
  290. /// <returns></returns>
  291. public IActionResult Add(string right)
  292. {
  293. ViewBag.RightInfo = RightInfo;
  294. ViewBag.right = right;
  295. return View();
  296. }
  297. #endregion
  298. #region 增加创客账户变动记录
  299. /// <summary>
  300. /// 增加或修改创客账户变动记录信息
  301. /// </summary>
  302. /// <returns></returns>
  303. [HttpPost]
  304. public string Add(UserAccountRecord data)
  305. {
  306. Dictionary<string, object> Fields = new Dictionary<string, object>();
  307. Fields.Add("SeoTitle", data.SeoTitle);
  308. Fields.Add("SeoKeyword", data.SeoKeyword);
  309. Fields.Add("SeoDescription", data.SeoDescription);
  310. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("UserAccountRecord", Fields, 0);
  311. AddSysLog(data.Id.ToString(), "UserAccountRecord", "add");
  312. db.SaveChanges();
  313. return "success";
  314. }
  315. #endregion
  316. #region 修改创客账户变动记录
  317. /// <summary>
  318. /// 增加或修改创客账户变动记录信息
  319. /// </summary>
  320. /// <returns></returns>
  321. public IActionResult Edit(string right, int Id = 0)
  322. {
  323. ViewBag.RightInfo = RightInfo;
  324. ViewBag.right = right;
  325. UserAccountRecord editData = db.UserAccountRecord.FirstOrDefault(m => m.Id == Id) ?? new UserAccountRecord();
  326. ViewBag.data = editData;
  327. return View();
  328. }
  329. #endregion
  330. #region 修改创客账户变动记录
  331. /// <summary>
  332. /// 增加或修改创客账户变动记录信息
  333. /// </summary>
  334. /// <returns></returns>
  335. [HttpPost]
  336. public string Edit(UserAccountRecord data)
  337. {
  338. Dictionary<string, object> Fields = new Dictionary<string, object>();
  339. Fields.Add("SeoTitle", data.SeoTitle);
  340. Fields.Add("SeoKeyword", data.SeoKeyword);
  341. Fields.Add("SeoDescription", data.SeoDescription);
  342. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserAccountRecord", Fields, data.Id);
  343. AddSysLog(data.Id.ToString(), "UserAccountRecord", "update");
  344. db.SaveChanges();
  345. return "success";
  346. }
  347. #endregion
  348. #region 删除创客账户变动记录信息
  349. /// <summary>
  350. /// 删除创客账户变动记录信息
  351. /// </summary>
  352. /// <returns></returns>
  353. public string Delete(string Id)
  354. {
  355. string[] idlist = Id.Split(new char[] { ',' });
  356. AddSysLog(Id, "UserAccountRecord", "del");
  357. foreach (string subid in idlist)
  358. {
  359. int id = int.Parse(subid);
  360. Dictionary<string, object> Fields = new Dictionary<string, object>();
  361. Fields.Add("Status", -1);
  362. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserAccountRecord", Fields, id);
  363. }
  364. db.SaveChanges();
  365. return "success";
  366. }
  367. #endregion
  368. #region 开启
  369. /// <summary>
  370. /// 开启
  371. /// </summary>
  372. /// <returns></returns>
  373. public string Open(string Id)
  374. {
  375. string[] idlist = Id.Split(new char[] { ',' });
  376. AddSysLog(Id, "UserAccountRecord", "open");
  377. foreach (string subid in idlist)
  378. {
  379. int id = int.Parse(subid);
  380. Dictionary<string, object> Fields = new Dictionary<string, object>();
  381. Fields.Add("Status", 1);
  382. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserAccountRecord", Fields, id);
  383. }
  384. db.SaveChanges();
  385. return "success";
  386. }
  387. #endregion
  388. #region 关闭
  389. /// <summary>
  390. /// 关闭
  391. /// </summary>
  392. /// <returns></returns>
  393. public string Close(string Id)
  394. {
  395. string[] idlist = Id.Split(new char[] { ',' });
  396. AddSysLog(Id, "UserAccountRecord", "close");
  397. foreach (string subid in idlist)
  398. {
  399. int id = int.Parse(subid);
  400. Dictionary<string, object> Fields = new Dictionary<string, object>();
  401. Fields.Add("Status", 0);
  402. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserAccountRecord", Fields, id);
  403. }
  404. db.SaveChanges();
  405. return "success";
  406. }
  407. #endregion
  408. #region 排序
  409. /// <summary>
  410. /// 排序
  411. /// </summary>
  412. /// <param name="Id"></param>
  413. public string Sort(int Id, int Sort)
  414. {
  415. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("UserAccountRecord", Sort, Id);
  416. AddSysLog(Id.ToString(), "UserAccountRecord", "sort");
  417. return "success";
  418. }
  419. #endregion
  420. #region 导入数据
  421. /// <summary>
  422. /// 导入数据
  423. /// </summary>
  424. /// <param name="ExcelData"></param>
  425. public string Import(string ExcelData)
  426. {
  427. ExcelData = HttpUtility.UrlDecode(ExcelData);
  428. JsonData list = JsonMapper.ToObject(ExcelData);
  429. for (int i = 1; i < list.Count; i++)
  430. {
  431. JsonData dr = list[i];
  432. db.UserAccountRecord.Add(new UserAccountRecord()
  433. {
  434. CreateDate = DateTime.Now,
  435. UpdateDate = DateTime.Now,
  436. });
  437. db.SaveChanges();
  438. }
  439. AddSysLog("0", "UserAccountRecord", "Import");
  440. return "success";
  441. }
  442. #endregion
  443. #region 导出Excel
  444. /// <summary>
  445. /// 导出Excel
  446. /// </summary>
  447. /// <returns></returns>
  448. public JsonResult ExportExcel(UserAccountRecord data, int ChangeType, int ProductType, string TransRecordNo, string MakerCode, string RealName, string CreateDateData, int TopUserId, int UserId)
  449. {
  450. Dictionary<string, string> Fields = new Dictionary<string, string>();
  451. // Fields.Add("ChangeType", "1"); //交易类型
  452. // Fields.Add("ProductType", "1"); //产品类型
  453. // Fields.Add("TransRecordNo", "3"); //交易流水编号
  454. string condition = " and Status>-1";
  455. //创客编号
  456. if (!string.IsNullOrEmpty(MakerCode))
  457. {
  458. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  459. }
  460. //创客名称
  461. if (!string.IsNullOrEmpty(RealName))
  462. {
  463. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  464. }
  465. //顶级创客
  466. if (TopUserId > 0)
  467. {
  468. condition += " and UserId in (select Id from Users where ParentNav like '," + TopUserId + ",%')";
  469. }
  470. if (UserId > 0)
  471. {
  472. condition += " and UserId=" + UserId;
  473. }
  474. if (ChangeType > 0)
  475. {
  476. if (ChangeType == 1)
  477. {
  478. condition += " and (ChangeType=" + ChangeType + " or (ChangeType in(112,1) and ProductType=101))";
  479. }
  480. else if (ChangeType == 30)
  481. {
  482. condition += " and ChangeType=31 and Remark='开机抢红包活动'";
  483. }
  484. else if (ChangeType == 31)
  485. {
  486. condition += " and (ChangeType=" + ChangeType + " and (Remark!='开机抢红包活动' or Remark IS NULL))";
  487. }
  488. else
  489. {
  490. condition += " and ChangeType=" + ChangeType;
  491. }
  492. }
  493. if (ProductType > 0)
  494. {
  495. condition += " and ProductType=" + ProductType;
  496. }
  497. if (!string.IsNullOrEmpty(TransRecordNo))
  498. {
  499. condition += " and TransRecordNo='" + TransRecordNo + "'";
  500. }
  501. if (!string.IsNullOrEmpty(CreateDateData))
  502. {
  503. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  504. var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
  505. var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
  506. var check = db.UserAccountRecord.Any(m => m.CreateDate >= start);
  507. var checks = db.UserAccountRecord.Any(m => m.CreateDate <= end);
  508. if (check)
  509. {
  510. var sId = db.UserAccountRecord.Where(m => m.CreateDate >= start).Min(m => m.Id);
  511. condition += " and Id >=" + sId;
  512. }
  513. if (checks)
  514. {
  515. var eId = db.UserAccountRecord.Where(m => m.CreateDate <= end).Max(m => m.Id);
  516. condition += " and Id <=" + eId;
  517. }
  518. }
  519. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserAccountRecord", Fields, "Id desc", "0", 1, 20000, condition, "UserId,ProductType,TransRecordNo,ChangeType,ChangeAmount,Remark,BeforeTotalAmount,AfterTotalAmount,BeforeFreezeAmount,AfterFreezeAmount,BeforeBalanceAmount,AfterBalanceAmount,CreateDate", false);
  520. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  521. foreach (Dictionary<string, object> dic in diclist)
  522. {
  523. int UId = int.Parse(dic["UserId"].ToString());
  524. Users user = db.Users.FirstOrDefault(m => m.Id == UId) ?? new Users();
  525. dic["MakerCode"] = user.MakerCode;
  526. dic["RealName"] = user.RealName;
  527. if (!string.IsNullOrEmpty(user.ParentNav))
  528. {
  529. int TopId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  530. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  531. dic["TopMakerCode"] = tuser.MakerCode;
  532. dic["TopRealName"] = tuser.RealName;
  533. }
  534. int ProductTypes = int.Parse(dic["ProductType"].ToString());
  535. dic["ProductTypeName"] = RelationClass.GetKqProductBrandInfo(ProductTypes);
  536. int ChangeTypes = int.Parse(dic["ChangeType"].ToString());
  537. string Remark = dic["Remark"].ToString();
  538. if (ChangeTypes == 31 && (Remark == "开机抢红包活动" || string.IsNullOrEmpty(Remark)))
  539. {
  540. dic["ChangeTypeName"] = "红包奖励";
  541. }
  542. else
  543. {
  544. dic["ChangeTypeName"] = RelationClassForConst.GetChangeTypeInfo(ChangeTypes);
  545. }
  546. dic.Remove("UserId");
  547. dic.Remove("ChangeType");
  548. dic.Remove("ProductType");
  549. }
  550. Dictionary<string, object> result = new Dictionary<string, object>();
  551. result.Add("Status", "1");
  552. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  553. result.Add("Obj", diclist);
  554. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  555. ReturnFields.Add("MakerCode", "创客编号");
  556. ReturnFields.Add("RealName", "创客姓名");
  557. ReturnFields.Add("TopMakerCode", "顶级创客编号");
  558. ReturnFields.Add("TopRealName", "顶级创客名称");
  559. ReturnFields.Add("ProductTypeName", "产品类型");
  560. ReturnFields.Add("TransRecordNo", "交易流水编号");
  561. ReturnFields.Add("ChangeTypeName", "交易类型");
  562. ReturnFields.Add("ChangeAmount", "交易金额");
  563. ReturnFields.Add("Remark", "备注");
  564. ReturnFields.Add("BeforeTotalAmount", "交易前总金额");
  565. ReturnFields.Add("AfterTotalAmount", "交易后总金额");
  566. ReturnFields.Add("BeforeFreezeAmount", "交易前冻结金额");
  567. ReturnFields.Add("AfterFreezeAmount", "交易后冻结金额");
  568. ReturnFields.Add("BeforeBalanceAmount", "交易前余额");
  569. ReturnFields.Add("AfterBalanceAmount", "交易后余额");
  570. ReturnFields.Add("CreateDate", "交易时间");
  571. result.Add("Fields", ReturnFields);
  572. AddSysLog("0", "UserAccountRecord", "ExportExcel");
  573. return Json(result);
  574. }
  575. #endregion
  576. }
  577. }