12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109 |
- using EyeSoft.Runtime.InteropServices;
- using NPOI.SS.Formula.Functions;
- 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;
- using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
- 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="diId"></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>
- /// <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 市场部新增客户资源统计
- /// <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>
- /// <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="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="sign"></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="sign"></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;
- }
- #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
- }
- }
|