UserAccountRecordController.cs 34 KB

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