HelpProfitAccountRecordController.cs 14 KB

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