浏览代码

优化客户和机票费用提示查询逻辑

在 `GroupsController.cs` 中,更新了客户列表查询,增加了对 `Crm_DeleClient` 和 `Crm_CustomerCompany` 的左连接,并解密 `CompanyFullName`。调整了舱位人数计算逻辑,排除陪同人员和特定公司。

修改了机票费用提示的获取逻辑,使用 `GeneralMethod` 中的 `EntryAndExitTips` 方法。

更新了 `appsettings.json` 中的 `KiMiSetting` 的 `Key` 值。

在 `GeneralMethod.cs` 中新增了处理机票费用提示和行程代码识别的逻辑。

新增 `groupClints` 类以表示客户信息,并在 `AirTicketReservationsView.cs` 中更新了 `EntryAndExitTipsView` 类,增加了 `tdcCurrentRate` 和 `TripDesc` 属性。

在 `GoodsRepository.cs` 中增加了对“全部团组”的处理逻辑,并在查询条件中引入了 `isAllGroups` 变量。

删除了 `TicketBlackCodeRepository.cs` 中的原有 `EntryAndExitTips` 方法,改为使用新的逻辑处理机票费用提示。
LEIYI 1 年之前
父节点
当前提交
5cc4012b97

+ 20 - 14
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -2123,21 +2123,27 @@ FROM
                 subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
             }
 
-
             var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
