Browse Source

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

yuanrf 1 month ago
parent
commit
3838fcff66

+ 2 - 2
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -200,7 +200,7 @@ namespace OASystem.API.Controllers
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.DailyPayment, title, content, userIds, 0);
 
-                await APNsTools.iOS_PushNotifications("051", $"日付费用审核", "", content);
+                await APNsTools.iOS_PushNotifications1("051", $"日付费用审核", "", content);
             }
             catch (Exception ex)
             {
@@ -243,7 +243,7 @@ namespace OASystem.API.Controllers
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.DailyPayment, title, content, userIds, 0);
 
-                await APNsTools.iOS_PushNotifications("051", $"日付费用审核", "", content);
+                await APNsTools.iOS_PushNotifications1("051", $"日付费用审核", "", content);
             }
             catch (Exception ex)
             {

+ 15 - 16
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -2768,7 +2768,7 @@ FROM
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
 
-                await APNsTools.iOS_PushNotifications("051", $"机票费用审核", "", content);
+                await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content);
 
             }
             catch (Exception ex)
@@ -3643,9 +3643,13 @@ FROM
             }
 
             #region 应用推送
+            int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
             int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
             int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
 
+            //自动审核
+            var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
+
             await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
 
             //2024-10-21 新增LZ UID
@@ -3660,9 +3664,7 @@ FROM
 
             await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
 
-            await APNsTools.iOS_PushNotifications("051", $"其他款项费用审核", "", content);
-
-
+            //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
 
             #endregion
 
@@ -4265,7 +4267,7 @@ FROM
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
 
-                await APNsTools.iOS_PushNotifications("051", $"商邀费用审核", "", content);
+                await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content);
             }
             catch (Exception ex)
             {
@@ -7291,7 +7293,7 @@ FROM
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId); 
                 
-                await APNsTools.iOS_PushNotifications("051", $"签证费用审核", "", content);
+                await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content);
             }
             catch (Exception ex)
             {
@@ -7664,7 +7666,7 @@ FROM
                     string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
 
                     await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
-                    await APNsTools.iOS_PushNotifications("051", "OP费用审核", "", content);
+                    await APNsTools.iOS_PushNotifications1("051", "OP费用审核", "", content);
                 }
                 catch (Exception ex)
                 {
@@ -11204,13 +11206,12 @@ ORDER by  gctggrc.id DESC
                 if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
                 else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
 
-               
-
                 try
                 {
-                    Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
-                    var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
-                    Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
+                    var iosRes1 = await APNsTools.iOS_PushNotifications1("051", title, "", content);
+                    //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
+                    //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
+                    //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
                 }
                 catch (Exception ex )
                 {
@@ -11249,9 +11250,7 @@ ORDER by  gctggrc.id DESC
                 else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
-                //await GeneralMethod.iOS_PushNotifications("051", "费用审核", "", content);
-
-            }
+                            }
             catch (Exception ex)
             {
             }
@@ -13344,7 +13343,7 @@ ORDER by  gctggrc.id DESC
                 else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
