StoreHouseAmountRecordController.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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 StoreHouseAmountRecordController : BaseController
  23. {
  24. public StoreHouseAmountRecordController(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(StoreHouseAmountRecord 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(StoreHouseAmountRecord data, string UserIdRealName, string UserIdMakerCode, string CreateDateData, string AmountTypeSelect, string OperateTypeSelect, string ChangeTypeSelect, string PayModeSelect, int page = 1, int limit = 30)
  46. {
  47. Dictionary<string, string> Fields = new Dictionary<string, string>();
  48. string condition = " and Status>=-1";
  49. //创客真实姓名
  50. if (!string.IsNullOrEmpty(UserIdRealName))
  51. {
  52. condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
  53. }
  54. //创客编号
  55. if (!string.IsNullOrEmpty(UserIdMakerCode))
  56. {
  57. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  58. }
  59. if (!string.IsNullOrEmpty(CreateDateData))
  60. {
  61. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  62. string start = datelist[0];
  63. string end = datelist[1];
  64. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  65. }
  66. //额度类别
  67. if (!string.IsNullOrEmpty(AmountTypeSelect))
  68. {
  69. //临时额度
  70. if (AmountTypeSelect == "1")
  71. {
  72. condition += " and (Sort=1 or Sort=3)";
  73. }
  74. else
  75. {
  76. condition += " and Sort!=1 and Sort!=3)";
  77. }
  78. }
  79. //变动类别
  80. if (!string.IsNullOrEmpty(ChangeTypeSelect))
  81. {
  82. condition += " and Sort=" + ChangeTypeSelect;
  83. }
  84. //操作类别
  85. if (!string.IsNullOrEmpty(OperateTypeSelect))
  86. {
  87. condition += " and OperateType=" + OperateTypeSelect;
  88. }
  89. //额度类别
  90. if (!string.IsNullOrEmpty(PayModeSelect))
  91. {
  92. condition += " and PayMode=" + PayModeSelect;
  93. }
  94. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreHouseAmountRecord", Fields, "Id desc", "0", page, limit, condition);
  95. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  96. foreach (Dictionary<string, object> dic in diclist)
  97. {
  98. //创客
  99. int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
  100. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  101. dic["UserIdRealName"] = userid_Users.RealName;
  102. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  103. dic.Remove("UserId");
  104. //申请单
  105. dic["ApplyId"] = RelationClass.GetStoreMachineApplyInfo(int.Parse(dic["ApplyId"].ToString()));
  106. //额度类别
  107. int Sort = int.Parse(dic["Sort"].ToString());
  108. if (Sort == 1 || Sort == 3) dic["AmountType"] = "临时额度";
  109. else dic["AmountType"] = "可用额度";
  110. //变动类别
  111. int ChangeType = int.Parse(dic["Sort"].ToString());
  112. if (ChangeType == 1) dic["ChangeType"] = "购买临时额度";
  113. if (ChangeType == 2) dic["ChangeType"] = "增减分仓可用额度";
  114. if (ChangeType == 3) dic["ChangeType"] = "调低额度";
  115. if (ChangeType == 4) dic["ChangeType"] = "仓库发货|预发机申请";
  116. if (ChangeType == 5) dic["ChangeType"] = "后台仓库调拨";
  117. //操作类别
  118. int OperateType = int.Parse(dic["OperateType"].ToString());
  119. if (OperateType == 1) dic["OperateType"] = "增加";
  120. if (OperateType == 2) dic["OperateType"] = "减少";
  121. if (OperateType == 0) dic["OperateType"] = "";
  122. //额度类别
  123. int PayMode = int.Parse(dic["PayMode"].ToString());
  124. if (PayMode == 1) dic["PayMode"] = "支付宝";
  125. if (PayMode == 3) dic["PayMode"] = "余额";
  126. if (PayMode == 0) dic["PayMode"] = "";
  127. }
  128. return Json(obj);
  129. }
  130. #endregion
  131. #region 增加分仓机具额度记录
  132. /// <summary>
  133. /// 增加或修改分仓机具额度记录信息
  134. /// </summary>
  135. /// <returns></returns>
  136. public IActionResult Add(string right)
  137. {
  138. ViewBag.RightInfo = RightInfo;
  139. ViewBag.right = right;
  140. return View();
  141. }
  142. #endregion
  143. #region 增加分仓机具额度记录
  144. /// <summary>
  145. /// 增加或修改分仓机具额度记录信息
  146. /// </summary>
  147. /// <returns></returns>
  148. [HttpPost]
  149. public string Add(StoreHouseAmountRecord data)
  150. {
  151. Dictionary<string, object> Fields = new Dictionary<string, object>();
  152. Fields.Add("OperateType", data.OperateType); //操作类别
  153. Fields.Add("SeoTitle", data.SeoTitle);
  154. Fields.Add("SeoKeyword", data.SeoKeyword);
  155. Fields.Add("SeoDescription", data.SeoDescription);
  156. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("StoreHouseAmountRecord", Fields, 0);
  157. AddSysLog(data.Id.ToString(), "StoreHouseAmountRecord", "add");
  158. db.SaveChanges();
  159. return "success";
  160. }
  161. #endregion
  162. #region 修改分仓机具额度记录
  163. /// <summary>
  164. /// 增加或修改分仓机具额度记录信息
  165. /// </summary>
  166. /// <returns></returns>
  167. public IActionResult Edit(string right, int Id = 0)
  168. {
  169. ViewBag.RightInfo = RightInfo;
  170. ViewBag.right = right;
  171. StoreHouseAmountRecord editData = db.StoreHouseAmountRecord.FirstOrDefault(m => m.Id == Id) ?? new StoreHouseAmountRecord();
  172. ViewBag.data = editData;
  173. return View();
  174. }
  175. #endregion
  176. #region 修改分仓机具额度记录
  177. /// <summary>
  178. /// 增加或修改分仓机具额度记录信息
  179. /// </summary>
  180. /// <returns></returns>
  181. [HttpPost]
  182. public string Edit(StoreHouseAmountRecord data)
  183. {
  184. Dictionary<string, object> Fields = new Dictionary<string, object>();
  185. Fields.Add("OperateType", data.OperateType); //操作类别
  186. Fields.Add("SeoTitle", data.SeoTitle);
  187. Fields.Add("SeoKeyword", data.SeoKeyword);
  188. Fields.Add("SeoDescription", data.SeoDescription);
  189. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouseAmountRecord", Fields, data.Id);
  190. AddSysLog(data.Id.ToString(), "StoreHouseAmountRecord", "update");
  191. db.SaveChanges();
  192. return "success";
  193. }
  194. #endregion
  195. #region 删除分仓机具额度记录信息
  196. /// <summary>
  197. /// 删除分仓机具额度记录信息
  198. /// </summary>
  199. /// <returns></returns>
  200. public string Delete(string Id)
  201. {
  202. string[] idlist = Id.Split(new char[] { ',' });
  203. AddSysLog(Id, "StoreHouseAmountRecord", "del");
  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", -1);
  209. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouseAmountRecord", Fields, id);
  210. }
  211. db.SaveChanges();
  212. return "success";
  213. }
  214. #endregion
  215. #region 开启
  216. /// <summary>
  217. /// 开启
  218. /// </summary>
  219. /// <returns></returns>
  220. public string Open(string Id)
  221. {
  222. string[] idlist = Id.Split(new char[] { ',' });
  223. AddSysLog(Id, "StoreHouseAmountRecord", "open");
  224. foreach (string subid in idlist)
  225. {
  226. int id = int.Parse(subid);
  227. Dictionary<string, object> Fields = new Dictionary<string, object>();
  228. Fields.Add("Status", 1);
  229. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouseAmountRecord", Fields, id);
  230. }
  231. db.SaveChanges();
  232. return "success";
  233. }
  234. #endregion
  235. #region 关闭
  236. /// <summary>
  237. /// 关闭
  238. /// </summary>
  239. /// <returns></returns>
  240. public string Close(string Id)
  241. {
  242. string[] idlist = Id.Split(new char[] { ',' });
  243. AddSysLog(Id, "StoreHouseAmountRecord", "close");
  244. foreach (string subid in idlist)
  245. {
  246. int id = int.Parse(subid);
  247. Dictionary<string, object> Fields = new Dictionary<string, object>();
  248. Fields.Add("Status", 0);
  249. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouseAmountRecord", Fields, id);
  250. }
  251. db.SaveChanges();
  252. return "success";
  253. }
  254. #endregion
  255. #region 排序
  256. /// <summary>
  257. /// 排序
  258. /// </summary>
  259. /// <param name="Id"></param>
  260. public string Sort(int Id, int Sort)
  261. {
  262. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("StoreHouseAmountRecord", Sort, Id);
  263. AddSysLog(Id.ToString(), "StoreHouseAmountRecord", "sort");
  264. return "success";
  265. }
  266. #endregion
  267. #region 导入数据
  268. /// <summary>
  269. /// 导入数据
  270. /// </summary>
  271. /// <param name="ExcelData"></param>
  272. public string Import(string ExcelData)
  273. {
  274. ExcelData = HttpUtility.UrlDecode(ExcelData);
  275. JsonData list = JsonMapper.ToObject(ExcelData);
  276. for (int i = 1; i < list.Count; i++)
  277. {
  278. JsonData dr = list[i];
  279. db.StoreHouseAmountRecord.Add(new StoreHouseAmountRecord()
  280. {
  281. CreateDate = DateTime.Now,
  282. UpdateDate = DateTime.Now,
  283. });
  284. db.SaveChanges();
  285. }
  286. AddSysLog("0", "StoreHouseAmountRecord", "Import");
  287. return "success";
  288. }
  289. #endregion
  290. #region 导出Excel
  291. /// <summary>
  292. /// 导出Excel
  293. /// </summary>
  294. /// <returns></returns>
  295. public JsonResult ExportExcel(StoreHouseAmountRecord data, string UserIdRealName, string UserIdMakerCode, string AmountTypeSelect, string OperateTypeSelect)
  296. {
  297. Dictionary<string, string> Fields = new Dictionary<string, string>();
  298. Fields.Add("CreateDate", "3"); //时间
  299. string condition = " and Status>-1";
  300. //创客真实姓名
  301. if (!string.IsNullOrEmpty(UserIdRealName))
  302. {
  303. condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
  304. }
  305. //创客编号
  306. if (!string.IsNullOrEmpty(UserIdMakerCode))
  307. {
  308. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  309. }
  310. //额度类别
  311. if (!string.IsNullOrEmpty(AmountTypeSelect))
  312. {
  313. condition += " and AmountType=" + AmountTypeSelect;
  314. }
  315. //操作类别
  316. if (!string.IsNullOrEmpty(OperateTypeSelect))
  317. {
  318. condition += " and OperateType=" + OperateTypeSelect;
  319. }
  320. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreHouseAmountRecord", Fields, "Id desc", "0", 1, 20000, condition, "UserId,ApplyId,UseAmount,BeforeAmount,AfterAmount,AmountType,OperateType", false);
  321. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  322. foreach (Dictionary<string, object> dic in diclist)
  323. {
  324. //创客
  325. int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
  326. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  327. dic["UserIdRealName"] = userid_Users.RealName;
  328. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  329. dic.Remove("UserId");
  330. //申请单
  331. dic["ApplyId"] = RelationClass.GetStoreMachineApplyInfo(int.Parse(dic["ApplyId"].ToString()));
  332. //额度类别
  333. int AmountType = int.Parse(dic["AmountType"].ToString());
  334. if (AmountType == 0) dic["AmountType"] = "固定额度";
  335. if (AmountType == 1) dic["AmountType"] = "临时额度";
  336. //操作类别
  337. int OperateType = int.Parse(dic["OperateType"].ToString());
  338. if (OperateType == 1) dic["OperateType"] = "增加";
  339. if (OperateType == 2) dic["OperateType"] = "减少";
  340. if (OperateType == 0) dic["OperateType"] = "";
  341. }
  342. Dictionary<string, object> result = new Dictionary<string, object>();
  343. result.Add("Status", "1");
  344. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  345. result.Add("Obj", diclist);
  346. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  347. ReturnFields.Add("UserIdRealName", "创客真实姓名");
  348. ReturnFields.Add("UserIdMakerCode", "创客编号");
  349. ReturnFields.Add("ApplyId", "申请单");
  350. ReturnFields.Add("UseAmount", "使用额度");
  351. ReturnFields.Add("BeforeAmount", "使用前剩余额度");
  352. ReturnFields.Add("AfterAmount", "使用后剩余额度");
  353. ReturnFields.Add("AmountType", "额度类别");
  354. ReturnFields.Add("OperateType", "操作类别");
  355. result.Add("Fields", ReturnFields);
  356. AddSysLog("0", "StoreHouseAmountRecord", "ExportExcel");
  357. return Json(result);
  358. }
  359. #endregion
  360. #region 银行卡临额提现记录列表
  361. /// <summary>
  362. /// 根据条件查询分仓机具额度记录列表
  363. /// </summary>
  364. /// <returns></returns>
  365. public IActionResult Indexs(StoreHouseAmountRecord data, string right)
  366. {
  367. ViewBag.RightInfo = RightInfo;
  368. ViewBag.right = right;
  369. return View();
  370. }
  371. #endregion
  372. #region 银行卡临额提现记录列表
  373. /// <summary>
  374. /// 分仓机具额度记录列表
  375. /// </summary>
  376. /// <returns></returns>
  377. public JsonResult IndexsData(StoreHouseAmountRecord data, string UserIdRealName, string UserIdMakerCode, string CreateDateData, string AmountTypeSelect, string OperateTypeSelect, string ChangeTypeSelect, string PayModeSelect, string StatusSelect = "0", int page = 1, int limit = 30)
  378. {
  379. Dictionary<string, string> Fields = new Dictionary<string, string>();
  380. string condition = " and Status>=-1 and PayMode=1 and Sort=3";
  381. //创客真实姓名
  382. if (!string.IsNullOrEmpty(UserIdRealName))
  383. {
  384. condition += " and UserId in (select UserId from Users where RealName='" + UserIdRealName + "')";
  385. }
  386. //创客编号
  387. if (!string.IsNullOrEmpty(UserIdMakerCode))
  388. {
  389. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  390. }
  391. if (!string.IsNullOrEmpty(CreateDateData))
  392. {
  393. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  394. string start = datelist[0];
  395. string end = datelist[1];
  396. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  397. }
  398. //额度类别
  399. if (!string.IsNullOrEmpty(AmountTypeSelect))
  400. {
  401. condition += " and AmountType=" + AmountTypeSelect;
  402. }
  403. //变动类别
  404. if (!string.IsNullOrEmpty(ChangeTypeSelect))
  405. {
  406. condition += " and Sort=" + ChangeTypeSelect;
  407. }
  408. //操作类别
  409. if (!string.IsNullOrEmpty(OperateTypeSelect))
  410. {
  411. condition += " and OperateType=" + OperateTypeSelect;
  412. }
  413. //支付类别
  414. if (!string.IsNullOrEmpty(PayModeSelect))
  415. {
  416. condition += " and PayMode=" + PayModeSelect;
  417. }
  418. //状态
  419. if (!string.IsNullOrEmpty(StatusSelect))
  420. {
  421. condition += " and Status=" + StatusSelect;
  422. }
  423. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreHouseAmountRecord", Fields, "Id desc", "0", page, limit, condition);
  424. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  425. foreach (Dictionary<string, object> dic in diclist)
  426. {
  427. //创客
  428. int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
  429. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  430. dic["UserIdRealName"] = userid_Users.RealName;
  431. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  432. dic["CertId"] = userid_Users.CertId;
  433. dic["SettleBankCardNo"] = userid_Users.SettleBankCardNo;
  434. dic["SettleBankName"] = userid_Users.SettleBankName;
  435. dic["Mobile"] = userid_Users.Mobile;
  436. dic["Type"] = "临额提现";
  437. dic.Remove("UserId");
  438. //申请单
  439. dic["ApplyId"] = RelationClass.GetStoreMachineApplyInfo(int.Parse(dic["ApplyId"].ToString()));
  440. //额度类别
  441. int AmountType = int.Parse(dic["AmountType"].ToString());
  442. if (AmountType == 0) dic["AmountType"] = "固定额度";
  443. if (AmountType == 1) dic["AmountType"] = "临时额度";
  444. //变动类别
  445. int ChangeType = int.Parse(dic["Sort"].ToString());
  446. if (ChangeType == 1) dic["ChangeType"] = "购买临时额度";
  447. if (ChangeType == 2) dic["ChangeType"] = "增减分仓临时额度";
  448. if (ChangeType == 3) dic["ChangeType"] = "调低额度返回余额";
  449. if (ChangeType == 4) dic["ChangeType"] = "仓库发货|预发机申请";
  450. if (ChangeType == 5) dic["ChangeType"] = "后台仓库调拨";
  451. //操作类别
  452. int OperateType = int.Parse(dic["OperateType"].ToString());
  453. if (OperateType == 1) dic["OperateType"] = "增加";
  454. if (OperateType == 2) dic["OperateType"] = "减少";
  455. if (OperateType == 0) dic["OperateType"] = "";
  456. //额度类别
  457. int PayMode = int.Parse(dic["PayMode"].ToString());
  458. if (PayMode == 1) dic["PayMode"] = "支付宝";
  459. if (PayMode == 3) dic["PayMode"] = "余额";
  460. if (PayMode == 0) dic["PayMode"] = "";
  461. //状态
  462. int Status = int.Parse(dic["Status"].ToString());
  463. if (Status == 0) dic["Status"] = "待处理";
  464. if (Status == 2) dic["Status"] = "处理中";
  465. if (Status == 1) dic["Status"] = "成功";
  466. if (Status == -1) dic["Status"] = "失败";
  467. decimal UseAmount = Convert.ToDecimal(dic["UseAmount"].ToString());
  468. dic["UseAmount"] = UseAmount / 2;
  469. }
  470. return Json(obj);
  471. }
  472. #endregion
  473. #region 银行卡临额提现记录导出Excel
  474. /// <summary>
  475. /// 导出Excel
  476. /// </summary>
  477. /// <returns></returns>
  478. public JsonResult ExportsExcel(StoreHouseAmountRecord data, string UserIdRealName, string UserIdMakerCode, string CreateDateData, string StatusSelect)
  479. {
  480. Dictionary<string, string> Fields = new Dictionary<string, string>();
  481. string condition = " and PayMode=1 and Sort=3";
  482. //创客真实姓名
  483. if (!string.IsNullOrEmpty(UserIdRealName))
  484. {
  485. condition += " and UserId in (select UserId from Users where RealName='" + UserIdRealName + "')";
  486. }
  487. //创客编号
  488. if (!string.IsNullOrEmpty(UserIdMakerCode))
  489. {
  490. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  491. }
  492. if (!string.IsNullOrEmpty(CreateDateData))
  493. {
  494. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  495. string start = datelist[0];
  496. string end = datelist[1];
  497. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  498. }
  499. //状态
  500. if (!string.IsNullOrEmpty(StatusSelect))
  501. {
  502. condition += " and Status=" + StatusSelect;
  503. }
  504. var Ids = "";
  505. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreHouseAmountRecord", Fields, "Id desc", "0", 1, 20000, condition, "Id,CreateDate,UserId,UseAmount", false);
  506. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  507. foreach (Dictionary<string, object> dic in diclist)
  508. {
  509. //创客
  510. int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
  511. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  512. dic["UserIdRealName"] = userid_Users.RealName;
  513. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  514. decimal UseAmount = Convert.ToDecimal(dic["UseAmount"].ToString());
  515. dic["UseAmount"] = UseAmount / 2;
  516. dic["CertId"] = userid_Users.CertId;
  517. dic["SettleBankCardNo"] = userid_Users.SettleBankCardNo;
  518. dic["SettleBankName"] = userid_Users.SettleBankName;
  519. dic["Mobile"] = userid_Users.Mobile;
  520. dic["Type"] = "临额提现";
  521. dic["IsOk"] = "";
  522. dic.Remove("UserId");
  523. //记录Id
  524. int Id = int.Parse(function.CheckInt(dic["Id"].ToString()));
  525. var storeHouseAmountRecord = db.StoreHouseAmountRecord.FirstOrDefault(m => m.Id == Id) ?? new StoreHouseAmountRecord();
  526. if (storeHouseAmountRecord.Status == 0) dic["Status"] = "待处理";
  527. if (storeHouseAmountRecord.Status == 2) dic["Status"] = "处理中";
  528. if (storeHouseAmountRecord.Status == 1) dic["Status"] = "成功";
  529. if (storeHouseAmountRecord.Status == -1) dic["Status"] = "失败";
  530. dic["Id"] = Id;
  531. Ids += Id + ",";
  532. }
  533. Ids = Ids.TrimEnd(',');
  534. Dictionary<string, object> result = new Dictionary<string, object>();
  535. result.Add("Status", "1");
  536. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  537. result.Add("Obj", diclist);
  538. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  539. ReturnFields.Add("Id", "记录ID");
  540. ReturnFields.Add("CreateDate", "提现申请时间");
  541. ReturnFields.Add("Status", "提现结果");
  542. ReturnFields.Add("UserIdRealName", "创客真实姓名");
  543. ReturnFields.Add("UserIdMakerCode", "创客编号");
  544. ReturnFields.Add("UseAmount", "申请提现临额");
  545. ReturnFields.Add("CertId", "身份证号");
  546. ReturnFields.Add("SettleBankCardNo", "银行卡号");
  547. ReturnFields.Add("SettleBankName", "银行名称");
  548. ReturnFields.Add("Mobile", "手机号");
  549. ReturnFields.Add("Type", "交易类型");
  550. ReturnFields.Add("IsOk", "是否成功(是、否)");
  551. result.Add("Fields", ReturnFields);
  552. OtherMySqlConn.op("UPDATE StoreHouseAmountRecord SET `Status`=2 WHERE Id IN(" + Ids + ") AND `Status`=0");
  553. AddSysLog("0", "StoreHouseAmountRecord", "ExportExcel");
  554. return Json(result);
  555. }
  556. #endregion
  557. #region 快捷导出Excel
  558. public IActionResult QuickExportExcel(string right)
  559. {
  560. ViewBag.RightInfo = RightInfo;
  561. ViewBag.right = right;
  562. return View();
  563. }
  564. [HttpPost]
  565. public string QuickExportExcelDo(string UserIdRealName, string UserIdMakerCode, string CreateDateData, string StatusSelect)
  566. {
  567. Dictionary<string, string> Fields = new Dictionary<string, string>();
  568. string condition = " where 1=1 and a.PayMode=1 and a.Sort=3";
  569. //创客真实姓名
  570. if (!string.IsNullOrEmpty(UserIdRealName))
  571. {
  572. condition += " and a.UserId in (select UserId from Users where RealName='" + UserIdRealName + "')";
  573. }
  574. //创客编号
  575. if (!string.IsNullOrEmpty(UserIdMakerCode))
  576. {
  577. condition += " and a.UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  578. }
  579. if (!string.IsNullOrEmpty(CreateDateData))
  580. {
  581. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  582. string start = datelist[0];
  583. string end = datelist[1];
  584. condition += " and a.CreateDate>='" + start + " 00:00:00' and a.CreateDate<='" + end + " 23:59:59'";
  585. }
  586. //状态
  587. if (!string.IsNullOrEmpty(StatusSelect))
  588. {
  589. condition += " and a.Status=" + StatusSelect;
  590. }
  591. var Ids = "";
  592. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreHouseAmountRecord", Fields, "Id desc", "0", 1, 20000000, condition, "", false);
  593. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  594. foreach (Dictionary<string, object> dic in diclist)
  595. {
  596. //记录Id
  597. int Id = int.Parse(function.CheckInt(dic["Id"].ToString()));
  598. Ids += Id + ",";
  599. }
  600. Ids = Ids.TrimEnd(',');
  601. var Sql = "SELECT a.Id '记录ID',DATE_FORMAT(a.CreateDate,'%Y-%m-%d %H:%i:%s') '提现申请时间',(CASE WHEN a.Status=0 THEN '待处理' WHEN a.Status=2 THEN '处理中' WHEN a.Status=1 THEN '成功' WHEN a.Status=-1 THEN '失败' ELSE '' end) '提现结果',b.RealName '创客真实姓名',b.MakerCode '创客编号',FORMAT(a.UseAmount/2,2) '申请提现临额',b.CertId '身份证号',b.SettleBankCardNo '银行卡号',b.SettleBankName '银行名称',b.Mobile '手机号',(CASE WHEN a.AmountType=1 THEN '临额提现' ELSE '' end) '交易类型',null '是否成功(是、否)' FROM StoreHouseAmountRecord a LEFT JOIN Users b ON a.UserId=b.Id" + condition + "";
  602. var sysAdmin = bsdb.SysAdmin.FirstOrDefault(m => m.AdminName == SysUserName && m.Status > -1);
  603. var FileName = "分仓临额提现记录" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  604. string SendData = "{\"Operater\":\"" + sysAdmin.Id + "\",\"SqlString\":\"" + Sql + "\",\"FileName\":\"" + FileName + "\",\"MaxCount\":\"0\"}";
  605. RedisDbconn.Instance.AddList("ExportQueue", SendData);
  606. OtherMySqlConn.op("UPDATE StoreHouseAmountRecord SET `Status`=2 WHERE Id IN(" + Ids + ") AND `Status`=0");
  607. AddSysLog(Ids, "StoreHouseAmountRecord", "QuickExportExcel");
  608. return "success";
  609. }
  610. #endregion
  611. #region
  612. /// <summary>
  613. /// 开启
  614. /// </summary>
  615. /// <returns></returns>
  616. public string BatchSetting(string Id)
  617. {
  618. string[] idlist = Id.Split(new char[] { ',' });
  619. AddSysLog(Id, "StoreHouseCardAmountRecord", "BatchSetting");
  620. foreach (string subid in idlist)
  621. {
  622. int id = int.Parse(subid);
  623. Dictionary<string, object> Fields = new Dictionary<string, object>();
  624. Fields.Add("Status", -1);
  625. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouseAmountRecord", Fields, id);
  626. }
  627. db.SaveChanges();
  628. return "success";
  629. }
  630. #endregion
  631. #region 银行卡临额提现记录结果导入Excel
  632. /// <summary>
  633. /// 银行卡临额提现记录结果导入Excel
  634. /// </summary>
  635. /// <param name="ExcelData"></param>
  636. public string Imports(string ExcelData)
  637. {
  638. ExcelData = HttpUtility.UrlDecode(ExcelData);
  639. JsonData list = JsonMapper.ToObject(ExcelData);
  640. string error = "";
  641. List<int> IdList = new List<int>();
  642. List<int> IdLists = new List<int>();
  643. for (int i = 1; i < list.Count; i++)
  644. {
  645. JsonData dr = list[i];
  646. string itemJson = dr.ToJson();
  647. string Id = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
  648. string IsOk = itemJson.Contains("\"L\"") ? dr["L"].ToString() : "";
  649. if (IdList.Contains(Convert.ToInt32(Id)))
  650. {
  651. error += "以下操作失败" + Id + ',' + "该记录重复" + '\n';
  652. }
  653. else if (IsOk == "否")
  654. {
  655. IdLists.Add(Convert.ToInt32(Id));
  656. }
  657. else
  658. {
  659. IdList.Add(Convert.ToInt32(Id));
  660. }
  661. }
  662. if (!string.IsNullOrEmpty(error))
  663. {
  664. return "Warning|" + error;
  665. }
  666. else
  667. {
  668. var Info = db.StoreHouseAmountRecord.Where(m => IdList.Contains(m.Id) && m.Status == 2).ToList();//成功
  669. var Infos = db.StoreHouseAmountRecord.Where(m => IdLists.Contains(m.Id) && m.Status == 2).ToList();//失败
  670. foreach (var item in Info)
  671. {
  672. item.Status = 1;//设置为成功
  673. db.SaveChanges();
  674. }
  675. foreach (var items in Infos)
  676. {
  677. items.Status = -1;//设置为失败
  678. var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == items.UserId) ?? new UserAccount();
  679. if (userAccount.Id > 0)
  680. {
  681. userAccount.TempAmount += items.UseAmount;//退还卡充值临额
  682. userAccount.ValidAmount += items.UseAmount;//退还可用额度
  683. }
  684. db.SaveChanges();
  685. }
  686. }
  687. AddSysLog("0", "StoreHouseCardAmountRecord", "Import");
  688. return "success";
  689. }
  690. #endregion
  691. }
  692. }