using OASystem.Domain.Entities.Groups; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OASystem.Domain.ViewModels.Groups { public class EnterExitCostQuoteView:Grp_EnterExitCostQuoteItem { } /// /// 初始化基础项视图 /// public class InitBasicItemView { public int Id { get; set; } public string Name { get; set; } public bool IsOnlyRemark { get; set; } = false; public int Index { get; set; } } public class NameView { public int Id { get; set; } public string Name { get; set; } } public class EnterExitCostQuoteNameView : NameView { } public class EnterExitCostQuoteGroupNameView : NameView { } public class EnterExitCostQuoteInfoView { /// /// Id /// public int Id { get; set; } /// /// 报价名称 /// public string Name { get; set; } /// /// 团组Id /// public int GroupId { get; set; } /// /// 汇率信息 /// public CurrencyInfo[] Rates { get; set; } = Array.Empty(); /// /// 费用列表 /// public QuoteItemInfo[] FeeItems { get; set; } = Array.Empty(); /// /// 费用合计 /// public decimal TotalAmt { get { return FeeItems.Sum(x => x.TotalAmt); } } } public class QuoteItemInfo { public int QuoteId { get; set; } public int ItemId { get; set; } public string ItemName { get; set; } public bool IsOnlyRemark { get; set; } public string ItemWrapName { get { var thisItemName = ItemName; var label = new StringBuilder(); if (!string.IsNullOrEmpty(thisItemName)) { if (thisItemName.Contains("\\n")) { var strs = thisItemName.Split("\\n"); label.AppendLine(strs[0]); label.AppendLine(strs[1]); } else label.Append(thisItemName); } return label.ToString(); } } public decimal TotalAmt { get { return Infos.Any() ? TruncDecimals(Infos.Sum(x => x.TotalAmt)) : 0.00M; } } public QuoteSubItemInfo[] Infos { get; set; } = Array.Empty(); public int Index { get; set; } /// /// decimal 保留小数,不四舍五入 /// /// /// /// private decimal TruncDecimals(decimal value, int decimalPlaces = 2) { decimal scaleFactor = (decimal)Math.Pow(10, decimalPlaces); var truncated = Math.Truncate(scaleFactor * value) / scaleFactor; // 检查是否需要补零 if (GetDecimalDigits(value) < decimalPlaces) { string format = "0." + new string('0', decimalPlaces); truncated = decimal.Parse(truncated.ToString(format)); } return truncated; } private int GetDecimalDigits(decimal number) { string[] parts = number.ToString().Split('.'); return parts.Length > 1 ? parts[1].Length : 0; } } public class QuoteSubItemInfo { public int Id { get; set; } public int ItemId { get; set; } public int Index { get; set; } public string FeeName { get; set; } /// /// 单价 /// public decimal UnitPrice { get; set; } /// /// 币种 /// public string Currency { get; set; } /// /// 数量/天数/间/晚/次 /// public decimal Quantity { get; set; } /// /// 人数 /// public int PplNum { get; set; } /// /// 合计(CNY) /// public decimal TotalAmt { get; set; } public string Remark { get; set; } } }