-                await APNsTools.iOS_PushNotifications("051", $"保险费用审核", "", content);
+                await APNsTools.iOS_PushNotifications1("051", $"保险费用审核", "", content);
             }
             catch (Exception ex)
             {

+ 6 - 0
OASystem/OASystem.Api/File/AuthKey_RMV7Y4KM9V.p8

@@ -0,0 +1,6 @@
+-----BEGIN PRIVATE KEY-----
+MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQglyUl7hjI75YJUVMb
+ZLN6TpkiFzuTXUN+UIjuJA7+y8ugCgYIKoZIzj0DAQehRANCAAS8GR7lKNst4KEN
+Cp45OXCMyiytvzK0qdRBrx0l+bMaHjiU+Upfox82G+Xy4wd8hI+0wMDh341aNelq
+EdYUUx3O
+-----END PRIVATE KEY-----

+ 118 - 3
OASystem/OASystem.Api/OAMethodLib/APNs/APNsService.cs

@@ -10,6 +10,13 @@ using System.Net.Http;
 using Flurl.Http.Configuration;
 using System.Net;
 using QuzrtzJob.Factory;
+using Org.BouncyCastle.Crypto.Parameters;
+using System.IO;
+using CurlThin;
+using CurlThin.Enums;
+using CurlThin.Helpers;
+using CurlThin.Native;
+using CurlThin.SafeHandles;
 
 namespace OASystem.API.OAMethodLib.APNs
 {
@@ -53,6 +60,18 @@ namespace OASystem.API.OAMethodLib.APNs
             return this.GetnerateAPNsJWTToken(APNsService.token);
         }
 
+        //private static CngKey GetPrivateKey()
+        //{
+        //    using (var reader = System.IO.File.OpenText("File/AuthKey_RMV7Y4KM9V.p8"))
+        //    {
+        //        var ecPrivateKeyParameters = (ECPrivateKeyParameters)new PemReader(reader).ReadObject();
+        //        var x = ecPrivateKeyParameters.Parameters.G.AffineXCoord.GetEncoded();
+        //        var y = ecPrivateKeyParameters.Parameters.G.AffineYCoord.GetEncoded();
+        //        var d = ecPrivateKeyParameters.D.ToByteArrayUnsigned();
+        //        return EccKey.New(x, y, d);
+        //    }
+        //}
+
         /// <summary>
         /// 生成 APNs JWT token
         /// </summary>
@@ -81,7 +100,8 @@ namespace OASystem.API.OAMethodLib.APNs
             }
 
             var kid = _configuration["apple:kid"];
-            var securityKey = _configuration["apple:securityKey"].Replace("\n", "");
+           //var securityKey = _configuration["apple:securityKey"].Replace("\n", "");
+            var securityKey = string.Format("MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQglyUl7hjI75YJUVMbZLN6TpkiFzuTXUN+UIjuJA7+y8ugCgYIKoZIzj0DAQehRANCAAS8GR7lKNst4KENCp45OXCMyiytvzK0qdRBrx0l+bMaHjiU+Upfox82G+Xy4wd8hI+0wMDh341aNelqEdYUUx3O");
             var iss = _configuration["apple:iss"];
             var claims = new Claim[]
             {
@@ -89,37 +109,132 @@ namespace OASystem.API.OAMethodLib.APNs
                 new Claim("iat", iat.ToString())
             };
 
+            string msg = string.Empty;
+
+            msg += $"[GetnerateAPNsJWTToken] 0";
             try
             {
+                msg += $"[GetnerateAPNsJWTToken] 1";
                 var eCDsa = ECDsa.Create();
 
+                msg += $"[GetnerateAPNsJWTToken] 2";
                 eCDsa.ImportPkcs8PrivateKey(Convert.FromBase64String(securityKey), out _);
 
+                msg += $"[GetnerateAPNsJWTToken] 3";
                 var key = new ECDsaSecurityKey(eCDsa);
 
+                msg += $"[GetnerateAPNsJWTToken] 4";
                 key.KeyId = kid;
 
+                msg += $"[GetnerateAPNsJWTToken] 5";
                 var signingCredentials = new SigningCredentials(key, SecurityAlgorithms.EcdsaSha256);
+                msg += $"[GetnerateAPNsJWTToken] 6";
                 var jwtHeader = new JwtHeader(signingCredentials);
+                msg += $"[GetnerateAPNsJWTToken] 7";
                 var jwtPayload = new JwtPayload(claims);
 
+                msg += $"[GetnerateAPNsJWTToken] 8";
                 var jwtSecurityToken = new JwtSecurityToken(jwtHeader, jwtPayload);
 
+                msg += $"[GetnerateAPNsJWTToken] 9";
                 APNsService.token = tokenHandler.WriteToken(jwtSecurityToken);
             }
             catch (Exception ex)
             {
-                return $"[ECDsa] ExMsg:[{ex.Message}]";
+                return msg += $"[GetnerateAPNsJWTToken] --> ExMsg:[{ex.Message}]";
             }
             
             return APNsService.token;
         }
 
