Browse Source

增强费用信息处理与展示格式

在 `GroupsController.cs` 中,修改了国际旅费、住宿费、餐饮费等多个费用项的处理逻辑,增加了对 `ItemWrapName` 属性的使用,确保费用信息格式化更清晰。同时,添加了对 `Infos` 集合的空值检查,提升了代码的健壮性。此外,增加了汇率处理逻辑,以便正确显示各货币的汇率信息。

在 `EnterExitCostQuoteView.cs` 中,新增了 `ItemWrapName` 属性,用于格式化 `ItemName`,提升了数据展示的可读性。
LEIYI 2 days ago
parent
commit
7202fe3d5f

+ 185 - 27
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -13620,7 +13620,6 @@ FROM
             if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
             if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
 
-
             var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
             if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
 
@@ -13648,8 +13647,8 @@ FROM
             designer.SetDataSource("CompanyLabel", "");
 
             #region 国际旅费
-            designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
-            if (intTravelCosts.Infos.Any())
+            designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
+            if (intTravelCosts != null && intTravelCosts.Infos.Any())
             {
                 var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
 
@@ -13683,46 +13682,47 @@ FROM
                 designer.SetDataSource("IntTravelLabel", label.ToString());
             }
             #endregion
+
             #region 住宿费 
-            designer.SetDataSource("AccomTitle", accomCosts.ItemName);
-            if (accomCosts.Infos.Any())
+            designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
+            if (accomCosts!=null && accomCosts.Infos.Any())
             {
-                string currencyName = string.Empty;
+                string currencyName = string.Empty,
+                       countryName = string.Empty;
                 decimal rate = 1.0000M;
 
                 StringBuilder label = new StringBuilder();
                 label.AppendLine("全程五星酒店,每人1间房");
                 foreach (var item in accomCosts.Infos)
                 {
-                    string hotelName = string.Empty;
+                    //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
+                    string name = string.Empty, thisCountryName = string.Empty;
                     if (item.FeeName.Contains("-"))
                     {
                         var feeName = item.FeeName.Split('-');
-                        hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
+                        thisCountryName = feeName[0];
+                        if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
+
+                        name = feeName[1];
                     }
-                    else hotelName = $"\r\n{item.FeeName}:";
+                    else name = item.FeeName;
+                    string thisFeeName = string.Empty;
+                    if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
+                    else thisFeeName = $"\r\n{name}:";
 
                     var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
                     currencyName = rateInfo?.CurrencyName ?? "UnKnow";
                     rate = rateInfo?.Rate ?? 1.0000M;
 
-                    label.Append(hotelName);
-                    label.Append(item.UnitPrice.TruncDecimals(2));
-                    label.Append(currencyName);
-                    label.Append("/间/晚*");
-                    label.Append(item.Quantity.ToString("#0"));
-                    label.AppendLine("人");
+                    string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
+                    label.AppendLine(subLabel);
 
                 }
                 if (label.HasValue())
                 {
-                    label.Append("\r\n以上小计:");
-                    label.Append(accomCosts.TotalAmt.TruncDecimals(2));
-                    label.Append("元(");
-                    label.Append(currencyName);
-                    label.Append("汇率:");
-                    label.Append(rate.TruncDecimals(4));
-                    label.Append(")");
+                    //以上小计:52440元(美金汇率:7.5  )
+                    string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
+                    label.AppendLine(subLabel);
                 }
 
                 designer.SetDataSource("AccomLabel", label.ToString());
@@ -13730,8 +13730,8 @@ FROM
             #endregion
 
             #region 餐饮费 
-            designer.SetDataSource("MealTitle", mealCosts.ItemName);
-            if (mealCosts.Infos.Any())
+            designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
+            if (mealCosts != null && mealCosts.Infos.Any())
             {
                 string currencyName = string.Empty;
                 decimal rate = 1.0000M;
@@ -13777,8 +13777,8 @@ FROM
             #endregion
 
             #region 车辆安排 
-            designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
-            if (vehArranges.Infos.Any())
+            designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
+            if (vehArranges!=null&&vehArranges.Infos.Any())
             {
                 string currencyName = string.Empty;
                 //decimal rate = 1.0000M;
@@ -13799,9 +13799,167 @@ FROM
             #endregion
 
             #region 邀请函发放对象
-            designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
+            designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
+            designer.SetDataSource("InviteToContent", "");
+            #endregion
+
+            #region 邀请函费
+            designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
+            StringBuilder is_label = new StringBuilder();
+            if (inviteCosts != null&&inviteCosts.Infos.Any())
+            {
+                string currencyName = string.Empty;
+                decimal rate = 1.0000M;
+                foreach (var item in inviteCosts.Infos)
+                {
+                    //乌兹别克斯坦:2000美金
+                    currencyName = item.Currency;
+                    rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
+                    string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
+                    is_label.AppendLine(label);
+                }
+
+                if (is_label.HasValue())
+                {
+                    //以上小计:28500元(美金汇率:7.5)
+                    string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2),"元", currencyName, rate.TruncDecimals(4));
+                    is_label.AppendLine(label);
+                }
+            }
+            designer.SetDataSource("InviteCostContent", is_label.ToString());
+            #endregion
+
+            #region 邀请函发放时间
+            designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
+            designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
+            #endregion
+
+            #region 公务活动(含翻译)
+            designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
+
+            StringBuilder oa_label = new StringBuilder();
+            if (officialActs != null && officialActs.Infos.Any())
+            {
+                string currencyName = string.Empty;
+                decimal rate = 1.0000M;
+                string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
+                foreach (var item in officialActs.Infos)
+                {
+                    //乌兹别克斯坦:1000美金/场
+                    currencyName = item.Currency;
+                    rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
+                    string label_remark = string.Empty;
+                    if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
+                    label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
+                }
+                label_content += "*总费用中未含超出公务活动价格";
+
+                //8场公务活动(以上小计:60000元)
+                var quantity = officialActs.Infos.Sum(x => x.Quantity);
+                label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
+                oa_label.AppendLine(label_title);
+                oa_label.AppendLine(label_content);
+            }
+            designer.SetDataSource("OfficialActsContent", oa_label.ToString());
+            #endregion
+
+            #region 签证+保险
+            designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
+
+            StringBuilder vi_label = new StringBuilder();
+            if (visaIns  != null &&  visaIns.Infos.Any())
+            {
+                foreach (var item in visaIns.Infos)
+                {
+                    //签证:500元/人
+                    string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
+                    vi_label.AppendLine(label);
+                }
+                if (vi_label.HasValue())
+                {
+                    //以上小计:6000元
+                    string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
+                    vi_label.AppendLine(label);
+                }
+
+                designer.SetDataSource("AccomLabel", vi_label.ToString());
+            }
+
+            designer.SetDataSource("VisaInsContent", vi_label.ToString());
+            #endregion
+
+            #region 服务费
+            designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
+            designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
             #endregion
 
+            #region 公杂费
+            designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
+            StringBuilder pm_label = new StringBuilder();
+            if (pubMiscs != null && pubMiscs.Infos.Any())
+            {
+                string currencyName = string.Empty,
+                       countryName = string.Empty;
+                decimal rate = 1.0000M;
+                foreach (var item in pubMiscs.Infos)
+                {
+                    //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
+                    string name = string.Empty, thisCountryName = string.Empty;
+                    if (item.FeeName.Contains("-"))
+                    {
+                        var feeName = item.FeeName.Split('-');
+                        thisCountryName = feeName[0];
+                        if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
+
+                        name = feeName[1];
+                    }
+                    else name = item.FeeName;
+                    string thisFeeName = string.Empty;
+                    if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
+                    else thisFeeName = $"\r\n{name}:";
+
+                    var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
+                    currencyName = rateInfo?.CurrencyName ?? "UnKnow";
+                    rate = rateInfo?.Rate ?? 1.0000M;
+
+                    string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
+                    vi_label.AppendLine(label);
+                }
+                if (vi_label.HasValue())
+                {
+                    //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
+                    vi_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
+                    vi_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
+                    vi_label.AppendLine(string.Format("部分发放成员"));
+                }
+
+                designer.SetDataSource("AccomLabel", vi_label.ToString());
+            }
+            designer.SetDataSource("PubMiscsContent", pm_label.ToString());
+            #endregion
+
+            #region 税费
+            designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
+            designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
+            #endregion
+
+            #region 合计(单位:元)
+            designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
+            designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
+            #endregion
+
+            #region 汇率 Remark
+            var rate_label = new StringBuilder();
+            var rateGroups = rates.GroupBy(x => x.CurrencyName);
+            foreach (var item in rateGroups)
+            {
+                //美元汇率按\r\n1:7.5
+                string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
+                rate_label.AppendLine(label);
+            }
+
+            designer.SetDataSource("RateLabel", rate_label.ToString());
+            #endregion
 
             designer.Process();
 

+ 19 - 0
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostQuoteView.cs

@@ -76,6 +76,25 @@ namespace OASystem.Domain.ViewModels.Groups
         public int ItemId { get; set; }
         public string ItemName { 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<QuoteSubItemInfo>();