UserCashRecordController.cs 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234
  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 UserCashRecordController : BaseController
  24. {
  25. public UserCashRecordController(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(UserCashRecord data, string right)
  35. {
  36. ViewBag.RightInfo = RightInfo;
  37. ViewBag.right = right;
  38. string Condition = "";
  39. Condition += "CashOrderNo:\"" + data.CashOrderNo + "\",";
  40. Condition += "TradeType:\"" + data.TradeType + "\",";
  41. if (!string.IsNullOrEmpty(Condition))
  42. {
  43. Condition = Condition.TrimEnd(',');
  44. Condition = ", where: {" + Condition + "}";
  45. }
  46. ViewBag.Condition = Condition;
  47. return View();
  48. }
  49. #endregion
  50. #region 根据条件查询提现记录列表
  51. /// <summary>
  52. /// 提现记录列表
  53. /// </summary>
  54. /// <returns></returns>
  55. public JsonResult IndexData(UserCashRecord data, string MakerCode, string RealName, string StatusSelect, string QueryCountSelect, string CreateDateData, int page = 1, int limit = 30)
  56. {
  57. Dictionary<string, string> Fields = new Dictionary<string, string>();
  58. Fields.Add("CashOrderNo", "1"); //提现单号
  59. Fields.Add("TradeType", "0"); //交易类型
  60. string condition = " and Status>-1 and TradeType<3";
  61. //创客编号
  62. if (!string.IsNullOrEmpty(MakerCode))
  63. {
  64. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  65. }
  66. //创客名称
  67. if (!string.IsNullOrEmpty(RealName))
  68. {
  69. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  70. // condition += " and UserId in (select Id from Users where RealName='" + RealName + "')";
  71. }
  72. //提现状态
  73. if (!string.IsNullOrEmpty(StatusSelect))
  74. {
  75. condition += " and Status=" + StatusSelect;
  76. }
  77. if (!string.IsNullOrEmpty(data.CashOrderNo))
  78. {
  79. condition += " and CashOrderNo='" + data.CashOrderNo + "'";
  80. }
  81. if (data.TradeType > 0)
  82. {
  83. condition += " and TradeType=" + data.TradeType;
  84. }
  85. //提交到代付状态
  86. if (!string.IsNullOrEmpty(QueryCountSelect))
  87. {
  88. condition += " and QueryCount=" + QueryCountSelect;
  89. }
  90. if (!string.IsNullOrEmpty(CreateDateData))
  91. {
  92. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  93. // string start = datelist[0];
  94. // string end = datelist[1];
  95. // condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  96. var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
  97. var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
  98. var check = db.UserCashRecord.Any(m => m.CreateDate >= start && m.TradeType < 3);
  99. var checks = db.UserCashRecord.Any(m => m.CreateDate <= end && m.TradeType < 3);
  100. if (check)
  101. {
  102. var sId = db.UserCashRecord.Where(m => m.CreateDate >= start && m.TradeType < 3).Min(m => m.Id);
  103. condition += " and Id >=" + sId;
  104. }
  105. if (checks)
  106. {
  107. var eId = db.UserCashRecord.Where(m => m.CreateDate <= end && m.TradeType < 3).Max(m => m.Id);
  108. condition += " and Id <=" + eId;
  109. }
  110. }
  111. else
  112. {
  113. var start = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
  114. var check = db.UserCashRecord.Any(m => m.CreateDate >= start && m.TradeType < 3);
  115. if (check)
  116. {
  117. var minId = db.UserCashRecord.Where(m => m.CreateDate >= start && m.TradeType < 3).Min(m => m.Id);
  118. var Info = function.ReadInstance("/WritePage/UserCashRecord/UserCashRecord.txt");
  119. if (string.IsNullOrEmpty(Info.ToString()))
  120. {
  121. function.WritePage("/WritePage/UserCashRecord/", "UserCashRecord.txt", minId.ToString());
  122. condition += " and Id >=" + minId;
  123. }
  124. else
  125. {
  126. condition += " and Id >=" + Convert.ToInt32(Info);
  127. }
  128. }
  129. else
  130. {
  131. condition += " and Id =0";
  132. }
  133. }
  134. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserCashRecord", Fields, "Id desc", "0", page, limit, condition);
  135. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  136. foreach (Dictionary<string, object> dic in diclist)
  137. {
  138. int UserId = int.Parse(dic["UserId"].ToString());
  139. Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  140. dic["MakerCode"] = user.MakerCode;
  141. dic["RealName"] = user.RealName;
  142. dic["TradeType"] = RelationClassForConst.GetTradeTypeInfo(int.Parse(dic["TradeType"].ToString()));
  143. int Status = int.Parse(dic["Status"].ToString());
  144. if (Status == 0) dic["StatusName"] = "处理中";
  145. if (Status == 1) dic["StatusName"] = "成功";
  146. if (Status == 2) dic["StatusName"] = "失败";
  147. int QueryCount = int.Parse(dic["QueryCount"].ToString());
  148. if (QueryCount == 0) dic["LockName"] = "待提交";
  149. if (QueryCount == 1) dic["LockName"] = "已提交";
  150. }
  151. Dictionary<string, object> other = new Dictionary<string, object>();
  152. string WaitAmount = "0.00";//待处理总金额
  153. string SuccessAmount = "0.00";//提现成功总金额
  154. string FailAmount = "0.00";//提现失败总金额
  155. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(if(Status=0,TradeAmount,0)),SUM(if(Status=1,TradeAmount,0)),SUM(if(Status=2,TradeAmount,0)) FROM UserCashRecord where 1=1 " + condition);
  156. if (dt.Rows.Count > 0)
  157. {
  158. WaitAmount = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString())).ToString("f2");
  159. SuccessAmount = decimal.Parse(function.CheckNum(dt.Rows[0][1].ToString())).ToString("f2");
  160. FailAmount = decimal.Parse(function.CheckNum(dt.Rows[0][2].ToString())).ToString("f2");
  161. }
  162. // dt = OtherMySqlConn.dtable("select sum(TradeAmount) from UserCashRecord where Status=1" + condition);
  163. // if (dt.Rows.Count > 0)
  164. // {
  165. // SuccessAmount = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString())).ToString("f2");
  166. // }
  167. // dt = OtherMySqlConn.dtable("select sum(TradeAmount) from UserCashRecord where Status=2" + condition);
  168. // if (dt.Rows.Count > 0)
  169. // {
  170. // FailAmount = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString())).ToString("f2");
  171. // }
  172. other.Add("WaitAmount", WaitAmount);
  173. other.Add("SuccessAmount", SuccessAmount);
  174. other.Add("FailAmount", FailAmount);
  175. obj.Add("other", other);
  176. return Json(obj);
  177. }
  178. #endregion
  179. #region 增加提现记录
  180. /// <summary>
  181. /// 增加或修改提现记录信息
  182. /// </summary>
  183. /// <returns></returns>
  184. public IActionResult Add(string right)
  185. {
  186. ViewBag.RightInfo = RightInfo;
  187. ViewBag.right = right;
  188. return View();
  189. }
  190. #endregion
  191. #region 增加提现记录
  192. /// <summary>
  193. /// 增加或修改提现记录信息
  194. /// </summary>
  195. /// <returns></returns>
  196. [HttpPost]
  197. public string Add(UserCashRecord data)
  198. {
  199. Dictionary<string, object> Fields = new Dictionary<string, object>();
  200. Fields.Add("Remark", data.Remark); //备注
  201. Fields.Add("SeoTitle", data.SeoTitle);
  202. Fields.Add("SeoKeyword", data.SeoKeyword);
  203. Fields.Add("SeoDescription", data.SeoDescription);
  204. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("UserCashRecord", Fields, 0);
  205. AddSysLog(data.Id.ToString(), "UserCashRecord", "add");
  206. db.SaveChanges();
  207. return "success";
  208. }
  209. #endregion
  210. #region 修改提现记录
  211. /// <summary>
  212. /// 增加或修改提现记录信息
  213. /// </summary>
  214. /// <returns></returns>
  215. public IActionResult Edit(string right, int Id = 0)
  216. {
  217. ViewBag.RightInfo = RightInfo;
  218. ViewBag.right = right;
  219. UserCashRecord editData = db.UserCashRecord.FirstOrDefault(m => m.Id == Id) ?? new UserCashRecord();
  220. ViewBag.data = editData;
  221. return View();
  222. }
  223. #endregion
  224. #region 修改提现记录
  225. /// <summary>
  226. /// 增加或修改提现记录信息
  227. /// </summary>
  228. /// <returns></returns>
  229. [HttpPost]
  230. public string Edit(UserCashRecord data)
  231. {
  232. Dictionary<string, object> Fields = new Dictionary<string, object>();
  233. Fields.Add("Remark", data.Remark); //备注
  234. Fields.Add("SeoTitle", data.SeoTitle);
  235. Fields.Add("SeoKeyword", data.SeoKeyword);
  236. Fields.Add("SeoDescription", data.SeoDescription);
  237. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserCashRecord", Fields, data.Id);
  238. AddSysLog(data.Id.ToString(), "UserCashRecord", "update");
  239. db.SaveChanges();
  240. return "success";
  241. }
  242. #endregion
  243. #region 删除提现记录信息
  244. /// <summary>
  245. /// 删除提现记录信息
  246. /// </summary>
  247. /// <returns></returns>
  248. public string Delete(string Id)
  249. {
  250. string[] idlist = Id.Split(new char[] { ',' });
  251. AddSysLog(Id, "UserCashRecord", "del");
  252. foreach (string subid in idlist)
  253. {
  254. int id = int.Parse(subid);
  255. Dictionary<string, object> Fields = new Dictionary<string, object>();
  256. Fields.Add("Status", -1);
  257. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserCashRecord", Fields, id);
  258. }
  259. db.SaveChanges();
  260. return "success";
  261. }
  262. #endregion
  263. #region 开启
  264. /// <summary>
  265. /// 开启
  266. /// </summary>
  267. /// <returns></returns>
  268. public string Open(string Id)
  269. {
  270. string[] idlist = Id.Split(new char[] { ',' });
  271. AddSysLog(Id, "UserCashRecord", "open");
  272. foreach (string subid in idlist)
  273. {
  274. int id = int.Parse(subid);
  275. Dictionary<string, object> Fields = new Dictionary<string, object>();
  276. Fields.Add("Status", 1);
  277. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserCashRecord", Fields, id);
  278. }
  279. db.SaveChanges();
  280. return "success";
  281. }
  282. #endregion
  283. #region 关闭
  284. /// <summary>
  285. /// 关闭
  286. /// </summary>
  287. /// <returns></returns>
  288. public string Close(string Id)
  289. {
  290. string[] idlist = Id.Split(new char[] { ',' });
  291. AddSysLog(Id, "UserCashRecord", "close");
  292. foreach (string subid in idlist)
  293. {
  294. int id = int.Parse(subid);
  295. Dictionary<string, object> Fields = new Dictionary<string, object>();
  296. Fields.Add("Status", 0);
  297. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserCashRecord", Fields, id);
  298. }
  299. db.SaveChanges();
  300. return "success";
  301. }
  302. #endregion
  303. #region 批量设置成功
  304. /// <summary>
  305. /// 批量设置成功
  306. /// </summary>
  307. /// <returns></returns>
  308. public string BatchSetting(string Id)
  309. {
  310. string[] idlist = Id.Split(new char[] { ',' });
  311. AddSysLog(Id, "UserCashRecord", "BatchSetting");
  312. foreach (string subid in idlist)
  313. {
  314. int id = int.Parse(subid);
  315. Dictionary<string, object> Fields = new Dictionary<string, object>();
  316. Fields.Add("Status", 1);//设置提现记录为成功
  317. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserCashRecord", Fields, id);
  318. var userCashRecord = db.UserCashRecord.FirstOrDefault(m => m.Id == id) ?? new UserCashRecord();
  319. if (userCashRecord.Id > 0)
  320. {
  321. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == Convert.ToInt32(userCashRecord.UserId));
  322. if (account != null)
  323. {
  324. account.QueryCount = 1;
  325. decimal TradeAmount = userCashRecord.TradeAmount;
  326. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  327. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  328. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  329. account.WithdrawAmount += userCashRecord.TradeAmount;
  330. account.FreezeAmount -= userCashRecord.TradeAmount;
  331. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  332. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  333. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  334. db.UserAccountRecord.Add(new UserAccountRecord()
  335. {
  336. CreateDate = DateTime.Now,
  337. UpdateDate = DateTime.Now,
  338. UserId = userCashRecord.UserId, //创客
  339. ChangeType = 3, //变动类型
  340. ProductType = 99, //产品类型
  341. ChangeAmount = userCashRecord.ActualTradeAmount, //变更金额
  342. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  343. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  344. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  345. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  346. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  347. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  348. });
  349. db.UserAccountRecord.Add(new UserAccountRecord()
  350. {
  351. CreateDate = DateTime.Now,
  352. UpdateDate = DateTime.Now,
  353. UserId = userCashRecord.UserId, //创客
  354. ChangeType = 4, //变动类型
  355. ProductType = 99, //产品类型
  356. ChangeAmount = userCashRecord.TradeFee, //变更金额
  357. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  358. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  359. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  360. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  361. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  362. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  363. });
  364. db.UserAccountRecord.Add(new UserAccountRecord()
  365. {
  366. CreateDate = DateTime.Now,
  367. UpdateDate = DateTime.Now,
  368. UserId = userCashRecord.UserId, //创客
  369. ChangeType = 5, //变动类型
  370. ProductType = 99, //产品类型
  371. ChangeAmount = userCashRecord.ManageFee, //变更金额
  372. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  373. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  374. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  375. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  376. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  377. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  378. });
  379. db.SaveChanges();
  380. RedisDbconn.Instance.Set("UserAccount:" + userCashRecord.UserId, account);
  381. }
  382. }
  383. }
  384. db.SaveChanges();
  385. return "success";
  386. }
  387. #endregion
  388. #region 排序
  389. /// <summary>
  390. /// 排序
  391. /// </summary>
  392. /// <param name="Id"></param>
  393. public string Sort(int Id, int Sort)
  394. {
  395. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("UserCashRecord", Sort, Id);
  396. AddSysLog(Id.ToString(), "UserCashRecord", "sort");
  397. return "success";
  398. }
  399. #endregion
  400. #region 导入数据
  401. public IActionResult Import(string right)
  402. {
  403. ViewBag.RightInfo = RightInfo;
  404. ViewBag.right = right;
  405. return View();
  406. }
  407. /// <summary>
  408. /// 导入数据
  409. /// </summary>
  410. /// <param name="ExcelData"></param>
  411. [HttpPost]
  412. public string ImportPost(string ExcelPath)
  413. {
  414. string key = function.MD5_16(Guid.NewGuid().ToString());
  415. RedisDbconn.Instance.AddList("ExcelImportV2", ExcelPath + "#cut#UserCashRecord#cut#" + key + "#cut#" + SysUserName);
  416. return "success|" + key;
  417. }
  418. public string CheckImport(string key)
  419. {
  420. string result = RedisDbconn.Instance.Get<string>("CheckImport:" + key);
  421. if (!string.IsNullOrEmpty(result))
  422. {
  423. string[] datalist = result.Split('|');
  424. if (datalist[0] == "success")
  425. {
  426. return result;
  427. }
  428. return datalist[0];
  429. }
  430. return "0";
  431. }
  432. #endregion
  433. #region 导出Excel
  434. /// <summary>
  435. /// 导出Excel
  436. /// </summary>
  437. /// <returns></returns>
  438. public JsonResult ExportExcel(UserCashRecord data, string MakerCode, string RealName, string StatusSelect, string PayStatus)
  439. {
  440. Dictionary<string, string> Fields = new Dictionary<string, string>();
  441. Fields.Add("CashOrderNo", "1"); //提现单号
  442. Fields.Add("CreateDate", "3"); //创建时间
  443. Fields.Add("TradeType", "0"); //交易类型
  444. string condition = " and Status>-1 and TradeType<3";
  445. //创客编号
  446. if (!string.IsNullOrEmpty(MakerCode))
  447. {
  448. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  449. }
  450. //创客名称
  451. if (!string.IsNullOrEmpty(RealName))
  452. {
  453. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  454. }
  455. //提现状态
  456. if (!string.IsNullOrEmpty(StatusSelect))
  457. {
  458. condition += " and Status=" + StatusSelect;
  459. }
  460. //提交到代付状态
  461. if (!string.IsNullOrEmpty(PayStatus))
  462. {
  463. int QueryCount = int.Parse(function.CheckInt(PayStatus));
  464. if (QueryCount == 2)
  465. {
  466. QueryCount = 0;
  467. }
  468. condition += " and QueryCount=" + QueryCount;
  469. }
  470. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserCashRecord", Fields, "Id desc", "0", 1, 20000, condition, "CashOrderNo,UserId,IdCardNo,ActualTradeAmount,Remark,Status,QueryCount,CreateDate", false);
  471. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  472. foreach (Dictionary<string, object> dic in diclist)
  473. {
  474. int UserId = int.Parse(dic["UserId"].ToString());
  475. Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  476. dic["MakerCode"] = user.MakerCode;
  477. dic["RealName"] = user.RealName;
  478. dic["Mobile"] = user.Mobile;
  479. dic["SettleBankName"] = user.SettleBankName;
  480. dic["SettleBankCardNo"] = user.SettleBankCardNo;
  481. dic.Remove("UserId");
  482. // dic["TradeType"] = RelationClassForConst.GetTradeTypeInfo(int.Parse(dic["TradeType"].ToString()));
  483. int Status = int.Parse(dic["Status"].ToString());
  484. if (Status == 0) dic["StatusName"] = "处理中";
  485. if (Status == 1) dic["StatusName"] = "成功";
  486. if (Status == 2) dic["StatusName"] = "失败";
  487. dic.Remove("Status");
  488. int QueryCount = int.Parse(dic["QueryCount"].ToString());
  489. if (QueryCount == 0) dic["LockName"] = "待提交";
  490. if (QueryCount == 1) dic["LockName"] = "已提交";
  491. dic.Remove("QueryCount");
  492. }
  493. Dictionary<string, object> result = new Dictionary<string, object>();
  494. result.Add("Status", "1");
  495. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  496. result.Add("Obj", diclist);
  497. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  498. ReturnFields.Add("CashOrderNo", "提现单号");
  499. ReturnFields.Add("MakerCode", "创客编号");
  500. ReturnFields.Add("RealName", "灵工姓名");
  501. ReturnFields.Add("Mobile", "手机号");
  502. ReturnFields.Add("IdCardNo", "身份证号");
  503. ReturnFields.Add("SettleBankName", "开户行名称");
  504. ReturnFields.Add("SettleBankCardNo", "开户行卡号");
  505. ReturnFields.Add("ActualTradeAmount", "发佣金额(单位:元)");
  506. ReturnFields.Add("LockName", "代付标记");
  507. ReturnFields.Add("StatusName", "状态");
  508. ReturnFields.Add("Remark", "备注");
  509. ReturnFields.Add("CreateDate", "创建时间");
  510. // ReturnFields.Add("CashOrderNo", "提现单号");
  511. // ReturnFields.Add("MakerCode", "创客编码");
  512. // ReturnFields.Add("RealName", "创客名称");
  513. // ReturnFields.Add("IdCardNo", "身份证号");
  514. // ReturnFields.Add("SettleBankCardNo", "提现卡号");
  515. // ReturnFields.Add("SettleBankName", "银行名称");
  516. // ReturnFields.Add("TradeType", "交易类型");
  517. // ReturnFields.Add("TradeAmount", "交易金额(元)");
  518. // ReturnFields.Add("Status", "订单状态");
  519. // ReturnFields.Add("ReturnCode", "提现服务返回编码");
  520. // ReturnFields.Add("ReturnMsg", "提现服务返回信息");
  521. result.Add("Fields", ReturnFields);
  522. AddSysLog("0", "UserCashRecord", "ExportExcel");
  523. return Json(result);
  524. }
  525. #endregion
  526. #region 盟主提现记录列表
  527. /// <summary>
  528. /// 根据条件查询盟主提现记录列表
  529. /// </summary>
  530. /// <returns></returns>
  531. public IActionResult LeaderIndex(UserCashRecord data, string right)
  532. {
  533. ViewBag.RightInfo = RightInfo;
  534. ViewBag.right = right;
  535. string Condition = "";
  536. Condition += "CashOrderNo:\"" + data.CashOrderNo + "\",";
  537. Condition += "TradeType:\"" + data.TradeType + "\",";
  538. if (!string.IsNullOrEmpty(Condition))
  539. {
  540. Condition = Condition.TrimEnd(',');
  541. Condition = ", where: {" + Condition + "}";
  542. }
  543. ViewBag.Condition = Condition;
  544. return View();
  545. }
  546. #endregion
  547. #region 根据条件查询盟主提现记录列表
  548. /// <summary>
  549. /// 盟主提现记录列表
  550. /// </summary>
  551. /// <returns></returns>
  552. public JsonResult LeaderIndexData(UserCashRecord data, string MakerCode, string RealName, string StatusSelect, string QueryCountSelect, string CreateDateData, int page = 1, int limit = 30)
  553. {
  554. Dictionary<string, string> Fields = new Dictionary<string, string>();
  555. Fields.Add("CashOrderNo", "1"); //提现单号
  556. string condition = " and Status>-1 and TradeType=3";
  557. //创客编号
  558. if (!string.IsNullOrEmpty(MakerCode))
  559. {
  560. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  561. }
  562. //创客名称
  563. if (!string.IsNullOrEmpty(RealName))
  564. {
  565. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  566. // condition += " and UserId in (select Id from Users where RealName='" + RealName + "')";
  567. }
  568. //提现状态
  569. if (!string.IsNullOrEmpty(StatusSelect))
  570. {
  571. condition += " and Status=" + StatusSelect;
  572. }
  573. if (!string.IsNullOrEmpty(data.CashOrderNo))
  574. {
  575. condition += " and CashOrderNo='" + data.CashOrderNo + "'";
  576. }
  577. if (data.TradeType > 0)
  578. {
  579. condition += " and TradeType=" + data.TradeType;
  580. }
  581. //提交到代付状态
  582. if (!string.IsNullOrEmpty(QueryCountSelect))
  583. {
  584. condition += " and QueryCount=" + QueryCountSelect;
  585. }
  586. if (!string.IsNullOrEmpty(CreateDateData))
  587. {
  588. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  589. // string start = datelist[0];
  590. // string end = datelist[1];
  591. // condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  592. var start = Convert.ToDateTime(Convert.ToDateTime(datelist[0]).ToString("yyyy-MM-dd"));
  593. var end = Convert.ToDateTime(Convert.ToDateTime(datelist[1]).ToString("yyyy-MM-dd") + " 23:59:59");
  594. var check = db.UserCashRecord.Any(m => m.CreateDate >= start && m.TradeType == 3);
  595. var checks = db.UserCashRecord.Any(m => m.CreateDate <= end && m.TradeType == 3);
  596. if (check)
  597. {
  598. var sId = db.UserCashRecord.Where(m => m.CreateDate >= start && m.TradeType == 3).Min(m => m.Id);
  599. condition += " and Id >=" + sId;
  600. }
  601. if (checks)
  602. {
  603. var eId = db.UserCashRecord.Where(m => m.CreateDate <= end && m.TradeType == 3).Max(m => m.Id);
  604. condition += " and Id <=" + eId;
  605. }
  606. }
  607. else
  608. {
  609. // var start = DateTime.Now.ToString("yyyy-MM") + "-01";
  610. // var end = Convert.ToDateTime(start).AddMonths(1);
  611. // condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<'" + end + " 00:00:00'";
  612. var start = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
  613. var check = db.UserCashRecord.Any(m => m.CreateDate >= start && m.TradeType == 3);
  614. if (check)
  615. {
  616. var minId = db.UserCashRecord.Where(m => m.CreateDate >= start && m.TradeType == 3).Min(m => m.Id);
  617. var Info = function.ReadInstance("/WritePage/UserCashRecord/LeaderUserCashRecord.txt");
  618. if (string.IsNullOrEmpty(Info.ToString()))
  619. {
  620. function.WritePage("/WritePage/UserCashRecord/", "LeaderUserCashRecord.txt", minId.ToString());
  621. condition += " and Id >=" + minId;
  622. }
  623. else
  624. {
  625. condition += " and Id >=" + Convert.ToInt32(Info);
  626. }
  627. }
  628. else
  629. {
  630. condition += " and Id =0";
  631. }
  632. }
  633. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserCashRecord", Fields, "Id desc", "0", page, limit, condition);
  634. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  635. foreach (Dictionary<string, object> dic in diclist)
  636. {
  637. int UserId = int.Parse(dic["UserId"].ToString());
  638. Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  639. dic["MakerCode"] = user.MakerCode;
  640. dic["RealName"] = user.RealName;
  641. dic["TradeType"] = RelationClassForConst.GetTradeTypeInfo(int.Parse(dic["TradeType"].ToString()));
  642. int Status = int.Parse(dic["Status"].ToString());
  643. if (Status == 0) dic["StatusName"] = "处理中";
  644. if (Status == 1) dic["StatusName"] = "成功";
  645. if (Status == 2) dic["StatusName"] = "失败";
  646. int QueryCount = int.Parse(dic["QueryCount"].ToString());
  647. if (QueryCount == 0) dic["LockName"] = "待提交";
  648. if (QueryCount == 1) dic["LockName"] = "已提交";
  649. }
  650. Dictionary<string, object> other = new Dictionary<string, object>();
  651. string WaitAmount = "0.00";//待处理总金额
  652. string SuccessAmount = "0.00";//提现成功总金额
  653. string FailAmount = "0.00";//提现失败总金额
  654. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(if(Status=0,TradeAmount,0)),SUM(if(Status=1,TradeAmount,0)),SUM(if(Status=2,TradeAmount,0)) FROM UserCashRecord where 1=1 " + condition);
  655. if (dt.Rows.Count > 0)
  656. {
  657. WaitAmount = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString())).ToString("f2");
  658. SuccessAmount = decimal.Parse(function.CheckNum(dt.Rows[0][1].ToString())).ToString("f2");
  659. FailAmount = decimal.Parse(function.CheckNum(dt.Rows[0][2].ToString())).ToString("f2");
  660. }
  661. other.Add("WaitAmount", WaitAmount);
  662. other.Add("SuccessAmount", SuccessAmount);
  663. other.Add("FailAmount", FailAmount);
  664. obj.Add("other", other);
  665. return Json(obj);
  666. }
  667. #endregion
  668. #region 导出盟主Excel
  669. /// <summary>
  670. /// 导出Excel
  671. /// </summary>
  672. /// <returns></returns>
  673. public JsonResult LeaderExportExcel(UserCashRecord data, string MakerCode, string RealName, string StatusSelect, string PayStatus)
  674. {
  675. Dictionary<string, string> Fields = new Dictionary<string, string>();
  676. Fields.Add("CashOrderNo", "1"); //提现单号
  677. Fields.Add("CreateDate", "3"); //创建时间
  678. string condition = " and Status>-1 and TradeType=3";
  679. //创客编号
  680. if (!string.IsNullOrEmpty(MakerCode))
  681. {
  682. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  683. }
  684. //创客名称
  685. if (!string.IsNullOrEmpty(RealName))
  686. {
  687. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  688. }
  689. //提现状态
  690. if (!string.IsNullOrEmpty(StatusSelect))
  691. {
  692. condition += " and Status=" + StatusSelect;
  693. }
  694. //提交到代付状态
  695. if (!string.IsNullOrEmpty(PayStatus))
  696. {
  697. int QueryCount = int.Parse(function.CheckInt(PayStatus));
  698. if (QueryCount == 2)
  699. {
  700. QueryCount = 0;
  701. }
  702. condition += " and QueryCount=" + QueryCount;
  703. }
  704. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserCashRecord", Fields, "Id desc", "0", 1, 20000, condition, "CashOrderNo,UserId,IdCardNo,ActualTradeAmount,Remark,Status,QueryCount,CreateDate", false);
  705. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  706. foreach (Dictionary<string, object> dic in diclist)
  707. {
  708. int UserId = int.Parse(dic["UserId"].ToString());
  709. Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  710. dic["MakerCode"] = user.MakerCode;
  711. dic["RealName"] = user.RealName;
  712. dic["Mobile"] = user.Mobile;
  713. dic["SettleBankName"] = user.SettleBankName;
  714. dic["SettleBankCardNo"] = user.SettleBankCardNo;
  715. dic.Remove("UserId");
  716. // dic["TradeType"] = RelationClassForConst.GetTradeTypeInfo(int.Parse(dic["TradeType"].ToString()));
  717. int Status = int.Parse(dic["Status"].ToString());
  718. if (Status == 0) dic["StatusName"] = "处理中";
  719. if (Status == 1) dic["StatusName"] = "成功";
  720. if (Status == 2) dic["StatusName"] = "失败";
  721. dic.Remove("Status");
  722. int QueryCount = int.Parse(dic["QueryCount"].ToString());
  723. if (QueryCount == 0) dic["LockName"] = "待提交";
  724. if (QueryCount == 1) dic["LockName"] = "已提交";
  725. dic.Remove("QueryCount");
  726. }
  727. Dictionary<string, object> result = new Dictionary<string, object>();
  728. result.Add("Status", "1");
  729. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  730. result.Add("Obj", diclist);
  731. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  732. ReturnFields.Add("CashOrderNo", "提现单号");
  733. ReturnFields.Add("MakerCode", "创客编号");
  734. ReturnFields.Add("RealName", "灵工姓名");
  735. ReturnFields.Add("Mobile", "手机号");
  736. ReturnFields.Add("IdCardNo", "身份证号");
  737. ReturnFields.Add("SettleBankName", "开户行名称");
  738. ReturnFields.Add("SettleBankCardNo", "开户行卡号");
  739. ReturnFields.Add("ActualTradeAmount", "发佣金额(单位:元)");
  740. ReturnFields.Add("LockName", "代付标记");
  741. ReturnFields.Add("StatusName", "状态");
  742. ReturnFields.Add("Remark", "备注");
  743. ReturnFields.Add("CreateDate", "创建时间");
  744. result.Add("Fields", ReturnFields);
  745. AddSysLog("0", "UserCashRecord", "ExportExcel");
  746. return Json(result);
  747. }
  748. #endregion
  749. #region 助利宝提现记录列表
  750. /// <summary>
  751. /// 根据条件查询助利宝提现记录列表
  752. /// </summary>
  753. /// <returns></returns>
  754. public IActionResult HelpProfitIndex(UserCashRecord data, string right)
  755. {
  756. ViewBag.RightInfo = RightInfo;
  757. ViewBag.right = right;
  758. string Condition = "";
  759. Condition += "CashOrderNo:\"" + data.CashOrderNo + "\",";
  760. Condition += "TradeType:\"" + data.TradeType + "\",";
  761. if (!string.IsNullOrEmpty(Condition))
  762. {
  763. Condition = Condition.TrimEnd(',');
  764. Condition = ", where: {" + Condition + "}";
  765. }
  766. ViewBag.Condition = Condition;
  767. return View();
  768. }
  769. #endregion
  770. #region
  771. /// <summary>
  772. /// 助利宝提现记录列表
  773. /// </summary>
  774. /// <returns></returns>
  775. public JsonResult HelpProfitIndexData(UserCashRecord data, string MakerCode, string RealName, string StatusSelect, string QueryCountSelect, string CreateDateData, int page = 1, int limit = 30)
  776. {
  777. Dictionary<string, string> Fields = new Dictionary<string, string>();
  778. Fields.Add("CashOrderNo", "1"); //提现单号
  779. string condition = " and Status>-1 and TradeType=4";
  780. //创客编号
  781. if (!string.IsNullOrEmpty(MakerCode))
  782. {
  783. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  784. }
  785. //创客名称
  786. if (!string.IsNullOrEmpty(RealName))
  787. {
  788. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  789. // condition += " and UserId in (select Id from Users where RealName='" + RealName + "')";
  790. }
  791. //提现状态
  792. if (!string.IsNullOrEmpty(StatusSelect))
  793. {
  794. condition += " and Status=" + StatusSelect;
  795. }
  796. if (!string.IsNullOrEmpty(data.CashOrderNo))
  797. {
  798. condition += " and CashOrderNo='" + data.CashOrderNo + "'";
  799. }
  800. if (data.TradeType > 0)
  801. {
  802. condition += " and TradeType=" + data.TradeType;
  803. }
  804. //提交到代付状态
  805. if (!string.IsNullOrEmpty(QueryCountSelect))
  806. {
  807. condition += " and QueryCount=" + QueryCountSelect;
  808. }
  809. if (!string.IsNullOrEmpty(CreateDateData))
  810. {
  811. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  812. string start = datelist[0];
  813. string end = datelist[1];
  814. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  815. }
  816. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserCashRecord", Fields, "Id desc", "0", page, limit, condition);
  817. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  818. foreach (Dictionary<string, object> dic in diclist)
  819. {
  820. int UserId = int.Parse(dic["UserId"].ToString());
  821. Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  822. dic["MakerCode"] = user.MakerCode;
  823. dic["RealName"] = user.RealName;
  824. dic["TradeType"] = RelationClassForConst.GetTradeTypeInfo(int.Parse(dic["TradeType"].ToString()));
  825. int Status = int.Parse(dic["Status"].ToString());
  826. if (Status == 0) dic["StatusName"] = "处理中";
  827. if (Status == 1) dic["StatusName"] = "成功";
  828. if (Status == 2) dic["StatusName"] = "失败";
  829. int QueryCount = int.Parse(dic["QueryCount"].ToString());
  830. if (QueryCount == 0) dic["LockName"] = "待提交";
  831. if (QueryCount == 1) dic["LockName"] = "已提交";
  832. }
  833. Dictionary<string, object> other = new Dictionary<string, object>();
  834. string WaitAmount = "0.00";//待处理总金额
  835. string SuccessAmount = "0.00";//提现成功总金额
  836. string FailAmount = "0.00";//提现失败总金额
  837. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(if(Status=0,TradeAmount,0)),SUM(if(Status=1,TradeAmount,0)),SUM(if(Status=2,TradeAmount,0)) FROM UserCashRecord where 1=1 " + condition);
  838. if (dt.Rows.Count > 0)
  839. {
  840. WaitAmount = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString())).ToString("f2");
  841. SuccessAmount = decimal.Parse(function.CheckNum(dt.Rows[0][1].ToString())).ToString("f2");
  842. FailAmount = decimal.Parse(function.CheckNum(dt.Rows[0][2].ToString())).ToString("f2");
  843. }
  844. other.Add("WaitAmount", WaitAmount);
  845. other.Add("SuccessAmount", SuccessAmount);
  846. other.Add("FailAmount", FailAmount);
  847. obj.Add("other", other);
  848. return Json(obj);
  849. }
  850. #endregion
  851. #region 导出助利宝Excel
  852. /// <summary>
  853. /// 导出Excel
  854. /// </summary>
  855. /// <returns></returns>
  856. public JsonResult HelpProfitExportExcel(UserCashRecord data, string MakerCode, string RealName, string StatusSelect, string PayStatus)
  857. {
  858. Dictionary<string, string> Fields = new Dictionary<string, string>();
  859. Fields.Add("CashOrderNo", "1"); //提现单号
  860. Fields.Add("CreateDate", "3"); //创建时间
  861. string condition = " and Status>-1 and TradeType=4";
  862. //创客编号
  863. if (!string.IsNullOrEmpty(MakerCode))
  864. {
  865. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  866. }
  867. //创客名称
  868. if (!string.IsNullOrEmpty(RealName))
  869. {
  870. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  871. }
  872. //提现状态
  873. if (!string.IsNullOrEmpty(StatusSelect))
  874. {
  875. condition += " and Status=" + StatusSelect;
  876. }
  877. //提交到代付状态
  878. if (!string.IsNullOrEmpty(PayStatus))
  879. {
  880. int QueryCount = int.Parse(function.CheckInt(PayStatus));
  881. if (QueryCount == 2)
  882. {
  883. QueryCount = 0;
  884. }
  885. condition += " and QueryCount=" + QueryCount;
  886. }
  887. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserCashRecord", Fields, "Id desc", "0", 1, 20000, condition, "CashOrderNo,UserId,IdCardNo,ActualTradeAmount,Remark,Status,QueryCount,CreateDate", false);
  888. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  889. foreach (Dictionary<string, object> dic in diclist)
  890. {
  891. int UserId = int.Parse(dic["UserId"].ToString());
  892. Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  893. dic["MakerCode"] = user.MakerCode;
  894. dic["RealName"] = user.RealName;
  895. dic["Mobile"] = user.Mobile;
  896. dic["SettleBankName"] = user.SettleBankName;
  897. dic["SettleBankCardNo"] = user.SettleBankCardNo;
  898. dic.Remove("UserId");
  899. // dic["TradeType"] = RelationClassForConst.GetTradeTypeInfo(int.Parse(dic["TradeType"].ToString()));
  900. int Status = int.Parse(dic["Status"].ToString());
  901. if (Status == 0) dic["StatusName"] = "处理中";
  902. if (Status == 1) dic["StatusName"] = "成功";
  903. if (Status == 2) dic["StatusName"] = "失败";
  904. dic.Remove("Status");
  905. int QueryCount = int.Parse(dic["QueryCount"].ToString());
  906. if (QueryCount == 0) dic["LockName"] = "待提交";
  907. if (QueryCount == 1) dic["LockName"] = "已提交";
  908. dic.Remove("QueryCount");
  909. }
  910. Dictionary<string, object> result = new Dictionary<string, object>();
  911. result.Add("Status", "1");
  912. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  913. result.Add("Obj", diclist);
  914. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  915. ReturnFields.Add("CashOrderNo", "提现单号");
  916. ReturnFields.Add("MakerCode", "创客编号");
  917. ReturnFields.Add("RealName", "灵工姓名");
  918. ReturnFields.Add("Mobile", "手机号");
  919. ReturnFields.Add("IdCardNo", "身份证号");
  920. ReturnFields.Add("SettleBankName", "开户行名称");
  921. ReturnFields.Add("SettleBankCardNo", "开户行卡号");
  922. ReturnFields.Add("ActualTradeAmount", "发佣金额(单位:元)");
  923. ReturnFields.Add("LockName", "代付标记");
  924. ReturnFields.Add("StatusName", "状态");
  925. ReturnFields.Add("Remark", "备注");
  926. ReturnFields.Add("CreateDate", "创建时间");
  927. result.Add("Fields", ReturnFields);
  928. AddSysLog("0", "UserCashRecord", "ExportExcel");
  929. return Json(result);
  930. }
  931. #endregion
  932. #region 提交代付平台
  933. /// <summary>
  934. /// 提交代付平台
  935. /// </summary>
  936. /// <returns></returns>
  937. public string Cash(string Id)
  938. {
  939. string[] idlist = Id.Split(new char[] { ',' });
  940. AddSysLog(Id, "UserCashRecord", "cash");
  941. db.SaveChanges();
  942. foreach (string subid in idlist)
  943. {
  944. int id = int.Parse(subid);
  945. UserCashRecord edit = db.UserCashRecord.FirstOrDefault(m => m.Id == id && m.QueryCount == 0);
  946. if (edit != null)
  947. {
  948. edit.QueryCount = 1;
  949. edit.UpdateDate = DateTime.Now;
  950. db.SaveChanges();
  951. RedisDbconn.Instance.AddList("CashPayApplyQueue", Newtonsoft.Json.JsonConvert.SerializeObject(edit));
  952. }
  953. }
  954. return "success";
  955. }
  956. #endregion
  957. #region 拒绝
  958. /// <summary>
  959. /// 拒绝
  960. /// </summary>
  961. /// <returns></returns>
  962. public IActionResult Reduce(string right, int Id = 0)
  963. {
  964. ViewBag.RightInfo = RightInfo;
  965. ViewBag.right = right;
  966. UserCashRecord editData = db.UserCashRecord.FirstOrDefault(m => m.Id == Id) ?? new UserCashRecord();
  967. ViewBag.data = editData;
  968. return View();
  969. }
  970. #endregion
  971. #region 拒绝
  972. /// <summary>
  973. /// 拒绝
  974. /// </summary>
  975. /// <returns></returns>
  976. public string ReduceDo(int Id, string Remark)
  977. {
  978. AddSysLog(Id, "UserCashRecord", "Reduce");
  979. UserCashRecord edit = db.UserCashRecord.FirstOrDefault(m => m.Id == Id);
  980. if (edit != null)
  981. {
  982. if (edit.TradeType == 3)
  983. {
  984. edit.Status = 2;
  985. edit.Remark = Remark;
  986. edit.UpdateMan = SysUserName;
  987. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == edit.UserId);
  988. if (account != null)
  989. {
  990. decimal TradeAmount = edit.TradeAmount;
  991. account.LeaderBalanceAmount += TradeAmount;
  992. db.LeaderAccountRecord.Add(new LeaderAccountRecord()
  993. {
  994. CreateDate = DateTime.Now,
  995. UserId = edit.UserId, //创客
  996. ChangeType = 6, //变动类型
  997. ProductType = 99, //产品类型
  998. ChangeAmount = TradeAmount, //变更金额
  999. BeforeBalanceAmount = account.LeaderBalanceAmount - TradeAmount, //变更前余额
  1000. AfterBalanceAmount = account.LeaderBalanceAmount, //变更后余额
  1001. });
  1002. db.SaveChanges();
  1003. RedisDbconn.Instance.Set("UserAccount:" + edit.UserId, account);
  1004. }
  1005. }
  1006. else if (edit.TradeType == 4)
  1007. {
  1008. edit.Status = 2;
  1009. edit.Remark = Remark;
  1010. edit.UpdateMan = SysUserName;
  1011. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == edit.UserId);
  1012. if (account != null)
  1013. {
  1014. decimal TradeAmount = edit.TradeAmount;
  1015. account.HelpProfitBalanceAmount += TradeAmount;
  1016. db.HelpProfitAccountRecord.Add(new HelpProfitAccountRecord()
  1017. {
  1018. CreateDate = DateTime.Now,
  1019. UserId = edit.UserId, //创客
  1020. ChangeType = 6, //变动类型
  1021. ProductType = 99, //产品类型
  1022. ChangeAmount = TradeAmount, //变更金额
  1023. BeforeBalanceAmount = account.HelpProfitBalanceAmount - TradeAmount, //变更前余额
  1024. AfterBalanceAmount = account.HelpProfitBalanceAmount, //变更后余额
  1025. });
  1026. db.SaveChanges();
  1027. RedisDbconn.Instance.Set("UserAccount:" + edit.UserId, account);
  1028. }
  1029. }
  1030. else
  1031. {
  1032. edit.Status = 2;
  1033. edit.Remark = Remark;
  1034. edit.UpdateMan = SysUserName;
  1035. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == edit.UserId);
  1036. if (account != null)
  1037. {
  1038. decimal TradeAmount = edit.TradeAmount;
  1039. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  1040. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  1041. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  1042. account.BalanceAmount += TradeAmount;
  1043. if (account.FreezeAmount >= TradeAmount)
  1044. {
  1045. account.FreezeAmount -= TradeAmount;
  1046. }
  1047. else
  1048. {
  1049. return "冻结金额不足";
  1050. }
  1051. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  1052. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  1053. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  1054. db.UserAccountRecord.Add(new UserAccountRecord()
  1055. {
  1056. CreateDate = DateTime.Now,
  1057. UpdateDate = DateTime.Now,
  1058. UserId = edit.UserId, //创客
  1059. ChangeType = 6, //变动类型
  1060. ProductType = 99, //产品类型
  1061. ChangeAmount = TradeAmount, //变更金额
  1062. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  1063. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  1064. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  1065. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  1066. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  1067. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  1068. });
  1069. db.SaveChanges();
  1070. RedisDbconn.Instance.Set("UserAccount:" + edit.UserId, account);
  1071. }
  1072. }
  1073. db.SaveChanges();
  1074. }
  1075. return "success";
  1076. }
  1077. #endregion
  1078. #region 解除
  1079. /// <summary>
  1080. /// 解除
  1081. /// </summary>
  1082. /// <returns></returns>
  1083. public string Cancel(string Id)
  1084. {
  1085. string[] idlist = Id.Split(new char[] { ',' });
  1086. AddSysLog(Id, "WithdrawRecord", "Cancel");
  1087. foreach (string subid in idlist)
  1088. {
  1089. int id = int.Parse(subid);
  1090. UserCashRecord edit = db.UserCashRecord.FirstOrDefault(m => m.Id == id);
  1091. if (edit != null)
  1092. {
  1093. edit.QueryCount = 0;
  1094. db.SaveChanges();
  1095. }
  1096. }
  1097. return "success";
  1098. }
  1099. #endregion
  1100. }
  1101. }