+        public async Task<Result>  PushNotification1(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body)
+        {
+            var res = new Result() { Code = 0, Msg = "", Data = "" };
+
+            //This string is for extracting libcurl and ssl libs to the bin directory.
+            CurlResources.Init();
+            var global = CurlNative.Init();
+            var easy = CurlNative.Easy.Init();
+            string content=string.Empty;
+            try
+            {
+                var token = GetnerateAPNsJWTToken(); 
+
+                var dataCopier = new DataCallbackCopier();
+
+                CurlNative.Easy.SetOpt(easy, CURLoption.URL, $"https://api.push.apple.com:443/3/device/{deviceToken}");
+                CurlNative.Easy.SetOpt(easy, CURLoption.WRITEFUNCTION, dataCopier.DataHandler);
+                //This string is needed when you call a https endpoint.
+                CurlNative.Easy.SetOpt(easy, CURLoption.CAINFO, CurlResources.CaBundlePath);
+
+                var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, APNsService.baseUrl + deviceToken)
+                {
+                    Headers =
+                    {
+                        { HeaderNames.Authorization, "bearer " +  token },
+                        { "apns-topic", apnsTopic },
+                        { "apns-expiration", "0" }
+                    },
+                    Version = new Version(2, 0)
+                };
+
+                var notContent = new
+                {
+                    aps = new
+                    {
+                        alert = new
+                        {
+                            title = title,
+                            subtitle = subtitle,
+                            body = body
+                        }
+                    }
+                };
+
+                var headers = CurlNative.Slist.Append(SafeSlistHandle.Null, $"Authorization: Bearer {token}");
+                CurlNative.Slist.Append(headers, $"apns-topic: {apnsTopic}");
+                CurlNative.Slist.Append(headers, $"apns-expiration: 0");
+
+                CurlNative.Easy.SetOpt(easy, CURLoption.HTTPHEADER, headers.DangerousGetHandle());
+
+                var contentJson = new StringContent(System.Text.Json.JsonSerializer.Serialize(notContent), System.Text.Encoding.UTF8, Application.Json);
+                CurlNative.Easy.SetOpt(easy, CURLoption.POSTFIELDS, System.Text.Json.JsonSerializer.Serialize(notContent));
+
+                //Your set of ciphers, full list is here https://curl.se/docs/ssl-ciphers.html
+                CurlNative.Easy.SetOpt(easy, CURLoption.SSL_CIPHER_LIST, "ECDHE-RSA-AES256-GCM-SHA384");
+
+
+
+                res.Msg += $"[PushNotification1] --> 发送请求";
+                CurlNative.Easy.Perform(easy);
+
+                content = Encoding.UTF8.GetString(dataCopier.Stream.ToArray());
+            }
+            catch (Exception ex)
+            {
+                res.Msg += $"[PushNotification1] ExMsg:{ex.Message}";
+                if (ex.InnerException != null)
+                {
+                    res.Msg += $"[PushNotification1] InnerException:{ex.InnerException.Message}";
+                }
+            }
+            finally
+            {
+                easy.Dispose();
+
+                if (global == CURLcode.OK)
+                    CurlNative.Cleanup();
+            }
+            res.Data = content;
+            return res;
+        }
+
+
         /// <summary>
         /// 发送推送通知
         /// </summary>
         /// <param name="apnsTopic">APP Id</param>
-        /// <param name="deviceToken">设备标识</param>
+        /// <param name="deviceToken">设备标识</param>[文件:AuthKey_RMV7Y4KM9V.p8]
         /// <param name="type">通知类型</param>
         /// <param name="title">标题</param>
         /// <param name="subtitle">子标题</param>

+ 27 - 0
OASystem/OASystem.Api/OAMethodLib/APNs/APNsTools.cs

