Library.cs 52 KB

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