using Vbdsm.Common; namespace Vbdsm.Gen { public class TerminalData { public TerminalData() { CompanyId = ""; TerminalId = ""; } public TerminalData(string? companyId, string terminalId) { CompanyId = companyId; TerminalId = terminalId; } public long GenDateTime { get; set; } = 0; public string? CompanyId { get; set; } public string TerminalId { get; set; } public Dictionary DayTotal_P { get; set; } = new Dictionary(); public decimal Total_P { get; set; } public Dictionary DayTotal_E { get; set; } = new Dictionary(); public decimal Total_E { get; set; } private string Key => $"{DateTime.Now:yyyyMMdd}"; public decimal GetCurMonthTotal_P() { if (!DayTotal_P.TryGetValue(Key, out var d)) { d = 0; } return d; } public decimal GetCurMonthTotal_E() { if (!DayTotal_E.TryGetValue(Key, out var d)) { d = 0; } return d; } public TerminalData SetTotal_P(decimal d) { Total_P = d; return this; } public TerminalData SetMouthTotal_P(decimal d) { if (DayTotal_P.ContainsKey(Key)) { DayTotal_P.Remove(Key); } DayTotal_P.Add(Key, d); return this; } public TerminalData SetTotal_E(decimal d) { Total_E = d; return this; } public TerminalData SetMouthTotal_E(decimal d) { if (DayTotal_E.ContainsKey(Key)) { DayTotal_E.Remove(Key); } DayTotal_E.Add(Key, d); return this; } public TerminalData SetGenDateTime(long time) { GenDateTime = time; return this; } public TerminalData Save() { FileHelper.SaveFileInfo(this, $"{CompanyId}@{TerminalId}"); return this; } } }