@@ -36,5 +36,32 @@ namespace OASystem.API.OAMethodLib.APNs
             }
             return rst2;
         }
+
+        public static async Task<Result> iOS_PushNotifications1(string Numbers, string title, string subtitle, string body)
+        {
+
+            Result rst2 = new Result() { Code = -1, Msg = "" };
+            try
+            {
+
+
+                var _APNsService = AutofacIocManager.Instance.GetService<IAPNsService>();
+                var rst = await _deviceTokenRep.Query(s => s.Number == Numbers).FirstAsync();
+                //var rst = new Sys_DeviceToken() { DeviceToken = "08be7ba1ee42ecf36f695fd6b795b5e203295eaed0ba3857276141dbeee025ff" }
+                if (rst != null)
+                {
+                    rst2 =await  _APNsService.PushNotification1("com.panamerican.oa2024", rst.DeviceToken, NotificationType.Alert, title, subtitle, body);
+                }
+
+            }
+            catch (Exception ex)
+            {
+                rst2.Msg = $"[iOS_PushNotifications1] --> MSG:{ex.Message}";
+                rst2.Msg = $"[iOS_PushNotifications1] --> InnerException:{ex.InnerException .Message}";
+
+            }
+            return rst2;
+        }
+
     }
 }

+ 13 - 0
OASystem/OASystem.Api/OAMethodLib/APNs/IAPNsService.cs

@@ -19,5 +19,18 @@
         /// <param name="body">通知内容</param>
         /// <returns></returns>
         Task<Result> PushNotification(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body);
+
+        /// <summary>
+        /// 发送推送通知
+        /// </summary>
+        /// <param name="apnsTopic">APP Id</param>
+        /// <param name="deviceToken">设备标识</param>
+        /// <param name="type">通知类型</param>
+        /// <param name="title">标题</param>
+        /// <param name="subtitle">子标题</param>
+        /// <param name="body">通知内容</param>
+        /// <returns></returns>
+        Task<Result> PushNotification1(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body);
+
     }
 }

+ 2 - 2
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -830,7 +830,7 @@ namespace OASystem.API.OAMethodLib
         #region 三公费用相关
 
 
-        // <summary>
+        /// <summary>
         /// 保存操作前汇率
         /// </summary>
         /// <param name="currUserId"></param>
@@ -879,7 +879,7 @@ namespace OASystem.API.OAMethodLib
 
 
         /// <summary>
-        /// 三公费用导入款账单数据
+        /// 三公费用导入款账单数据
         /// </summary>
         /// <param name="groupId"></param>
         /// <returns></returns>

+ 8 - 0
OASystem/OASystem.Api/OASystem.API.csproj

@@ -32,6 +32,8 @@
     <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
     <PackageReference Include="Betalgo.OpenAI.GPT3" Version="6.8.3" />
     <PackageReference Include="BouncyCastle.NetCore" Version="1.8.8" />
+    <PackageReference Include="CurlThin" Version="0.0.7" />
+    <PackageReference Include="CurlThin.Native" Version="0.0.8" />
     <PackageReference Include="EPPlus" Version="7.4.1" />
     <PackageReference Include="Flurl.Http" Version="3.2.4" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.11" />
@@ -65,6 +67,12 @@
   <ItemGroup>
     <Resource Include="Images\VoucherHeader.png" />
   </ItemGroup>
+	
+  <ItemGroup>
+    <None Update="File\AuthKey_RMV7Y4KM9V.p8">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
 
   <ProjectExtensions><VisualStudio><UserProperties properties_4launchsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
 

+ 2 - 0
OASystem/OASystem.Api/Program.cs

@@ -15,6 +15,7 @@ using Quartz.Impl;
 using Quartz.Spi;
 using QuzrtzJob.Factory;
 
+Console.Title = $"FMGJ OASystem Server";
 var builder = WebApplication.CreateBuilder(args);
 var basePath = AppContext.BaseDirectory;
 
