using OASystem.Domain.Dtos.Groups; using OASystem.Domain.Entities.Financial; using OASystem.Domain.Entities.Groups; using OASystem.Domain.ViewModels.CRM; using OASystem.Domain.ViewModels.Groups; using OASystem.Domain.ViewModels.QiYeWeChat; using OASystem.Infrastructure.Repositories.Groups; namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice { public static class AppNoticeLibrary { private static readonly IQiYeWeChatApiService _qiYeWeChatApiService = AutofacIocManager.Instance.GetService(); private static readonly DelegationInfoRepository _grpDeleRep = AutofacIocManager.Instance.GetService(); #region 获取企微Id public static List GetQiyeChatUserIdList(List userId) { List result = new List(); try { foreach (string item in userId) { int uid = int.Parse(item); Sys_Users users = _grpDeleRep.Query(s => s.Id == uid).First(); if (!string.IsNullOrEmpty(users.QiyeChatUserId)) { result.Add(users.QiyeChatUserId); } } } catch (Exception ex) { } return result; } #endregion #region 确认出团 /// /// 向指定群聊发送- 确认出团 -通知 /// /// /// /// public static async Task SendChatMsg_GroupStatus_Create(int diId, QiyeWeChatEnum qwEnum) { Grp_DelegationInfo entity = _grpDeleRep.Query(s => s.Id == diId).First(); string dateRange = string.Format(@"{0}至{1}", entity.VisitStartDate.ToString("yyyy-MM-dd"), entity.VisitEndDate.ToString("yyyy-MM-dd")); string grpTypeStr = (_grpDeleRep.Query(s => s.Id == entity.TeamDid).First()).Name; GroupStatus_CreateModel info = new GroupStatus_CreateModel() { ClientName = entity.ClientName, ClientUnit = entity.ClientUnit, TeamName = entity.TeamName, VisitDays = entity.VisitDays, VisitPNumber = entity.VisitPNumber, VisitDateRange = dateRange, TeamDid_Text = grpTypeStr }; string chatId = qwEnum.GetEnumDescription(); //发送信息 ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupStatus_Create(info)); if (result.errcode != 0) { //抄送日志 return false; } return true; } /// /// 向指定用户发送- 确认出团 -通知 /// /// /// /// public static async Task SendUserMsg_GroupStatus_Create(int diId, List userId) { Grp_DelegationInfo entity = _grpDeleRep.Query(s => s.Id == diId).First(); string dateRange = string.Format(@"{0}至{1}", entity.VisitStartDate.ToString("yyyy-MM-dd"), entity.VisitEndDate.ToString("yyyy-MM-dd")); string grpTypeStr = (_grpDeleRep.Query(s => s.Id == entity.TeamDid).First()).Name; GroupStatus_CreateModel info = new GroupStatus_CreateModel() { ClientName = entity.ClientName, ClientUnit = entity.ClientUnit, TeamName = entity.TeamName, VisitDays = entity.VisitDays, VisitPNumber = entity.VisitPNumber, VisitDateRange = dateRange, TeamDid_Text = grpTypeStr }; //发送信息 List qwUserIdList = GetQiyeChatUserIdList(userId); if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupStatus_Create(info)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } #endregion #region 团组费用审核 /// /// 向指定群聊发送- 费用申请 -通知 /// /// /// /// public static async Task SendChatMsg_GroupStatus_ApplyFee(int Grp_CreditCardPaymentId, int sign, QiyeWeChatEnum qwEnum) { string chatId = qwEnum.GetEnumDescription(); Grp_CreditCardPayment ccp = _grpDeleRep.Query(s => s.Id == Grp_CreditCardPaymentId).First(); Grp_DelegationInfo group = _grpDeleRep.Query(s => s.Id == ccp.DIId).First(); Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query(s => s.Id == ccp.PaymentCurrency).First(); string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name); List entityList = _grpDeleRep .Query(s => s.DIId == ccp.DIId && s.IsDel == 0 && s.CreateUserId > 0 && s.IsAuditGM == 0) .ToList(); GroupStatus_ApplyFeeModel info = new GroupStatus_ApplyFeeModel() { QueueCount = entityList.Count, TeamName = group.TeamName, Price = priceStr }; if (sign == 2) { info.TitleStr = "[更新]一项费用待审核"; } //CTable #region CTable if (ccp.CTable == 76)//76,酒店预订 { Grp_HotelReservations _HotelReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.CreateDt = _HotelReservations.CreateTime.ToString("yyyy-MM-dd HH:mm"); Sys_Users user = _grpDeleRep.Query(s => s.Id == _HotelReservations.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "酒店预订"; info.PriceName = _HotelReservations.HotelName; } else if (ccp.CTable == 79) //79://车/导游地接 { Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.CreateDt = _CarTouristGuideGroundReservations.CreateTime.ToString("yyyy-MM-dd HH:mm"); Sys_Users user = _grpDeleRep.Query(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "车/导游地接"; info.PriceName = _CarTouristGuideGroundReservations.PriceName; } else if (ccp.CTable == 80) //签证 { List clientNameList = getSimplClientList(group.Id); Grp_VisaInfo _VisaInfos = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.CreateDt = _VisaInfos.CreateTime.ToString("yyyy-MM-dd HH:mm"); Sys_Users user = _grpDeleRep.Query(s => s.Id == _VisaInfos.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "签证"; info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient); } else if (ccp.CTable == 81)//邀请/公务活动 { Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.CreateDt = _InvitationOfficialActivities.CreateTime.ToString("yyyy-MM-dd HH:mm"); Sys_Users user = _grpDeleRep.Query(s => s.Id == _InvitationOfficialActivities.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "邀请/公务活动"; info.PriceName = _InvitationOfficialActivities.InviterArea; } else if (ccp.CTable == 82)//团组客户保险 { List clientNameList = getSimplClientList(group.Id); Grp_Customers _Customers = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.CreateDt = _Customers.CreateTime.ToString("yyyy-MM-dd HH:mm"); Sys_Users user = _grpDeleRep.Query(s => s.Id == _Customers.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "团组客户保险"; info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName); } else if (ccp.CTable == 85) //机票预订 { Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.CreateDt = _AirTicketReservations.CreateTime.ToString("yyyy-MM-dd HH:mm"); Sys_Users user = _grpDeleRep.Query(s => s.Id == _AirTicketReservations.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "机票预订"; info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")"; } else if (ccp.CTable == 98) //其他款项 { Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.CreateDt = _DecreasePayments.CreateTime.ToString("yyyy-MM-dd HH:mm"); Sys_Users user = _grpDeleRep.Query(s => s.Id == _DecreasePayments.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "其他款项"; info.PriceName = _DecreasePayments.PriceName; } #endregion //发送信息 ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupStatus_ApplyFee(info)); if (result.errcode != 0) { //抄送日志 return false; } return true; } /// /// 向财务群发送费用审核结果通知(审核通过条件下发送) /// /// /// /// public static async Task SendChatMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, QiyeWeChatEnum qwEnum) { string chatId = qwEnum.GetEnumDescription(); Grp_CreditCardPayment ccp = _grpDeleRep.Query(s => s.Id == Grp_CreditCardPaymentId).First(); Grp_DelegationInfo group = _grpDeleRep.Query(s => s.Id == ccp.DIId).First(); Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query(s => s.Id == ccp.PaymentCurrency).First(); string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name); AuditResult_ApplyFee_GroupModel info = new AuditResult_ApplyFee_GroupModel() { TeamName = group.TeamName, Price = priceStr, GMAuditDate = "-" }; DateTime gmAuditDt; bool bGMAuditDt = DateTime.TryParse(ccp.AuditGMDate, out gmAuditDt); info.GMAuditDate = gmAuditDt.ToString("yyyy-MM-dd HH:mm"); //CTable #region CTable if (ccp.CTable == 76)//76,酒店预订 { Grp_HotelReservations _HotelReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _HotelReservations.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "酒店预订"; info.PriceName = _HotelReservations.HotelName; } else if (ccp.CTable == 79) //79://车/导游地接 { Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "车/导游地接"; info.PriceName = _CarTouristGuideGroundReservations.PriceName; } else if (ccp.CTable == 80) //签证 { List clientNameList = getSimplClientList(group.Id); Grp_VisaInfo _VisaInfos = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _VisaInfos.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "签证"; info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient); } else if (ccp.CTable == 81)//邀请/公务活动 { Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _InvitationOfficialActivities.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "邀请/公务活动"; info.PriceName = _InvitationOfficialActivities.InviterArea; } else if (ccp.CTable == 82)//团组客户保险 { List clientNameList = getSimplClientList(group.Id); Grp_Customers _Customers = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _Customers.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "团组客户保险"; info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName); } else if (ccp.CTable == 85) //机票预订 { Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _AirTicketReservations.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "机票预订"; info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")"; } else if (ccp.CTable == 98) //其他款项 { Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _DecreasePayments.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "其他款项"; info.PriceName = _DecreasePayments.PriceName; } #endregion //发送信息 ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.AuditResult_ApplyFee_Chat(info)); if (result.errcode != 0) { //抄送日志 return false; } return true; } /// /// 向指定用户发送-团组费用审核结果 /// /// /// /// public static async Task SendUserMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, List userId, QiyeWeChatEnum qwEnum) { Grp_CreditCardPayment ccp = _grpDeleRep.Query(s => s.Id == Grp_CreditCardPaymentId).First(); Grp_DelegationInfo group = _grpDeleRep.Query(s => s.Id == ccp.DIId).First(); Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query(s => s.Id == ccp.PaymentCurrency).First(); string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name); AuditResult_ApplyFee_GroupModel info = new AuditResult_ApplyFee_GroupModel() { TeamName = group.TeamName, Price = priceStr, GMAuditDate = "-" }; DateTime gmAuditDt; bool bGMAuditDt = DateTime.TryParse(ccp.AuditGMDate, out gmAuditDt); info.GMAuditDate = gmAuditDt.ToString("yyyy-MM-dd HH:mm"); if (ccp.IsAuditGM == 2) { info.Result = "总经理审核未通过"; info.ResultColor = "warning"; } //CTable #region CTable if (ccp.CTable == 76)//76,酒店预订 { Grp_HotelReservations _HotelReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _HotelReservations.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "酒店预订"; info.PriceName = _HotelReservations.HotelName; } else if (ccp.CTable == 79) //79://车/导游地接 { Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "车/导游地接"; info.PriceName = _CarTouristGuideGroundReservations.PriceName; } else if (ccp.CTable == 80) //签证 { List clientNameList = getSimplClientList(group.Id); Grp_VisaInfo _VisaInfos = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _VisaInfos.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "签证"; info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient); } else if (ccp.CTable == 81)//邀请/公务活动 { Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _InvitationOfficialActivities.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "邀请/公务活动"; info.PriceName = _InvitationOfficialActivities.InviterArea; } else if (ccp.CTable == 82)//团组客户保险 { List clientNameList = getSimplClientList(group.Id); Grp_Customers _Customers = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _Customers.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "团组客户保险"; info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName); } else if (ccp.CTable == 85) //机票预订 { Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _AirTicketReservations.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "机票预订"; info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")"; } else if (ccp.CTable == 98) //其他款项 { Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == _DecreasePayments.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName); info.PriceModule = "其他款项"; info.PriceName = _DecreasePayments.PriceName; } #endregion //发送信息 List qwUserIdList = GetQiyeChatUserIdList(userId); if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.AuditResult_ApplyFee_User(info)); if (ccp.IsAuditGM == 1) { await SendChatMsg_GroupStatus_AuditFee(Grp_CreditCardPaymentId, qwEnum); } if (result.errcode != 0) { //抄送日志 return false; } } return true; } /// /// 向指定用户发送-团组费用支付结果 /// /// /// /// public static async Task SendUserMsg_GroupStatus_PayResult(int Grp_CreditCardPaymentId, List userId) { //, QiyeWeChatEnum qiyeWeChat Grp_CreditCardPayment ccp = _grpDeleRep.Query(s => s.Id == Grp_CreditCardPaymentId).First(); Grp_DelegationInfo group = _grpDeleRep.Query(s => s.Id == ccp.DIId).First(); Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query(s => s.Id == ccp.PaymentCurrency).First(); string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name); PayResult_Group_ToUserModel info = new PayResult_Group_ToUserModel() { PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"), Price = priceStr, TeamName = group.TeamName }; #region CTable if (ccp.CTable == 76)//76,酒店预订 { Grp_HotelReservations _HotelReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.PriceModule = "酒店预订"; info.PriceName = _HotelReservations.HotelName; } else if (ccp.CTable == 79) //79://车/导游地接 { Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.PriceModule = "车/导游地接"; info.PriceName = _CarTouristGuideGroundReservations.PriceName; } else if (ccp.CTable == 80) //签证 { List clientNameList = getSimplClientList(group.Id); Grp_VisaInfo _VisaInfos = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.PriceModule = "签证"; info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient); } else if (ccp.CTable == 81)//邀请/公务活动 { Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.PriceModule = "邀请/公务活动"; info.PriceName = _InvitationOfficialActivities.InviterArea; } else if (ccp.CTable == 82)//团组客户保险 { List clientNameList = getSimplClientList(group.Id); Grp_Customers _Customers = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.PriceModule = "团组客户保险"; info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName); } else if (ccp.CTable == 85) //机票预订 { Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.PriceModule = "机票预订"; info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")"; } else if (ccp.CTable == 98) //其他款项 { Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query(s => s.Id == ccp.CId).First(); info.PriceModule = "其他款项"; info.PriceName = _DecreasePayments.PriceName; } #endregion //发送信息 List qwUserIdList = GetQiyeChatUserIdList(userId); if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.PayResult_Group_ToUser(info)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } #endregion #region 团组出发、结束提醒(财务群) public static async Task SendChatMsg_GroupRemindersToCaiwu(List list_7day, List list_3day, List list_minus1day, QiyeWeChatEnum qwEnum) { string chatId = qwEnum.GetEnumDescription(); ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToCaiwuChat(list_7day, list_3day, list_minus1day)); if (result.errcode != 0) { //抄送日志 return false; } return true; } #endregion #region 团组结束提醒(国交群) public static async Task SendChatMsg_GroupRemindersToGuojiao(List list_3day, QiyeWeChatEnum qwEnum) { string chatId = qwEnum.GetEnumDescription(); ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToGuojiao(list_3day)); if (result.errcode != 0) { //抄送日志 return false; } return true; } #endregion #region 团组出发提醒(HR) public static async Task SendUserMsg_DelegationVisit_ToHR(List list_3day, List userId) { //发送信息 List qwUserIdList = GetQiyeChatUserIdList(userId); if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupRemindersToHR(list_3day)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } #endregion #region 市场部新增客户资源统计 /// /// 周统计 /// /// /// /// /// /// public static async Task SendUserMsg_CRMStatistics_ToHR(List sourceList, List userId, string begin, string end) { //发送信息 List qwUserIdList = GetQiyeChatUserIdList(userId); if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_ToUser(sourceList, begin, end)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } /// /// 月统计 /// /// /// /// /// /// public static async Task SendUserMsg_CRMStatistics_Month_ToHR(List sourceList, List userId, string begin, string end, int totalInsert, int totalDelete) { //发送信息 List qwUserIdList = GetQiyeChatUserIdList(userId); if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_Month_ToUser(sourceList, begin, end, totalInsert, totalDelete)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } #endregion #region 日付申请审核 /// /// 日付申请提交时推送财务群 /// /// /// /// public static async Task DailyPayReminders_Create_ToCaiwuChat(int dailyPayId, int sign, QiyeWeChatEnum qwEnum) { string chatId = qwEnum.GetEnumDescription(); Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query(s => s.Id == dailyPayId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == fin_DailyFeePayment.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); string users = string.Format(@"{0}-{1}", job.JobName, user.CnName); string[] companyArr = new string[] { "未知", "成都泛美商务有限公司", "四川泛美交流有限公司", "成都纽茵教育科技有限公司", "成都鸿企中元科技有限公司", "测试公司1" }; string companyStr = "未知"; if (fin_DailyFeePayment.CompanyId < companyArr.Length) { companyStr = companyArr[fin_DailyFeePayment.CompanyId]; } Sys_SetData sd_tansferType = _grpDeleRep.Query(s => s.Id == fin_DailyFeePayment.TransferTypeId).First(); Sys_SetData sd_priceType = _grpDeleRep.Query(s => s.Id == fin_DailyFeePayment.PriceTypeId).First(); string feeSignStr = string.Format(@"{0}-{1}", sd_tansferType.Name, sd_priceType.Name); string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00"); DailyPayReminders_Create_ToCaiwuChatModel info = new DailyPayReminders_Create_ToCaiwuChatModel() { CreateDt = fin_DailyFeePayment.CreateTime.ToString("yyyy-MM-dd HH:mm"), CreateUser = users, Price = priceStr, Company = companyStr, FeeSign = feeSignStr, PriceName = fin_DailyFeePayment.Instructions }; if (sign == 2) { info.TitleStr = "[更新]一项费用待审核"; } ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.DailyPayReminders_Create_ToCaiwuChat(info)); if (result.errcode != 0) { //抄送日志 return false; } return true; } /// /// 日付申请审核结果推送给申请人 /// /// /// /// /// public static async Task DailyPayReminder_Audit_ToUser(int dailyPayId, List userId, QiyeWeChatEnum qwEnum) { Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query(s => s.Id == dailyPayId).First(); Sys_Users user = _grpDeleRep.Query(s => s.Id == fin_DailyFeePayment.CreateUserId).First(); Sys_JobPost job = _grpDeleRep.Query(s => s.Id == user.JobPostId).First(); string users = string.Format(@"{0}-{1}", job.JobName, user.CnName); string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00"); DailyPayReminder_Audit_ToUserModel info = new DailyPayReminder_Audit_ToUserModel() { Price = priceStr, PriceName = fin_DailyFeePayment.Instructions }; if (fin_DailyFeePayment.FAudit == 1) { info.AuditDate = fin_DailyFeePayment.MAuditDate.ToString("yyyy-MM-dd HH:mm"); if (fin_DailyFeePayment.MAudit == 1) { info.Result = "你有一笔日付申请已通过审核"; info.ResultColor = "info"; //发送至财务群 DailyPayReminder_Audit_ToCaiwuChatModel chatInfo = new DailyPayReminder_Audit_ToCaiwuChatModel() { AuditDate = info.AuditDate, CreateUser = users, Price = priceStr, PriceName = fin_DailyFeePayment.Instructions }; string chatId = qwEnum.GetEnumDescription(); await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.DailyPayReminder_Audit_ToCaiwuChat(chatInfo)); } else if (fin_DailyFeePayment.MAudit == 2) { info.Result = "你有一笔日付申请未通过总经理审核"; info.ResultColor = "warning"; } } else if (fin_DailyFeePayment.FAudit == 2) { info.AuditDate = fin_DailyFeePayment.FAuditDate.ToString("yyyy-MM-dd HH:mm"); info.Result = "你有一笔日付申请未通过财务审核"; info.ResultColor = "warning"; } List qwUserIdList = GetQiyeChatUserIdList(userId); if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.DailyPayReminder_Audit_ToUser(info)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } /// /// 日付申请已付款推送给申请人 /// /// public static async Task DailyPayReminder_Pay_ToUser(int dailyPayId, List userId) { Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query(s => s.Id == dailyPayId).First(); string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00"); DailyPayReminder_Pay_ToUserModel info = new DailyPayReminder_Pay_ToUserModel() { PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"), PriceName = fin_DailyFeePayment.Instructions, Price = priceStr }; List qwUserIdList = GetQiyeChatUserIdList(userId); if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.DailyPayReminder_Pay_ToUser(info)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } #endregion #region 费用保存发送消息 #region 三公费用更改通知 /// /// 三公费用更改通知发送总经理(21) /// /// /// public static async Task SendUserMsg_GroupShare_ToGM(int diId, List receivedUserIds, int updateUserId, string url) { Grp_DelegationInfo groupInfo = _grpDeleRep.Query(s => s.Id == diId).First(); GroupShare_ToGMModel info = new GroupShare_ToGMModel() { RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"), TeamName = groupInfo.TeamName, CreateUser = _grpDeleRep.Query(s => s.Id == updateUserId).First()?.CnName ?? "-", Url = url }; if (receivedUserIds.Count > 0) { List qwUserIdList = GetQiyeChatUserIdList(receivedUserIds); ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToGM(info)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } /// /// 三公费用确认通知发送财务部人员 /// /// /// public static async Task SendUserMsg_GroupShare_ToFinance(int diId) { Grp_DelegationInfo groupInfo = _grpDeleRep.Query(s => s.Id == diId).First(); GroupShare_ToUserModel info = new GroupShare_ToUserModel() { RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"), TeamName = groupInfo.TeamName }; List receivedUserIds = _grpDeleRep.Query(s => s.IsDel == 0 && s.DepId == 3).Select(x => x.Id.ToString()).ToList(); var defaultUserIds = new List() { "208", "233" }; receivedUserIds.AddRange(defaultUserIds); if (receivedUserIds.Contains("150")) receivedUserIds.Remove("150"); if (receivedUserIds.Count > 0) { List qwUserIdList = GetQiyeChatUserIdList(receivedUserIds); ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToFinance(info)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } #endregion /// /// 机票行程代码录入变更通知发送国交经理、主管、王鸽 /// /// /// /// public static async Task SendUserMsg_GroupShare_ToDP(int diId, int operationId) { Grp_DelegationInfo groupInfo = _grpDeleRep.Query(s => s.Id == diId).First(); var operationName = _grpDeleRep.Query(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown"; var defaultJobPostIds = new List() { 22, 32 }; List receivedUserIds = _grpDeleRep.Query(s => s.IsDel == 0 && s.DepId == 7 && defaultJobPostIds.Contains(s.JobPostId)).Select(x => x.Id.ToString()).ToList(); var defaultUserIds = new List() { "208", "233" }; receivedUserIds.AddRange(defaultUserIds); if (receivedUserIds.Count > 0) { List qwUserIdList = GetQiyeChatUserIdList(receivedUserIds); string resMsg = string.Format(@" `机票行程代码已调整更新通知` >团组:{0} >操作人员:{1} >操作时间:{2} [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm")); ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg); if (result.errcode != 0) { //抄送日志 return false; } } return true; } #region 公务出访数据变更发送通知 /// /// 机票行程代码录入变更通知发送国交经理、主管、王鸽 /// /// /// /// public static async Task SendUserMsg_GroupShare_ToOP(int diId, int operationId) { Grp_DelegationInfo groupInfo = _grpDeleRep.Query(s => s.Id == diId).First(); var operationName = _grpDeleRep.Query(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown"; var defaultJobPostIds = new List(); List receivedUserIds = _grpDeleRep.Query(s => s.IsDel == 0 && s.DepId == 7 && s.JobPostId == 28).Select(x => x.Id.ToString()).ToList(); var defaultUserIds = new List() { "208", "233" }; receivedUserIds.AddRange(defaultUserIds); if (receivedUserIds.Count > 0) { List qwUserIdList = GetQiyeChatUserIdList(receivedUserIds); string resMsg = string.Format(@" `公务出访有数据更新通知` >团组:{0} >操作人员:{1} >操作时间:{2} [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm")); ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg); if (result.errcode != 0) { //抄送日志 return false; } } return true; } #endregion #endregion #region 成本通知 /// /// 成本通知发送给对应岗位用户 /// /// /// public static async Task SendUserMsg_GroupShare_ToJob(int diId) { Grp_DelegationInfo groupInfo = _grpDeleRep.Query(s => s.Id == diId).First(); List list_user = _grpDeleRep.Query(s => s.IsDel == 0 && (s.JobPostId == 24 || s.JobPostId == 25 || s.JobPostId == 28)).ToList(); //List list_user = _grpDeleRep.Query(s => s.IsDel == 0 && (s.JobPostId == 40 || s.JobPostId == 41)).ToList(); List userIds = new List(); list_user.ForEach(s => userIds.Add(s.Id.ToString())); List qwUserIdList = GetQiyeChatUserIdList(userIds); GroupShare_ToUserModel info = new GroupShare_ToUserModel() { RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"), TeamName = groupInfo.TeamName }; if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToUser(info)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } public static async Task SendUserMsg_blackAirInfo_ToVisaUser(int diId , List arr) { Grp_DelegationInfo groupInfo = _grpDeleRep.Query(s => s.Id == diId).First(); var visaUser = _grpDeleRep.Query(x => x.IsDel == 0 && x.JobPostId == 26) .Select(x => x.Id) .ToList(); List userIds = new List() { "235" }; userIds.AddRange(visaUser.Select(x=>x.ToString())); List qwUserIdList = GetQiyeChatUserIdList(userIds); BlackCodeInfo_ToVisaUser info = new BlackCodeInfo_ToVisaUser() { RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"), TeamName = groupInfo.TeamName, info = arr }; if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.BlackCodeInfo_ToVisaUser(info)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } public static async Task SendUserMsg_GroupTimeInfo_ToVisaUser(int diId, string startTime, string endTime) { Grp_DelegationInfo groupInfo = _grpDeleRep.Query(s => s.Id == diId).First(); var visaUser = _grpDeleRep.Query(x => x.IsDel == 0 && x.JobPostId == 26) .Select(x => x.Id) .ToList(); List userIds = new List() { "235" }; userIds.AddRange(visaUser.Select(x => x.ToString())); List qwUserIdList = GetQiyeChatUserIdList(userIds); GroupDateTime_ToVisaUser info = new GroupDateTime_ToVisaUser() { RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"), TeamName = groupInfo.TeamName, EndTime = endTime, StartTime = startTime, }; if (qwUserIdList.Count > 0) { ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupDateTime_ToVisaUser(info)); if (result.errcode != 0) { //抄送日志 return false; } } return true; } #endregion #region Helper private static string getClientNameStr(List list, string origin) { string result = origin; if (Regex.Match(origin, @"\d+,?").Value.Length > 0) { string[] temparr = origin.Split(','); string fistrStr = temparr[0]; int count = temparr.Count(); int tempId; bool success = int.TryParse(fistrStr, out tempId); if (success) { SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId); if (tempInfo != null) { if (count > 1) { result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count); } else { result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName); } } } } return result; } private static List getSimplClientList(int diId) { string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", diId); List arr = _grpDeleRep._sqlSugar.SqlQueryable(sql).ToList(); return arr; } #endregion } }