Library.cs 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769
  1. using OASystem.Domain.Dtos.Groups;
  2. using OASystem.Domain.Entities.Financial;
  3. using OASystem.Domain.Entities.Groups;
  4. using OASystem.Domain.Entities.PersonnelModule;
  5. using OASystem.Domain.ViewModels.CRM;
  6. using OASystem.Domain.ViewModels.Groups;
  7. using OASystem.Domain.ViewModels.QiYeWeChat;
  8. using OASystem.Infrastructure.Repositories.Groups;
  9. using OASystem.Domain.Entities.WorkOrder;
  10. using OASystem.Infrastructure.Logging;
  11. namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
  12. {
  13. public static class AppNoticeLibrary
  14. {
  15. private static readonly IQiYeWeChatApiService _qiYeWeChatApiService = AutofacIocManager.Instance.GetService<IQiYeWeChatApiService>();
  16. private static readonly DelegationInfoRepository _grpDeleRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
  17. private static readonly IGroupTextFileLogger _groupLog = AutofacIocManager.Instance.GetService<IGroupTextFileLogger>();
  18. #region 获取企微Id
  19. public static List<string> GetQiyeChatUserIdList(List<string> userId)
  20. {
  21. List<string> result = new List<string>();
  22. try
  23. {
  24. foreach (string item in userId)
  25. {
  26. int uid = int.Parse(item);
  27. Sys_Users users = _grpDeleRep._sqlSugar.Queryable<Sys_Users>().First(s => s.Id == uid);
  28. if (!string.IsNullOrEmpty(users.QiyeChatUserId))
  29. {
  30. result.Add(users.QiyeChatUserId);
  31. }
  32. }
  33. }
  34. catch (Exception ex)
  35. {
  36. }
  37. return result;
  38. }
  39. #endregion
  40. #region 确认出团
  41. /// <summary>
  42. /// 向指定群聊发送- 确认出团 -通知
  43. /// </summary>
  44. /// <param name="diId"></param>
  45. /// <param name="qwEnum"></param>
  46. /// <returns></returns>
  47. public static async Task<bool> SendChatMsg_GroupStatus_Create(int diId, QiyeWeChatEnum qwEnum)
  48. {
  49. Grp_DelegationInfo entity = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  50. string dateRange = string.Format(@"{0}至{1}", entity.VisitStartDate.ToString("yyyy-MM-dd"), entity.VisitEndDate.ToString("yyyy-MM-dd"));
  51. string grpTypeStr = (_grpDeleRep.Query<Sys_SetData>(s => s.Id == entity.TeamDid).First()).Name;
  52. GroupStatus_CreateModel info = new GroupStatus_CreateModel()
  53. {
  54. ClientName = entity.ClientName,
  55. ClientUnit = entity.ClientUnit,
  56. TeamName = entity.TeamName,
  57. VisitDays = entity.VisitDays,
  58. VisitPNumber = entity.VisitPNumber,
  59. VisitDateRange = dateRange,
  60. TeamDid_Text = grpTypeStr
  61. };
  62. string chatId = qwEnum.GetEnumDescription();
  63. //发送信息
  64. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupStatus_Create(info));
  65. if (result.errcode != 0)
  66. {
  67. //抄送日志
  68. return false;
  69. }
  70. return true;
  71. }
  72. /// <summary>
  73. /// 向指定用户发送- 确认出团 -通知
  74. /// </summary>
  75. /// <param name="diId"></param>
  76. /// <param name="userId"></param>
  77. /// <returns></returns>
  78. public static async Task<bool> SendUserMsg_GroupStatus_Create(int diId, List<string> userId)
  79. {
  80. Grp_DelegationInfo entity = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  81. string dateRange = string.Format(@"{0}至{1}", entity.VisitStartDate.ToString("yyyy-MM-dd"), entity.VisitEndDate.ToString("yyyy-MM-dd"));
  82. string grpTypeStr = (_grpDeleRep.Query<Sys_SetData>(s => s.Id == entity.TeamDid).First()).Name;
  83. GroupStatus_CreateModel info = new GroupStatus_CreateModel()
  84. {
  85. ClientName = entity.ClientName,
  86. ClientUnit = entity.ClientUnit,
  87. TeamName = entity.TeamName,
  88. VisitDays = entity.VisitDays,
  89. VisitPNumber = entity.VisitPNumber,
  90. VisitDateRange = dateRange,
  91. TeamDid_Text = grpTypeStr
  92. };
  93. //发送信息
  94. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  95. if (qwUserIdList.Count > 0)
  96. {
  97. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupStatus_Create(info));
  98. if (result.errcode != 0)
  99. {
  100. //抄送日志
  101. return false;
  102. }
  103. }
  104. return true;
  105. }
  106. #endregion
  107. #region 团组费用审核
  108. /// <summary>
  109. /// 向指定群聊发送- 费用申请 -通知
  110. /// </summary>
  111. /// <param name="creditCardId"></param>
  112. /// <param name="sign"></param>
  113. /// <param name="qwEnum"></param>
  114. /// <returns></returns>
  115. public static async Task<bool> SendChatMsg_GroupStatus_ApplyFee(int creditCardId, int sign, QiyeWeChatEnum qwEnum)
  116. {
  117. string chatId = qwEnum.GetEnumDescription();
  118. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == creditCardId).First();
  119. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  120. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  121. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  122. List<Grp_CreditCardPayment> entityList = _grpDeleRep
  123. .Query<Grp_CreditCardPayment>(s => s.DIId == ccp.DIId && s.IsDel == 0 && s.CreateUserId > 0 && s.IsAuditGM == 0)
  124. .ToList();
  125. GroupStatus_ApplyFeeModel info = new GroupStatus_ApplyFeeModel()
  126. {
  127. QueueCount = entityList.Count,
  128. TeamName = group.TeamName,
  129. Price = priceStr
  130. };
  131. if (sign == 2)
  132. {
  133. info.TitleStr = "[更新]一项费用待审核";
  134. }
  135. // CTable
  136. #region CTable
  137. if (ccp.CTable == 76)//76,酒店预订
  138. {
  139. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  140. info.CreateDt = _HotelReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  141. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  142. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  143. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  144. info.PriceModule = "酒店预订";
  145. info.PriceName = _HotelReservations.HotelName;
  146. }
  147. else if (ccp.CTable == 79) //79://车/导游地接
  148. {
  149. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  150. info.CreateDt = _CarTouristGuideGroundReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  151. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  152. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  153. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  154. info.PriceModule = "车/导游地接";
  155. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  156. }
  157. else if (ccp.CTable == 80) //签证
  158. {
  159. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  160. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  161. info.CreateDt = _VisaInfos.CreateTime.ToString("yyyy-MM-dd HH:mm");
  162. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  163. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  164. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  165. info.PriceModule = "签证";
  166. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  167. }
  168. else if (ccp.CTable == 81)//邀请/公务活动
  169. {
  170. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  171. info.CreateDt = _InvitationOfficialActivities.CreateTime.ToString("yyyy-MM-dd HH:mm");
  172. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  173. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  174. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  175. info.PriceModule = "邀请/公务活动";
  176. info.PriceName = _InvitationOfficialActivities.InviterArea;
  177. }
  178. else if (ccp.CTable == 82)//团组客户保险
  179. {
  180. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  181. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  182. info.CreateDt = _Customers.CreateTime.ToString("yyyy-MM-dd HH:mm");
  183. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  184. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  185. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  186. info.PriceModule = "团组客户保险";
  187. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  188. }
  189. else if (ccp.CTable == 85) //机票预订
  190. {
  191. var _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  192. if (_AirTicketReservations == null)
  193. {
  194. return false;
  195. }
  196. info.CreateDt = _AirTicketReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  197. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  198. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  199. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  200. info.PriceModule = "机票预订";
  201. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  202. }
  203. else if (ccp.CTable == 98) //其他款项
  204. {
  205. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  206. info.CreateDt = _DecreasePayments.CreateTime.ToString("yyyy-MM-dd HH:mm");
  207. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  208. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  209. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  210. info.PriceModule = "其他款项";
  211. info.PriceName = _DecreasePayments.PriceName;
  212. }
  213. #endregion
  214. //发送信息
  215. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupStatus_ApplyFee(info));
  216. if (result.errcode != 0)
  217. {
  218. //抄送日志
  219. return false;
  220. }
  221. return true;
  222. }
  223. /// <summary>
  224. /// 向财务群发送费用审核结果通知(审核通过条件下发送)
  225. /// </summary>
  226. /// <param name="Grp_CreditCardPaymentId"></param>
  227. /// <param name="qwEnum"></param>
  228. /// <returns></returns>
  229. public static async Task<bool> SendChatMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, QiyeWeChatEnum qwEnum)
  230. {
  231. string chatId = qwEnum.GetEnumDescription();
  232. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  233. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  234. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  235. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  236. AuditResult_ApplyFee_GroupModel info = new AuditResult_ApplyFee_GroupModel()
  237. {
  238. TeamName = group.TeamName,
  239. Price = priceStr,
  240. GMAuditDate = "-"
  241. };
  242. DateTime gmAuditDt;
  243. bool bGMAuditDt = DateTime.TryParse(ccp.AuditGMDate, out gmAuditDt);
  244. info.GMAuditDate = gmAuditDt.ToString("yyyy-MM-dd HH:mm");
  245. //CTable
  246. #region CTable
  247. if (ccp.CTable == 76)//76,酒店预订
  248. {
  249. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  250. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  251. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  252. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  253. info.PriceModule = "酒店预订";
  254. info.PriceName = _HotelReservations.HotelName;
  255. }
  256. else if (ccp.CTable == 79) //79://车/导游地接
  257. {
  258. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  259. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  260. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  261. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  262. info.PriceModule = "车/导游地接";
  263. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  264. }
  265. else if (ccp.CTable == 80) //签证
  266. {
  267. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  268. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  269. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  270. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  271. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  272. info.PriceModule = "签证";
  273. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  274. }
  275. else if (ccp.CTable == 81)//邀请/公务活动
  276. {
  277. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  278. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  279. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  280. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  281. info.PriceModule = "邀请/公务活动";
  282. info.PriceName = _InvitationOfficialActivities.InviterArea;
  283. }
  284. else if (ccp.CTable == 82)//团组客户保险
  285. {
  286. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  287. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  288. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  289. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  290. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  291. info.PriceModule = "团组客户保险";
  292. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  293. }
  294. else if (ccp.CTable == 85) //机票预订
  295. {
  296. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  297. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  298. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  299. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  300. info.PriceModule = "机票预订";
  301. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  302. }
  303. else if (ccp.CTable == 98) //其他款项
  304. {
  305. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  306. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  307. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  308. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  309. info.PriceModule = "其他款项";
  310. info.PriceName = _DecreasePayments.PriceName;
  311. }
  312. #endregion
  313. //发送信息
  314. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.AuditResult_ApplyFee_Chat(info));
  315. if (result.errcode != 0)
  316. {
  317. //抄送日志
  318. return false;
  319. }
  320. return true;
  321. }
  322. /// <summary>
  323. /// 向指定用户发送-团组费用审核结果
  324. /// </summary>
  325. /// <param name="Grp_CreditCardPaymentId"></param>
  326. /// <param name="userId"></param>
  327. /// <param name="qwEnum"></param>
  328. /// <returns></returns>
  329. public static async Task<bool> SendUserMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, List<string> userId, QiyeWeChatEnum qwEnum)
  330. {
  331. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  332. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  333. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  334. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  335. AuditResult_ApplyFee_GroupModel info = new AuditResult_ApplyFee_GroupModel()
  336. {
  337. TeamName = group.TeamName,
  338. Price = priceStr,
  339. GMAuditDate = "-"
  340. };
  341. DateTime gmAuditDt;
  342. bool bGMAuditDt = DateTime.TryParse(ccp.AuditGMDate, out gmAuditDt);
  343. info.GMAuditDate = gmAuditDt.ToString("yyyy-MM-dd HH:mm");
  344. if (ccp.IsAuditGM == 2)
  345. {
  346. info.Result = "总经理审核未通过";
  347. info.ResultColor = "warning";
  348. }
  349. //CTable
  350. #region CTable
  351. if (ccp.CTable == 76)//76,酒店预订
  352. {
  353. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  354. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  355. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  356. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  357. info.PriceModule = "酒店预订";
  358. info.PriceName = _HotelReservations.HotelName;
  359. }
  360. else if (ccp.CTable == 79) //79://车/导游地接
  361. {
  362. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  363. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  364. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  365. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  366. info.PriceModule = "车/导游地接";
  367. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  368. }
  369. else if (ccp.CTable == 80) //签证
  370. {
  371. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  372. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  373. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  374. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  375. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  376. info.PriceModule = "签证";
  377. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  378. }
  379. else if (ccp.CTable == 81)//邀请/公务活动
  380. {
  381. //默认增加王鸽ID
  382. userId.Add("149");//王鸽
  383. //userId.Add("208");//雷怡
  384. //userId.Add("5");//杨俊霄
  385. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  386. Sys_Users user = _grpDeleRep._sqlSugar.Queryable<Sys_Users>().First(s => s.Id == _InvitationOfficialActivities.CreateUserId);
  387. if (user != null)
  388. {
  389. Sys_JobPost job = _grpDeleRep._sqlSugar.Queryable<Sys_JobPost>().First(s => s.Id == user.JobPostId);
  390. info.CreateUser = string.Format(@"{0} - {1}", job?.JobName ?? "-", user.CnName);
  391. }
  392. info.PriceModule = "邀请/公务活动";
  393. info.PriceName = _InvitationOfficialActivities.InviterArea;
  394. }
  395. else if (ccp.CTable == 82)//团组客户保险
  396. {
  397. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  398. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  399. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  400. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  401. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  402. info.PriceModule = "团组客户保险";
  403. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  404. }
  405. else if (ccp.CTable == 85) //机票预订
  406. {
  407. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  408. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  409. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  410. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  411. info.PriceModule = "机票预订";
  412. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  413. }
  414. else if (ccp.CTable == 98) //其他款项
  415. {
  416. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  417. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  418. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  419. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  420. info.PriceModule = "其他款项";
  421. info.PriceName = _DecreasePayments.PriceName;
  422. }
  423. #endregion
  424. //发送信息
  425. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  426. if (qwUserIdList.Count > 0)
  427. {
  428. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.AuditResult_ApplyFee_User(info));
  429. if (ccp.IsAuditGM == 1)
  430. {
  431. await SendChatMsg_GroupStatus_AuditFee(Grp_CreditCardPaymentId, qwEnum);
  432. }
  433. if (result.errcode != 0)
  434. {
  435. //抄送日志
  436. return false;
  437. }
  438. }
  439. return true;
  440. }
  441. /// <summary>
  442. /// 向指定用户发送-团组费用支付结果
  443. /// </summary>
  444. /// <param name="Grp_CreditCardPaymentId"></param>
  445. /// <param name="userId"></param>
  446. /// <returns></returns>
  447. public static async Task<bool> SendUserMsg_GroupStatus_PayResult(int Grp_CreditCardPaymentId, List<string> userId)
  448. {
  449. //, QiyeWeChatEnum qiyeWeChat
  450. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  451. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  452. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  453. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  454. PayResult_Group_ToUserModel info = new PayResult_Group_ToUserModel()
  455. {
  456. PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  457. Price = priceStr,
  458. TeamName = group.TeamName
  459. };
  460. #region CTable
  461. if (ccp.CTable == 76)//76,酒店预订
  462. {
  463. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  464. info.PriceModule = "酒店预订";
  465. info.PriceName = _HotelReservations.HotelName;
  466. }
  467. else if (ccp.CTable == 79) //79://车/导游地接
  468. {
  469. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  470. info.PriceModule = "车/导游地接";
  471. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  472. }
  473. else if (ccp.CTable == 80) //签证
  474. {
  475. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  476. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  477. info.PriceModule = "签证";
  478. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  479. }
  480. else if (ccp.CTable == 81)//邀请/公务活动
  481. {
  482. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  483. info.PriceModule = "邀请/公务活动";
  484. info.PriceName = _InvitationOfficialActivities.InviterArea;
  485. }
  486. else if (ccp.CTable == 82)//团组客户保险
  487. {
  488. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  489. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  490. info.PriceModule = "团组客户保险";
  491. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  492. }
  493. else if (ccp.CTable == 85) //机票预订
  494. {
  495. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  496. info.PriceModule = "机票预订";
  497. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  498. }
  499. else if (ccp.CTable == 98) //其他款项
  500. {
  501. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  502. info.PriceModule = "其他款项";
  503. info.PriceName = _DecreasePayments.PriceName;
  504. }
  505. #endregion
  506. //发送信息
  507. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  508. if (qwUserIdList.Count > 0)
  509. {
  510. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.PayResult_Group_ToUser(info));
  511. if (result.errcode != 0)
  512. {
  513. //抄送日志
  514. return false;
  515. }
  516. }
  517. return true;
  518. }
  519. #endregion
  520. #region 团组出发、结束提醒(财务群)
  521. public static async Task<bool> SendChatMsg_GroupRemindersToCaiwu(List<Grp_DelegationInfo> list_7day, List<Grp_DelegationInfo> list_3day, List<Grp_DelegationInfo> list_minus1day, QiyeWeChatEnum qwEnum)
  522. {
  523. string chatId = qwEnum.GetEnumDescription();
  524. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToCaiwuChat(list_7day, list_3day, list_minus1day));
  525. if (result.errcode != 0)
  526. {
  527. //抄送日志
  528. return false;
  529. }
  530. return true;
  531. }
  532. #endregion
  533. #region 团组结束提醒(国交群)
  534. public static async Task<bool> SendChatMsg_GroupRemindersToGuojiao(List<Grp_DelegationInfo> list_3day, QiyeWeChatEnum qwEnum)
  535. {
  536. string chatId = qwEnum.GetEnumDescription();
  537. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToGuojiao(list_3day));
  538. if (result.errcode != 0)
  539. {
  540. //抄送日志
  541. return false;
  542. }
  543. return true;
  544. }
  545. #endregion
  546. #region 团组出发提醒(HR)
  547. public static async Task<bool> SendUserMsg_DelegationVisit_ToHR(List<Grp_DelegationInfo> list_3day, List<string> userId)
  548. {
  549. //发送信息
  550. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  551. if (qwUserIdList.Count > 0)
  552. {
  553. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupRemindersToHR(list_3day));
  554. if (result.errcode != 0)
  555. {
  556. //抄送日志
  557. return false;
  558. }
  559. }
  560. return true;
  561. }
  562. #endregion
  563. #region 市场部新增客户资源统计
  564. /// <summary>
  565. /// 周统计
  566. /// </summary>
  567. /// <param name="sourceList"></param>
  568. /// <param name="userId"></param>
  569. /// <param name="begin"></param>
  570. /// <param name="end"></param>
  571. /// <returns></returns>
  572. public static async Task<bool> SendUserMsg_CRMStatistics_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end)
  573. {
  574. //发送信息
  575. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  576. if (qwUserIdList.Count > 0)
  577. {
  578. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_ToUser(sourceList, begin, end));
  579. if (result.errcode != 0)
  580. {
  581. //抄送日志
  582. return false;
  583. }
  584. }
  585. return true;
  586. }
  587. /// <summary>
  588. /// 月统计
  589. /// </summary>
  590. /// <param name="sourceList"></param>
  591. /// <param name="userId"></param>
  592. /// <param name="begin"></param>
  593. /// <param name="end"></param>
  594. /// <param name="totalInsert"></param>
  595. /// <param name="totalDelete"></param>
  596. /// <returns></returns>
  597. public static async Task<bool> SendUserMsg_CRMStatistics_Month_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end, int totalInsert, int totalDelete)
  598. {
  599. //发送信息
  600. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  601. if (qwUserIdList.Count > 0)
  602. {
  603. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_Month_ToUser(sourceList, begin, end, totalInsert, totalDelete));
  604. if (result.errcode != 0)
  605. {
  606. //抄送日志
  607. return false;
  608. }
  609. }
  610. return true;
  611. }
  612. #endregion
  613. #region 日付申请审核
  614. /// <summary>
  615. /// 日付申请提交时推送财务群
  616. /// </summary>
  617. /// <param name="dailyPayId"></param>
  618. /// <param name="sign"></param>
  619. /// <param name="qwEnum"></param>
  620. /// <returns></returns>
  621. public static async Task<bool> DailyPayReminders_Create_ToCaiwuChat(int dailyPayId, int sign, QiyeWeChatEnum qwEnum)
  622. {
  623. string chatId = qwEnum.GetEnumDescription();
  624. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  625. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
  626. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  627. string users = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  628. string[] companyArr = new string[] { "未知", "成都泛美商务有限公司", "四川泛美交流有限公司", "成都纽茵教育科技有限公司", "成都鸿企中元科技有限公司", "测试公司1" };
  629. string companyStr = "未知";
  630. if (fin_DailyFeePayment.CompanyId < companyArr.Length)
  631. {
  632. companyStr = companyArr[fin_DailyFeePayment.CompanyId];
  633. }
  634. Sys_SetData sd_tansferType = _grpDeleRep.Query<Sys_SetData>(s => s.Id == fin_DailyFeePayment.TransferTypeId).First();
  635. Sys_SetData sd_priceType = _grpDeleRep.Query<Sys_SetData>(s => s.Id == fin_DailyFeePayment.PriceTypeId).First();
  636. string feeSignStr = string.Format(@"{0}-{1}", sd_tansferType.Name, sd_priceType?.Name ?? "");
  637. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  638. DailyPayReminders_Create_ToCaiwuChatModel info = new DailyPayReminders_Create_ToCaiwuChatModel()
  639. {
  640. CreateDt = fin_DailyFeePayment.CreateTime.ToString("yyyy-MM-dd HH:mm"),
  641. CreateUser = users,
  642. Price = priceStr,
  643. Company = companyStr,
  644. FeeSign = feeSignStr,
  645. PriceName = fin_DailyFeePayment.Instructions
  646. };
  647. if (sign == 2) info.TitleStr = "[更新]一项费用待审核";
  648. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.DailyPayReminders_Create_ToCaiwuChat(info));
  649. if (result.errcode != 0)
  650. {
  651. //抄送日志
  652. return false;
  653. }
  654. return true;
  655. }
  656. /// <summary>
  657. /// 日付申请审核结果推送给申请人
  658. /// </summary>
  659. /// <param name="dailyPayId"></param>
  660. /// <param name="userId"></param>
  661. /// <param name="qwEnum"></param>
  662. /// <returns></returns>
  663. public static async Task<bool> DailyPayReminder_Audit_ToUser(int dailyPayId, List<string> userId, QiyeWeChatEnum qwEnum)
  664. {
  665. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  666. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
  667. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  668. string users = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  669. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  670. DailyPayReminder_Audit_ToUserModel info = new DailyPayReminder_Audit_ToUserModel()
  671. {
  672. Price = priceStr,
  673. PriceName = fin_DailyFeePayment.Instructions
  674. };
  675. if (fin_DailyFeePayment.FAudit == 1)
  676. {
  677. info.AuditDate = fin_DailyFeePayment.MAuditDate.ToString("yyyy-MM-dd HH:mm");
  678. if (fin_DailyFeePayment.MAudit == 1)
  679. {
  680. info.Result = "你有一笔日付申请已通过审核";
  681. info.ResultColor = "info";
  682. //发送至财务群
  683. DailyPayReminder_Audit_ToCaiwuChatModel chatInfo = new DailyPayReminder_Audit_ToCaiwuChatModel()
  684. {
  685. AuditDate = info.AuditDate,
  686. CreateUser = users,
  687. Price = priceStr,
  688. PriceName = fin_DailyFeePayment.Instructions
  689. };
  690. string chatId = qwEnum.GetEnumDescription();
  691. await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.DailyPayReminder_Audit_ToCaiwuChat(chatInfo));
  692. }
  693. else if (fin_DailyFeePayment.MAudit == 2)
  694. {
  695. info.Result = "你有一笔日付申请未通过总经理审核";
  696. info.ResultColor = "warning";
  697. }
  698. }
  699. else if (fin_DailyFeePayment.FAudit == 2)
  700. {
  701. info.AuditDate = fin_DailyFeePayment.FAuditDate.ToString("yyyy-MM-dd HH:mm");
  702. info.Result = "你有一笔日付申请未通过财务审核";
  703. info.ResultColor = "warning";
  704. }
  705. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  706. if (qwUserIdList.Count > 0)
  707. {
  708. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.DailyPayReminder_Audit_ToUser(info));
  709. if (result.errcode != 0)
  710. {
  711. //抄送日志
  712. return false;
  713. }
  714. }
  715. return true;
  716. }
  717. /// <summary>
  718. /// 日付申请已付款推送给申请人
  719. /// </summary>
  720. /// <returns></returns>
  721. public static async Task<bool> DailyPayReminder_Pay_ToUser(int dailyPayId, List<string> userId)
  722. {
  723. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  724. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  725. DailyPayReminder_Pay_ToUserModel info = new DailyPayReminder_Pay_ToUserModel()
  726. {
  727. PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  728. PriceName = fin_DailyFeePayment.Instructions,
  729. Price = priceStr
  730. };
  731. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  732. if (qwUserIdList.Count > 0)
  733. {
  734. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.DailyPayReminder_Pay_ToUser(info));
  735. if (result.errcode != 0)
  736. {
  737. //抄送日志
  738. return false;
  739. }
  740. }
  741. return true;
  742. }
  743. #endregion
  744. #region 费用保存发送消息
  745. #region 三公费用更改通知
  746. /// <summary>
  747. /// 三公费用汇率大于实时汇率 通知发送(22、208、5)
  748. /// </summary>
  749. /// <param name="diId"></param>
  750. /// <param name="operationId"></param>
  751. /// <param name="msgContent"></param>
  752. /// <returns></returns>
  753. public static async Task<bool> SendUserMsg_GroupShare_ToFin(int diId, int operationId, string msgContent)
  754. {
  755. var groupInfo = _grpDeleRep._sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == diId);
  756. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  757. var defaultUserIds = new List<string>() { "208", "22", "5" };
  758. if (defaultUserIds.Count > 0)
  759. {
  760. List<string> qwUserIdList = GetQiyeChatUserIdList(defaultUserIds);
  761. string resMsg = string.Format(@" `三公费用异常通知 - 汇率预警`
  762. >团组:<font color='info'>{0}</font>
  763. >**汇率明细**
  764. {1}
  765. >操作人员:<font color='comment'>{2}</font>
  766. >操作时间:<font color='comment'>{3}</font>
  767. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo?.TeamName ?? "-", msgContent, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  768. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  769. if (result.errcode != 0)
  770. {
  771. //抄送日志
  772. return false;
  773. }
  774. }
  775. return true;
  776. }
  777. #endregion
  778. #region 三公费用更改通知
  779. /// <summary>
  780. /// 三公费用更改通知发送总经理(21)
  781. /// </summary>
  782. /// <param name="diId"></param>
  783. /// <param name="receivedUserIds"></param>
  784. /// <param name="updateUserId"></param>
  785. /// <param name="url"></param>
  786. /// <returns></returns>
  787. public static async Task<bool> SendUserMsg_GroupShare_ToGM(int diId, List<string> receivedUserIds, int updateUserId, string url)
  788. {
  789. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  790. GroupShare_ToGMModel info = new GroupShare_ToGMModel()
  791. {
  792. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  793. TeamName = groupInfo?.TeamName ?? "-",
  794. CreateUser = _grpDeleRep.Query<Sys_Users>(s => s.Id == updateUserId).First()?.CnName ?? "-",
  795. Url = url
  796. };
  797. if (receivedUserIds.Count > 0)
  798. {
  799. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  800. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToGM(info));
  801. if (result.errcode != 0)
  802. {
  803. //抄送日志
  804. return false;
  805. }
  806. }
  807. return true;
  808. }
  809. /// <summary>
  810. /// 三公费用确认通知发送财务部人员
  811. /// </summary>
  812. /// <param name="diId"></param>
  813. /// <returns></returns>
  814. public static async Task<bool> SendUserMsg_GroupShare_ToFinance(int diId)
  815. {
  816. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  817. GroupShare_ToUserModel info = new GroupShare_ToUserModel()
  818. {
  819. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  820. TeamName = groupInfo.TeamName
  821. };
  822. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 3).Select(x => x.Id.ToString()).ToList();
  823. var defaultUserIds = new List<string>() { "208", "233" };
  824. receivedUserIds.AddRange(defaultUserIds);
  825. if (receivedUserIds.Contains("150")) receivedUserIds.Remove("150");
  826. if (receivedUserIds.Count > 0)
  827. {
  828. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  829. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToFinance(info));
  830. if (result.errcode != 0)
  831. {
  832. //抄送日志
  833. return false;
  834. }
  835. }
  836. return true;
  837. }
  838. #endregion
  839. /// <summary>
  840. /// 机票行程代码录入变更通知发送国交经理、主管、王鸽
  841. /// </summary>
  842. /// <param name="diId"></param>
  843. /// <param name="operationId"></param>
  844. /// <returns></returns>
  845. public static async Task<bool> SendUserMsg_GroupShare_ToDP(int diId, int operationId)
  846. {
  847. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  848. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  849. var defaultJobPostIds = new List<int>() { 22, 32 };
  850. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && defaultJobPostIds.Contains(s.JobPostId)).Select(x => x.Id.ToString()).ToList();
  851. var defaultUserIds = new List<string>() { "208", "233" };
  852. receivedUserIds.AddRange(defaultUserIds);
  853. if (receivedUserIds.Count > 0)
  854. {
  855. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  856. string resMsg = string.Format(@" `机票行程代码已调整更新通知`
  857. >团组:<font color='info'>{0}</font>
  858. >操作人员:<font color='comment'>{1}</font>
  859. >操作时间:<font color='comment'>{2}</font>
  860. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  861. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  862. if (result.errcode != 0)
  863. {
  864. //抄送日志
  865. return false;
  866. }
  867. }
  868. return true;
  869. }
  870. #region 公务出访数据变更发送通知
  871. /// <summary>
  872. /// 机票行程代码录入变更通知发送国交经理、主管、王鸽、OP操作人员
  873. /// </summary>
  874. /// <param name="diId"></param>
  875. /// <param name="operationId"></param>
  876. /// <returns></returns>
  877. public static async Task<bool> SendUserMsg_GroupShare_ToOP(int diId, int operationId)
  878. {
  879. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  880. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  881. var defaultJobPostIds = new List<int>();
  882. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && s.JobPostId == 28).Select(x => x.Id.ToString()).ToList();
  883. var defaultUserIds = new List<string>() { "208", "233", "235" };
  884. receivedUserIds.AddRange(defaultUserIds);
  885. #region 添加对应的OP操作人员
  886. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diId);
  887. var opUserIds = groupModuleOperators
  888. .Where(x => x.CTableId == 79)
  889. .FirstOrDefault()?
  890. .OperationUsers.Select(x => x.UserId.ToString())
  891. .ToList();
  892. receivedUserIds.AddRange(opUserIds ?? new List<string>());
  893. receivedUserIds = receivedUserIds.Distinct().ToList();
  894. #endregion
  895. if (receivedUserIds.Count > 0)
  896. {
  897. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  898. string resMsg = string.Format(@" `公务出访有数据更新通知`
  899. >团组:<font color='info'>{0}</font>
  900. >操作人员:<font color='comment'>{1}</font>
  901. >操作时间:<font color='comment'>{2}</font>
  902. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  903. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  904. if (result.errcode != 0)
  905. {
  906. //抄送日志
  907. return false;
  908. }
  909. }
  910. return true;
  911. }
  912. #endregion
  913. #endregion
  914. #region 成本通知
  915. /// <summary>
  916. /// 成本通知发送给对应岗位用户
  917. /// </summary>
  918. /// <param name="diId"></param>
  919. /// <returns></returns>
  920. public static async Task<bool> SendUserMsg_GroupShare_ToJob(int diId)
  921. {
  922. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  923. List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 24 || s.JobPostId == 25 || s.JobPostId == 28 || s.JobPostId == 23)).ToList();
  924. //List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 40 || s.JobPostId == 41)).ToList();
  925. List<string> userIds = new List<string>();
  926. list_user.ForEach(s => userIds.Add(s.Id.ToString()));
  927. userIds.Add("235");
  928. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  929. GroupShare_ToUserModel info = new GroupShare_ToUserModel()
  930. {
  931. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  932. TeamName = groupInfo.TeamName
  933. };
  934. if (qwUserIdList.Count > 0)
  935. {
  936. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToUser(info));
  937. if (result.errcode != 0)
  938. {
  939. //抄送日志
  940. return false;
  941. }
  942. }
  943. return true;
  944. }
  945. public static async Task<bool> SendUserMsg_blackAirInfo_ToVisaUser(int diId, List<CountryDataTime> arr)
  946. {
  947. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  948. var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
  949. .Select(x => x.Id)
  950. .ToList();
  951. List<string> userIds = new List<string>() { "235" };
  952. userIds.AddRange(visaUser.Select(x => x.ToString()));
  953. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  954. BlackCodeInfo_ToVisaUser info = new BlackCodeInfo_ToVisaUser()
  955. {
  956. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  957. TeamName = groupInfo.TeamName,
  958. info = arr
  959. };
  960. if (qwUserIdList.Count > 0)
  961. {
  962. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.BlackCodeInfo_ToVisaUser(info));
  963. if (result.errcode != 0)
  964. {
  965. //抄送日志
  966. return false;
  967. }
  968. }
  969. return true;
  970. }
  971. public static async Task<bool> SendUserMsg_GroupTimeInfo_ToVisaUser(int diId, string startTime, string endTime)
  972. {
  973. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  974. var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
  975. .Select(x => x.Id)
  976. .ToList();
  977. List<string> userIds = new List<string>() { "235" };
  978. userIds.AddRange(visaUser.Select(x => x.ToString()));
  979. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  980. GroupDateTime_ToVisaUser info = new GroupDateTime_ToVisaUser()
  981. {
  982. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  983. TeamName = groupInfo.TeamName,
  984. EndTime = endTime,
  985. StartTime = startTime,
  986. };
  987. if (qwUserIdList.Count > 0)
  988. {
  989. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupDateTime_ToVisaUser(info));
  990. if (result.errcode != 0)
  991. {
  992. //抄送日志
  993. return false;
  994. }
  995. }
  996. return true;
  997. }
  998. #region 机票群预算通知
  999. /// <summary>
  1000. /// 机票群预算通知
  1001. /// </summary>
  1002. /// <param name="diId"></param>
  1003. /// <param name="qwEnum"></param>
  1004. /// <returns></returns>
  1005. public static async Task<bool> SendChatMsg_AirCostChat(int diId, QiyeWeChatEnum qwEnum)
  1006. {
  1007. string chatId = qwEnum.GetEnumDescription();
  1008. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId && s.IsDel == 0).First();
  1009. var groupcost = _grpDeleRep.Query<Grp_GroupCostParameter>(s => s.DiId == diId && s.IsDel == 0 && s.CostType == "A").First();
  1010. var info = new GroupShare_ToAirUserModel()
  1011. {
  1012. TeamName = groupInfo.TeamName,
  1013. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  1014. AirCost = @$"
  1015. 经济舱:{groupcost.JJCCB}元/人 {groupcost.JJCRS}人 共:{groupcost.JJCCB * groupcost.JJCRS}元
  1016. 公务舱:{groupcost.GWCCB}元/人 {groupcost.GWCRS}人 共:{groupcost.GWCCB * groupcost.GWCRS}元"
  1017. };
  1018. ResponseBase result = await _qiYeWeChatApiService.
  1019. GroupStatus_SendChatMsg_Markdown(chatId,
  1020. MarkdownLib.GroupShare_ToAirUser(info));
  1021. if (result.errcode != 0)
  1022. {
  1023. //抄送日志
  1024. return false;
  1025. }
  1026. return true;
  1027. }
  1028. #endregion
  1029. #endregion
  1030. #region 任务通知
  1031. /// <summary>
  1032. /// 任务通知
  1033. /// </summary>
  1034. /// <param name="userIds"></param>
  1035. /// <param name="groupId"></param>
  1036. /// <param name="title"></param>
  1037. /// <param name="currUserId"></param>
  1038. /// <returns></returns>
  1039. public static async Task<bool> SendUserMsg_Task_ToUser(List<string> userIds, int groupId, string title, int currUserId)
  1040. {
  1041. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  1042. if (qwUserIdList.Any())
  1043. {
  1044. var groupName = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.IsDel == 0 && s.Id == groupId).First()?.TeamName ?? "未选择";
  1045. var userName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == currUserId).First()?.CnName ?? "Unknown";
  1046. var model = new TaskAssignment_Create_ToUserModel()
  1047. {
  1048. GroupName = groupName,
  1049. Title = title,
  1050. CreateUser = userName,
  1051. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm")
  1052. };
  1053. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskAssignment_Create_ToUser(model));
  1054. if (result.errcode != 0)
  1055. {
  1056. //抄送日志
  1057. return false;
  1058. }
  1059. }
  1060. return true;
  1061. }
  1062. #endregion
  1063. #region 物资通知
  1064. /// <summary>
  1065. /// 物资领用通知
  1066. /// 接收者:审核节点相关审核人
  1067. /// </summary>
  1068. /// <param name="dataId"></param>
  1069. /// <param name="diId"></param>
  1070. /// <param name="operationId"></param>
  1071. /// <returns></returns>
  1072. public static async Task<bool> SendUserMsg_CompanyShare_ToHR(int dataId, int diId, int operationId)
  1073. {
  1074. //企微通知
  1075. var userIds = new List<string>()
  1076. {
  1077. "208", //雷怡
  1078. "374", //罗颖
  1079. };
  1080. var isCheckValuable = false;
  1081. var valuableUserNames = new List<string>();
  1082. //根据审核节点的审核人,发送通知
  1083. var flow = _grpDeleRep._sqlSugar.Queryable<Sys_AuditFlow>().First(x => x.IsDel == 0 && x.BusinessType == 1 && x.BusinessId == dataId);
  1084. if (flow != null)
  1085. {
  1086. var auditNode = _grpDeleRep._sqlSugar
  1087. .Queryable<Sys_AuditTemplateNode>()
  1088. .First(x => x.IsDel == 0 && x.TemplateId == flow.TemplateId && x.Id == flow.CurrentNodeId);
  1089. if (auditNode != null)
  1090. {
  1091. var auditUserList = _grpDeleRep._sqlSugar.Queryable<Sys_AuditTemplateNodeUser>()
  1092. .Where(x => x.IsDel == 0 && x.NodeId == auditNode.Id)
  1093. .Select(x => new
  1094. {
  1095. x.UserId,
  1096. x.UserName
  1097. })
  1098. .ToList();
  1099. if (auditUserList.Any())
  1100. {
  1101. if (auditUserList.Count > 1) isCheckValuable = true;
  1102. userIds.AddRange(auditUserList.Select(x => x.UserId.ToString()).ToList());
  1103. userIds = userIds.Distinct().ToList();
  1104. valuableUserNames.AddRange(auditUserList.Select(x => x.UserName).ToList());
  1105. }
  1106. }
  1107. }
  1108. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  1109. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  1110. var groupName = diId switch
  1111. {
  1112. 0 => "其他物资(公司内部物资)",
  1113. -1 => "拜访客户所使用的物资",
  1114. -2 => "库存调整",
  1115. _ => groupInfo?.TeamName ?? "-"
  1116. };
  1117. var receiveInfo = _grpDeleRep._sqlSugar.Queryable<Pm_GoodsReceive>().First(x => x.IsDel == 0 && x.Id == dataId);
  1118. if (receiveInfo == null) return false;
  1119. var receiveDetails = _grpDeleRep._sqlSugar
  1120. .Queryable<Pm_GoodsReceiveDetails>()
  1121. .LeftJoin<Pm_GoodsInfo>((x, y) => x.GoodsId == y.Id)
  1122. .Where(x => x.IsDel == 0 && x.GoodsReceiveId == dataId)
  1123. .Select((x, y) => new
  1124. {
  1125. y.Name,
  1126. x.Quantity,
  1127. y.Unit
  1128. })
  1129. .ToList();
  1130. if (!receiveDetails.Any()) return false;
  1131. var goodsMsg = new StringBuilder();
  1132. foreach (var info in receiveDetails)
  1133. {
  1134. goodsMsg.AppendLine($">- {info.Name}:{info.Quantity:#0.00} {info.Unit}");
  1135. }
  1136. var groupLabel = string.Empty;
  1137. if (string.IsNullOrEmpty(groupName) || !groupName.Equals("-"))
  1138. {
  1139. groupLabel = $">团组归属:<font color='info'>{groupName}</font>";
  1140. }
  1141. //普通物品审批消息通知
  1142. string resMsg = string.Format(@" ` 物资领用申请通知 `
  1143. > ` {0} `提交物资领用申请:
  1144. {1}
  1145. >**物资明细**
  1146. {2}
  1147. >用途:<font color='comment'>{3}</font>
  1148. >申请时间:<font color='comment'>{4}</font>
  1149. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1150. operationName,
  1151. groupLabel,
  1152. goodsMsg,
  1153. receiveInfo.Reason,
  1154. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1155. //贵重物品审批消息通知
  1156. if (isCheckValuable)
  1157. {
  1158. var auditUserLabel = string.Empty;
  1159. foreach (var userName in valuableUserNames)
  1160. {
  1161. auditUserLabel += $"@{userName} ";
  1162. }
  1163. resMsg = string.Format(@" ` 【或签审批】物资领用(任一人审批即可)通知 `
  1164. >{0}
  1165. > ` {1} `提交物资领用申请,您被列为或签审批人:
  1166. **或签规则**
  1167. • 您与其他{2}人并行审批
  1168. • 任意一人通过即视为本环节通过
  1169. • 任意一人拒绝即视为终止流程
  1170. {3}
  1171. >**物资明细**
  1172. {4}
  1173. >用途:<font color='comment'>{5}</font>
  1174. >申请时间:<font color='comment'>{6}</font>
  1175. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1176. auditUserLabel,
  1177. operationName,
  1178. valuableUserNames.Count - 1,
  1179. groupLabel,
  1180. goodsMsg,
  1181. receiveInfo.Reason,
  1182. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1183. }
  1184. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  1185. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1186. if (result.errcode != 0)
  1187. {
  1188. //抄送日志
  1189. return false;
  1190. }
  1191. return true;
  1192. }
  1193. #endregion
  1194. #region 日服申请
  1195. /// <summary>
  1196. /// 日服申请、编辑通知
  1197. /// 接收者:指定接收者
  1198. /// </summary>
  1199. /// <param name="dataId"></param>
  1200. /// <param name="operationId">操作人Id</param>
  1201. /// <param name="recipients">接收者Id集合</param>
  1202. /// <returns></returns>
  1203. public static async Task<bool> SendUserMsg_CompanyShare_ToDailtPay(int dataId, int operationId, List<string> recipients)
  1204. {
  1205. //企微通知
  1206. var userIds = recipients;
  1207. string operationName = _grpDeleRep._sqlSugar.Queryable<Sys_Users>().First(x => x.IsDel
  1208. == 0 && x.Id == operationId).CnName ?? "Unknown";
  1209. var dailyPaymentInfo = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePayment>()
  1210. .FirstAsync(x => x.IsDel == 0 && x.Id == dataId);
  1211. var details = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePaymentContent>()
  1212. .Where(x => x.IsDel == 0 && x.DFPId == dataId)
  1213. .Select(x => new { x.PriceName, x.Quantity, x.Price })
  1214. .ToListAsync();
  1215. var detailsMsg = new StringBuilder();
  1216. foreach (var info in details)
  1217. {
  1218. detailsMsg.AppendLine($">- {info.PriceName}:{info.Quantity:#0.00} * {info.Price:#0.00} = {info.Quantity * info.Price:#0.00} 元");
  1219. }
  1220. if (detailsMsg.Length == 0 || detailsMsg == null)
  1221. {
  1222. detailsMsg.Append("无费用明细");
  1223. }
  1224. //普通物品审批消息通知
  1225. string resMsg = string.Format(@" ` 日付申请通知 `
  1226. > ` {0} `提交费用申请:
  1227. >**费用明细**
  1228. {1}
  1229. >总金额:<font color='comment'>{2} 元</font>
  1230. >申请说明:<font color='comment'>{3}</font>
  1231. >申请时间:<font color='comment'>{4}</font>
  1232. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1233. operationName,
  1234. detailsMsg.ToString(),
  1235. dailyPaymentInfo?.SumPrice.ToString("#0.00") ?? "0.00",
  1236. dailyPaymentInfo?.Instructions ?? "无申请说明",
  1237. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1238. List<string> qwUserIdList = GetQiyeChatUserIdList(recipients);
  1239. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1240. if (result.errcode != 0)
  1241. {
  1242. //抄送日志
  1243. return false;
  1244. }
  1245. return true;
  1246. }
  1247. #endregion
  1248. #region OA任务通知
  1249. public static async Task<bool> SendUserMsg_Task_ToUser(int taskOrderId, List<string> msgUserList, bool isNew)
  1250. {
  1251. msgUserList.Add("235");
  1252. msgUserList = msgUserList.Distinct().ToList();
  1253. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1254. var workOrder = _grpDeleRep._sqlSugar.Queryable<Task_WorkOrder>().First(x => x.IsDel == 0 && x.Id == taskOrderId);
  1255. var task = _grpDeleRep._sqlSugar.Queryable<Task_WorkTask>().Where(x => x.IsDel == 0 && x.WorkOrderId == taskOrderId).ToList();
  1256. TaskInfo_ToUser info = new TaskInfo_ToUser
  1257. {
  1258. isNew = isNew,
  1259. TaskName = workOrder.Name,
  1260. StartTime = workOrder.StartTime.ToString("yyyy-MM-dd HH:mm"),
  1261. TaskCount = task.Count,
  1262. UrgentCount = task.Count(x => x.IsUrgent)
  1263. };
  1264. if (qwUserIdList.Count > 0)
  1265. {
  1266. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_ToUser(info));
  1267. if (result.errcode != 0)
  1268. {
  1269. //抄送日志
  1270. return false;
  1271. }
  1272. }
  1273. return true;
  1274. }
  1275. public static async Task<bool> SendUserMsg_TaskSubMit_ToUser(int taskId, List<string> msgUserList)
  1276. {
  1277. msgUserList.Add("235");
  1278. msgUserList = msgUserList.Distinct().ToList();
  1279. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1280. var task = _grpDeleRep._sqlSugar.
  1281. Queryable<Task_WorkTask>().
  1282. Includes(x => x.WorkOrder).
  1283. First(x => x.IsDel == 0 && x.Id == taskId);
  1284. TaskInfo_SubMit_ToUser info = new TaskInfo_SubMit_ToUser
  1285. {
  1286. TaskName = task.WorkOrder.Name + " - " + task.Name,
  1287. StartTime = task.StartTime.ToString("yyyy-MM-dd HH:mm"),
  1288. EndTime = task.EndTime?.ToString("yyyy-MM-dd HH:mm") ?? ""
  1289. };
  1290. if (qwUserIdList.Count > 0)
  1291. {
  1292. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_SubMit_ToUser(info));
  1293. if (result.errcode != 0)
  1294. {
  1295. //抄送日志
  1296. return false;
  1297. }
  1298. }
  1299. return true;
  1300. }
  1301. public static async Task<bool> SendUserMsg_TaskAudit_ToUser(int taskId, bool auditResult, string message, List<string> msgUserList)
  1302. {
  1303. msgUserList.Add("235");
  1304. msgUserList = msgUserList.Distinct().ToList();
  1305. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1306. var task = _grpDeleRep._sqlSugar.
  1307. Queryable<Task_WorkTask>().
  1308. Includes(x => x.WorkOrder).
  1309. First(x => x.IsDel == 0 && x.Id == taskId);
  1310. TaskInfo_Audit_ToUser info = new TaskInfo_Audit_ToUser
  1311. {
  1312. TaskName = task.WorkOrder.Name + " - " + task.Name,
  1313. auditResult = auditResult,
  1314. Message = message
  1315. };
  1316. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_Audit_ToUser(info));
  1317. if (result.errcode != 0)
  1318. {
  1319. //抄送日志
  1320. return false;
  1321. }
  1322. return true;
  1323. }
  1324. #endregion
  1325. #region 报批通知
  1326. public static async Task<bool> SendUserMsg_BaoPi_ToUser(List<string> msgUserList, int diid)
  1327. {
  1328. var di = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.IsDel == 0 && s.Id == diid).First();
  1329. if (di == null) return false;
  1330. msgUserList.Add("235");
  1331. msgUserList = msgUserList.Distinct().ToList();
  1332. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1333. var resMsg = string.Format(@" ` 团组确认通知 `
  1334. > {0}已确认,请进行下一步业务操作
  1335. - 客户单位:{1}
  1336. - 出访日期:{2}
  1337. - 天数:{3}
  1338. - 人数:{4}
  1339. ",
  1340. di.TeamName,
  1341. di.ClientName,
  1342. di.VisitDate.ToString("yyyy-MM-dd"),
  1343. di.VisitDays,
  1344. di.VisitPNumber);
  1345. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1346. if (result.errcode != 0)
  1347. {
  1348. throw new Exception(result.errmsg);
  1349. }
  1350. return true;
  1351. }
  1352. #endregion
  1353. #region 团组超支费用通知
  1354. public static async Task<bool> SendChatMsg_ExpenseOverrunsChat(int diId, int userid, int cTable, QiyeWeChatEnum qwEnum)
  1355. {
  1356. string chatId = qwEnum.GetEnumDescription();
  1357. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId && s.IsDel == 0).First();
  1358. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == userid).First()?.CnName ?? "Unknown";
  1359. var table = _grpDeleRep.Query<Sys_SetData>(s => s.IsDel == 0 && s.Id == cTable && s.STid == 16).First()?.Name ?? "Unknown";
  1360. string markDown = @$"`团组超支费用通知`
  1361. >团组名称:<font color='info'> {groupInfo.TeamName} </font>
  1362. ><font color='warning'>此团组{table}版块有超支费用产生(目前因票据未出,无法上传相应票据)</font>
  1363. >更新时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}
  1364. >更新人:{operationName}";
  1365. ResponseBase result = await _qiYeWeChatApiService.
  1366. GroupStatus_SendChatMsg_Markdown(chatId,
  1367. markDown);
  1368. if (result.errcode != 0)
  1369. {
  1370. //抄送日志
  1371. return false;
  1372. }
  1373. return true;
  1374. }
  1375. #endregion
  1376. #region 团组流程节点任务通知、预警
  1377. /// <summary>
  1378. /// 团组流程节点任务通知
  1379. /// 接收者:审核节点相关人
  1380. /// </summary>
  1381. /// <param name="title"></param>
  1382. /// <param name="groupName"></param>
  1383. /// <param name="msgs"></param>
  1384. /// <param name="qwUserIds"></param>
  1385. /// <returns></returns>
  1386. public static async Task<bool> SendUserMsg_GroupProcNode_Notif(string title, string groupName,List<string> msgs, List<string> qwUserIds)
  1387. {
  1388. //消息体 或者 接收人 集合为空,则不发送
  1389. if (!msgs.Any() || !qwUserIds.Any())
  1390. {
  1391. return false;
  1392. }
  1393. var msgLabel = string.Join("\n", msgs);
  1394. string resMsg = string.Format(@" ` {0} `
  1395. > ` {1} `:
  1396. > {2}
  1397. >通知时间:<font color='comment'>{3}</font>
  1398. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1399. title,
  1400. groupName,
  1401. msgLabel,
  1402. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1403. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIds, resMsg);
  1404. if (result.errcode != 0)
  1405. {
  1406. //抄送日志
  1407. return false;
  1408. }
  1409. return true;
  1410. }
  1411. #endregion
  1412. #region Helper
  1413. private static string getClientNameStr(List<SimplClientInfo> list, string origin)
  1414. {
  1415. string result = origin;
  1416. if (Regex.Match(origin, @"\d +,?").Value.Length > 0)
  1417. {
  1418. string[] temparr = origin.Split(',');
  1419. string fistrStr = temparr[0];
  1420. int count = temparr.Length;
  1421. int tempId;
  1422. bool success = int.TryParse(fistrStr, out tempId);
  1423. if (success)
  1424. {
  1425. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1426. if (tempInfo != null)
  1427. {
  1428. if (count > 1)
  1429. {
  1430. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1431. }
  1432. else
  1433. {
  1434. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1435. }
  1436. }
  1437. }
  1438. }
  1439. return result;
  1440. }
  1441. private static List<SimplClientInfo> getSimplClientList(int diId)
  1442. {
  1443. 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);
  1444. List<SimplClientInfo> arr = _grpDeleRep._sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1445. return arr;
  1446. }
  1447. #endregion
  1448. }
  1449. }