HelpProfitAccountRecordController.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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.Threading.Tasks;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Microsoft.AspNetCore.Http;
  12. using Microsoft.Extensions.Logging;
  13. using Microsoft.Extensions.Options;
  14. using MySystem.Models;
  15. using Library;
  16. using LitJson;
  17. using MySystemLib;
  18. namespace MySystem.Areas.Admin.Controllers
  19. {
  20. [Area("Admin")]
  21. [Route("Admin/[controller]/[action]")]
  22. public class HelpProfitAccountRecordController : BaseController
  23. {
  24. public HelpProfitAccountRecordController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  25. {
  26. OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  27. }
  28. #region 助利宝账户变动记录列表
  29. /// <summary>
  30. /// 根据条件查询助利宝账户变动记录列表
  31. /// </summary>
  32. /// <returns></returns>
  33. public IActionResult Index(HelpProfitAccountRecord data, string right)
  34. {
  35. ViewBag.RightInfo = RightInfo;
  36. ViewBag.right = right;
  37. return View();
  38. }
  39. #endregion
  40. #region 根据条件查询助利宝账户变动记录列表
  41. /// <summary>
  42. /// 助利宝账户变动记录列表
  43. /// </summary>
  44. /// <returns></returns>
  45. public JsonResult IndexData(HelpProfitAccountRecord data, string ChangeTypeSelect, string ProductTypeSelect, int page = 1, int limit = 30)
  46. {
  47. Dictionary<string, string> Fields = new Dictionary<string, string>();
  48. Fields.Add("CreateDate", "3"); //时间
  49. Fields.Add("TransRecordNo", "1"); //交易流水编号
  50. string condition = " and Status>-1";
  51. //变动类型
  52. if (!string.IsNullOrEmpty(ChangeTypeSelect))
  53. {
  54. condition += " and ChangeType=" + ChangeTypeSelect;
  55. }
  56. //产品类型
  57. if (!string.IsNullOrEmpty(ProductTypeSelect))
  58. {
  59. condition += " and ProductType=" + ProductTypeSelect;
  60. }
  61. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("HelpProfitAccountRecord", Fields, "Id desc", "0", page, limit, condition);
  62. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  63. foreach (Dictionary<string, object> dic in diclist)
  64. {
  65. //变动类型
  66. int ChangeType = int.Parse(dic["ChangeType"].ToString());
  67. if (ChangeType == 0) dic["ChangeType"] = " 激活奖励";
  68. if (ChangeType == 1) dic["ChangeType"] = " 交易分润";
  69. if (ChangeType == 2) dic["ChangeType"] = " 提现申请";
  70. if (ChangeType == 3) dic["ChangeType"] = " 提现代付";
  71. if (ChangeType == 4) dic["ChangeType"] = " 提现手续费";
  72. if (ChangeType == 5) dic["ChangeType"] = " 提现税点扣除";
  73. if (ChangeType == 6) dic["ChangeType"] = " 提现失败,解冻";
  74. if (ChangeType == 7) dic["ChangeType"] = " 系统扣除";
  75. if (ChangeType == 10) dic["ChangeType"] = " 办卡奖励";
  76. if (ChangeType == 20) dic["ChangeType"] = " 余额支付";
  77. if (ChangeType == 21) dic["ChangeType"] = " 余额支付退款";
  78. if (ChangeType == 22) dic["ChangeType"] = " 余额支付退款手续费";
  79. if (ChangeType == 30) dic["ChangeType"] = " 签到红包";
  80. if (ChangeType == 31) dic["ChangeType"] = " 系统红包奖励";
  81. //产品类型
  82. int ProductType = int.Parse(dic["ProductType"].ToString());
  83. if (ProductType == 0) dic["ProductType"] = "星支付";
  84. if (ProductType == 1) dic["ProductType"] = "在线办卡";
  85. if (ProductType == 2) dic["ProductType"] = "环迅大POS";
  86. if (ProductType == 3) dic["ProductType"] = "系统奖励";
  87. if (ProductType == 4) dic["ProductType"] = "灵动商城";
  88. if (ProductType == 99) dic["ProductType"] = "提现";
  89. }
  90. return Json(obj);
  91. }
  92. #endregion
  93. #region 增加助利宝账户变动记录
  94. /// <summary>
  95. /// 增加或修改助利宝账户变动记录信息
  96. /// </summary>
  97. /// <returns></returns>
  98. public IActionResult Add(string right)
  99. {
  100. ViewBag.RightInfo = RightInfo;
  101. ViewBag.right = right;
  102. return View();
  103. }
  104. #endregion
  105. #region 增加助利宝账户变动记录
  106. /// <summary>
  107. /// 增加或修改助利宝账户变动记录信息
  108. /// </summary>
  109. /// <returns></returns>
  110. [HttpPost]
  111. public string Add(HelpProfitAccountRecord data)
  112. {
  113. Dictionary<string, object> Fields = new Dictionary<string, object>();
  114. Fields.Add("SeoTitle", data.SeoTitle);
  115. Fields.Add("SeoKeyword", data.SeoKeyword);
  116. Fields.Add("SeoDescription", data.SeoDescription);
  117. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("HelpProfitAccountRecord", Fields, 0);
  118. AddSysLog(data.Id.ToString(), "HelpProfitAccountRecord", "add");
  119. db.SaveChanges();
  120. return "success";
  121. }
  122. #endregion
  123. #region 修改助利宝账户变动记录
  124. /// <summary>
  125. /// 增加或修改助利宝账户变动记录信息
  126. /// </summary>
  127. /// <returns></returns>
  128. public IActionResult Edit(string right, int Id = 0)
  129. {
  130. ViewBag.RightInfo = RightInfo;
  131. ViewBag.right = right;
  132. HelpProfitAccountRecord editData = db.HelpProfitAccountRecord.FirstOrDefault(m => m.Id == Id) ?? new HelpProfitAccountRecord();
  133. ViewBag.data = editData;
  134. return View();
  135. }
  136. #endregion
  137. #region 修改助利宝账户变动记录
  138. /// <summary>
  139. /// 增加或修改助利宝账户变动记录信息
  140. /// </summary>
  141. /// <returns></returns>
  142. [HttpPost]
  143. public string Edit(HelpProfitAccountRecord data)
  144. {
  145. Dictionary<string, object> Fields = new Dictionary<string, object>();
  146. Fields.Add("SeoTitle", data.SeoTitle);
  147. Fields.Add("SeoKeyword", data.SeoKeyword);
  148. Fields.Add("SeoDescription", data.SeoDescription);
  149. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("HelpProfitAccountRecord", Fields, data.Id);
  150. AddSysLog(data.Id.ToString(), "HelpProfitAccountRecord", "update");
  151. db.SaveChanges();
  152. return "success";
  153. }
  154. #endregion
  155. #region 删除助利宝账户变动记录信息
  156. /// <summary>
  157. /// 删除助利宝账户变动记录信息
  158. /// </summary>
  159. /// <returns></returns>
  160. public string Delete(string Id)
  161. {
  162. string[] idlist = Id.Split(new char[] { ',' });
  163. AddSysLog(Id, "HelpProfitAccountRecord", "del");
  164. foreach (string subid in idlist)
  165. {
  166. int id = int.Parse(subid);
  167. Dictionary<string, object> Fields = new Dictionary<string, object>();
  168. Fields.Add("Status", -1);
  169. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("HelpProfitAccountRecord", Fields, id);
  170. }
  171. db.SaveChanges();
  172. return "success";
  173. }
  174. #endregion
  175. #region 开启
  176. /// <summary>
  177. /// 开启
  178. /// </summary>
  179. /// <returns></returns>
  180. public string Open(string Id)
  181. {
  182. string[] idlist = Id.Split(new char[] { ',' });
  183. AddSysLog(Id, "HelpProfitAccountRecord", "open");
  184. foreach (string subid in idlist)
  185. {
  186. int id = int.Parse(subid);
  187. Dictionary<string, object> Fields = new Dictionary<string, object>();
  188. Fields.Add("Status", 1);
  189. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("HelpProfitAccountRecord", Fields, id);
  190. }
  191. db.SaveChanges();
  192. return "success";
  193. }
  194. #endregion
  195. #region 关闭
  196. /// <summary>
  197. /// 关闭
  198. /// </summary>
  199. /// <returns></returns>
  200. public string Close(string Id)
  201. {
  202. string[] idlist = Id.Split(new char[] { ',' });
  203. AddSysLog(Id, "HelpProfitAccountRecord", "close");
  204. foreach (string subid in idlist)
  205. {
  206. int id = int.Parse(subid);
  207. Dictionary<string, object> Fields = new Dictionary<string, object>();
  208. Fields.Add("Status", 0);
  209. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("HelpProfitAccountRecord", Fields, id);
  210. }
  211. db.SaveChanges();
  212. return "success";
  213. }
  214. #endregion
  215. #region 排序
  216. /// <summary>
  217. /// 排序
  218. /// </summary>
  219. /// <param name="Id"></param>
  220. public string Sort(int Id, int Sort)
  221. {
  222. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("HelpProfitAccountRecord", Sort, Id);
  223. AddSysLog(Id.ToString(), "HelpProfitAccountRecord", "sort");
  224. return "success";
  225. }
  226. #endregion
  227. #region 导入数据
  228. /// <summary>
  229. /// 导入数据
  230. /// </summary>
  231. /// <param name="ExcelData"></param>
  232. public string Import(string ExcelData)
  233. {
  234. ExcelData = HttpUtility.UrlDecode(ExcelData);
  235. JsonData list = JsonMapper.ToObject(ExcelData);
  236. for (int i = 1; i < list.Count; i++)
  237. {
  238. JsonData dr = list[i];
  239. db.HelpProfitAccountRecord.Add(new HelpProfitAccountRecord()
  240. {
  241. CreateDate = DateTime.Now,
  242. UpdateDate = DateTime.Now,
  243. });
  244. db.SaveChanges();
  245. }
  246. AddSysLog("0", "HelpProfitAccountRecord", "Import");
  247. return "success";
  248. }
  249. #endregion
  250. #region 导出Excel
  251. /// <summary>
  252. /// 导出Excel
  253. /// </summary>
  254. /// <returns></returns>
  255. public JsonResult ExportExcel(HelpProfitAccountRecord data, string ChangeTypeSelect, string ProductTypeSelect)
  256. {
  257. Dictionary<string, string> Fields = new Dictionary<string, string>();
  258. Fields.Add("CreateDate", "3"); //时间
  259. Fields.Add("TransRecordNo", "1"); //交易流水编号
  260. string condition = " and Status>-1";
  261. //变动类型
  262. if (!string.IsNullOrEmpty(ChangeTypeSelect))
  263. {
  264. condition += " and ChangeType=" + ChangeTypeSelect;
  265. }
  266. //产品类型
  267. if (!string.IsNullOrEmpty(ProductTypeSelect))
  268. {
  269. condition += " and ProductType=" + ProductTypeSelect;
  270. }
  271. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("HelpProfitAccountRecord", Fields, "Id desc", "0", 1, 20000, condition, "UserId,ChangeType,ProductType,ChangeAmount,BeforeTotalAmount,AfterTotalAmount,BeforeFreezeAmount,AfterFreezeAmount,BeforeBalanceAmount,AfterBalanceAmount,Remark,TransRecordNo", false);
  272. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  273. foreach (Dictionary<string, object> dic in diclist)
  274. {
  275. //变动类型
  276. int ChangeType = int.Parse(dic["ChangeType"].ToString());
  277. if (ChangeType == 0) dic["ChangeType"] = " 激活奖励";
  278. if (ChangeType == 1) dic["ChangeType"] = " 交易分润";
  279. if (ChangeType == 2) dic["ChangeType"] = " 提现申请";
  280. if (ChangeType == 3) dic["ChangeType"] = " 提现代付";
  281. if (ChangeType == 4) dic["ChangeType"] = " 提现手续费";
  282. if (ChangeType == 5) dic["ChangeType"] = " 提现税点扣除";
  283. if (ChangeType == 6) dic["ChangeType"] = " 提现失败,解冻";
  284. if (ChangeType == 7) dic["ChangeType"] = " 系统扣除";
  285. if (ChangeType == 10) dic["ChangeType"] = " 办卡奖励";
  286. if (ChangeType == 20) dic["ChangeType"] = " 余额支付";
  287. if (ChangeType == 21) dic["ChangeType"] = " 余额支付退款";
  288. if (ChangeType == 22) dic["ChangeType"] = " 余额支付退款手续费";
  289. if (ChangeType == 30) dic["ChangeType"] = " 签到红包";
  290. if (ChangeType == 31) dic["ChangeType"] = " 系统红包奖励";
  291. //产品类型
  292. int ProductType = int.Parse(dic["ProductType"].ToString());
  293. if (ProductType == 0) dic["ProductType"] = "星支付";
  294. if (ProductType == 1) dic["ProductType"] = "在线办卡";
  295. if (ProductType == 2) dic["ProductType"] = "环迅大POS";
  296. if (ProductType == 3) dic["ProductType"] = "系统奖励";
  297. if (ProductType == 4) dic["ProductType"] = "灵动商城";
  298. if (ProductType == 99) dic["ProductType"] = "提现";
  299. }
  300. Dictionary<string, object> result = new Dictionary<string, object>();
  301. result.Add("Status", "1");
  302. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  303. result.Add("Obj", diclist);
  304. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  305. ReturnFields.Add("UserId", "创客");
  306. ReturnFields.Add("ChangeType", "变动类型");
  307. ReturnFields.Add("ProductType", "产品类型");
  308. ReturnFields.Add("ChangeAmount", "变更金额");
  309. ReturnFields.Add("BeforeTotalAmount", "变更前总金额");
  310. ReturnFields.Add("AfterTotalAmount", "变更后总金额");
  311. ReturnFields.Add("BeforeFreezeAmount", "变更前冻结金额");
  312. ReturnFields.Add("AfterFreezeAmount", "变更后冻结金额");
  313. ReturnFields.Add("BeforeBalanceAmount", "变更前余额");
  314. ReturnFields.Add("AfterBalanceAmount", "变更后余额");
  315. ReturnFields.Add("Remark", "账户变动明细备注信息");
  316. ReturnFields.Add("TransRecordNo", "交易流水编号");
  317. result.Add("Fields", ReturnFields);
  318. AddSysLog("0", "HelpProfitAccountRecord", "ExportExcel");
  319. return Json(result);
  320. }
  321. #endregion
  322. }
  323. }