Library.cs 52 KB

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