UserAccountRecordController.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  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. obj.Add("other", other);
  214. return Json(obj);
  215. }
  216. #endregion
  217. #region 增加创客账户变动记录
  218. /// <summary>
  219. /// 增加或修改创客账户变动记录信息
  220. /// </summary>
  221. /// <returns></returns>
  222. public IActionResult Add(string right)
  223. {
  224. ViewBag.RightInfo = RightInfo;
  225. ViewBag.right = right;
  226. return View();
  227. }
  228. #endregion
  229. #region 增加创客账户变动记录
  230. /// <summary>
  231. /// 增加或修改创客账户变动记录信息
  232. /// </summary>
  233. /// <returns></returns>
  234. [HttpPost]
  235. public string Add(UserAccountRecord data)
  236. {
  237. Dictionary<string, object> Fields = new Dictionary<string, object>();
  238. Fields.Add("SeoTitle", data.SeoTitle);
  239. Fields.Add("SeoKeyword", data.SeoKeyword);
  240. Fields.Add("SeoDescription", data.SeoDescription);
  241. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("UserAccountRecord", Fields, 0);
  242. AddSysLog(data.Id.ToString(), "UserAccountRecord", "add");
  243. db.SaveChanges();
  244. return "success";
  245. }
  246. #endregion
  247. #region 修改创客账户变动记录
  248. /// <summary>
  249. /// 增加或修改创客账户变动记录信息
  250. /// </summary>
  251. /// <returns></returns>
  252. public IActionResult Edit(string right, int Id = 0)
  253. {
  254. ViewBag.RightInfo = RightInfo;
  255. ViewBag.right = right;
  256. UserAccountRecord editData = db.UserAccountRecord.FirstOrDefault(m => m.Id == Id) ?? new UserAccountRecord();
  257. ViewBag.data = editData;
  258. return View();
  259. }
  260. #endregion
  261. #region 修改创客账户变动记录
  262. /// <summary>
  263. /// 增加或修改创客账户变动记录信息
  264. /// </summary>
  265. /// <returns></returns>
  266. [HttpPost]
  267. public string Edit(UserAccountRecord data)
  268. {
  269. Dictionary<string, object> Fields = new Dictionary<string, object>();
  270. Fields.Add("SeoTitle", data.SeoTitle);
  271. Fields.Add("SeoKeyword", data.SeoKeyword);
  272. Fields.Add("SeoDescription", data.SeoDescription);
  273. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserAccountRecord", Fields, data.Id);
  274. AddSysLog(data.Id.ToString(), "UserAccountRecord", "update");
  275. db.SaveChanges();
  276. return "success";
  277. }
  278. #endregion
  279. #region 删除创客账户变动记录信息
  280. /// <summary>
  281. /// 删除创客账户变动记录信息
  282. /// </summary>
  283. /// <returns></returns>
  284. public string Delete(string Id)
  285. {
  286. string[] idlist = Id.Split(new char[] { ',' });
  287. AddSysLog(Id, "UserAccountRecord", "del");
  288. foreach (string subid in idlist)
  289. {
  290. int id = int.Parse(subid);
  291. Dictionary<string, object> Fields = new Dictionary<string, object>();
  292. Fields.Add("Status", -1);
  293. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserAccountRecord", Fields, id);
  294. }
  295. db.SaveChanges();
  296. return "success";
  297. }
  298. #endregion
  299. #region 开启
  300. /// <summary>
  301. /// 开启
  302. /// </summary>
  303. /// <returns></returns>
  304. public string Open(string Id)
  305. {
  306. string[] idlist = Id.Split(new char[] { ',' });
  307. AddSysLog(Id, "UserAccountRecord", "open");
  308. foreach (string subid in idlist)
  309. {
  310. int id = int.Parse(subid);
  311. Dictionary<string, object> Fields = new Dictionary<string, object>();
  312. Fields.Add("Status", 1);
  313. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserAccountRecord", Fields, id);
  314. }
  315. db.SaveChanges();
  316. return "success";
  317. }
  318. #endregion
  319. #region 关闭
  320. /// <summary>
  321. /// 关闭
  322. /// </summary>
  323. /// <returns></returns>
  324. public string Close(string Id)
  325. {
  326. string[] idlist = Id.Split(new char[] { ',' });
  327. AddSysLog(Id, "UserAccountRecord", "close");
  328. foreach (string subid in idlist)
  329. {
  330. int id = int.Parse(subid);
  331. Dictionary<string, object> Fields = new Dictionary<string, object>();
  332. Fields.Add("Status", 0);
  333. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserAccountRecord", Fields, id);
  334. }
  335. db.SaveChanges();
  336. return "success";
  337. }
  338. #endregion
  339. #region 排序
  340. /// <summary>
  341. /// 排序
  342. /// </summary>
  343. /// <param name="Id"></param>
  344. public string Sort(int Id, int Sort)
  345. {
  346. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("UserAccountRecord", Sort, Id);
  347. AddSysLog(Id.ToString(), "UserAccountRecord", "sort");
  348. return "success";
  349. }
  350. #endregion
  351. #region 导入数据
  352. /// <summary>
  353. /// 导入数据
  354. /// </summary>
  355. /// <param name="ExcelData"></param>
  356. public string Import(string ExcelData)
  357. {
  358. ExcelData = HttpUtility.UrlDecode(ExcelData);
  359. JsonData list = JsonMapper.ToObject(ExcelData);
  360. for (int i = 1; i < list.Count; i++)
  361. {
  362. JsonData dr = list[i];
  363. db.UserAccountRecord.Add(new UserAccountRecord()
  364. {
  365. CreateDate = DateTime.Now,
  366. UpdateDate = DateTime.Now,
  367. });
  368. db.SaveChanges();
  369. }
  370. AddSysLog("0", "UserAccountRecord", "Import");
  371. return "success";
  372. }
  373. #endregion
  374. #region 导出Excel
  375. /// <summary>
  376. /// 导出Excel
  377. /// </summary>
  378. /// <returns></returns>
  379. public JsonResult ExportExcel(UserAccountRecord data, int ChangeType, int ProductType, string TransRecordNo, string MakerCode, string RealName, string CreateDateData, int TopUserId, int UserId)
  380. {
  381. Dictionary<string, string> Fields = new Dictionary<string, string>();
  382. // Fields.Add("ChangeType", "1"); //交易类型
  383. // Fields.Add("ProductType", "1"); //产品类型
  384. // Fields.Add("TransRecordNo", "3"); //交易流水编号
  385. string condition = " and Status>-1";
  386. //创客编号
  387. if (!string.IsNullOrEmpty(MakerCode))
  388. {
  389. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  390. }
  391. //创客名称
  392. if (!string.IsNullOrEmpty(RealName))
  393. {
  394. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  395. }
  396. //顶级创客
  397. if (TopUserId > 0)
  398. {
  399. condition += " and UserId in (select Id from Users where ParentNav like '," + TopUserId + ",%')";
  400. }
  401. if (UserId > 0)
  402. {
  403. condition += " and UserId=" + UserId;
  404. }
  405. if (ChangeType > 0)
  406. {
  407. if (ChangeType == 1)
  408. {
  409. condition += " and (ChangeType=" + ChangeType + " or (ChangeType in(112,1) and ProductType=101))";
  410. }
  411. else if (ChangeType == 30)
  412. {
  413. condition += " and ChangeType=31 and Remark='开机抢红包活动'";
  414. }
  415. else if (ChangeType == 31)
  416. {
  417. condition += " and (ChangeType=" + ChangeType + " and (Remark!='开机抢红包活动' or Remark IS NULL))";
  418. }
  419. else
  420. {
  421. condition += " and ChangeType=" + ChangeType;
  422. }
  423. }
  424. if (ProductType > 0)
  425. {
  426. condition += " and ProductType=" + ProductType;
  427. }
  428. if (!string.IsNullOrEmpty(TransRecordNo))
  429. {
  430. condition += " and TransRecordNo='" + TransRecordNo + "'";
  431. }
  432. if (!string.IsNullOrEmpty(CreateDateData))
  433. {
  434. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  435. var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
  436. var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
  437. var check = db.UserAccountRecord.Any(m => m.CreateDate >= start);
  438. var checks = db.UserAccountRecord.Any(m => m.CreateDate <= end);
  439. if (check)
  440. {
  441. var sId = db.UserAccountRecord.Where(m => m.CreateDate >= start).Min(m => m.Id);
  442. condition += " and Id >=" + sId;
  443. }
  444. if (checks)
  445. {
  446. var eId = db.UserAccountRecord.Where(m => m.CreateDate <= end).Max(m => m.Id);
  447. condition += " and Id <=" + eId;
  448. }
  449. }
  450. 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);
  451. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  452. foreach (Dictionary<string, object> dic in diclist)
  453. {
  454. int UId = int.Parse(dic["UserId"].ToString());
  455. Users user = db.Users.FirstOrDefault(m => m.Id == UId) ?? new Users();
  456. dic["MakerCode"] = user.MakerCode;
  457. dic["RealName"] = user.RealName;
  458. if (!string.IsNullOrEmpty(user.ParentNav))
  459. {
  460. int TopId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  461. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  462. dic["TopMakerCode"] = tuser.MakerCode;
  463. dic["TopRealName"] = tuser.RealName;
  464. }
  465. int ProductTypes = int.Parse(dic["ProductType"].ToString());
  466. dic["ProductTypeName"] = RelationClass.GetKqProductBrandInfo(ProductTypes);
  467. int ChangeTypes = int.Parse(dic["ChangeType"].ToString());
  468. string Remark = dic["Remark"].ToString();
  469. if (ChangeTypes == 31 && (Remark == "开机抢红包活动" || string.IsNullOrEmpty(Remark)))
  470. {
  471. dic["ChangeTypeName"] = "红包奖励";
  472. }
  473. else
  474. {
  475. dic["ChangeTypeName"] = RelationClassForConst.GetChangeTypeInfo(ChangeTypes);
  476. }
  477. dic.Remove("UserId");
  478. dic.Remove("ChangeType");
  479. dic.Remove("ProductType");
  480. }
  481. Dictionary<string, object> result = new Dictionary<string, object>();
  482. result.Add("Status", "1");
  483. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  484. result.Add("Obj", diclist);
  485. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  486. ReturnFields.Add("MakerCode", "创客编号");
  487. ReturnFields.Add("RealName", "创客姓名");
  488. ReturnFields.Add("TopMakerCode", "顶级创客编号");
  489. ReturnFields.Add("TopRealName", "顶级创客名称");
  490. ReturnFields.Add("ProductTypeName", "产品类型");
  491. ReturnFields.Add("TransRecordNo", "交易流水编号");
  492. ReturnFields.Add("ChangeTypeName", "交易类型");
  493. ReturnFields.Add("ChangeAmount", "交易金额");
  494. ReturnFields.Add("Remark", "备注");
  495. ReturnFields.Add("BeforeTotalAmount", "交易前总金额");
  496. ReturnFields.Add("AfterTotalAmount", "交易后总金额");
  497. ReturnFields.Add("BeforeFreezeAmount", "交易前冻结金额");
  498. ReturnFields.Add("AfterFreezeAmount", "交易后冻结金额");
  499. ReturnFields.Add("BeforeBalanceAmount", "交易前余额");
  500. ReturnFields.Add("AfterBalanceAmount", "交易后余额");
  501. ReturnFields.Add("CreateDate", "交易时间");
  502. result.Add("Fields", ReturnFields);
  503. AddSysLog("0", "UserAccountRecord", "ExportExcel");
  504. return Json(result);
  505. }
  506. #endregion
  507. }
  508. }