TerminalData.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 string? CompanyId { get; set; }
  17. public string TerminalId { get; set; }
  18. public Dictionary<string, decimal> MonthTotal_P { get; set; } = new Dictionary<string, decimal>();
  19. public decimal Total_P { get; set; }
  20. public Dictionary<string, decimal> MonthTotal_E { get; set; } = new Dictionary<string, decimal>();
  21. public decimal Total_E { get; set; }
  22. private string Key => $"{DateTime.Now:yyyyMMdd}";
  23. public decimal GetCurMonthTotal_P()
  24. {
  25. if (!MonthTotal_P.TryGetValue(Key, out var d))
  26. {
  27. d = 0;
  28. }
  29. return d;
  30. }
  31. public decimal GetCurMonthTotal_E()
  32. {
  33. if (!MonthTotal_E.TryGetValue(Key, out var d))
  34. {
  35. d = 0;
  36. }
  37. return d;
  38. }
  39. public TerminalData SetTotal_P(decimal d)
  40. {
  41. Total_P = d;
  42. return this;
  43. }
  44. public TerminalData SetMouthTotal_P(decimal d)
  45. {
  46. if (MonthTotal_P.ContainsKey(Key))
  47. {
  48. MonthTotal_P.Remove(Key);
  49. }
  50. MonthTotal_P.Add(Key, d);
  51. return this;
  52. }
  53. public TerminalData SetTotal_E(decimal d)
  54. {
  55. Total_E = d;
  56. return this;
  57. }
  58. public TerminalData SetMouthTotal_E(decimal d)
  59. {
  60. if (MonthTotal_E.ContainsKey(Key))
  61. {
  62. MonthTotal_E.Remove(Key);
  63. }
  64. MonthTotal_E.Add(Key, d);
  65. return this;
  66. }
  67. public TerminalData Save()
  68. {
  69. FileHelper.SaveFileInfo(this, $"{CompanyId}@{TerminalId}");
  70. return this;
  71. }
  72. }
  73. }