PosFeeHelper.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using Library;
  6. using MySystem.JavaProductModels;
  7. namespace MySystem
  8. {
  9. public class PosFeeHelper
  10. {
  11. public readonly static PosFeeHelper Instance = new PosFeeHelper();
  12. private PosFeeHelper()
  13. { }
  14. public void Start()
  15. {
  16. Thread th = new Thread(DoWorks);
  17. th.IsBackground = true;
  18. th.Start();
  19. }
  20. private void DoWorks()
  21. {
  22. // while (true)
  23. // {
  24. // try
  25. // {
  26. // InitPosList();
  27. // int timespan = 1000 * 60 * 60 * 2;
  28. // Thread.Sleep(timespan);
  29. // }
  30. // catch (Exception ex)
  31. // {
  32. // Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "初始化机具名单异常");
  33. // }
  34. // }
  35. try
  36. {
  37. InitPosList();
  38. }
  39. catch (Exception ex)
  40. {
  41. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "初始化机具名单异常");
  42. }
  43. }
  44. #region 初始化机具名单
  45. public void InitPosList()
  46. {
  47. List<string> jkPos = function.ReadInstance("tmpdata/jk.txt").Split('\n').ToList();
  48. List<string> Pos = new List<string>();
  49. string posString = function.ReadInstance("tmpdata/1.txt");
  50. Pos.AddRange(posString.Split('\n'));
  51. posString = function.ReadInstance("tmpdata/2.txt");
  52. Pos.AddRange(posString.Split('\n'));
  53. posString = function.ReadInstance("tmpdata/3.txt");
  54. Pos.AddRange(posString.Split('\n'));
  55. posString = function.ReadInstance("tmpdata/4.txt");
  56. Pos.AddRange(posString.Split('\n'));
  57. WebCMSEntities db = new WebCMSEntities();
  58. //金控
  59. var list1 = db.KxsMachine.Select(m => new { m.PosSn, m.BrandId, m.MachineRatio, m.SecondFee }).Where(m => (m.BrandId == 1 || m.BrandId == 3) && !jkPos.Contains(m.PosSn)).ToList().Select(m => new PosFeeItem(){ PosSn = m.PosSn, FeeRate = m.MachineRatio, FeeAmt = m.SecondFee }).ToArray();
  60. //盛付通、来客吧、联动
  61. var list2 = db.KxsMachine.Select(m => new { m.PosSn, m.BrandId, m.MachineRatio, m.SecondFee }).Where(m => Pos.Contains(m.PosSn)).ToList().Select(m => new PosFeeItem(){ PosSn = m.PosSn, FeeRate = m.MachineRatio, FeeAmt = m.SecondFee }).ToArray();
  62. RedisDbconn.Instance.Del("PosFeeList");
  63. RedisDbconn.Instance.AddList("PosFeeList", list1);
  64. RedisDbconn.Instance.AddList("PosFeeList", list2);
  65. db.Dispose();
  66. }
  67. #endregion
  68. }
  69. }