EnterExitCostQuoteView.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using OASystem.Domain.Entities.Groups;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace OASystem.Domain.ViewModels.Groups
  8. {
  9. public class EnterExitCostQuoteView:Grp_EnterExitCostQuoteItem
  10. {
  11. }
  12. /// <summary>
  13. /// 初始化基础项视图
  14. /// </summary>
  15. public class InitBasicItemView
  16. {
  17. public int Id { get; set; }
  18. public string Name { get; set; }
  19. public bool IsOnlyRemark { get; set; } = false;
  20. public int Index { get; set; }
  21. }
  22. public class NameView
  23. {
  24. public int Id { get; set; }
  25. public string Name { get; set; }
  26. }
  27. public class EnterExitCostQuoteNameView : NameView { }
  28. public class EnterExitCostQuoteGroupNameView : NameView { }
  29. public class EnterExitCostQuoteInfoView
  30. {
  31. /// <summary>
  32. /// Id
  33. /// </summary>
  34. public int Id { get; set; }
  35. /// <summary>
  36. /// 报价名称
  37. /// </summary>
  38. public string Name { get; set; }
  39. /// <summary>
  40. /// 团组Id
  41. /// </summary>
  42. public int GroupId { get; set; }
  43. /// <summary>
  44. /// 汇率信息
  45. /// </summary>
  46. public CurrencyInfo[] Rates { get; set; } = Array.Empty<CurrencyInfo>();
  47. /// <summary>
  48. /// 费用列表
  49. /// </summary>
  50. public QuoteItemInfo[] FeeItems { get; set; } = Array.Empty<QuoteItemInfo>();
  51. /// <summary>
  52. /// 费用合计
  53. /// </summary>
  54. public decimal TotalAmt
  55. {
  56. get
  57. {
  58. return FeeItems.Sum(x => x.TotalAmt);
  59. }
  60. }
  61. }
  62. public class QuoteItemInfo
  63. {
  64. public int QuoteId { get; set; }
  65. public int ItemId { get; set; }
  66. public string ItemName { get; set; }
  67. public bool IsOnlyRemark { get; set; }
  68. public string ItemWrapName
  69. {
  70. get {
  71. var thisItemName = ItemName;
  72. var label = new StringBuilder();
  73. if (!string.IsNullOrEmpty(thisItemName))
  74. {
  75. if (thisItemName.Contains("\\n"))
  76. {
  77. var strs = thisItemName.Split("\\n");
  78. label.AppendLine(strs[0]);
  79. label.AppendLine(strs[1]);
  80. }
  81. else label.Append(thisItemName);
  82. }
  83. return label.ToString();
  84. }
  85. }
  86. public decimal TotalAmt { get { return Infos.Any() ? TruncDecimals(Infos.Sum(x => x.TotalAmt)) : 0.00M; } }
  87. public QuoteSubItemInfo[] Infos { get; set; } = Array.Empty<QuoteSubItemInfo>();
  88. public int Index { get; set; }
  89. /// <summary>
  90. /// decimal 保留小数,不四舍五入
  91. /// </summary>
  92. /// <param name="value"></param>
  93. /// <param name="decimalPlaces"></param>
  94. /// <returns></returns>
  95. private decimal TruncDecimals(decimal value, int decimalPlaces = 2)
  96. {
  97. decimal scaleFactor = (decimal)Math.Pow(10, decimalPlaces);
  98. var truncated = Math.Truncate(scaleFactor * value) / scaleFactor;
  99. // 检查是否需要补零
  100. if (GetDecimalDigits(value) < decimalPlaces)
  101. {
  102. string format = "0." + new string('0', decimalPlaces);
  103. truncated = decimal.Parse(truncated.ToString(format));
  104. }
  105. return truncated;
  106. }
  107. private int GetDecimalDigits(decimal number)
  108. {
  109. string[] parts = number.ToString().Split('.');
  110. return parts.Length > 1 ? parts[1].Length : 0;
  111. }
  112. }
  113. public class QuoteSubItemInfo
  114. {
  115. public int Id { get; set; }
  116. public int ItemId { get; set; }
  117. public int Index { get; set; }
  118. public string FeeName { get; set; }
  119. /// <summary>
  120. /// 单价
  121. /// </summary>
  122. public decimal UnitPrice { get; set; }
  123. /// <summary>
  124. /// 币种
  125. /// </summary>
  126. public string Currency { get; set; }
  127. /// <summary>
  128. /// 数量/天数/间/晚/次
  129. /// </summary>
  130. public decimal Quantity { get; set; }
  131. /// <summary>
  132. /// 人数
  133. /// </summary>
  134. public int PplNum { get; set; }
  135. /// <summary>
  136. /// 合计(CNY)
  137. /// </summary>
  138. public decimal TotalAmt { get; set; }
  139. public string Remark { get; set; }
  140. }
  141. }