Library.cs 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  1. using EyeSoft.Runtime.InteropServices;
  2. using NPOI.SS.Formula.Functions;
  3. using OASystem.Domain.Entities.Financial;
  4. using OASystem.Domain.Entities.Groups;
  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 static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  10. namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
  11. {
  12. public static class AppNoticeLibrary
  13. {
  14. private static readonly IQiYeWeChatApiService _qiYeWeChatApiService = AutofacIocManager.Instance.GetService<IQiYeWeChatApiService>();
  15. private static readonly DelegationInfoRepository _grpDeleRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
  16. #region 获取企微Id
  17. public static List<string> GetQiyeChatUserIdList(List<string> userId)
  18. {
  19. List<string> result = new List<string>();
  20. try
  21. {
  22. foreach (string item in userId)
  23. {
  24. int uid = int.Parse(item);
  25. Sys_Users users = _grpDeleRep.Query<Sys_Users>(s => s.Id == uid).First();
  26. if (!string.IsNullOrEmpty(users.QiyeChatUserId))
  27. {
  28. result.Add(users.QiyeChatUserId);
  29. }
  30. }
  31. }
  32. catch (Exception ex)
  33. {
  34. }
  35. return result;
  36. }
  37. #endregion
  38. #region 确认出团
  39. /// <summary>
  40. /// 向指定群聊发送- 确认出团 -通知
  41. /// </summary>
  42. /// <param name="diId"></param>
  43. /// <param name="qwEnum"></param>
  44. /// <returns></returns>
  45. public static async Task<bool> SendChatMsg_GroupStatus_Create(int diId, QiyeWeChatEnum qwEnum)
  46. {
  47. Grp_DelegationInfo entity = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  48. string dateRange = string.Format(@"{0}至{1}", entity.VisitStartDate.ToString("yyyy-MM-dd"), entity.VisitEndDate.ToString("yyyy-MM-dd"));
  49. string grpTypeStr = (_grpDeleRep.Query<Sys_SetData>(s => s.Id == entity.TeamDid).First()).Name;
  50. GroupStatus_CreateModel info = new GroupStatus_CreateModel()
  51. {
  52. ClientName = entity.ClientName,
  53. ClientUnit = entity.ClientUnit,
  54. TeamName = entity.TeamName,
  55. VisitDays = entity.VisitDays,
  56. VisitPNumber = entity.VisitPNumber,
  57. VisitDateRange = dateRange,
  58. TeamDid_Text = grpTypeStr
  59. };
  60. string chatId = qwEnum.GetEnumDescription();
  61. //发送信息
  62. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupStatus_Create(info));
  63. if (result.errcode != 0)
  64. {
  65. //抄送日志
  66. return false;
  67. }
  68. return true;
  69. }
  70. /// <summary>
  71. /// 向指定用户发送- 确认出团 -通知
  72. /// </summary>
  73. /// <param name="diId"></param>
  74. /// <param name="userId"></param>
  75. /// <returns></returns>
  76. public static async Task<bool> SendUserMsg_GroupStatus_Create(int diId, List<string> userId)
  77. {
  78. Grp_DelegationInfo entity = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  79. string dateRange = string.Format(@"{0}至{1}", entity.VisitStartDate.ToString("yyyy-MM-dd"), entity.VisitEndDate.ToString("yyyy-MM-dd"));
  80. string grpTypeStr = (_grpDeleRep.Query<Sys_SetData>(s => s.Id == entity.TeamDid).First()).Name;
  81. GroupStatus_CreateModel info = new GroupStatus_CreateModel()
  82. {
  83. ClientName = entity.ClientName,
  84. ClientUnit = entity.ClientUnit,
  85. TeamName = entity.TeamName,
  86. VisitDays = entity.VisitDays,
  87. VisitPNumber = entity.VisitPNumber,
  88. VisitDateRange = dateRange,
  89. TeamDid_Text = grpTypeStr
  90. };
  91. //发送信息
  92. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  93. if (qwUserIdList.Count > 0)
  94. {
  95. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupStatus_Create(info));
  96. if (result.errcode != 0)
  97. {
  98. //抄送日志
  99. return false;
  100. }
  101. }
  102. return true;
  103. }
  104. #endregion
  105. #region 团组费用审核
  106. /// <summary>
  107. /// 向指定群聊发送- 费用申请 -通知
  108. /// </summary>
  109. /// <param name="diId"></param>
  110. /// <param name="qwEnum"></param>
  111. /// <returns></returns>
  112. public static async Task<bool> SendChatMsg_GroupStatus_ApplyFee(int Grp_CreditCardPaymentId, int sign, QiyeWeChatEnum qwEnum)
  113. {
  114. string chatId = qwEnum.GetEnumDescription();
  115. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  116. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  117. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  118. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  119. List<Grp_CreditCardPayment> entityList = _grpDeleRep
  120. .Query<Grp_CreditCardPayment>(s => s.DIId == ccp.DIId && s.IsDel == 0 && s.CreateUserId > 0 && s.IsAuditGM == 0)
  121. .ToList();
  122. GroupStatus_ApplyFeeModel info = new GroupStatus_ApplyFeeModel()
  123. {
  124. QueueCount = entityList.Count,
  125. TeamName = group.TeamName,
  126. Price = priceStr
  127. };
  128. if (sign == 2)
  129. {
  130. info.TitleStr = "[更新]一项费用待审核";
  131. }
  132. //CTable
  133. #region CTable
  134. if (ccp.CTable == 76)//76,酒店预订
  135. {
  136. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  137. info.CreateDt = _HotelReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  138. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  139. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  140. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  141. info.PriceModule = "酒店预订";
  142. info.PriceName = _HotelReservations.HotelName;
  143. }
  144. else if (ccp.CTable == 79) //79://车/导游地接
  145. {
  146. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  147. info.CreateDt = _CarTouristGuideGroundReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  148. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  149. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  150. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  151. info.PriceModule = "车/导游地接";
  152. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  153. }
  154. else if (ccp.CTable == 80) //签证
  155. {
  156. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  157. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  158. info.CreateDt = _VisaInfos.CreateTime.ToString("yyyy-MM-dd HH:mm");
  159. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  160. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  161. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  162. info.PriceModule = "签证";
  163. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  164. }
  165. else if (ccp.CTable == 81)//邀请/公务活动
  166. {
  167. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  168. info.CreateDt = _InvitationOfficialActivities.CreateTime.ToString("yyyy-MM-dd HH:mm");
  169. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  170. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  171. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  172. info.PriceModule = "邀请/公务活动";
  173. info.PriceName = _InvitationOfficialActivities.InviterArea;
  174. }
  175. else if (ccp.CTable == 82)//团组客户保险
  176. {
  177. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  178. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  179. info.CreateDt = _Customers.CreateTime.ToString("yyyy-MM-dd HH:mm");
  180. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  181. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  182. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  183. info.PriceModule = "团组客户保险";
  184. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  185. }
  186. else if (ccp.CTable == 85) //机票预订
  187. {
  188. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  189. info.CreateDt = _AirTicketReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  190. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  191. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  192. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  193. info.PriceModule = "机票预订";
  194. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  195. }
  196. else if (ccp.CTable == 98) //其他款项
  197. {
  198. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  199. info.CreateDt = _DecreasePayments.CreateTime.ToString("yyyy-MM-dd HH:mm");
  200. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  201. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  202. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  203. info.PriceModule = "其他款项";
  204. info.PriceName = _DecreasePayments.PriceName;
  205. }
  206. #endregion
  207. //发送信息
  208. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupStatus_ApplyFee(info));
  209. if (result.errcode != 0)
  210. {
  211. //抄送日志
  212. return false;
  213. }
  214. return true;
  215. }
  216. /// <summary>
  217. /// 向财务群发送费用审核结果通知(审核通过条件下发送)
  218. /// </summary>
  219. /// <param name="Grp_CreditCardPaymentId"></param>
  220. /// <param name="qwEnum"></param>
  221. /// <returns></returns>
  222. public static async Task<bool> SendChatMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, QiyeWeChatEnum qwEnum)
  223. {
  224. string chatId = qwEnum.GetEnumDescription();
  225. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  226. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  227. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  228. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  229. AuditResult_ApplyFee_GroupModel info = new AuditResult_ApplyFee_GroupModel()
  230. {
  231. TeamName = group.TeamName,
  232. Price = priceStr,
  233. GMAuditDate = "-"
  234. };
  235. DateTime gmAuditDt;
  236. bool bGMAuditDt = DateTime.TryParse(ccp.AuditGMDate, out gmAuditDt);
  237. info.GMAuditDate = gmAuditDt.ToString("yyyy-MM-dd HH:mm");
  238. //CTable
  239. #region CTable
  240. if (ccp.CTable == 76)//76,酒店预订
  241. {
  242. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  243. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  244. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  245. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  246. info.PriceModule = "酒店预订";
  247. info.PriceName = _HotelReservations.HotelName;
  248. }
  249. else if (ccp.CTable == 79) //79://车/导游地接
  250. {
  251. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  252. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  253. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  254. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  255. info.PriceModule = "车/导游地接";
  256. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  257. }
  258. else if (ccp.CTable == 80) //签证
  259. {
  260. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  261. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  262. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  263. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  264. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  265. info.PriceModule = "签证";
  266. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  267. }
  268. else if (ccp.CTable == 81)//邀请/公务活动
  269. {
  270. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  271. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  272. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  273. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  274. info.PriceModule = "邀请/公务活动";
  275. info.PriceName = _InvitationOfficialActivities.InviterArea;
  276. }
  277. else if (ccp.CTable == 82)//团组客户保险
  278. {
  279. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  280. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  281. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  282. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  283. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  284. info.PriceModule = "团组客户保险";
  285. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  286. }
  287. else if (ccp.CTable == 85) //机票预订
  288. {
  289. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  290. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  291. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  292. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  293. info.PriceModule = "机票预订";
  294. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  295. }
  296. else if (ccp.CTable == 98) //其他款项
  297. {
  298. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  299. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  300. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  301. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  302. info.PriceModule = "其他款项";
  303. info.PriceName = _DecreasePayments.PriceName;
  304. }
  305. #endregion
  306. //发送信息
  307. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.AuditResult_ApplyFee_Chat(info));
  308. if (result.errcode != 0)
  309. {
  310. //抄送日志
  311. return false;
  312. }
  313. return true;
  314. }
  315. /// <summary>
  316. /// 向指定用户发送-团组费用审核结果
  317. /// </summary>
  318. /// <param name="Grp_CreditCardPaymentId"></param>
  319. /// <param name="userId"></param>
  320. /// <returns></returns>
  321. public static async Task<bool> SendUserMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, List<string> userId, QiyeWeChatEnum qwEnum)
  322. {
  323. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  324. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  325. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  326. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  327. AuditResult_ApplyFee_GroupModel info = new AuditResult_ApplyFee_GroupModel()
  328. {
  329. TeamName = group.TeamName,
  330. Price = priceStr,
  331. GMAuditDate = "-"
  332. };
  333. DateTime gmAuditDt;
  334. bool bGMAuditDt = DateTime.TryParse(ccp.AuditGMDate, out gmAuditDt);
  335. info.GMAuditDate = gmAuditDt.ToString("yyyy-MM-dd HH:mm");
  336. if (ccp.IsAuditGM == 2)
  337. {
  338. info.Result = "总经理审核未通过";
  339. info.ResultColor = "warning";
  340. }
  341. //CTable
  342. #region CTable
  343. if (ccp.CTable == 76)//76,酒店预订
  344. {
  345. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  346. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  347. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  348. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  349. info.PriceModule = "酒店预订";
  350. info.PriceName = _HotelReservations.HotelName;
  351. }
  352. else if (ccp.CTable == 79) //79://车/导游地接
  353. {
  354. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  355. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  356. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  357. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  358. info.PriceModule = "车/导游地接";
  359. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  360. }
  361. else if (ccp.CTable == 80) //签证
  362. {
  363. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  364. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  365. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  366. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  367. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  368. info.PriceModule = "签证";
  369. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  370. }
  371. else if (ccp.CTable == 81)//邀请/公务活动
  372. {
  373. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  374. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  375. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  376. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  377. info.PriceModule = "邀请/公务活动";
  378. info.PriceName = _InvitationOfficialActivities.InviterArea;
  379. }
  380. else if (ccp.CTable == 82)//团组客户保险
  381. {
  382. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  383. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  384. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  385. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  386. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  387. info.PriceModule = "团组客户保险";
  388. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  389. }
  390. else if (ccp.CTable == 85) //机票预订
  391. {
  392. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  393. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  394. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  395. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  396. info.PriceModule = "机票预订";
  397. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  398. }
  399. else if (ccp.CTable == 98) //其他款项
  400. {
  401. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  402. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  403. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  404. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  405. info.PriceModule = "其他款项";
  406. info.PriceName = _DecreasePayments.PriceName;
  407. }
  408. #endregion
  409. //发送信息
  410. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  411. if (qwUserIdList.Count > 0)
  412. {
  413. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.AuditResult_ApplyFee_User(info));
  414. if (ccp.IsAuditGM == 1)
  415. {
  416. await SendChatMsg_GroupStatus_AuditFee(Grp_CreditCardPaymentId, qwEnum);
  417. }
  418. if (result.errcode != 0)
  419. {
  420. //抄送日志
  421. return false;
  422. }
  423. }
  424. return true;
  425. }
  426. /// <summary>
  427. /// 向指定用户发送-团组费用支付结果
  428. /// </summary>
  429. /// <param name="Grp_CreditCardPaymentId"></param>
  430. /// <param name="userId"></param>
  431. /// <returns></returns>
  432. public static async Task<bool> SendUserMsg_GroupStatus_PayResult(int Grp_CreditCardPaymentId, List<string> userId)
  433. {
  434. //, QiyeWeChatEnum qiyeWeChat
  435. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  436. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  437. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  438. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  439. PayResult_Group_ToUserModel info = new PayResult_Group_ToUserModel()
  440. {
  441. PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  442. Price = priceStr,
  443. TeamName = group.TeamName
  444. };
  445. #region CTable
  446. if (ccp.CTable == 76)//76,酒店预订
  447. {
  448. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  449. info.PriceModule = "酒店预订";
  450. info.PriceName = _HotelReservations.HotelName;
  451. }
  452. else if (ccp.CTable == 79) //79://车/导游地接
  453. {
  454. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  455. info.PriceModule = "车/导游地接";
  456. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  457. }
  458. else if (ccp.CTable == 80) //签证
  459. {
  460. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  461. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  462. info.PriceModule = "签证";
  463. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  464. }
  465. else if (ccp.CTable == 81)//邀请/公务活动
  466. {
  467. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  468. info.PriceModule = "邀请/公务活动";
  469. info.PriceName = _InvitationOfficialActivities.InviterArea;
  470. }
  471. else if (ccp.CTable == 82)//团组客户保险
  472. {
  473. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  474. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  475. info.PriceModule = "团组客户保险";
  476. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  477. }
  478. else if (ccp.CTable == 85) //机票预订
  479. {
  480. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  481. info.PriceModule = "机票预订";
  482. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  483. }
  484. else if (ccp.CTable == 98) //其他款项
  485. {
  486. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  487. info.PriceModule = "其他款项";
  488. info.PriceName = _DecreasePayments.PriceName;
  489. }
  490. #endregion
  491. //发送信息
  492. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  493. if (qwUserIdList.Count > 0)
  494. {
  495. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.PayResult_Group_ToUser(info));
  496. if (result.errcode != 0)
  497. {
  498. //抄送日志
  499. return false;
  500. }
  501. }
  502. return true;
  503. }
  504. #endregion
  505. #region 团组出发、结束提醒(财务群)
  506. public static async Task<bool> SendChatMsg_GroupRemindersToCaiwu(List<Grp_DelegationInfo> list_7day, List<Grp_DelegationInfo> list_3day, List<Grp_DelegationInfo> list_minus1day, QiyeWeChatEnum qwEnum)
  507. {
  508. string chatId = qwEnum.GetEnumDescription();
  509. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToCaiwuChat(list_7day, list_3day, list_minus1day));
  510. if (result.errcode != 0)
  511. {
  512. //抄送日志
  513. return false;
  514. }
  515. return true;
  516. }
  517. #endregion
  518. #region 团组结束提醒(国交群)
  519. public static async Task<bool> SendChatMsg_GroupRemindersToGuojiao(List<Grp_DelegationInfo> list_3day, QiyeWeChatEnum qwEnum)
  520. {
  521. string chatId = qwEnum.GetEnumDescription();
  522. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToGuojiao(list_3day));
  523. if (result.errcode != 0)
  524. {
  525. //抄送日志
  526. return false;
  527. }
  528. return true;
  529. }
  530. #endregion
  531. #region 市场部新增客户资源统计
  532. /// <summary>
  533. /// 周统计
  534. /// </summary>
  535. /// <param name="sourceList"></param>
  536. /// <param name="userId"></param>
  537. /// <param name="begin"></param>
  538. /// <param name="end"></param>
  539. /// <returns></returns>
  540. public static async Task<bool> SendUserMsg_CRMStatistics_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end)
  541. {
  542. //发送信息
  543. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  544. if (qwUserIdList.Count > 0)
  545. {
  546. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_ToUser(sourceList, begin, end));
  547. if (result.errcode != 0)
  548. {
  549. //抄送日志
  550. return false;
  551. }
  552. }
  553. return true;
  554. }
  555. /// <summary>
  556. /// 月统计
  557. /// </summary>
  558. /// <param name="sourceList"></param>
  559. /// <param name="userId"></param>
  560. /// <param name="begin"></param>
  561. /// <param name="end"></param>
  562. /// <returns></returns>
  563. public static async Task<bool> SendUserMsg_CRMStatistics_Month_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end, int totalInsert,int totalDelete)
  564. {
  565. //发送信息
  566. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  567. if (qwUserIdList.Count > 0)
  568. {
  569. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_Month_ToUser(sourceList, begin, end, totalInsert, totalDelete));
  570. if (result.errcode != 0)
  571. {
  572. //抄送日志
  573. return false;
  574. }
  575. }
  576. return true;
  577. }
  578. #endregion
  579. #region 日付申请审核
  580. /// <summary>
  581. /// 日付申请提交时推送财务群
  582. /// </summary>
  583. /// <param name="dailyPayId"></param>
  584. /// <param name="qwEnum"></param>
  585. /// <returns></returns>
  586. public static async Task<bool> DailyPayReminders_Create_ToCaiwuChat(int dailyPayId, int sign, QiyeWeChatEnum qwEnum)
  587. {
  588. string chatId = qwEnum.GetEnumDescription();
  589. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  590. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
  591. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  592. string users = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  593. string[] companyArr = new string[] { "未知", "成都泛美商务有限公司", "四川泛美交流有限公司", "成都纽茵教育科技有限公司", "成都鸿企中元科技有限公司", "测试公司1" };
  594. string companyStr = "未知";
  595. if (fin_DailyFeePayment.CompanyId < companyArr.Length)
  596. {
  597. companyStr = companyArr[fin_DailyFeePayment.CompanyId];
  598. }
  599. Sys_SetData sd_tansferType = _grpDeleRep.Query<Sys_SetData>(s => s.Id == fin_DailyFeePayment.TransferTypeId).First();
  600. Sys_SetData sd_priceType = _grpDeleRep.Query<Sys_SetData>(s => s.Id == fin_DailyFeePayment.PriceTypeId).First();
  601. string feeSignStr = string.Format(@"{0}-{1}", sd_tansferType.Name, sd_priceType.Name);
  602. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  603. DailyPayReminders_Create_ToCaiwuChatModel info = new DailyPayReminders_Create_ToCaiwuChatModel()
  604. {
  605. CreateDt = fin_DailyFeePayment.CreateTime.ToString("yyyy-MM-dd HH:mm"),
  606. CreateUser = users,
  607. Price = priceStr,
  608. Company = companyStr,
  609. FeeSign = feeSignStr,
  610. PriceName = fin_DailyFeePayment.Instructions
  611. };
  612. if (sign == 2)
  613. {
  614. info.TitleStr = "[更新]一项费用待审核";
  615. }
  616. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.DailyPayReminders_Create_ToCaiwuChat(info));
  617. if (result.errcode != 0)
  618. {
  619. //抄送日志
  620. return false;
  621. }
  622. return true;
  623. }
  624. /// <summary>
  625. /// 日付申请审核结果推送给申请人
  626. /// </summary>
  627. /// <param name="dailyPayId"></param>
  628. /// <param name="userId"></param>
  629. /// <param name="qwEnum"></param>
  630. /// <returns></returns>
  631. public static async Task<bool> DailyPayReminder_Audit_ToUser(int dailyPayId, List<string> userId, QiyeWeChatEnum qwEnum)
  632. {
  633. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  634. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
  635. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  636. string users = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  637. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  638. DailyPayReminder_Audit_ToUserModel info = new DailyPayReminder_Audit_ToUserModel()
  639. {
  640. Price = priceStr,
  641. PriceName = fin_DailyFeePayment.Instructions
  642. };
  643. if (fin_DailyFeePayment.FAudit == 1)
  644. {
  645. info.AuditDate = fin_DailyFeePayment.MAuditDate.ToString("yyyy-MM-dd HH:mm");
  646. if (fin_DailyFeePayment.MAudit == 1)
  647. {
  648. info.Result = "你有一笔日付申请已通过审核";
  649. info.ResultColor = "info";
  650. //发送至财务群
  651. DailyPayReminder_Audit_ToCaiwuChatModel chatInfo = new DailyPayReminder_Audit_ToCaiwuChatModel()
  652. {
  653. AuditDate = info.AuditDate,
  654. CreateUser = users,
  655. Price = priceStr,
  656. PriceName = fin_DailyFeePayment.Instructions
  657. };
  658. string chatId = qwEnum.GetEnumDescription();
  659. await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.DailyPayReminder_Audit_ToCaiwuChat(chatInfo));
  660. }
  661. else if (fin_DailyFeePayment.MAudit == 2)
  662. {
  663. info.Result = "你有一笔日付申请未通过总经理审核";
  664. info.ResultColor = "warning";
  665. }
  666. }
  667. else if (fin_DailyFeePayment.FAudit == 2)
  668. {
  669. info.AuditDate = fin_DailyFeePayment.FAuditDate.ToString("yyyy-MM-dd HH:mm");
  670. info.Result = "你有一笔日付申请未通过财务审核";
  671. info.ResultColor = "warning";
  672. }
  673. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  674. if (qwUserIdList.Count > 0)
  675. {
  676. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.DailyPayReminder_Audit_ToUser(info));
  677. if (result.errcode != 0)
  678. {
  679. //抄送日志
  680. return false;
  681. }
  682. }
  683. return true;
  684. }
  685. /// <summary>
  686. /// 日付申请已付款推送给申请人
  687. /// </summary>
  688. /// <returns></returns>
  689. public static async Task<bool> DailyPayReminder_Pay_ToUser(int dailyPayId, List<string> userId)
  690. {
  691. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  692. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  693. DailyPayReminder_Pay_ToUserModel info = new DailyPayReminder_Pay_ToUserModel()
  694. {
  695. PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  696. PriceName = fin_DailyFeePayment.Instructions,
  697. Price = priceStr
  698. };
  699. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  700. if (qwUserIdList.Count > 0)
  701. {
  702. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.DailyPayReminder_Pay_ToUser(info));
  703. if (result.errcode != 0)
  704. {
  705. //抄送日志
  706. return false;
  707. }
  708. }
  709. return true;
  710. }
  711. #endregion
  712. #region 费用保存发送消息
  713. #region 三公费用更改通知
  714. /// <summary>
  715. /// 三公费用更改通知发送总经理(21)
  716. /// </summary>
  717. /// <param name="sign"></param>
  718. /// <returns></returns>
  719. public static async Task<bool> SendUserMsg_GroupShare_ToGM(int diId, List<string> receivedUserIds, int updateUserId, string url)
  720. {
  721. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  722. GroupShare_ToGMModel info = new GroupShare_ToGMModel()
  723. {
  724. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  725. TeamName = groupInfo.TeamName,
  726. CreateUser = _grpDeleRep.Query<Sys_Users>(s => s.Id == updateUserId).First()?.CnName ?? "-",
  727. Url = url
  728. };
  729. if (receivedUserIds.Count > 0)
  730. {
  731. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  732. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToGM(info));
  733. if (result.errcode != 0)
  734. {
  735. //抄送日志
  736. return false;
  737. }
  738. }
  739. return true;
  740. }
  741. /// <summary>
  742. /// 三公费用确认通知发送财务部人员
  743. /// </summary>
  744. /// <param name="sign"></param>
  745. /// <returns></returns>
  746. public static async Task<bool> SendUserMsg_GroupShare_ToFinance(int diId)
  747. {
  748. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  749. GroupShare_ToUserModel info = new GroupShare_ToUserModel()
  750. {
  751. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  752. TeamName = groupInfo.TeamName
  753. };
  754. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 3).Select(x => x.Id.ToString()).ToList();
  755. var defaultUserIds = new List<string>() { "208", "233" };
  756. receivedUserIds.AddRange(defaultUserIds);
  757. if (receivedUserIds.Contains("150")) receivedUserIds.Remove("150");
  758. if (receivedUserIds.Count > 0)
  759. {
  760. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  761. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToFinance(info));
  762. if (result.errcode != 0)
  763. {
  764. //抄送日志
  765. return false;
  766. }
  767. }
  768. return true;
  769. }
  770. #endregion
  771. /// <summary>
  772. /// 机票行程代码录入变更通知发送国交经理、主管、王鸽
  773. /// </summary>
  774. /// <param name="diId"></param>
  775. /// <param name="operationId"></param>
  776. /// <returns></returns>
  777. public static async Task<bool> SendUserMsg_GroupShare_ToDP(int diId,int operationId)
  778. {
  779. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  780. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  781. var defaultJobPostIds = new List<int>() { 22, 32 };
  782. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && defaultJobPostIds.Contains(s.JobPostId)).Select(x => x.Id.ToString()).ToList();
  783. var defaultUserIds = new List<string>() { "208", "233" };
  784. receivedUserIds.AddRange(defaultUserIds);
  785. if (receivedUserIds.Count > 0)
  786. {
  787. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  788. string resMsg = string.Format(@" `机票行程代码已调整更新通知`
  789. >团组:<font color='info'>{0}</font>
  790. >操作人员:<font color='comment'>{1}</font>
  791. >操作时间:<font color='comment'>{2}</font>
  792. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  793. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  794. if (result.errcode != 0)
  795. {
  796. //抄送日志
  797. return false;
  798. }
  799. }
  800. return true;
  801. }
  802. #region 公务出访数据变更发送通知
  803. /// <summary>
  804. /// 机票行程代码录入变更通知发送国交经理、主管、王鸽
  805. /// </summary>
  806. /// <param name="diId"></param>
  807. /// <param name="operationId"></param>
  808. /// <returns></returns>
  809. public static async Task<bool> SendUserMsg_GroupShare_ToOP(int diId, int operationId)
  810. {
  811. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  812. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  813. var defaultJobPostIds = new List<int>();
  814. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && s.JobPostId == 28 ).Select(x => x.Id.ToString()).ToList();
  815. var defaultUserIds = new List<string>() { "208", "233" };
  816. receivedUserIds.AddRange(defaultUserIds);
  817. if (receivedUserIds.Count > 0)
  818. {
  819. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  820. string resMsg = string.Format(@" `公务出访有数据更新通知`
  821. >团组:<font color='info'>{0}</font>
  822. >操作人员:<font color='comment'>{1}</font>
  823. >操作时间:<font color='comment'>{2}</font>
  824. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  825. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  826. if (result.errcode != 0)
  827. {
  828. //抄送日志
  829. return false;
  830. }
  831. }
  832. return true;
  833. }
  834. #endregion
  835. #endregion
  836. #region 成本通知
  837. /// <summary>
  838. /// 成本通知发送给对应岗位用户
  839. /// </summary>
  840. /// <param name="diId"></param>
  841. /// <returns></returns>
  842. public static async Task<bool> SendUserMsg_GroupShare_ToJob(int diId)
  843. {
  844. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  845. List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 24 || s.JobPostId == 25 || s.JobPostId == 28)).ToList();
  846. //List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 40 || s.JobPostId == 41)).ToList();
  847. List<string> userIds = new List<string>();
  848. list_user.ForEach(s => userIds.Add(s.Id.ToString()));
  849. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  850. GroupShare_ToUserModel info = new GroupShare_ToUserModel()
  851. {
  852. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  853. TeamName = groupInfo.TeamName
  854. };
  855. if (qwUserIdList.Count > 0)
  856. {
  857. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToUser(info));
  858. if (result.errcode != 0)
  859. {
  860. //抄送日志
  861. return false;
  862. }
  863. }
  864. return true;
  865. }
  866. #endregion
  867. #region Helper
  868. private static string getClientNameStr(List<SimplClientInfo> list, string origin)
  869. {
  870. string result = origin;
  871. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  872. {
  873. string[] temparr = origin.Split(',');
  874. string fistrStr = temparr[0];
  875. int count = temparr.Count();
  876. int tempId;
  877. bool success = int.TryParse(fistrStr, out tempId);
  878. if (success)
  879. {
  880. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  881. if (tempInfo != null)
  882. {
  883. if (count > 1)
  884. {
  885. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  886. }
  887. else
  888. {
  889. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  890. }
  891. }
  892. }
  893. }
  894. return result;
  895. }
  896. private static List<SimplClientInfo> getSimplClientList(int diId)
  897. {
  898. 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);
  899. List<SimplClientInfo> arr = _grpDeleRep._sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  900. return arr;
  901. }
  902. #endregion
  903. }
  904. }