EnterExitCostQuoteView.cs 4.4 KB

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