Browse Source

酒店预定iOs推送通知

jiangjc 2 months ago
parent
commit
9f482c84b3

+ 45 - 44
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -108,39 +108,39 @@ namespace OASystem.API.Controllers
         private readonly OpinionaireRepository _opinionaireRep;  //对外收款账单仓库
 
         public GroupsController(
-            ILogger<GroupsController> logger, 
+            ILogger<GroupsController> logger,
             IMapper mapper,
             IHubContext<ChatHub, IChatClient> hubContext,
-            SqlSugarClient sqlSugar, 
-            GrpScheduleRepository grpScheduleRep, 
+            SqlSugarClient sqlSugar,
+            GrpScheduleRepository grpScheduleRep,
             DelegationInfoRepository groupRepository,
-            TaskAssignmentRepository taskAssignmentRep, 
-            AirTicketResRepository airTicketResRep, 
+            TaskAssignmentRepository taskAssignmentRep,
+            AirTicketResRepository airTicketResRep,
             DecreasePaymentsRepository decreasePaymentsRep,
-            InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, 
-            DelegationEnDataRepository delegationEnDataRep, 
-            EnterExitCostRepository enterExitCostRep, 
+            InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
+            DelegationEnDataRepository delegationEnDataRep,
+            EnterExitCostRepository enterExitCostRep,
             DelegationVisaRepository delegationVisaRep,
-            MessageRepository message, 
-            VisaPriceRepository visaPriceRep, 
+            MessageRepository message,
+            VisaPriceRepository visaPriceRep,
             CarTouristGuideGroundRepository carTouristGuideGroundRep,
-            CheckBoxsRepository checkBoxs, 
-            GroupCostRepository GroupCostRepository, 
+            CheckBoxsRepository checkBoxs,
+            GroupCostRepository GroupCostRepository,
             CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
             GroupCostParameterRepository GroupCostParameterRepository,
-            HotelPriceRepository hotelPriceRep, 
-            CustomersRepository customersRep, 
+            HotelPriceRepository hotelPriceRep,
+            CustomersRepository customersRep,
             SetDataRepository setDataRep,
-            TourClientListRepository tourClientListRep, 
+            TourClientListRepository tourClientListRep,
             TeamRateRepository teamRateRep,
             UsersRepository usersRep, IJuHeApiService juHeApi,
-            InvertedListRepository invertedListRep, 
-            VisaFeeInfoRepository visaFeeInfoRep, 
-            TicketBlackCodeRepository ticketBlackCodeRep, 
+            InvertedListRepository invertedListRep,
+            VisaFeeInfoRepository visaFeeInfoRep,
+            TicketBlackCodeRepository ticketBlackCodeRep,
             HotelInquiryRepository hotelInquiryRep,
-            ThreeCodeRepository threeCodeRepository, 
-            FeeAuditRepository feeAuditRep, 
-            VisaCommissionRepository visaCommissionRep, 
+            ThreeCodeRepository threeCodeRepository,
+            FeeAuditRepository feeAuditRep,
+            VisaCommissionRepository visaCommissionRep,
             ForeignReceivablesRepository ffrRep,
             OpinionaireRepository opinionaireRep
             )
@@ -820,7 +820,7 @@ namespace OASystem.API.Controllers
                     await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
 
                     //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
-                    List<int> _managerIds = new List<int>() { 21,22, 32 };
+                    List<int> _managerIds = new List<int>() { 21, 22, 32 };
                     var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
                     if (userIds.Count > 0)
                     {
@@ -1881,7 +1881,7 @@ FROM
                             entity.PayMoney = czInfo.Price * czInfo.PriceCount;
                             entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
                         }
