StoreHouseAmountRecordController.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  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 Users 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. decimal UseAmount = Convert.ToDecimal(dic["UseAmount"].ToString());
  460. dic["UseAmount"] = UseAmount / 2;
  461. }
  462. return Json(obj);
  463. }
  464. #endregion
  465. #region 银行卡临额提现记录导出Excel
  466. /// <summary>
  467. /// 导出Excel
  468. /// </summary>
  469. /// <returns></returns>
  470. public JsonResult ExportsExcel(StoreHouseAmountRecord data, string UserIdRealName, string UserIdMakerCode, string CreateDateData, string StatusSelect)
  471. {
  472. Dictionary<string, string> Fields = new Dictionary<string, string>();
  473. string condition = " and PayMode=1 and Sort=3";
  474. //创客真实姓名
  475. if (!string.IsNullOrEmpty(UserIdRealName))
  476. {
  477. condition += " and UserId in (select UserId from Users where RealName='" + UserIdRealName + "')";
  478. }
  479. //创客编号
  480. if (!string.IsNullOrEmpty(UserIdMakerCode))
  481. {
  482. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  483. }
  484. if (!string.IsNullOrEmpty(CreateDateData))
  485. {
  486. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  487. string start = datelist[0];
  488. string end = datelist[1];
  489. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  490. }
  491. //状态
  492. if (!string.IsNullOrEmpty(StatusSelect))
  493. {
  494. condition += " and Status=" + StatusSelect;
  495. }
  496. var Ids = "";
  497. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreHouseAmountRecord", Fields, "Id desc", "0", 1, 20000, condition, "Id,CreateDate,UserId,UseAmount", false);
  498. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  499. foreach (Dictionary<string, object> dic in diclist)
  500. {
  501. //创客
  502. int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
  503. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  504. dic["UserIdRealName"] = userid_Users.RealName;
  505. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  506. decimal UseAmount = Convert.ToDecimal(dic["UseAmount"].ToString());
  507. dic["UseAmount"] = UseAmount / 2;
  508. dic["CertId"] = userid_Users.CertId;
  509. dic["SettleBankCardNo"] = userid_Users.SettleBankCardNo;
  510. dic["SettleBankName"] = userid_Users.SettleBankName;
  511. dic["Mobile"] = userid_Users.Mobile;
  512. dic["Type"] = "临额提现";
  513. dic["IsOk"] = "";
  514. dic.Remove("UserId");
  515. //记录Id
  516. int Id = int.Parse(function.CheckInt(dic["Id"].ToString()));
  517. var storeHouseAmountRecord = db.StoreHouseAmountRecord.FirstOrDefault(m => m.Id == Id) ?? new StoreHouseAmountRecord();
  518. if (storeHouseAmountRecord.Status == 0) dic["Status"] = "待处理";
  519. if (storeHouseAmountRecord.Status == 2) dic["Status"] = "处理中";
  520. if (storeHouseAmountRecord.Status == 1) dic["Status"] = "成功";
  521. if (storeHouseAmountRecord.Status == -1) dic["Status"] = "失败";
  522. dic["Id"] = Id;
  523. Ids += Id + ",";
  524. }
  525. Ids = Ids.TrimEnd(',');
  526. Dictionary<string, object> result = new Dictionary<string, object>();
  527. result.Add("Status", "1");
  528. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  529. result.Add("Obj", diclist);
  530. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  531. ReturnFields.Add("Id", "记录ID");
  532. ReturnFields.Add("CreateDate", "提现申请时间");
  533. ReturnFields.Add("Status", "提现结果");
  534. ReturnFields.Add("UserIdRealName", "创客真实姓名");
  535. ReturnFields.Add("UserIdMakerCode", "创客编号");
  536. ReturnFields.Add("UseAmount", "申请提现临额");
  537. ReturnFields.Add("CertId", "身份证号");
  538. ReturnFields.Add("SettleBankCardNo", "银行卡号");
  539. ReturnFields.Add("SettleBankName", "银行名称");
  540. ReturnFields.Add("Mobile", "手机号");
  541. ReturnFields.Add("Type", "交易类型");
  542. ReturnFields.Add("IsOk", "是否成功(是、否)");
  543. result.Add("Fields", ReturnFields);
  544. OtherMySqlConn.op("UPDATE StoreHouseAmountRecord SET `Status`=2 WHERE Id IN(" + Ids + ") AND `Status`=0");
  545. AddSysLog("0", "StoreHouseAmountRecord", "ExportExcel");
  546. return Json(result);
  547. }
  548. #endregion
  549. #region
  550. /// <summary>
  551. /// 开启
  552. /// </summary>
  553. /// <returns></returns>
  554. public string BatchSetting(string Id)
  555. {
  556. string[] idlist = Id.Split(new char[] { ',' });
  557. AddSysLog(Id, "StoreHouseCardAmountRecord", "BatchSetting");
  558. foreach (string subid in idlist)
  559. {
  560. int id = int.Parse(subid);
  561. Dictionary<string, object> Fields = new Dictionary<string, object>();
  562. Fields.Add("Status", -1);
  563. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouseAmountRecord", Fields, id);
  564. }
  565. db.SaveChanges();
  566. return "success";
  567. }
  568. #endregion
  569. #region 银行卡临额提现记录结果导入Excel
  570. /// <summary>
  571. /// 银行卡临额提现记录结果导入Excel
  572. /// </summary>
  573. /// <param name="ExcelData"></param>
  574. public string Imports(string ExcelData)
  575. {
  576. ExcelData = HttpUtility.UrlDecode(ExcelData);
  577. JsonData list = JsonMapper.ToObject(ExcelData);
  578. string error = "";
  579. List<int> IdList = new List<int>();
  580. List<int> IdLists = new List<int>();
  581. for (int i = 1; i < list.Count; i++)
  582. {
  583. JsonData dr = list[i];
  584. string itemJson = dr.ToJson();
  585. string Id = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
  586. string IsOk = itemJson.Contains("\"J\"") ? dr["J"].ToString() : "";
  587. if (IdList.Contains(Convert.ToInt32(Id)))
  588. {
  589. error += "以下操作失败" + Id + ',' + "该记录重复" + '\n';
  590. }
  591. else if (IsOk == "否")
  592. {
  593. IdLists.Add(Convert.ToInt32(Id));
  594. }
  595. else
  596. {
  597. IdList.Add(Convert.ToInt32(Id));
  598. }
  599. }
  600. if (!string.IsNullOrEmpty(error))
  601. {
  602. return "Warning|" + error;
  603. }
  604. else
  605. {
  606. var Info = db.StoreHouseAmountRecord.Where(m => IdList.Contains(m.Id)).ToList();//成功
  607. var Infos = db.StoreHouseAmountRecord.Where(m => IdLists.Contains(m.Id)).ToList();//失败
  608. foreach (var item in Info)
  609. {
  610. item.Status = 1;//设置为成功
  611. db.SaveChanges();
  612. }
  613. foreach (var items in Infos)
  614. {
  615. items.Status = -1;//设置为失败
  616. var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == items.UserId) ?? new UserAccount();
  617. if (userAccount.Id > 0)
  618. {
  619. userAccount.TempAmount += items.UseAmount;//退还卡充值临额
  620. userAccount.ValidAmount += items.UseAmount;//退还可用额度
  621. }
  622. db.SaveChanges();
  623. }
  624. }
  625. AddSysLog("0", "StoreHouseCardAmountRecord", "Import");
  626. return "success";
  627. }
  628. #endregion
  629. }
  630. }