@@ -424,6 +425,7 @@ app.MapHub<ChatHub>("/ChatHub", options =>
 
 #endregion
 
+
 app.MapControllerRoute(
     name: "default",
     pattern: "{controller=Home}/{action=Index}/{id?}");

+ 5 - 5
OASystem/OASystem.Domain/ViewModels/Financial/Fin_DailyFeePaymentView.cs

@@ -1500,11 +1500,11 @@ namespace OASystem.Domain.ViewModels.Financial
         {
             get
             {
-                if (BudgetAmount == 0)
-                {
-                    return $"0%";
-                }
-                var percentage = (RealityAmount / BudgetAmount) * 100;
+                if (BudgetAmount == 0) return $"0%";
+
+                //if (ExcessAmount<=0) return $"0%";
+
+                var percentage = (ExcessAmount / BudgetAmount) * 100;
                 return $"{percentage.ToString("0.00")}%";
             }
         }

+ 6 - 0
OASystem/OASystem.Domain/ViewModels/Groups/FeeAuditView.cs

@@ -179,5 +179,11 @@ namespace OASystem.Domain.ViewModels.Groups
 
         #endregion
 
+        #region 自动审核 - 其他费用相关字段
+        /// <summary>
+        /// 出行物资费用
+        /// </summary>
+        public decimal TeFee { get { return TE; } set { TE = value; } }
+        #endregion
     }
 }

+ 8 - 72
OASystem/OASystem.Infrastructure/Repositories/Groups/DecreasePaymentsRepository.cs

@@ -154,77 +154,13 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             BeginTran();
             int id = 0;
-            Grp_DecreasePayments grp_Decrease = _mapper.Map<Grp_DecreasePayments>(dto);
+            var grp_Decrease = _mapper.Map<Grp_DecreasePayments>(dto);
             //处理费用总计
             if (grp_Decrease.FeeTotal == 0.00M)
             {
                 grp_Decrease.FeeTotal = grp_Decrease.Price * grp_Decrease.Price;
             }
 