-                        
+
                     }
 
                     /*
@@ -3806,7 +3806,7 @@ FROM
             foreach (DataRow item in dt.Rows)
             {
                 var otaOrderNo = item["OTAOrderNo"].ToString();
-                var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) &&  x.OTAOrderNo.Contains(otaOrderNo));
+                var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
                 if (oaData == null) continue;
 
                 item["GroupName"] = oaData.TeamName;
@@ -3999,7 +3999,7 @@ FROM
                             catch (Exception)
                             {
 
-                            files = new List<string>() { info.Attachment }.ToArray();
+                                files = new List<string>() { info.Attachment }.ToArray();
                             }
                         }
                         if (files.Length > 0)
@@ -4009,7 +4009,7 @@ FROM
                             string filePath2 = string.Empty;
                             if (files1.Length > 0)
                             {
-                                filePath2 = JsonConvert.SerializeObject( files1);
+                                filePath2 = JsonConvert.SerializeObject(files1);
                             }
 
                             id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
@@ -4018,16 +4018,16 @@ FROM
                                                 .ExecuteCommandAsync();
                         }
                     }
-            }
+                }
                 if (id != 0)
-            {
-                return Ok(JsonView(true, "成功!"));
-            }
-            else
-            {
-                return Ok(JsonView(false, "失败!"));
+                {
+                    return Ok(JsonView(true, "成功!"));
+                }
+                else
+                {
+                    return Ok(JsonView(false, "失败!"));
+                }
             }
-        }
             catch (Exception ex)
             {
                 return Ok(JsonView(false, "程序错误!"));
@@ -4175,7 +4175,7 @@ FROM
                 }
             }
 
-            return Ok(JsonView(new {url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
+            return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
         }
 
         /// <summary>
@@ -5231,7 +5231,7 @@ FROM
                 string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
                 await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
                 //汇率信息记录
-                await GeneralMethod.RateRecordSave(dto.UserId,sign,"出入境费用");
+                await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
 
                 return Ok(JsonView(true, data.Msg, data.Data));
             }
@@ -5300,7 +5300,7 @@ FROM
                 var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
                 if (_EnterExitCosts == null)
                 {
-                    return Ok(JsonView(400, "该团组未填写出入境费用;",""));
+                    return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
                 }
 
                 //数据源
@@ -5673,7 +5673,7 @@ FROM
                         string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
 
                         if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
-                        else if (dto.PortType == 2 ) return Ok(JsonView(true, "成功", url));
+                        else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
                     }
                     else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
                     {
@@ -5897,7 +5897,7 @@ FROM
                         string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
 
                         if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
-                        else if (dto.PortType == 2 ) return Ok(JsonView(true, "成功", url));
+                        else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
                     }
                     else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
                     {
@@ -6578,7 +6578,7 @@ FROM
                     {
                         if (DeleClientList.Count < 1)
                         {
-                            return Ok(JsonView(false, "团组成员暂未录入!!!",""));
+                            return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
                         }
 
                         //获取模板
@@ -11057,6 +11057,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)
@@ -12264,7 +12265,7 @@ ORDER by  gctggrc.id DESC
             if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
             var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
             var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
-            
+
             var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
             //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
             if (_GroupCostParameter == null)
@@ -12474,7 +12475,7 @@ ORDER by  gctggrc.id DESC
                 var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
                 designer.SetDataSource("TourNo", groupInfo.TourCode);
 
-               var rateDatas1 = rateDatas.Distinct();
+                var rateDatas1 = rateDatas.Distinct();
                 var rateStr = string.Empty;
                 foreach (var item in rateDatas1)
                 {
@@ -15943,7 +15944,7 @@ And (UnitName != '' Or UnitName != null) {sqlWhere}");
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> OpinionaireManageList(int groupId)
         {
-            if (groupId < 1) Ok(JsonView(false,"请传入有效的diId"));
+            if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
 
             var data = await _opinionaireRep.Query(x => x.DiId == groupId)
                  .Select(x => new
@@ -15997,7 +15998,7 @@ And (UnitName != '' Or UnitName != null) {sqlWhere}");
                 var upd = await _opinionaireRep._sqlSugar
                     .Updateable(updData)
                     .UpdateColumns(x => new { x.CityName, x.TourGuideName })
-                    .WhereColumns(x =>new{ x.Id})
+                    .WhereColumns(x => new { x.Id })
                     .ExecuteCommandAsync();
             }
             _opinionaireRep.CommitTran();

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

@@ -2344,7 +2344,7 @@ OPTION (MAXRECURSION 0); -- 允许无限递归      ";
             var jw = JsonView(false);
 
 
-            APNsLib.pushMsg("com.panamerican.oa2024", "db151df1d25823f84323c4597c5672460a983d49ba039c7ff54c4c8e36edd5c6", NotificationType.Alert, "测试", "测试字标题", "测试内容");
+            APNsLib.pushMsg("com.panamerican.oa2024", "9a624f38602a8d2cc12b8c44c3cb37633e246963ec2bfd7bca2094b59dc9f09c", NotificationType.Alert, "Ver.Production测试", "测试字标题", "测试内容");
 
             return Ok(jw);
         }

+ 23 - 5
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -5,6 +5,7 @@ using Aspose.Words.Layout;
 using Aspose.Words.Saving;
 using Microsoft.AspNetCore.SignalR;
 using Microsoft.International.Converters.PinYinConverter;
+using OASystem.API.OAMethodLib.APNs;
 using OASystem.API.OAMethodLib.File;
 using OASystem.API.OAMethodLib.Hub.HubClients;
 using OASystem.API.OAMethodLib.Hub.Hubs;
@@ -19,6 +20,7 @@ using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.JuHeExchangeRate;
 using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Groups;
+using OASystem.Infrastructure.Repositories.Login;
 using OfficeOpenXml;
 using System.Data;
 using System.IdentityModel.Tokens.Jwt;
@@ -36,10 +38,11 @@ namespace OASystem.API.OAMethodLib
         private static readonly SetDataRepository _setDataRep = AutofacIocManager.Instance.GetService<SetDataRepository>();
         private static readonly TableOperationRecordRepository _tableOperationRecordRep = AutofacIocManager.Instance.GetService<TableOperationRecordRepository>();
         private static readonly MessageRepository _messageRep = AutofacIocManager.Instance.GetService<MessageRepository>();
+        private static readonly DeviceTokenRepository _deviceTokenRep = AutofacIocManager.Instance.GetService<DeviceTokenRepository>();
         private static readonly IHubContext<ChatHub, IChatClient> _hubContext = AutofacIocManager.Instance.GetService<IHubContext<ChatHub, IChatClient>>();
 
         private readonly static string[] weekdays = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
-        
+
         #region 员工注册默认添加基础页面
 
         /// <summary>
@@ -436,7 +439,7 @@ namespace OASystem.API.OAMethodLib
         /// <returns></returns>
         public static async Task<List<Web_ShareGroupInfoView>> PostOperationAuthReturnGroupInfosAsync(int userId, int CTable)
         {
-           var shareGroupInfoViews = new List<Web_ShareGroupInfoView>();
+            var shareGroupInfoViews = new List<Web_ShareGroupInfoView>();
             var taskData = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.UId == userId && it.CTId == CTable && it.IsDel == 0).ToList();
 
             if (taskData.Count < 1) return shareGroupInfoViews;
@@ -726,8 +729,8 @@ namespace OASystem.API.OAMethodLib
 
 
             //98  其他款项  --> 总经办部门(1) 总经理(1) 岗位/国交部门(7)(ALL) 岗位/财务部门(3)(ALL) 岗位/策划部门(5)(ALL) 岗位/人事部门(4) 采购(74) 岗位
-           var depIds = new List<int>() { 7, 3, 5 };
-           var jobIds = new List<int>() { 1, 74 };
+            var depIds = new List<int>() { 7, 3, 5 };
+            var jobIds = new List<int>() { 1, 74 };
             groupsTaskAssignments.AddRange(
                 usersData
                 .Where(it => depIds.Contains(it.DepId) || jobIds.Contains(it.JobPostId))
@@ -895,7 +898,7 @@ namespace OASystem.API.OAMethodLib
             //数据源
             var stayData = dayAndCosts.Where(it => it.Type == 1).ToList();          //住宿费
             var mealData = dayAndCosts.Where(it => it.Type == 2).ToList();          //伙食费
-            var miscellaneousData =dayAndCosts.Where(it => it.Type == 3).ToList();  //公杂费
+            var miscellaneousData = dayAndCosts.Where(it => it.Type == 3).ToList();  //公杂费
             var trainData = dayAndCosts.Where(it => it.Type == 4).ToList();         //培训费
 
             //筛选 陪同人员 = 1
@@ -4438,6 +4441,21 @@ namespace OASystem.API.OAMethodLib
         }
 
 
+        #endregion
+
+        #region iOS推送通知
+
+        public static async Task<bool> iOS_PushNotifications(string Numbers, string title, string subtitle, string body)
+        {
+            var rst = await _deviceTokenRep.Query(s => s.Number == Numbers).SingleAsync();
+
+            if (rst != null) {
+                APNsLib.pushMsg("com.panamerican.oa2024", rst.DeviceToken, NotificationType.Alert, title, subtitle, body);
+            }
+            return false;
+        }
+
+
         #endregion
 
     }