UserAccountRecordController.cs 34 KB

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