-            //根据成本判断自动审核
-            #region 根据成本判断自动审核
-
-            var auto = false;
-            if (dto.IsSelect == 1)
-            {
-                var costInfo = _sqlSugar.Queryable<Grp_GroupCostParameter>()
-                                .LeftJoin<Grp_DelegationInfo>((a, b) => b.IsDel == 0 && b.Id == a.DiId)
-                                .Where((a, b) => a.DiId == dto.DiId && a.IsDel == 0 && a.CostType == "A")
-                                .Select((a,b) => new
-                                {
-                                   a.Currency,
-                                   a.CostType,
-                                   a.Rate,
-                                   b.VisitPNumber,
-                                })
-                                .First();
-
-                if (costInfo != null)
-                {
-                    //获取团组成本
-                    var groupCostPrice_Decimal = _sqlSugar.Queryable<Grp_GroupCost>()
-                            .Where(x => x.Diid == dto.DiId && x.IsDel == 0 && x.TE != 0)
-                            .Sum(x => x.TE);
-                    groupCostPrice_Decimal *= costInfo.VisitPNumber;
-
-                    var costPrice_Decimal = groupCostPrice_Decimal;
-                    var dtoPrice_Decimal = dto.FeeTotal;
-                    var costInfoCurr_Bool = int.TryParse(costInfo.Currency, out int costInfoCurr_Int);
-
-                    if(costInfoCurr_Int != dto.Currency)
-                    {
-                        if (costInfoCurr_Bool)
-                        {
-                            costPrice_Decimal *= costInfo.Rate;
-
-                            //获取其他款项汇率
-                            var rate_Object = await _setDataRepository.PostCurrencyByDiid(dto.DiId, 98, dto.Currency);
-                            if (rate_Object != null && rate_Object.Code == 0) {
-                                var currInfo = (rate_Object.Data as CurrencyInfo);
-                                if (currInfo != null)
-                                {
-                                    dtoPrice_Decimal *= currInfo.Rate;
-                                    if (costPrice_Decimal > dtoPrice_Decimal)
-                                    {
-                                        auto = true;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    else
-                    {
-                        if (costPrice_Decimal > dtoPrice_Decimal)
-                        {
-                            auto = true;
-                        }
-                    }
-                    
-                }
-
-            }
-            #endregion
-
             List<TeamRateDescAddCurrencyIdView> teamRates = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, dto.DiId, 98);
             if (dto.Status == 1)//添加
             {
@@ -273,7 +209,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     C.IsAuditMF = 0;
                     C.AuditMFOperate = 0;
                     C.AuditMFDate = "";
-                    C.IsAuditGM = auto ? 3 : 0;
+                    C.IsAuditGM = 0;
                     C.AuditGMOperate = 21;
                     C.AuditGMDate = "";
 
@@ -295,7 +231,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     //C.RMBPrice = 0.00f;
 
                     //设置该团组的汇率
-                    TeamRateDescAddCurrencyIdView teamRate = teamRates.Where(it => it.CurrencyId == grp_Decrease.Currency).FirstOrDefault();
+                    var teamRate = teamRates.Where(it => it.CurrencyId == grp_Decrease.Currency).FirstOrDefault();
                     //Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == grp_Decrease.DiId && a.IsDel == 0 && a.CTable == 98);
                     if (teamRate != null)
                     {
@@ -319,7 +255,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     if (cId != 0)
                     {
                         CommitTran();
-                        var data = new { ccpId = cId, sign = 1 };
+                        var data = new { ccpId = cId, sign = 1,dataId = id };
                         return new JsonView() { Code = 200, Msg = "添加成功!", Data = data };
                     }
                     else
@@ -354,11 +290,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 });
                 if (res)
                 {
-                    Grp_CreditCardPayment grp_CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == grp_Decrease.Id && a.CTable == 98 && a.CId == grp_Decrease.Id && a.IsDel == 0);
+                    var grp_CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == grp_Decrease.Id && a.CTable == 98 && a.CId == grp_Decrease.Id && a.IsDel == 0);
                     if (grp_CreditCardPayment != null)
                     {
                         //设置该团组的汇率
-                        TeamRateDescAddCurrencyIdView teamRate = teamRates.Where(it => it.CurrencyId == grp_Decrease.Currency).FirstOrDefault();
+                        var teamRate = teamRates.Where(it => it.CurrencyId == grp_Decrease.Currency).FirstOrDefault();
 
                         if (teamRate != null)
                         {
@@ -397,14 +333,14 @@ namespace OASystem.Infrastructure.Repositories.Groups
                                                         OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer,
                                                         DayRate = grp_CreditCardPayment.DayRate,
                                                         RMBPrice = grp_CreditCardPayment.RMBPrice,
-                                                        IsAuditGM = auto ? 3 : grp_CreditCardPayment.IsAuditGM
+                                                        //IsAuditGM = auto ? 3 : grp_CreditCardPayment.IsAuditGM
                                                     })
                                                     .ExecuteCommandAsync();
                         if (CTable > 0)
                         {
                             CommitTran();
 
-                            var data = new { ccpId = grp_CreditCardPayment.Id, sign = 2 };
+                            var data = new { ccpId = grp_CreditCardPayment.Id, sign = 2,dataId = grp_Decrease.Id };
 
                             return new JsonView() { Code = 200, Msg = "修改成功!", Data = data };
                         }

+ 101 - 11
OASystem/OASystem.Infrastructure/Repositories/Groups/FeeAuditRepository.cs

@@ -27,6 +27,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// <param name="feeType">
         /// 1.酒店 76 
         /// 2.op 79
+        /// 3.其他费用-出行物资 98
         /// </param>
         /// <param name="diId">团组Id</param>
         /// <param name="dataId">数据Id(模块类型主表Id)</param>
@@ -37,7 +38,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
             if (diId < 1) { _view.Msg = MsgTips.DiId; return _view; }
             if (dataId < 1) { _view.Msg = MsgTips.Id; return _view; }
 
-            List<int> stids = new List<int>() { 17, 66 };
+            var stids = new List<int>() { 17, 66, 91 };
             var setData = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && stids.Contains(x.STid)).ToList();
             string _teamCurrency = string.Empty;
            
@@ -48,7 +49,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
             //币种验证  统一为currencycode三字码
             if (int.TryParse(_teamCurrency,out int currency)) _teamCurrency = setData.Find(x => x.Id == currency)?.Name ?? "";
 
-
             string costContentSql = $"Select * From Grp_GroupCost";
             var costContents =  _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == diId).ToList();
             if (costContents.Count < 1) { _view.Msg = $"团组成本信息未填写!"; return _view; }
@@ -114,11 +114,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 DateTime checkIn = Convert.ToDateTime(hotelCostInfo.CheckInDate),
                          checkOut = Convert.ToDateTime(hotelCostInfo.CheckOutDate);
                 if (checkOut > checkIn) checkOut = checkOut.AddDays(-1); //房费计算,结束日期为前一天
-                var hotelCostInfos = costContents.Where(x =>  x.CurrTime >= checkIn && x.CurrTime <= checkOut).ToList();
+                var hotelCostInfos = costContents.Where(x => x.CurrTime >= checkIn && x.CurrTime <= checkOut).ToList();
                 if (hotelCostInfos.Count < 1) isAutoAudit = false;
 
                 decimal otherFee = hotelCostDetails.Where(x => x.PriceType != 1).Sum(x => x.Price * (x.Rate == 0.0000M ? 1.0000M : x.Rate));
-                if (otherFee > 0) { otherFee /= (checkOut-checkIn).Days; }
+                if (otherFee > 0) { otherFee /= (checkOut - checkIn).Days; }
                 var hotelCostInfosGroup = hotelCostInfos.GroupBy(x => x.Date);
                 foreach (var item in hotelCostInfosGroup)
                 {
@@ -160,10 +160,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         return _view;
                     }
                 }