-                                             .LeftJoin<Sys_SetData>((x,s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0 )
-                                             .Where((x, s) => x.DiId == dto.GroupId && x.IsDel == 0)
-                                             .Select((x, s) => new
-                                             {
-                                                 x.Id,
-                                                 s.Name,
-                                             })
-                                             .ToListAsync();
+                .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
+                .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
+                .LeftJoin<Crm_CustomerCompany>((x, s, dc,cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
+                .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
+                .Select((x, s, dc, cc) => new groupClints
+                {
+                    Id =x.Id,
+                    Name =s.Name,
+                    IsAccompany =x.IsAccompany,
+                    CompanyFullName =cc.CompanyFullName
+                })
+                .ToListAsync();
+
+            groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
 
             //获取舱位人数
-            var cabinCount = groupClints.GroupBy(x => x.Name)
-                                        .Select(x => new { Cabin = x.Key, Count = x.Count() })
-                                        .ToList();
+            var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
+                .GroupBy(x => x.Name)
+                .Select(x => new { Cabin = x.Key, Count = x.Count() })
+                .ToList();
 
             string cityPath = string.Empty;
             string startCity = string.Empty;
@@ -6750,7 +6756,7 @@ FROM
             //默认币种显示
             var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
             var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
-            var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
+            var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
             return Ok(JsonView(true, "查询成功!", new
             {
                 //GroupNameData = groupNameData.Data,
@@ -10614,7 +10620,7 @@ FROM
             }
             else if (dto.TipsType == 3)
             {
-                var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
+                var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
                 return Ok(JsonView(true, "查询成功!", airData));
             }
             return Ok(JsonView(false));

+ 1 - 0
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -1840,6 +1840,7 @@ WHERE
             countyDatas.Insert(0, new { id = 0, name = "其他物资(公司内部物资)"});
             countyDatas.Insert(0, new { id = -1, name = "拜访客户所使用的物资" });
             countyDatas.Insert(0, new { id = -2, name = "库存调整" });
+            countyDatas.Insert(0, new { id = -3, name = "全部团组" });
             var total = countyDatas.Count;
             countyDatas = countyDatas.WhereIF(!string.IsNullOrEmpty(dto.Search), x => x.name.Contains(dto.Search)).ToList();
             countyDatas = countyDatas

+ 87 - 3
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -5,14 +5,17 @@ using Aspose.Words.Layout;
 using Aspose.Words.Saving;
 using Microsoft.AspNetCore.SignalR;
 using Microsoft.International.Converters.PinYinConverter;
-using NodaTime.TimeZones;
 using NodaTime;
+using NodaTime.Extensions;
+using NodaTime.TimeZones;
 using OASystem.API.OAMethodLib.APNs;
 using OASystem.API.OAMethodLib.File;
 using OASystem.API.OAMethodLib.Hub.HubClients;
 using OASystem.API.OAMethodLib.Hub.Hubs;
 using OASystem.API.OAMethodLib.JuHeAPI;
+using OASystem.API.OAMethodLib.KiMiApi;
 using OASystem.API.OAMethodLib.SignalR.Hubs;
+using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.Financial;
@@ -27,8 +30,6 @@ using OfficeOpenXml;
 using System.Data;
 using System.IdentityModel.Tokens.Jwt;
 using System.Security.Claims;
-using NodaTime.Extensions;
-using OASystem.Domain.AesEncryption;
 
 namespace OASystem.API.OAMethodLib
 {
@@ -5492,6 +5493,89 @@ namespace OASystem.API.OAMethodLib
         }
 
 
+        #endregion
+
+        #region 机票费用提示
+        /// <summary>
+        /// 三公机票费用提示
+        /// </summary>
+        /// <param name="diId"></param>
+        /// <returns></returns>
+        public static async Task<EntryAndExitTipsView[]> EntryAndExitTips(int diId)
+        {
+            if (diId < 1) return Array.Empty<EntryAndExitTipsView>();
+
+            var airFees = await _sqlSugar.Queryable<Air_TicketBlackCode>().Where(a => a.IsDel == 0 && a.DiId == diId).ToListAsync();
+
+            if (airFees.Any())
+            {
+
+                var result = new List<EntryAndExitTipsView>();
+
+
+                foreach (var x in airFees)
+                {
+                    string tripDesc = "";
+                    if (!string.IsNullOrEmpty(x.BlackCode))
+                    {
+                        var redisKeyName = string.Format("AirTripDesc_{0}_{1}", x.DiId, x.Id);
+                        tripDesc = await KIMIAirTripCodeRec(redisKeyName, x.BlackCode);
+                    }
+                    
+
+                    result.Add(new EntryAndExitTipsView
+                    {
+                        jjcCurrentRate = x.ECPrice,
+                        gwcCurrentRate = x.BCPrice,
+                        tdcCurrentRate = x.FCPrice,
+                        remark = $"经济舱全价:{x.ECPrice.ToString("#0.00")} 元/人 公务舱全价:{x.BCPrice.ToString("#0.00")} 元/人 头等舱全价:{x.FCPrice.ToString("#0.00")} 元/人",
+                        TripDesc = tripDesc
+                    });
+                }
+                return result.OrderByDescending(x => x.jjcCurrentRate + x.gwcCurrentRate + x.tdcCurrentRate).ToArray();
+            }
+
+            return Array.Empty<EntryAndExitTipsView>();
+        }
+
+        /// <summary>
+        /// 机票行程代码识别
+        /// </summary>
+        /// <param name="redisKeyName">redis缓存名称(名称定义格式:AirTripDesc_Diid_Id)</param>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        public static async Task<string> KIMIAirTripCodeRec(string redisKeyName, string msg)
+        {
+            string result = string.Empty;
+
+            if (!string.IsNullOrEmpty(redisKeyName))
+            {
+                result = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>(redisKeyName);//string 取
+                if (!string.IsNullOrEmpty(result)) return result;
+            }
+
+            if (string.IsNullOrEmpty(msg)) return result;
+
+            KiMiApiClient KiMiApi = new KiMiApiClient();
+
+            var kimiMsgs = new List<SeedMessages>() {
+                    new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
+                    new SeedMessages { Role = KimiRole.user, Content = "请将提供的三字码行程信息翻译成中文,每条信息独立一行,并在次日到达的时间后加上“+1”以表示次日。日期(星期)格式请按照“04月14日(星期一)”标注。航站楼信息请按照“T1”、“T2”、“ ”等格式标注。只输出正文数据,不要除正文数据外的任何文字以及符号。格式示例如下:\r\n1. CA445 05月17日(星期六) 成都天府 T1 - 米兰马尔彭萨 T1 01:50 06:55" },
+                    new SeedMessages { Role = KimiRole.user, Content = msg }
+                };
+
+            var kimiApiResult = await KiMiApi.SeedMessage(kimiMsgs);
+            var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
+            result = kimiApiResult_JObject["content"].ToString();
+            if (!string.IsNullOrEmpty(result))
+            {
+                TimeSpan ts = TimeSpan.FromHours(2); //过期时间 2 小时
+                await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>(redisKeyName, result, ts);//string 存
+            }
+
+            return result;
+        }
+
         #endregion
         #endregion
     }

+ 2 - 1
OASystem/OASystem.Api/appsettings.json

@@ -450,7 +450,8 @@
   "KiMiSetting": {
     "Model": "moonshot-v1-8k",
     "BaseUrl": "https://api.moonshot.cn/v1",
-    "Key": "sk-AY1Sv4rLnSUgGGHcC8SGSWYYKzGID7leZJcFfxAYozLC8dIc"
+    //"Key": "sk-AY1Sv4rLnSUgGGHcC8SGSWYYKzGID7leZJcFfxAYozLC8dIc
+    "Key": "sk-b6jgRbgU4ZtIFLkgMSjtHeU67q8OHzPTqIVuKuNLG50zd5IY" //leiyi kimi key
   },
   "OverspendAuditUser": [
     {

+ 13 - 0
OASystem/OASystem.Domain/Entities/Customer/Crm_DeleClient.cs

@@ -478,4 +478,17 @@ namespace OASystem.Domain.Entities.Customer
         public string PhD { get; set; }
     }
 
+
+    public class groupClints {
+        public int Id { get; set; }
+        public string Name { get; set; }
+        /// <summary>
+        /// 是否陪同
+        /// 1 否 2 是
+        /// 默认:1
+        /// </summary>
+        public int IsAccompany { get; set; }
+        [Encrypted]
+        public string CompanyFullName { get; set; }
+    }
 }

+ 2 - 0
OASystem/OASystem.Domain/ViewModels/Groups/AirTicketReservationsView.cs

@@ -246,6 +246,8 @@ namespace OASystem.Domain.ViewModels.Groups
     {
         public decimal jjcCurrentRate { get; set; }
         public decimal gwcCurrentRate { get; set; }
+        public decimal tdcCurrentRate { get; set; }
         public string remark { get; set; }
+        public string TripDesc { get; set; }
     }
 }

+ 7 - 1
OASystem/OASystem.Infrastructure/Repositories/PersonnelModule/GoodsRepository.cs

@@ -1162,6 +1162,11 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                     .ToArray();
             }
 
+            //全部团组
+            bool isAllGroups = false;
+            if (groupLabel.Contains(-3)) isAllGroups = true;
+
+
             //物品ID和物品名称只能传一个
             if (dto.GoodsId > 0) dto.GoodsName = string.Empty;
             if (!string.IsNullOrEmpty(dto.GoodsName)) dto.GoodsId = 0;
@@ -1192,7 +1197,8 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                 .WhereIF(auditLabel.Length > 0, (gr, gi, sd, u1, u2, di) => auditLabel.Contains((int)gr.AuditStatus))
                 .WhereIF(typeLabel.Length > 0, (gr, gi, sd, u1, u2, di) => typeLabel.Contains(gi.Type))
                 .WhereIF(userLabel.Length > 0, (gr, gi, sd, u1, u2, di) => userLabel.Contains(gr.CreateUserId))
-                .WhereIF(groupLabel.Length > 0, (gr, gi, sd, u1, u2, di) => groupLabel.Contains(gr.GroupId))
+                .WhereIF(isAllGroups, (gr, gi, sd, u1, u2, di) => gr.GroupId > 0)
+                .WhereIF(!isAllGroups && groupLabel.Length > 0, (gr, gi, sd, u1, u2, di) => groupLabel.Contains(gr.GroupId))
                 .WhereIF(beginBool && endBool, (gr, gi, sd, u1, u2, di) => gr.CreateTime >= begin && gr.CreateTime <= end)
                 .WhereIF(hrAuditPer, (gr, gi, sd, u1, u2, di) => _goodsTypeIds.Contains(gi.Type))
                 .Select((gr, gi, sd, u1, u2, di) => new GoodsReceiveListMobileView

+ 1 - 24
OASystem/OASystem.Infrastructure/Repositories/Resource/TicketBlackCodeRepository.cs

@@ -173,30 +173,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
             }
         }
 
-        /// <summary>
-        /// 三公费用提示
-        /// 使用
-        /// </summary>
-        /// <param name="diId"></param>
-        /// <returns></returns>
-        public async Task<EntryAndExitTipsView[]> EntryAndExitTips(int diId)
-        {
-            if (diId < 1) return  Array.Empty<EntryAndExitTipsView>();
-
-            var airFees = await _sqlSugar.Queryable<Air_TicketBlackCode>().Where(a => a.IsDel == 0 && a.DiId == diId).ToListAsync();
-
-            if (airFees.Any())
-            {
-                return airFees.OrderByDescending(x => x.ECPrice + x.BCPrice).Select(x => new EntryAndExitTipsView
-                {
-                    jjcCurrentRate = x.ECPrice,
-                    gwcCurrentRate = x.BCPrice,
-                    remark = $"经济舱全价:{x.ECPrice.ToString("#0.00")} 元/人 公务舱全价:{x.BCPrice.ToString("#0.00")} 元/人"
-                }).ToArray();
-            }
-
-            return Array.Empty<EntryAndExitTipsView>();
-        }
+        
 
         public Result DescBlackToVisa(int diid)
         {