瀏覽代碼

费用审核 --> users 查询 去掉 isdel = 0

LEIYI 3 月之前
父節點
當前提交
f2916f82ef

+ 8 - 6
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -1791,34 +1791,36 @@ FROM
                  */
                 var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
 
+
+                var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
+
                 /*
                  * 币种信息
                  */
-                var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
+                var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
 
                 /*
                  * 车/导游地接 费用类型
                  */
-                var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
+                var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
 
                 /*
                  * 车/导游地接 费用类型
                  */
-                var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
+                var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
 
-                var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
 
                 var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
 
                 /*
                  * 用户信息
                  */
-                var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
+                var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
 
                 /*
                  * 费用模块
                  */
-                var sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
+                var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
                 string priceModule = string.Empty;
                 if (sdPriceName != null)
                 {

+ 83 - 3
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -15,6 +15,7 @@ using OASystem.API.OAMethodLib.JuHeAPI;
 using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.Statistics;
 using OASystem.Domain.Entities.Customer;
+using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.JuHeExchangeRate;
@@ -23,6 +24,7 @@ using OASystem.Domain.ViewModels.Statistics;
 using OASystem.Infrastructure.Repositories.Groups;
 using System;
 using System.Data;
+using TencentCloud.Ocr.V20181119.Models;
 using static OASystem.API.OAMethodLib.GeneralMethod;
 using TypeInfo = OASystem.Domain.ViewModels.Statistics.TypeInfo;
 
@@ -1296,6 +1298,33 @@ ORDER BY
                 _geView.GroupDecreaseFeeStr = string.Format(@"人民币总费用:{0} CNY", DecreaseCNYTotalPrice.ToString("#0.00"));
                 #endregion
 
+                #region 公司内部操作人员提成
+
+                var royaltyDatas = await _sqlSugar
+                    .Queryable<Fin_RoyaltyConfirm, Sys_Users, Sys_Users>((rc, u1, u2) =>
+                        new JoinQueryInfos(
+                            JoinType.Left, rc.UserId == u1.Id,
+                            JoinType.Left, rc.CreateUserId == u2.Id
+                        ))
+                    .Where((rc, u1, u2) => rc.IsDel == 0 && rc.TeamId == _dto.DiId && rc.IsConfirm == 1)
+                    .Select((rc, u1, u2) => new GroupRoyaltyFeeInfo()
+                    {
+                        GroupId = rc.TeamId,
+                        OverviewInfo = rc.Temp,
+                        DetailedInfo = rc.ChiArr,
+                        Amount = rc.Price,
+                        IsConfirm = rc.IsConfirm ,
+                        IsSeed = rc.IsSeed ,
+                        RoyaltyUserName = u1.CnName,
+                        CreateUserName = u2.CnName,
+                        CreateTime = rc.CreateTime
+                    })
+                    .ToListAsync();
+                decimal royaltyCNYTotalPrice = royaltyDatas.Sum(x => x.Amount);
+                _geView.GroupRoyaltyFeeViews = _mapper.Map<List<GroupRoyaltyFeeView>>(royaltyDatas);
+                _geView.GroupRoyaltyFeeStr = string.Format(@"人民币总费用:{0} CNY", royaltyCNYTotalPrice.ToString("#0.00"));
+                #endregion
+
                 _view.GroupExpenditure = _geView;
                 #endregion
 
@@ -1314,7 +1343,7 @@ ORDER BY
                 decimal _receivableProfit = 0.00M; //应收利润
                 decimal _receivedProfit = 0.00M;   //已收利润
                 _totalExpenditure = HotelCNYTotalPrice + CTGGRCNYTotalPrice + AirCNYTotalPrice + VisaCNYTotalPirce + InvitationalCNYTotalPrice +
-                                    InsuranceCNYTotalPrice + DecreaseCNYTotalPrice + exTotalAmount;
+                                    InsuranceCNYTotalPrice + DecreaseCNYTotalPrice + exTotalAmount + royaltyCNYTotalPrice;
                 _amountReceivable = frTotalAmount;
                 _amountReceived = prTotalAmount;
                 _receivableProfit = _amountReceivable - promTotalAmount - _totalExpenditure;
@@ -1423,6 +1452,12 @@ ORDER BY
             var SKTHFeeDt = new DataTable($"SKTHFeeView");
             decimal SKTHCNYTotalCost = 0.00M;
 
+            //操作提成
+            var royaltyFeeSheet = worksheets["操作提成"];
+            var royaltyFeeDt = new DataTable($"royaltyFeeView");
+            decimal royaltyCNYTotalCost = 0.00M;
+
+
             var totalAmount = 0.00M;     //支出成本合计
             var accountsAmount = 0.00M;  //应收金额合计
             var receivedAmount = 0.00M;  //已收金额合计
@@ -2027,6 +2062,46 @@ ORDER BY
 
             #endregion
 
+            #region 操作提成
+
+            if (SKTHFeeSheet != null)
+            {
+                var _royaltyDatas = await _sqlSugar
+                   .Queryable<Fin_RoyaltyConfirm, Sys_Users, Sys_Users>((rc, u1, u2) =>
+                       new JoinQueryInfos(
+                           JoinType.Left, rc.UserId == u1.Id,
+                           JoinType.Left, rc.CreateUserId == u2.Id
+                       ))
+                   .Where((rc, u1, u2) => rc.IsDel == 0 && rc.TeamId == _dto.DiId && rc.IsConfirm == 1)
+                   .Select((rc, u1, u2) => new GroupRoyaltyFeeInfo()
+                   {
+                       GroupId = rc.TeamId,
+                       OverviewInfo = rc.Temp,
+                       DetailedInfo = rc.ChiArr,
+                       Amount = rc.Price,
+                       IsConfirm = rc.IsConfirm,
+                       IsSeed = rc.IsSeed,
+                       RoyaltyUserName = u1.CnName,
+                       CreateUserName = u2.CnName,
+                       CreateTime = rc.CreateTime
+                   })
+                   .ToListAsync();
+
+                if (_royaltyDatas.Any())
+                {
+
+                    decimal royaltyCNYTotalPrice = _royaltyDatas.Sum(x => x.Amount);
+                    var _royaltyFeeViews = _mapper.Map<List<GroupRoyaltyFeeExcelView>>(_royaltyDatas);
+
+                    royaltyCNYTotalCost = _royaltyFeeViews.Sum(x => x.Amount);
+                    royaltyFeeDt = CommonFun.ToDataTableArray(_royaltyFeeViews);
+                    royaltyFeeDt.TableName = $"RoyaltyFeeView";
+                }
+
+            }
+
+            #endregion
+
             #region 应收金额(增加方式=实际报价时 费用必须审核才能进入团组报表)
             decimal frTotalAmount = 0.00M;//应收总金额
             string _frSql = string.Format(@"  Select fr.Id,fr.AddingWay,fr.Status,u.CnName As Auditor,fr.AuditTime,fr.Diid,fr.PriceName,fr.Price,fr.Count,fr.Unit,fr.Currency,
@@ -2091,6 +2166,7 @@ ORDER BY
                 new object[] { $"保险费用", insureCNYTotalCost, $"CNY" },
                 new object[] { $"其他费用", otherCNYTotalCost, $"CNY" },
                 new object[] { $"收款退还费用", SKTHCNYTotalCost, $"CNY" },
+                new object[] { $"操作提成费用", royaltyCNYTotalCost, $"CNY" },
             };
 
             // 批量添加
@@ -2137,7 +2213,11 @@ ORDER BY
 
             //收款退还
             designer.SetDataSource(SKTHFeeDt);
-            designer.SetDataSource("SKTHCNYTotalCost", $"{SKTHCNYTotalCost.ToString("#0.00")}");
+            designer.SetDataSource("SKTHCNYTotalCost", $"{SKTHCNYTotalCost.ToString("#0.00")} CNY");
+
+            //操作提成
+            designer.SetDataSource(royaltyFeeDt);
+            designer.SetDataSource("RoyaltyCNYTotalCost", $"{royaltyCNYTotalCost.ToString("#0.00")} CNY");
 
             //已收金额
             designer.SetDataSource(receivedFeeDt);
@@ -2164,7 +2244,7 @@ ORDER BY
              * 利润差 = 应收利润 - 已收利润
              */
 
-            totalAmount = visaCNYTotalCost + hotelCNYTotalCost + OPCNYTotalCost + OACNYTotalCost + airTicketCNYTotalCost + insureCNYTotalCost + otherCNYTotalCost;//合计金额
+            totalAmount = visaCNYTotalCost + hotelCNYTotalCost + OPCNYTotalCost + OACNYTotalCost + airTicketCNYTotalCost + insureCNYTotalCost + otherCNYTotalCost + royaltyCNYTotalCost;//合计金额
             accountsProfit = accountsAmount - totalAmount - SKTHCNYTotalCost;   //应收利润
             receiveProfit = receivedAmount - totalAmount - SKTHCNYTotalCost; //已收利润
             profitMargin = accountsProfit - receiveProfit;   //利润差

+ 3 - 0
OASystem/OASystem.Domain/AutoMappers/_baseMappingProfile.cs

@@ -23,6 +23,7 @@ using OASystem.Domain.Entities.PersonnelModule;
 using OASystem.Domain.Dtos.PersonnelModule;
 using OASystem.Domain.Dtos.Statistics;
 using OASystem.Domain.ViewModels.Financial;
+using OASystem.Domain.ViewModels.Statistics;
 
 namespace OASystem.Domain.AutoMappers
 {
@@ -300,6 +301,8 @@ namespace OASystem.Domain.AutoMappers
 
             #region Statistics
             CreateMap<StatisticsBRCostView, StatisticsBRCostBriefView>();
+            CreateMap<GroupRoyaltyFeeInfo, GroupRoyaltyFeeView>();
+            CreateMap<GroupRoyaltyFeeInfo, GroupRoyaltyFeeExcelView>();
             #endregion
 
             #region 人事 模块

+ 90 - 0
OASystem/OASystem.Domain/ViewModels/Statistics/GroupStatementView.cs

@@ -1,4 +1,5 @@
 using Google.Protobuf;
+using Newtonsoft.Json;
 using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
 using System;
@@ -612,6 +613,9 @@ namespace OASystem.Domain.ViewModels.Statistics
         /// 增减款项费用描述
         /// </summary>
         public string? GroupDecreaseFeeStr { get; set; }
+
+        public List<GroupRoyaltyFeeView> GroupRoyaltyFeeViews { get; set; }
+        public string? GroupRoyaltyFeeStr { get; set; }
     }
 
     /// <summary>
@@ -1415,6 +1419,76 @@ namespace OASystem.Domain.ViewModels.Statistics
         public string? Applicant { get; set; }
 
     }
+
+
+    public class GroupRoyaltyFeeInfo
+    {
+        public int GroupId { get; set; }
+        public string OverviewInfo { get; set; }
+        [JsonIgnore]
+        public string DetailedInfo { get; set; }
+        public string[] DetailedInfoText
+        {
+            get
+            {
+                var jsonArray = Array.Empty<string>();
+                string str = DetailedInfo;
+                if (string.IsNullOrWhiteSpace(str)) return jsonArray;
+                str = str.Trim();
+                if ((str.StartsWith("{") && str.EndsWith("}")) || // 检查是否是 JSON 对象
+                    (str.StartsWith("[") && str.EndsWith("]")))   // 检查是否是 JSON 数组
+                {
+                    try
+                    {
+                        return JsonConvert.DeserializeObject<string[]>(str);
+                    }
+                    catch (JsonException)
+                    {
+                        return jsonArray;
+                    }
+                }
+                return jsonArray;
+            }
+        }
+
+        public string DetailedInfoExcelText
+        {
+            get
+            {
+                string label = string.Empty;
+                var array = DetailedInfoText;
+                if (!array.Any()) return label;
+                foreach (var item in array) label += $"{item}\n";
+                if (label.EndsWith(@"\n")) label = label.Substring(0, label.Length - 2);
+                return label;
+            }
+        }
+        public decimal Amount { get; set; }
+        public int IsConfirm { get; set; }
+        public string IsConfrimText { get { return IsConfirm == 1 ? "已确认" : "未确认"; } }
+        public int IsSeed { get; set; }
+        public string IsSeedText { get { return IsSeed == 1 ? "已发放" : "未发放"; } }
+        public string RoyaltyUserName { get; set; }
+        public string CreateUserName { get; set; }
+        public DateTime CreateTime { get; set; }
+    }
+
+    /// <summary>
+    /// 操作人员提成View
+    /// </summary>
+    public class GroupRoyaltyFeeView
+    {
+        public int GroupId { get; set; }
+        public string OverviewInfo { get; set; }
+        public string[] DetailedInfoText { get; set; }
+        public decimal Amount { get; set; }
+        public string IsConfrimText { get; set; }
+        public string IsSeedText { get; set; }
+        public string RoyaltyUserName { get; set; }
+        public string CreateUserName { get; set; }
+        public DateTime CreateTime { get; set; }
+    }
+
     #endregion
 
     #region 团组统计报表下载
@@ -1891,6 +1965,22 @@ namespace OASystem.Domain.ViewModels.Statistics
         public string? Remark { get; set; }
     }
 
+    /// <summary>
+    /// 操作人员提成View
+    /// </summary>
+    public class GroupRoyaltyFeeExcelView
+    {
+        public int GroupId { get; set; }
+        public string OverviewInfo { get; set; }
+        public string DetailedInfoExcelText { get; set; }
+        public decimal Amount { get; set; }
+        public string IsConfrimText { get; set; }
+        public string IsSeedText { get; set; }
+        public string RoyaltyUserName { get; set; }
+        public string CreateUserName { get; set; }
+        public DateTime CreateTime { get; set; }
+    }
+
     #endregion
 
 }