-                else {
+                else
+                {
                     //撤销该条数据的自动审核 --> 该条数据的审核状态是自动审核  3 --> 0
-
-                    var quashStatus = QuashAudit(76,diId,dataId);
+                    var quashStatus = QuashAudit(76, diId, dataId);
 
                     if (quashStatus)
                     {
@@ -171,7 +171,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         _view.Msg = "费用超团组成本,自动审核撤销成功!";
                         return _view;
                     }
-                    
                 }
             }
             else if (feeType == 2)
@@ -199,7 +198,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 }
                 //1.参数验证
                 var opCheckPriceTyeps = opinfos.SelectCheck.Split(',');
-                var opCheckPriceTyepIds = setData.Where(x => opinfos.SelectCheck.Split(',').Contains(x.Name)).Select(x=>x.Id).ToList();
+                var opCheckPriceTyepIds = setData.Where(x => opinfos.SelectCheck.Split(',').Contains(x.Name)).Select(x => x.Id).ToList();
                 var opContents = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
                     .Where(x => x.IsDel == 0 && x.DiId == diId && x.CTGGRId == dataId && opCheckPriceTyepIds.Contains(x.SId))
                     .OrderBy(x => x.DatePrice, OrderByType.Asc)
@@ -228,7 +227,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     _teamRate = payInfo.DayRate;
                 }
 
-                
+
                 var opBasicDatas = setData.Where(x => x.STid == 17).ToList(); //费用类型基础数据
                 bool isAutoAudit = true;
                 if (!DateTime.TryParse(opinfos.ServiceStartTime, out DateTime startDt1) || !DateTime.TryParse(opinfos.ServiceEndTime, out DateTime endDt1))
