PublicFunction.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Data;
  5. using System.Text.RegularExpressions;
  6. using MySystem.Models;
  7. using Library;
  8. using NPOI.SS.UserModel;
  9. using NPOI.XSSF.UserModel;
  10. using System.IO;
  11. namespace MySystem
  12. {
  13. public class PublicFunction
  14. {
  15. public WebCMSEntities db = new WebCMSEntities();
  16. public BsModels.WebCMSEntities bsdb = new BsModels.WebCMSEntities();
  17. public OpModels.WebCMSEntities opdb = new OpModels.WebCMSEntities();
  18. #region 获取权限JSON数据
  19. public string GetRightJson()
  20. {
  21. string result = "[";
  22. List<BsModels.RightDic> list = bsdb.RightDic.ToList();
  23. List<BsModels.RightDic> Level1 = list.Where(m => m.RightLevel == 1).ToList();
  24. foreach (BsModels.RightDic sub1 in Level1)
  25. {
  26. result += "{title: '" + sub1.Name + "', id: '" + sub1.Id + "', spread: false, children: [";
  27. List<BsModels.RightDic> Level2 = list.Where(m => m.RightLevel == 2 && m.Id.StartsWith(sub1.Id)).ToList();
  28. if (Level2.Count > 0)
  29. {
  30. foreach (BsModels.RightDic sub2 in Level2)
  31. {
  32. result += "{title: '" + sub2.Name + "', id: '" + sub2.Id + "', spread: false, children: [";
  33. List<BsModels.RightDic> Level3 = list.Where(m => m.RightLevel == 3 && m.Id.StartsWith(sub2.Id)).ToList();
  34. if (Level3.Count > 0)
  35. {
  36. foreach (BsModels.RightDic sub3 in Level3)
  37. {
  38. result += "{title: '" + sub3.Name + "', id: '" + sub3.Id + "', spread: false, children: [";
  39. string rightString = ForOperateRight(sub3.Id);
  40. if (!string.IsNullOrEmpty(rightString))
  41. {
  42. result += rightString;
  43. }
  44. else
  45. {
  46. result += "{title: '基本权限', id: '" + sub3.Id + "_base'}";
  47. }
  48. result += "]},";
  49. }
  50. result = result.TrimEnd(',');
  51. }
  52. else
  53. {
  54. string rightString = ForOperateRight(sub2.Id);
  55. if (!string.IsNullOrEmpty(rightString))
  56. {
  57. result += rightString;
  58. }
  59. else
  60. {
  61. result += "{title: '基本权限', id: '" + sub2.Id + "_base'}";
  62. }
  63. }
  64. result += "]},";
  65. }
  66. result = result.TrimEnd(',');
  67. }
  68. else
  69. {
  70. result += ForOperateRight(sub1.Id);
  71. string rightString = ForOperateRight(sub1.Id);
  72. if (!string.IsNullOrEmpty(rightString))
  73. {
  74. result += rightString;
  75. }
  76. else
  77. {
  78. result += "{title: '基本权限', id: '" + sub1.Id + "_base'}";
  79. }
  80. }
  81. result += "]},";
  82. }
  83. result = result.TrimEnd(',');
  84. result += "]";
  85. return result;
  86. }
  87. //读取当前菜单有哪些权限
  88. public string ForOperateRight(string Id)
  89. {
  90. string result = "";
  91. List<BsModels.MenuRight> rights = bsdb.MenuRight.Where(m => m.MenuId.StartsWith(Id)).OrderBy(m => m.MenuId).ToList();
  92. foreach (BsModels.MenuRight right in rights)
  93. {
  94. result += "{title: '" + right.Name + "', id: '" + right.MenuId + "'},";
  95. }
  96. BsModels.RightDic rightDic = bsdb.RightDic.FirstOrDefault(m => m.Id == Id) ?? new BsModels.RightDic();
  97. if (!string.IsNullOrEmpty(rightDic.OtherRight))
  98. {
  99. string[] OtherRightList = rightDic.OtherRight.Split('\n');
  100. foreach (string SubOtherRight in OtherRightList)
  101. {
  102. string[] SubOtherRightData = SubOtherRight.Split('_');
  103. result += "{title: '" + SubOtherRightData[1] + "', id: '" + Id + "_" + SubOtherRightData[0] + "'},";
  104. }
  105. }
  106. result = result.TrimEnd(',');
  107. return result;
  108. }
  109. public string GetRightJsonNew()
  110. {
  111. string result = "[";
  112. List<BsModels.RightDicNew> list = bsdb.RightDicNew.ToList();
  113. List<BsModels.RightDicNew> Level1 = list.Where(m => m.RightLevel == 1).ToList();
  114. foreach (BsModels.RightDicNew sub1 in Level1)
  115. {
  116. result += "{title: '" + sub1.Name + "', id: '" + sub1.Id + "', spread: false, children: [";
  117. List<BsModels.RightDicNew> Level2 = list.Where(m => m.RightLevel == 2 && m.Id.StartsWith(sub1.Id)).ToList();
  118. if (Level2.Count > 0)
  119. {
  120. foreach (BsModels.RightDicNew sub2 in Level2)
  121. {
  122. result += "{title: '" + sub2.Name + "', id: '" + sub2.Id + "', spread: false, children: [";
  123. List<BsModels.RightDicNew> Level3 = list.Where(m => m.RightLevel == 3 && m.Id.StartsWith(sub2.Id)).ToList();
  124. if (Level3.Count > 0)
  125. {
  126. foreach (BsModels.RightDicNew sub3 in Level3)
  127. {
  128. result += "{title: '" + sub3.Name + "', id: '" + sub3.Id + "', spread: false, children: [";
  129. string rightString = ForOperateRight(sub3.Id);
  130. if (!string.IsNullOrEmpty(rightString))
  131. {
  132. result += rightString;
  133. }
  134. else
  135. {
  136. result += "{title: '基本权限', id: '" + sub3.Id + "_base'}";
  137. }
  138. result += "]},";
  139. }
  140. result = result.TrimEnd(',');
  141. }
  142. else
  143. {
  144. string rightString = ForOperateRightNew(sub2.Id);
  145. if (!string.IsNullOrEmpty(rightString))
  146. {
  147. result += rightString;
  148. }
  149. else
  150. {
  151. result += "{title: '基本权限', id: '" + sub2.Id + "_base'}";
  152. }
  153. }
  154. result += "]},";
  155. }
  156. result = result.TrimEnd(',');
  157. }
  158. else
  159. {
  160. result += ForOperateRightNew(sub1.Id);
  161. string rightString = ForOperateRightNew(sub1.Id);
  162. if (!string.IsNullOrEmpty(rightString))
  163. {
  164. result += rightString;
  165. }
  166. else
  167. {
  168. result += "{title: '基本权限', id: '" + sub1.Id + "_base'}";
  169. }
  170. }
  171. result += "]},";
  172. }
  173. result = result.TrimEnd(',');
  174. result += "]";
  175. return result;
  176. }
  177. //读取当前菜单有哪些权限
  178. public string ForOperateRightNew(string Id)
  179. {
  180. string result = "";
  181. List<BsModels.MenuRightNew> rights = bsdb.MenuRightNew.Where(m => m.MenuId.StartsWith(Id)).OrderBy(m => m.MenuId).ToList();
  182. foreach (BsModels.MenuRightNew right in rights)
  183. {
  184. result += "{title: '" + right.Name + "', id: '" + right.MenuId + "'},";
  185. }
  186. BsModels.RightDicNew rightDic = bsdb.RightDicNew.FirstOrDefault(m => m.Id == Id) ?? new BsModels.RightDicNew();
  187. if (!string.IsNullOrEmpty(rightDic.OtherRight))
  188. {
  189. string[] OtherRightList = rightDic.OtherRight.Split('\n');
  190. foreach (string SubOtherRight in OtherRightList)
  191. {
  192. string[] SubOtherRightData = SubOtherRight.Split('_');
  193. result += "{title: '" + SubOtherRightData[1] + "', id: '" + Id + "_" + SubOtherRightData[0] + "'},";
  194. }
  195. }
  196. result = result.TrimEnd(',');
  197. return result;
  198. }
  199. public string TranslateRightString(string RightString)
  200. {
  201. string result = "";
  202. if (!string.IsNullOrEmpty(RightString))
  203. {
  204. string[] RightList = RightString.Split(',');
  205. foreach (string sub in RightList)
  206. {
  207. string EndString = sub.Substring(sub.LastIndexOf("_") + 1);
  208. if (EndString.Length > 1 && !function.IsInt(EndString))
  209. {
  210. result += sub + ",";
  211. }
  212. }
  213. }
  214. return result.TrimEnd(',');
  215. }
  216. #endregion
  217. #region 中译英
  218. public string TranslateZHToEn(string Source)
  219. {
  220. string result = function.GetWebRequest("http://fanyi.youdao.com/translate?&doctype=json&type=ZH_CN2EN&i=" + Source);
  221. //{"type":"ZH_CN2EN","errorCode":0,"elapsedTime":2,"translateResult":[[{"src":"大事件","tgt":"The big event"}]]}
  222. Match match = Regex.Match(result, "\"tgt\":\".*?\"");
  223. if (match.Success)
  224. {
  225. return match.Value.Replace("\"tgt\":", "").Trim('"');
  226. }
  227. return "";
  228. }
  229. #endregion
  230. #region 解析编辑器里的视频代码
  231. public string CheckMediaFromHtml(string content)
  232. {
  233. if (string.IsNullOrEmpty(content))
  234. {
  235. return "";
  236. }
  237. string result = content;
  238. MatchCollection mc = Regex.Matches(content, "<embed.*?/>");
  239. foreach (Match submc in mc)
  240. {
  241. string info = submc.Value;
  242. Match match = Regex.Match(info, "src=\".*?\"");
  243. if (match.Success)
  244. {
  245. string path = match.Value;
  246. path = path.Replace("src=\"", "");
  247. path = path.TrimEnd(new char[] { '"' });
  248. string html = "";
  249. string width = "600";
  250. string height = "300";
  251. Match width_match = Regex.Match(info, "width=\".*?\"");
  252. if (width_match.Success)
  253. {
  254. width = width_match.Value.Replace("width=", "").Trim('"');
  255. }
  256. Match height_match = Regex.Match(info, "height=\".*?\"");
  257. if (height_match.Success)
  258. {
  259. height = height_match.Value.Replace("height=", "").Trim('"');
  260. }
  261. if (path.EndsWith(".mp4"))
  262. {
  263. if (string.IsNullOrEmpty(html))
  264. {
  265. html = "<video controls=\"controls\" autoplay=\"autoplay\" poster=\"\" onplay=\"true\" width=\"" + width + "\" height=\"" + height + "\" onclick=\"this.play();\">" +
  266. "<source src=\"" + path + "\">" +
  267. "<source src=\"" + path + "\" type=\"video/mp4\">" +
  268. "<source src=\"" + path + "\" type=\"video/webm\">" +
  269. "<source src=\"" + path + "\" type=\"video/ogg\">" +
  270. "</video>";
  271. }
  272. }
  273. else if (path.EndsWith(".mp3"))
  274. {
  275. html = "<audio controls=\"controls\" width=\"" + width + "\" height=\"" + height + "\" onclick=\"this.play();\">" +
  276. "<source src=\"" + path + "\" type=\"audio/mp3\" />" +
  277. "<embed src=\"" + path + "\" height=\"100\" width=\"100\" />" +
  278. "</audio>";
  279. }
  280. result = result.Replace(info, html);
  281. }
  282. }
  283. return result;
  284. }
  285. #endregion
  286. #region 对象转Json字符串
  287. public static string ObjectToJsonString(object obj)
  288. {
  289. return Newtonsoft.Json.JsonConvert.SerializeObject(obj);
  290. }
  291. #endregion
  292. #region Json字符串转对象
  293. public static T DeserializeJSON<T>(string json)
  294. {
  295. return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(json);
  296. }
  297. #endregion
  298. #region 删除文件
  299. public static bool DeleteFile(string VirtualPath)
  300. {
  301. string FilePath = function.getPath(VirtualPath);
  302. if (System.IO.File.Exists(FilePath))
  303. {
  304. System.IO.File.Delete(FilePath);
  305. return true;
  306. }
  307. return false;
  308. }
  309. #endregion
  310. #region 两点距离
  311. public static double GetDistanceNumber(string start, string end)
  312. {
  313. if (!string.IsNullOrEmpty(start) && !string.IsNullOrEmpty(end))
  314. {
  315. string[] startpos = start.Split(',');
  316. string[] endpos = end.Split(',');
  317. double lng1 = double.Parse(startpos[0]);
  318. double lat1 = double.Parse(startpos[1]);
  319. double lng2 = double.Parse(endpos[0]);
  320. double lat2 = double.Parse(endpos[1]);
  321. double radLat1 = rad(lat1);
  322. double radLat2 = rad(lat2);
  323. double a = radLat1 - radLat2;
  324. double b = rad(lng1) - rad(lng2);
  325. double s = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a / 2), 2) + Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin(b / 2), 2)));
  326. s = s * EARTH_RADIUS;
  327. s = Math.Round(s * 10000) / 10000;
  328. return s;
  329. }
  330. return 10000000;
  331. }
  332. private static double rad(double d)
  333. {
  334. return d * Math.PI / 180.0;
  335. }
  336. private static double EARTH_RADIUS = 6378.137;
  337. #endregion
  338. #region 短信条数
  339. public int SMSCount()
  340. {
  341. SystemSet check = db.SystemSet.FirstOrDefault() ?? new SystemSet();
  342. return check.QueryCount;
  343. }
  344. #endregion
  345. #region 短信消耗
  346. public void UseSMS()
  347. {
  348. SystemSet check = db.SystemSet.FirstOrDefault();
  349. if (check != null)
  350. {
  351. check.QueryCount -= 1;
  352. db.SaveChanges();
  353. }
  354. }
  355. #endregion
  356. #region 获取OSS开关
  357. public string GetOssStatus()
  358. {
  359. SystemSet set = db.SystemSet.FirstOrDefault() ?? new SystemSet();
  360. return set.UploadOss == 1 ? "-oss" : "";
  361. }
  362. #endregion
  363. #region 获取上传文件参数
  364. public string GetUploadParam(string buttonId)
  365. {
  366. string tag = function.MD5_16(buttonId);
  367. string param = RedisDbconn.Instance.Get<string>("btn:" + tag);
  368. if (!string.IsNullOrEmpty(param))
  369. {
  370. return param;
  371. }
  372. SystemSet set = db.SystemSet.FirstOrDefault() ?? new SystemSet();
  373. return "{width:" + set.UploadAutoZoomWidth + ",height:" + set.UploadAutoZoomHeight + ",quality:" + set.UploadAutoZoomQuality + "},{max_file_size:" + set.UploadMaxSize + "}";
  374. }
  375. #endregion
  376. #region 获取上传文件提示文字
  377. public string GetUploadHint(string buttonId, bool ispic = true)
  378. {
  379. string tag = function.MD5_16(buttonId);
  380. string param = RedisDbconn.Instance.Get<string>("btn:" + tag);
  381. if (string.IsNullOrEmpty(param))
  382. {
  383. SystemSet set = db.SystemSet.FirstOrDefault() ?? new SystemSet();
  384. param = "{width:" + set.UploadAutoZoomWidth + ",height:" + set.UploadAutoZoomHeight + ",quality:" + set.UploadAutoZoomQuality + "},{max_file_size:" + set.UploadMaxSize + "}";
  385. }
  386. string[] json = param.Replace(" ", "").Replace("},{", "}#cut#{").Split(new string[] { "#cut#" }, StringSplitOptions.None);
  387. Dictionary<string, string> resize = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(json[0]);
  388. Dictionary<string, string> size = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(json[1]);
  389. int max_file_size = int.Parse(size["max_file_size"]) / 1024;
  390. string unit = "KB";
  391. if (max_file_size / 1024 > 0)
  392. {
  393. max_file_size = max_file_size / 1024;
  394. unit = "MB";
  395. }
  396. if (max_file_size / 1024 > 0)
  397. {
  398. max_file_size = max_file_size / 1024;
  399. unit = "GB";
  400. }
  401. if (ispic)
  402. {
  403. return "建议尺寸" + resize["width"] + "x" + resize["height"] + "," + max_file_size + unit + "以内";
  404. }
  405. return "建议" + max_file_size + "以内";
  406. }
  407. #endregion
  408. #region 通过表名、文本、值获得字典数据
  409. public Dictionary<string, string> GetDictionaryByTableName(string tableEnName, string Text, string Value)
  410. {
  411. Text = Text.Split('_')[0];
  412. Value = Value.Split('_')[0];
  413. Dictionary<string, string> dic = new Dictionary<string, string>();
  414. DataTable dt = dbconn.dtable("select " + Text + "," + Value + " from " + tableEnName + " order by Sort desc,Id asc");
  415. foreach (DataRow dr in dt.Rows)
  416. {
  417. dic.Add(dr[1].ToString(), dr[0].ToString());
  418. }
  419. return dic;
  420. }
  421. #endregion
  422. #region 获取Excel文件内容
  423. public DataTable ExcelToDataTable(string filepath)
  424. {
  425. List<string> result = new List<string>();
  426. DataTable dtTable = new DataTable();
  427. List<string> rowList = new List<string>();
  428. try
  429. {
  430. ISheet sheet;
  431. using (var stream = new FileStream(filepath, FileMode.Open))
  432. {
  433. stream.Position = 0;
  434. XSSFWorkbook xssWorkbook = new XSSFWorkbook(stream);
  435. sheet = xssWorkbook.GetSheetAt(0);
  436. IRow headerRow = sheet.GetRow(0);
  437. int cellCount = headerRow.LastCellNum;
  438. for (int j = 0; j < cellCount; j++)
  439. {
  440. ICell cell = headerRow.GetCell(j);
  441. if (cell == null || string.IsNullOrWhiteSpace(cell.ToString())) continue;
  442. {
  443. dtTable.Columns.Add(cell.ToString());
  444. }
  445. }
  446. for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
  447. {
  448. IRow row = sheet.GetRow(i);
  449. if (row == null) continue;
  450. if (row.Cells.All(d => d.CellType == CellType.Blank)) continue;
  451. for (int j = row.FirstCellNum; j < cellCount; j++)
  452. {
  453. string cellVal = "";
  454. if (row.GetCell(j) != null)
  455. {
  456. cellVal = row.GetCell(j).ToString();
  457. }
  458. rowList.Add(cellVal);
  459. }
  460. if (rowList.Count > 0)
  461. dtTable.Rows.Add(rowList.ToArray());
  462. rowList.Clear();
  463. }
  464. }
  465. }
  466. catch (Exception ex)
  467. {
  468. function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "获取Excel文件内容异常");
  469. }
  470. return dtTable;
  471. }
  472. #endregion
  473. #region 重置创客机具数量
  474. public static void SycnMachineCount(int Id = 0, int BrandId = 0)
  475. {
  476. RedisDbconn.Instance.AddList("SycnUserMachineCountQueue", "{\"UserId\":\"" + Id + "\",\"BrandId\":\"" + BrandId + "\"}");
  477. }
  478. #endregion
  479. #region 统计机具绑定数据
  480. public static void StatUserMachineData(int UserId, int BrandId, int Count)
  481. {
  482. using (WebCMSEntities db = new WebCMSEntities())
  483. {
  484. string IdBrand = UserId + "_" + BrandId;
  485. UserMachineData MachineData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
  486. if (MachineData == null)
  487. {
  488. MachineData = db.UserMachineData.Add(new UserMachineData()
  489. {
  490. IdBrand = IdBrand,
  491. }).Entity;
  492. db.SaveChanges();
  493. }
  494. if (Count < 0)
  495. {
  496. MachineData.TotalMachineCount -= Math.Abs(Count);
  497. MachineData.UnBindCount -= Math.Abs(Count);
  498. }
  499. else
  500. {
  501. MachineData.TotalMachineCount += Count;
  502. MachineData.UnBindCount += Count;
  503. }
  504. db.SaveChanges();
  505. }
  506. }
  507. #endregion
  508. #region 退回仓库,清除历史记录
  509. public static void ClearPosHistory(WebCMSEntities db, string PosSn)
  510. {
  511. PreSendStockDetail prepos = db.PreSendStockDetail.FirstOrDefault(m => m.SnNo == PosSn && m.Status == 1);
  512. if (prepos != null)
  513. {
  514. prepos.Status = -1;
  515. prepos.ApplyFlag = 0;
  516. SmallStoreHouse sstore = db.SmallStoreHouse.FirstOrDefault(m => m.UserId == prepos.ToUserId);
  517. if (sstore != null)
  518. {
  519. sstore.LaveNum += 1;
  520. sstore.TotalNum -= 1;
  521. }
  522. StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.UserId == prepos.FromStoreId);
  523. if (store != null)
  524. {
  525. store.LaveNum += 1;
  526. }
  527. }
  528. MachineApply apply = db.MachineApply.FirstOrDefault(m => m.SwapSnExpand.Contains(PosSn));
  529. if (apply != null)
  530. {
  531. apply.SwapSnExpand = apply.SwapSnExpand.Replace(PosSn, PosSn.Substring(0, 3) + "d" + PosSn.Substring(4));
  532. }
  533. }
  534. #endregion
  535. #region 测试创客Id
  536. public static int[] testids = { };
  537. #endregion
  538. #region 数据库结构
  539. public static Dictionary<string, Dictionary<string, string>> MainTables = new Dictionary<string, Dictionary<string, string>>();
  540. public static Dictionary<string, Dictionary<string, string>> CashTables = new Dictionary<string, Dictionary<string, string>>();
  541. public static Dictionary<string, Dictionary<string, string>> BsTables = new Dictionary<string, Dictionary<string, string>>();
  542. public static Dictionary<string, Dictionary<string, string>> JobTables = new Dictionary<string, Dictionary<string, string>>();
  543. public static Dictionary<string, Dictionary<string, string>> SpTables = new Dictionary<string, Dictionary<string, string>>();
  544. public static Dictionary<string, Dictionary<string, string>> OpTables = new Dictionary<string, Dictionary<string, string>>();//运营中心数据模型
  545. #endregion
  546. #region 发送分表数据
  547. public static void SplitTradeRecord(TradeRecord obj, string TradeMonth = "")
  548. {
  549. if (string.IsNullOrEmpty(TradeMonth))
  550. {
  551. TradeMonth = DateTime.Now.ToString("yyyyMM");
  552. }
  553. RedisDbconn.Instance.AddList("AddTradeRecordQueue", Newtonsoft.Json.JsonConvert.SerializeObject(obj) + "#cut#" + TradeMonth);
  554. }
  555. public static void SplitUserAccountRecord(UserAccountRecord obj, string TradeMonth = "")
  556. {
  557. if (string.IsNullOrEmpty(TradeMonth))
  558. {
  559. TradeMonth = DateTime.Now.ToString("yyyyMM");
  560. }
  561. RedisDbconn.Instance.AddList("AddUserAccountRecordQueue", Newtonsoft.Json.JsonConvert.SerializeObject(obj) + "#cut#" + TradeMonth);
  562. }
  563. #endregion
  564. #region 设置押金添加记录公共方法
  565. public static void MerchantDepositSet(int BrandId, int UserId, int SnId, string SnNo, int BeforeDeposit, decimal DepositAmount, string ReturnNote)
  566. {
  567. try
  568. {
  569. WebCMSEntities maindb = new WebCMSEntities();
  570. MerchantDepositSet query = maindb.MerchantDepositSet.Add(new MerchantDepositSet()
  571. {
  572. CreateDate = DateTime.Now, //创建时间
  573. Sort = BrandId,//品牌
  574. SeoTitle = BeforeDeposit.ToString(),//变更前押金
  575. DepositAmount = DepositAmount,//押金
  576. ReturnNote = ReturnNote,//返回信息
  577. SnNo = SnNo,//机具Sn
  578. UserId = UserId,//创客Id
  579. }).Entity;
  580. maindb.SaveChanges();
  581. }
  582. catch (Exception ex)
  583. {
  584. function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + ex.ToString(), "设置押金队列异常");
  585. }
  586. }
  587. #endregion
  588. }
  589. }