StoreHouseAmountRecordController.cs 29 KB

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