@@ -357,13 +356,104 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 else
                 {
                     //撤销该条数据的自动审核 --> 该条数据的审核状态是自动审核  3 --> 0
-                    if (QuashAudit(79,diId,dataId))
+                    if (QuashAudit(79, diId, dataId))
+                    {
+                        _view.Code = 200;
+                        _view.Msg = "费用超团组成本,自动审核撤销成功!";
+                        return _view;
+                    }
+                }
+            }
+            else if (feeType == 3)
+            {
+                #region 出行物资的功能及相关费用自动审核
+
+                var isAutoAudit = false;
+                var currModule = 98; //其他款项
+                int groupSize = 0; // 团组人数
+                var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == diId).FirstAsync();
+                if (groupInfo != null) groupSize = groupDetails.VisitPNumber;
+
+                decimal groupCostCNYTotal = costContents.Sum(x => x.TeFee) * _teamRate * groupSize; //团组成本出行物资总金额
+                if (groupCostCNYTotal <= 0.00M)
+                {
+                    _view.Msg = $"团组成本出行物资费用数据未填写";
+                    QuashAudit(currModule, diId, dataId);
+                    return _view;
+                }
+
+                var teNames = setData.Where(x => x.STid == 91).Select(x => x.Name).ToList();
+                var otherFeeDatas = _sqlSugar.Queryable<Grp_DecreasePayments>()
+                    .InnerJoin<Grp_CreditCardPayment>((dp,ccp) => dp.Id == ccp.CId && ccp.CTable == 98 && ccp.IsDel == 0)
+                    .Where((dp, ccp) => dp.IsDel == 0 && dp.DiId == diId)
+                    .ToList();
+
+                var ids = new List<int>();
+                foreach (var item in otherFeeDatas)
+                {
+                    if (item.PriceName.Contains("、"))
+                    {
+                        var priceNames = item.PriceName.Split('、');
+                        foreach (var priceName in priceNames)
+                        {
+                            if (teNames.Contains(priceName))
+                            {
+                                ids.Add(item.Id);
+                                continue;
+                            }
+                        }
+                    }
+                    else if(teNames.Contains(item.PriceName))
+                    {
+                        ids.Add(item.Id);
+                    }
+                }
+                ids = ids.Distinct().ToList();
+                decimal otherFeeCNYTotal = otherFeeDatas.Where(x => ids.Contains(x.Id)).Sum(x => x.FeeTotal);  //其他费用出行物资总金额
+                if (otherFeeCNYTotal <= 0.00M)
+                {
+                    _view.Msg = $"其他款项出行物资费用数据未填写";
+                    QuashAudit(currModule, diId, dataId);
+                    return _view;
+                }
+
+                if (otherFeeCNYTotal > groupCostCNYTotal)
+                {
+                    _view.Msg = $"其他款项出行物资费用超出团组成本物资费用";
+                    QuashAudit(currModule, diId, dataId);
+                    return _view;
+                }
+                isAutoAudit = true;
+                //2.判断是否自动审核
+                if (isAutoAudit)
+                {
+                    var ccpUpdate = _sqlSugar.Updateable<Grp_CreditCardPayment>()
+                                       .SetColumns(it => it.IsAuditGM == 3)
+                                       .SetColumns(it => it.AuditGMOperate == 4)
+                                       .SetColumns(it => it.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
+                                       .Where(s => s.DIId == diId && s.CTable == currModule && s.CId == dataId)
+                                       .ExecuteCommand();
+                    if (ccpUpdate > 0)
+                    {
+                        _view.Code = 200;
+                        _view.Msg = "自动审核执行成功";
+                        return _view;
+                    }
+                }
+                else
+                {
+                    //撤销该条数据的自动审核 --> 该条数据的审核状态是自动审核  3 --> 0
+                    var quashStatus = QuashAudit(currModule, diId, dataId);
+
+                    if (quashStatus)
                     {
                         _view.Code = 200;
                         _view.Msg = "费用超团组成本,自动审核撤销成功!";
                         return _view;
                     }
                 }
+
+                #endregion
             }
             else _view.Msg = $"请传入有效的feeType参数";