TerminalData.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using Vbdsm.Common;
  2. namespace Vbdsm.Gen
  3. {
  4. public class TerminalData
  5. {
  6. public TerminalData()
  7. {
  8. CompanyId = "";
  9. TerminalId = "";
  10. }
  11. public TerminalData(string? companyId, string terminalId)
  12. {
  13. CompanyId = companyId;
  14. TerminalId = terminalId;
  15. }
  16. public long GenDateTime { get; set; } = 0;
  17. public string? CompanyId { get; set; }
  18. public string TerminalId { get; set; }
  19. public Dictionary<string, decimal> DayTotal_P { get; set; } = new Dictionary<string, decimal>();
  20. public decimal Total_P { get; set; }
  21. public Dictionary<string, decimal> DayTotal_E { get; set; } = new Dictionary<string, decimal>();
  22. public decimal Total_E { get; set; }
  23. private string Key => $"{DateTime.Now:yyyyMMdd}";
  24. public decimal GetCurMonthTotal_P()
  25. {
  26. if (!DayTotal_P.TryGetValue(Key, out var d))
  27. {
  28. d = 0;
  29. }
  30. return d;
  31. }
  32. public decimal GetCurMonthTotal_E()
  33. {
  34. if (!DayTotal_E.TryGetValue(Key, out var d))
  35. {
  36. d = 0;
  37. }
  38. return d;
  39. }
  40. public TerminalData SetTotal_P(decimal d)
  41. {
  42. Total_P = d;
  43. return this;
  44. }
  45. public TerminalData SetMouthTotal_P(decimal d)
  46. {
  47. if (DayTotal_P.ContainsKey(Key))
  48. {
  49. DayTotal_P.Remove(Key);
  50. }
  51. DayTotal_P.Add(Key, d);
  52. return this;
  53. }
  54. public TerminalData SetTotal_E(decimal d)
  55. {
  56. Total_E = d;
  57. return this;
  58. }
  59. public TerminalData SetMouthTotal_E(decimal d)
  60. {
  61. if (DayTotal_E.ContainsKey(Key))
  62. {
  63. DayTotal_E.Remove(Key);
  64. }
  65. DayTotal_E.Add(Key, d);
  66. return this;
  67. }
  68. public TerminalData SetGenDateTime(long time)
  69. {
  70. GenDateTime = time;
  71. return this;
  72. }
  73. public TerminalData Save()
  74. {
  75. FileHelper.SaveFileInfo(this, $"{CompanyId}@{TerminalId}");
  76. return this;
  77. }
  78. }
  79. }