Library.cs 49 KB

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