123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200 |
- 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<IQiYeWeChatApiService>();
- private static readonly DelegationInfoRepository _grpDeleRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
- #region 获取企微Id
- public static List<string> GetQiyeChatUserIdList(List<string> userId)
- {
- List<string> result = new List<string>();
- try
- {
- foreach (string item in userId)
- {
- int uid = int.Parse(item);
- Sys_Users users = _grpDeleRep.Query<Sys_Users>(s => s.Id == uid).First();
- if (!string.IsNullOrEmpty(users.QiyeChatUserId))
- {
- result.Add(users.QiyeChatUserId);
- }
- }
- }
- catch (Exception ex)
- {
- }
- return result;
- }
- #endregion
- #region 确认出团
- /// <summary>
- /// 向指定群聊发送- 确认出团 -通知
- /// </summary>
- /// <param name="diId"></param>
- /// <param name="qwEnum"></param>
- /// <returns></returns>
- public static async Task<bool> SendChatMsg_GroupStatus_Create(int diId, QiyeWeChatEnum qwEnum)
- {
- Grp_DelegationInfo entity = _grpDeleRep.Query<Grp_DelegationInfo>(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<Sys_SetData>(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;
- }
- /// <summary>
- /// 向指定用户发送- 确认出团 -通知
- /// </summary>
- /// <param name="diId"></param>
- /// <param name="userId"></param>
- /// <returns></returns>
- public static async Task<bool> SendUserMsg_GroupStatus_Create(int diId, List<string> userId)
- {
- Grp_DelegationInfo entity = _grpDeleRep.Query<Grp_DelegationInfo>(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<Sys_SetData>(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<string> 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 团组费用审核
- /// <summary>
- /// 向指定群聊发送- 费用申请 -通知
- /// </summary>
- /// <param name="Grp_CreditCardPaymentId"></param>
- /// <param name="sign"></param>
- /// <param name="qwEnum"></param>
- /// <returns></returns>
- public static async Task<bool> SendChatMsg_GroupStatus_ApplyFee(int Grp_CreditCardPaymentId, int sign, QiyeWeChatEnum qwEnum)
- {
- string chatId = qwEnum.GetEnumDescription();
- Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
- Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
- Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
- string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
- List<Grp_CreditCardPayment> entityList = _grpDeleRep
- .Query<Grp_CreditCardPayment>(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<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
- info.CreateDt = _HotelReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
- info.CreateDt = _CarTouristGuideGroundReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
- Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
- info.CreateDt = _VisaInfos.CreateTime.ToString("yyyy-MM-dd HH:mm");
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
- info.CreateDt = _InvitationOfficialActivities.CreateTime.ToString("yyyy-MM-dd HH:mm");
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
- Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
- info.CreateDt = _Customers.CreateTime.ToString("yyyy-MM-dd HH:mm");
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
- info.CreateDt = _AirTicketReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
- info.CreateDt = _DecreasePayments.CreateTime.ToString("yyyy-MM-dd HH:mm");
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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;
- }
- /// <summary>
- /// 向财务群发送费用审核结果通知(审核通过条件下发送)
- /// </summary>
- /// <param name="Grp_CreditCardPaymentId"></param>
- /// <param name="qwEnum"></param>
- /// <returns></returns>
- public static async Task<bool> SendChatMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, QiyeWeChatEnum qwEnum)
- {
- string chatId = qwEnum.GetEnumDescription();
- Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
- Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
- Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(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<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
- Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
- Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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;
- }
- /// <summary>
- /// 向指定用户发送-团组费用审核结果
- /// </summary>
- /// <param name="Grp_CreditCardPaymentId"></param>
- /// <param name="userId"></param>
- /// <param name="qwEnum"></param>
- /// <returns></returns>
- public static async Task<bool> SendUserMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, List<string> userId, QiyeWeChatEnum qwEnum)
- {
- Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
- Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
- Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(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<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
- Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
- Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
- info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
- info.PriceModule = "其他款项";
- info.PriceName = _DecreasePayments.PriceName;
- }
- #endregion
- //发送信息
- List<string> 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;
- }
- /// <summary>
- /// 向指定用户发送-团组费用支付结果
- /// </summary>
- /// <param name="Grp_CreditCardPaymentId"></param>
- /// <param name="userId"></param>
- /// <returns></returns>
- public static async Task<bool> SendUserMsg_GroupStatus_PayResult(int Grp_CreditCardPaymentId, List<string> userId)
- {
- //, QiyeWeChatEnum qiyeWeChat
- Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
- Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
- Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(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<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
- info.PriceModule = "酒店预订";
- info.PriceName = _HotelReservations.HotelName;
- }
- else if (ccp.CTable == 79) //79://车/导游地接
- {
- Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
- info.PriceModule = "车/导游地接";
- info.PriceName = _CarTouristGuideGroundReservations.PriceName;
- }
- else if (ccp.CTable == 80) //签证
- {
- List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
- Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
- info.PriceModule = "签证";
- info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
- }
- else if (ccp.CTable == 81)//邀请/公务活动
- {
- Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
- info.PriceModule = "邀请/公务活动";
- info.PriceName = _InvitationOfficialActivities.InviterArea;
- }
- else if (ccp.CTable == 82)//团组客户保险
- {
- List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
- Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
- info.PriceModule = "团组客户保险";
- info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
- }
- else if (ccp.CTable == 85) //机票预订
- {
- Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
- info.PriceModule = "机票预订";
- info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
- }
- else if (ccp.CTable == 98) //其他款项
- {
- Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
- info.PriceModule = "其他款项";
- info.PriceName = _DecreasePayments.PriceName;
- }
- #endregion
- //发送信息
- List<string> 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<bool> SendChatMsg_GroupRemindersToCaiwu(List<Grp_DelegationInfo> list_7day, List<Grp_DelegationInfo> list_3day, List<Grp_DelegationInfo> 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<bool> SendChatMsg_GroupRemindersToGuojiao(List<Grp_DelegationInfo> 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<bool> SendUserMsg_DelegationVisit_ToHR(List<Grp_DelegationInfo> list_3day, List<string> userId)
- {
- //发送信息
- List<string> 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 市场部新增客户资源统计
- /// <summary>
- /// 周统计
- /// </summary>
- /// <param name="sourceList"></param>
- /// <param name="userId"></param>
- /// <param name="begin"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- public static async Task<bool> SendUserMsg_CRMStatistics_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end)
- {
- //发送信息
- List<string> 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;
- }
- /// <summary>
- /// 月统计
- /// </summary>
- /// <param name="sourceList"></param>
- /// <param name="userId"></param>
- /// <param name="begin"></param>
- /// <param name="end"></param>
- /// <param name="totalInsert"></param>
- /// <param name="totalDelete"></param>
- /// <returns></returns>
- public static async Task<bool> SendUserMsg_CRMStatistics_Month_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end, int totalInsert, int totalDelete)
- {
- //发送信息
- List<string> 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 日付申请审核
- /// <summary>
- /// 日付申请提交时推送财务群
- /// </summary>
- /// <param name="dailyPayId"></param>
- /// <param name="sign"></param>
- /// <param name="qwEnum"></param>
- /// <returns></returns>
- public static async Task<bool> DailyPayReminders_Create_ToCaiwuChat(int dailyPayId, int sign, QiyeWeChatEnum qwEnum)
- {
- string chatId = qwEnum.GetEnumDescription();
- Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<Sys_SetData>(s => s.Id == fin_DailyFeePayment.TransferTypeId).First();
- Sys_SetData sd_priceType = _grpDeleRep.Query<Sys_SetData>(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;
- }
- /// <summary>
- /// 日付申请审核结果推送给申请人
- /// </summary>
- /// <param name="dailyPayId"></param>
- /// <param name="userId"></param>
- /// <param name="qwEnum"></param>
- /// <returns></returns>
- public static async Task<bool> DailyPayReminder_Audit_ToUser(int dailyPayId, List<string> userId, QiyeWeChatEnum qwEnum)
- {
- Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
- Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
- Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(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<string> 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;
- }
- /// <summary>
- /// 日付申请已付款推送给申请人
- /// </summary>
- /// <returns></returns>
- public static async Task<bool> DailyPayReminder_Pay_ToUser(int dailyPayId, List<string> userId)
- {
- Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(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<string> 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 三公费用更改通知
- /// <summary>
- /// 三公费用更改通知发送总经理(21)
- /// </summary>
- /// <param name="diId"></param>
- /// <param name="receivedUserIds"></param>
- /// <param name="updateUserId"></param>
- /// <param name="url"></param>
- /// <returns></returns>
- public static async Task<bool> SendUserMsg_GroupShare_ToGM(int diId, List<string> receivedUserIds, int updateUserId, string url)
- {
- Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(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<Sys_Users>(s => s.Id == updateUserId).First()?.CnName ?? "-",
- Url = url
- };
- if (receivedUserIds.Count > 0)
- {
- List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
- ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToGM(info));
- if (result.errcode != 0)
- {
- //抄送日志
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 三公费用确认通知发送财务部人员
- /// </summary>
- /// <param name="diId"></param>
- /// <returns></returns>
- public static async Task<bool> SendUserMsg_GroupShare_ToFinance(int diId)
- {
- Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
- GroupShare_ToUserModel info = new GroupShare_ToUserModel()
- {
- RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
- TeamName = groupInfo.TeamName
- };
- List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 3).Select(x => x.Id.ToString()).ToList();
- var defaultUserIds = new List<string>() { "208", "233" };
- receivedUserIds.AddRange(defaultUserIds);
- if (receivedUserIds.Contains("150")) receivedUserIds.Remove("150");
- if (receivedUserIds.Count > 0)
- {
- List<string> 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
- /// <summary>
- /// 机票行程代码录入变更通知发送国交经理、主管、王鸽
- /// </summary>
- /// <param name="diId"></param>
- /// <param name="operationId"></param>
- /// <returns></returns>
- public static async Task<bool> SendUserMsg_GroupShare_ToDP(int diId, int operationId)
- {
- Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
- var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
- var defaultJobPostIds = new List<int>() { 22, 32 };
- List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && defaultJobPostIds.Contains(s.JobPostId)).Select(x => x.Id.ToString()).ToList();
- var defaultUserIds = new List<string>() { "208", "233" };
- receivedUserIds.AddRange(defaultUserIds);
- if (receivedUserIds.Count > 0)
- {
- List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
- string resMsg = string.Format(@" `机票行程代码已调整更新通知`
- >团组:<font color='info'>{0}</font>
- >操作人员:<font color='comment'>{1}</font>
- >操作时间:<font color='comment'>{2}</font>
- [详细信息请前往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 公务出访数据变更发送通知
- /// <summary>
- /// 机票行程代码录入变更通知发送国交经理、主管、王鸽
- /// </summary>
- /// <param name="diId"></param>
- /// <param name="operationId"></param>
- /// <returns></returns>
- public static async Task<bool> SendUserMsg_GroupShare_ToOP(int diId, int operationId)
- {
- Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
- var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
- var defaultJobPostIds = new List<int>();
- List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && s.JobPostId == 28).Select(x => x.Id.ToString()).ToList();
- var defaultUserIds = new List<string>() { "208", "233" };
- receivedUserIds.AddRange(defaultUserIds);
- if (receivedUserIds.Count > 0)
- {
- List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
- string resMsg = string.Format(@" `公务出访有数据更新通知`
- >团组:<font color='info'>{0}</font>
- >操作人员:<font color='comment'>{1}</font>
- >操作时间:<font color='comment'>{2}</font>
- [详细信息请前往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 成本通知
- /// <summary>
- /// 成本通知发送给对应岗位用户
- /// </summary>
- /// <param name="diId"></param>
- /// <returns></returns>
- public static async Task<bool> SendUserMsg_GroupShare_ToJob(int diId)
- {
- Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
- List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 24 || s.JobPostId == 25 || s.JobPostId == 28)).ToList();
- //List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 40 || s.JobPostId == 41)).ToList();
- List<string> userIds = new List<string>();
- list_user.ForEach(s => userIds.Add(s.Id.ToString()));
- List<string> 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<bool> SendUserMsg_blackAirInfo_ToVisaUser(int diId, List<CountryDataTime> arr)
- {
- Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
- var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
- .Select(x => x.Id)
- .ToList();
- List<string> userIds = new List<string>() { "235" };
- userIds.AddRange(visaUser.Select(x => x.ToString()));
- List<string> 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<bool> SendUserMsg_GroupTimeInfo_ToVisaUser(int diId, string startTime, string endTime)
- {
- Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
- var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
- .Select(x => x.Id)
- .ToList();
- List<string> userIds = new List<string>() { "235" };
- userIds.AddRange(visaUser.Select(x => x.ToString()));
- List<string> 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<SimplClientInfo> 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<SimplClientInfo> 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<SimplClientInfo> arr = _grpDeleRep._sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
- return arr;
- }
- #endregion
- }
- }
|