Library.cs 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500
  1. using OASystem.Domain.Dtos.Groups;
  2. using OASystem.Domain.Entities.Financial;
  3. using OASystem.Domain.Entities.Groups;
  4. using OASystem.Domain.Entities.PersonnelModule;
  5. using OASystem.Domain.ViewModels.CRM;
  6. using OASystem.Domain.ViewModels.Groups;
  7. using OASystem.Domain.ViewModels.QiYeWeChat;
  8. using OASystem.Domain.ViewModels.Statistics;
  9. using OASystem.Infrastructure.Repositories.Groups;
  10. using Quartz.Logging;
  11. namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
  12. {
  13. public static class AppNoticeLibrary
  14. {
  15. private static readonly IQiYeWeChatApiService _qiYeWeChatApiService = AutofacIocManager.Instance.GetService<IQiYeWeChatApiService>();
  16. private static readonly DelegationInfoRepository _grpDeleRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
  17. #region 获取企微Id
  18. public static List<string> GetQiyeChatUserIdList(List<string> userId)
  19. {
  20. List<string> result = new List<string>();
  21. try
  22. {
  23. foreach (string item in userId)
  24. {
  25. int uid = int.Parse(item);
  26. Sys_Users users = _grpDeleRep.Query<Sys_Users>(s => s.Id == uid).First();
  27. if (!string.IsNullOrEmpty(users.QiyeChatUserId))
  28. {
  29. result.Add(users.QiyeChatUserId);
  30. }
  31. }
  32. }
  33. catch (Exception ex)
  34. {
  35. }
  36. return result;
  37. }
  38. #endregion
  39. #region 确认出团
  40. /// <summary>
  41. /// 向指定群聊发送- 确认出团 -通知
  42. /// </summary>
  43. /// <param name="diId"></param>
  44. /// <param name="qwEnum"></param>
  45. /// <returns></returns>
  46. public static async Task<bool> SendChatMsg_GroupStatus_Create(int diId, QiyeWeChatEnum qwEnum)
  47. {
  48. Grp_DelegationInfo entity = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  49. string dateRange = string.Format(@"{0}至{1}", entity.VisitStartDate.ToString("yyyy-MM-dd"), entity.VisitEndDate.ToString("yyyy-MM-dd"));
  50. string grpTypeStr = (_grpDeleRep.Query<Sys_SetData>(s => s.Id == entity.TeamDid).First()).Name;
  51. GroupStatus_CreateModel info = new GroupStatus_CreateModel()
  52. {
  53. ClientName = entity.ClientName,
  54. ClientUnit = entity.ClientUnit,
  55. TeamName = entity.TeamName,
  56. VisitDays = entity.VisitDays,
  57. VisitPNumber = entity.VisitPNumber,
  58. VisitDateRange = dateRange,
  59. TeamDid_Text = grpTypeStr
  60. };
  61. string chatId = qwEnum.GetEnumDescription();
  62. //发送信息
  63. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupStatus_Create(info));
  64. if (result.errcode != 0)
  65. {
  66. //抄送日志
  67. return false;
  68. }
  69. return true;
  70. }
  71. /// <summary>
  72. /// 向指定用户发送- 确认出团 -通知
  73. /// </summary>
  74. /// <param name="diId"></param>
  75. /// <param name="userId"></param>
  76. /// <returns></returns>
  77. public static async Task<bool> SendUserMsg_GroupStatus_Create(int diId, List<string> userId)
  78. {
  79. Grp_DelegationInfo entity = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  80. string dateRange = string.Format(@"{0}至{1}", entity.VisitStartDate.ToString("yyyy-MM-dd"), entity.VisitEndDate.ToString("yyyy-MM-dd"));
  81. string grpTypeStr = (_grpDeleRep.Query<Sys_SetData>(s => s.Id == entity.TeamDid).First()).Name;
  82. GroupStatus_CreateModel info = new GroupStatus_CreateModel()
  83. {
  84. ClientName = entity.ClientName,
  85. ClientUnit = entity.ClientUnit,
  86. TeamName = entity.TeamName,
  87. VisitDays = entity.VisitDays,
  88. VisitPNumber = entity.VisitPNumber,
  89. VisitDateRange = dateRange,
  90. TeamDid_Text = grpTypeStr
  91. };
  92. //发送信息
  93. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  94. if (qwUserIdList.Count > 0)
  95. {
  96. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupStatus_Create(info));
  97. if (result.errcode != 0)
  98. {
  99. //抄送日志
  100. return false;
  101. }
  102. }
  103. return true;
  104. }
  105. #endregion
  106. #region 团组费用审核
  107. /// <summary>
  108. /// 向指定群聊发送- 费用申请 -通知
  109. /// </summary>
  110. /// <param name="Grp_CreditCardPaymentId"></param>
  111. /// <param name="sign"></param>
  112. /// <param name="qwEnum"></param>
  113. /// <returns></returns>
  114. public static async Task<bool> SendChatMsg_GroupStatus_ApplyFee(int Grp_CreditCardPaymentId, int sign, QiyeWeChatEnum qwEnum)
  115. {
  116. string chatId = qwEnum.GetEnumDescription();
  117. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  118. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  119. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  120. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  121. List<Grp_CreditCardPayment> entityList = _grpDeleRep
  122. .Query<Grp_CreditCardPayment>(s => s.DIId == ccp.DIId && s.IsDel == 0 && s.CreateUserId > 0 && s.IsAuditGM == 0)
  123. .ToList();
  124. GroupStatus_ApplyFeeModel info = new GroupStatus_ApplyFeeModel()
  125. {
  126. QueueCount = entityList.Count,
  127. TeamName = group.TeamName,
  128. Price = priceStr
  129. };
  130. if (sign == 2)
  131. {
  132. info.TitleStr = "[更新]一项费用待审核";
  133. }
  134. //CTable
  135. #region CTable
  136. if (ccp.CTable == 76)//76,酒店预订
  137. {
  138. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  139. info.CreateDt = _HotelReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  140. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  141. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  142. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  143. info.PriceModule = "酒店预订";
  144. info.PriceName = _HotelReservations.HotelName;
  145. }
  146. else if (ccp.CTable == 79) //79://车/导游地接
  147. {
  148. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  149. info.CreateDt = _CarTouristGuideGroundReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  150. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  151. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  152. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  153. info.PriceModule = "车/导游地接";
  154. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  155. }
  156. else if (ccp.CTable == 80) //签证
  157. {
  158. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  159. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  160. info.CreateDt = _VisaInfos.CreateTime.ToString("yyyy-MM-dd HH:mm");
  161. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  162. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  163. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  164. info.PriceModule = "签证";
  165. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  166. }
  167. else if (ccp.CTable == 81)//邀请/公务活动
  168. {
  169. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  170. info.CreateDt = _InvitationOfficialActivities.CreateTime.ToString("yyyy-MM-dd HH:mm");
  171. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  172. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  173. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  174. info.PriceModule = "邀请/公务活动";
  175. info.PriceName = _InvitationOfficialActivities.InviterArea;
  176. }
  177. else if (ccp.CTable == 82)//团组客户保险
  178. {
  179. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  180. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  181. info.CreateDt = _Customers.CreateTime.ToString("yyyy-MM-dd HH:mm");
  182. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  183. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  184. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  185. info.PriceModule = "团组客户保险";
  186. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  187. }
  188. else if (ccp.CTable == 85) //机票预订
  189. {
  190. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  191. info.CreateDt = _AirTicketReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  192. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  193. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  194. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  195. info.PriceModule = "机票预订";
  196. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  197. }
  198. else if (ccp.CTable == 98) //其他款项
  199. {
  200. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  201. info.CreateDt = _DecreasePayments.CreateTime.ToString("yyyy-MM-dd HH:mm");
  202. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  203. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  204. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  205. info.PriceModule = "其他款项";
  206. info.PriceName = _DecreasePayments.PriceName;
  207. }
  208. #endregion
  209. //发送信息
  210. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupStatus_ApplyFee(info));
  211. if (result.errcode != 0)
  212. {
  213. //抄送日志
  214. return false;
  215. }
  216. return true;
  217. }
  218. /// <summary>
  219. /// 向财务群发送费用审核结果通知(审核通过条件下发送)
  220. /// </summary>
  221. /// <param name="Grp_CreditCardPaymentId"></param>
  222. /// <param name="qwEnum"></param>
  223. /// <returns></returns>
  224. public static async Task<bool> SendChatMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, QiyeWeChatEnum qwEnum)
  225. {
  226. string chatId = qwEnum.GetEnumDescription();
  227. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  228. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  229. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  230. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  231. AuditResult_ApplyFee_GroupModel info = new AuditResult_ApplyFee_GroupModel()
  232. {
  233. TeamName = group.TeamName,
  234. Price = priceStr,
  235. GMAuditDate = "-"
  236. };
  237. DateTime gmAuditDt;
  238. bool bGMAuditDt = DateTime.TryParse(ccp.AuditGMDate, out gmAuditDt);
  239. info.GMAuditDate = gmAuditDt.ToString("yyyy-MM-dd HH:mm");
  240. //CTable
  241. #region CTable
  242. if (ccp.CTable == 76)//76,酒店预订
  243. {
  244. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  245. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  246. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  247. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  248. info.PriceModule = "酒店预订";
  249. info.PriceName = _HotelReservations.HotelName;
  250. }
  251. else if (ccp.CTable == 79) //79://车/导游地接
  252. {
  253. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  254. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  255. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  256. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  257. info.PriceModule = "车/导游地接";
  258. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  259. }
  260. else if (ccp.CTable == 80) //签证
  261. {
  262. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  263. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  264. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  265. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  266. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  267. info.PriceModule = "签证";
  268. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  269. }
  270. else if (ccp.CTable == 81)//邀请/公务活动
  271. {
  272. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  273. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  274. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  275. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  276. info.PriceModule = "邀请/公务活动";
  277. info.PriceName = _InvitationOfficialActivities.InviterArea;
  278. }
  279. else if (ccp.CTable == 82)//团组客户保险
  280. {
  281. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  282. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  283. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  284. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  285. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  286. info.PriceModule = "团组客户保险";
  287. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  288. }
  289. else if (ccp.CTable == 85) //机票预订
  290. {
  291. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  292. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  293. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  294. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  295. info.PriceModule = "机票预订";
  296. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  297. }
  298. else if (ccp.CTable == 98) //其他款项
  299. {
  300. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  301. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  302. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  303. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  304. info.PriceModule = "其他款项";
  305. info.PriceName = _DecreasePayments.PriceName;
  306. }
  307. #endregion
  308. //发送信息
  309. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.AuditResult_ApplyFee_Chat(info));
  310. if (result.errcode != 0)
  311. {
  312. //抄送日志
  313. return false;
  314. }
  315. return true;
  316. }
  317. /// <summary>
  318. /// 向指定用户发送-团组费用审核结果
  319. /// </summary>
  320. /// <param name="Grp_CreditCardPaymentId"></param>
  321. /// <param name="userId"></param>
  322. /// <param name="qwEnum"></param>
  323. /// <returns></returns>
  324. public static async Task<bool> SendUserMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, List<string> userId, QiyeWeChatEnum qwEnum)
  325. {
  326. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  327. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  328. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  329. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  330. AuditResult_ApplyFee_GroupModel info = new AuditResult_ApplyFee_GroupModel()
  331. {
  332. TeamName = group.TeamName,
  333. Price = priceStr,
  334. GMAuditDate = "-"
  335. };
  336. DateTime gmAuditDt;
  337. bool bGMAuditDt = DateTime.TryParse(ccp.AuditGMDate, out gmAuditDt);
  338. info.GMAuditDate = gmAuditDt.ToString("yyyy-MM-dd HH:mm");
  339. if (ccp.IsAuditGM == 2)
  340. {
  341. info.Result = "总经理审核未通过";
  342. info.ResultColor = "warning";
  343. }
  344. //CTable
  345. #region CTable
  346. if (ccp.CTable == 76)//76,酒店预订
  347. {
  348. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  349. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  350. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  351. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  352. info.PriceModule = "酒店预订";
  353. info.PriceName = _HotelReservations.HotelName;
  354. }
  355. else if (ccp.CTable == 79) //79://车/导游地接
  356. {
  357. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  358. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  359. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  360. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  361. info.PriceModule = "车/导游地接";
  362. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  363. }
  364. else if (ccp.CTable == 80) //签证
  365. {
  366. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  367. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  368. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  369. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  370. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  371. info.PriceModule = "签证";
  372. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  373. }
  374. else if (ccp.CTable == 81)//邀请/公务活动
  375. {
  376. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  377. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  378. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  379. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  380. info.PriceModule = "邀请/公务活动";
  381. info.PriceName = _InvitationOfficialActivities.InviterArea;
  382. }
  383. else if (ccp.CTable == 82)//团组客户保险
  384. {
  385. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  386. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  387. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  388. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  389. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  390. info.PriceModule = "团组客户保险";
  391. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  392. }
  393. else if (ccp.CTable == 85) //机票预订
  394. {
  395. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  396. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  397. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  398. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  399. info.PriceModule = "机票预订";
  400. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  401. }
  402. else if (ccp.CTable == 98) //其他款项
  403. {
  404. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  405. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  406. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  407. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  408. info.PriceModule = "其他款项";
  409. info.PriceName = _DecreasePayments.PriceName;
  410. }
  411. #endregion
  412. //发送信息
  413. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  414. if (qwUserIdList.Count > 0)
  415. {
  416. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.AuditResult_ApplyFee_User(info));
  417. if (ccp.IsAuditGM == 1)
  418. {
  419. await SendChatMsg_GroupStatus_AuditFee(Grp_CreditCardPaymentId, qwEnum);
  420. }
  421. if (result.errcode != 0)
  422. {
  423. //抄送日志
  424. return false;
  425. }
  426. }
  427. return true;
  428. }
  429. /// <summary>
  430. /// 向指定用户发送-团组费用支付结果
  431. /// </summary>
  432. /// <param name="Grp_CreditCardPaymentId"></param>
  433. /// <param name="userId"></param>
  434. /// <returns></returns>
  435. public static async Task<bool> SendUserMsg_GroupStatus_PayResult(int Grp_CreditCardPaymentId, List<string> userId)
  436. {
  437. //, QiyeWeChatEnum qiyeWeChat
  438. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  439. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  440. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  441. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  442. PayResult_Group_ToUserModel info = new PayResult_Group_ToUserModel()
  443. {
  444. PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  445. Price = priceStr,
  446. TeamName = group.TeamName
  447. };
  448. #region CTable
  449. if (ccp.CTable == 76)//76,酒店预订
  450. {
  451. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  452. info.PriceModule = "酒店预订";
  453. info.PriceName = _HotelReservations.HotelName;
  454. }
  455. else if (ccp.CTable == 79) //79://车/导游地接
  456. {
  457. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  458. info.PriceModule = "车/导游地接";
  459. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  460. }
  461. else if (ccp.CTable == 80) //签证
  462. {
  463. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  464. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  465. info.PriceModule = "签证";
  466. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  467. }
  468. else if (ccp.CTable == 81)//邀请/公务活动
  469. {
  470. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  471. info.PriceModule = "邀请/公务活动";
  472. info.PriceName = _InvitationOfficialActivities.InviterArea;
  473. }
  474. else if (ccp.CTable == 82)//团组客户保险
  475. {
  476. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  477. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  478. info.PriceModule = "团组客户保险";
  479. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  480. }
  481. else if (ccp.CTable == 85) //机票预订
  482. {
  483. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  484. info.PriceModule = "机票预订";
  485. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  486. }
  487. else if (ccp.CTable == 98) //其他款项
  488. {
  489. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  490. info.PriceModule = "其他款项";
  491. info.PriceName = _DecreasePayments.PriceName;
  492. }
  493. #endregion
  494. //发送信息
  495. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  496. if (qwUserIdList.Count > 0)
  497. {
  498. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.PayResult_Group_ToUser(info));
  499. if (result.errcode != 0)
  500. {
  501. //抄送日志
  502. return false;
  503. }
  504. }
  505. return true;
  506. }
  507. #endregion
  508. #region 团组出发、结束提醒(财务群)
  509. public static async Task<bool> SendChatMsg_GroupRemindersToCaiwu(List<Grp_DelegationInfo> list_7day, List<Grp_DelegationInfo> list_3day, List<Grp_DelegationInfo> list_minus1day, QiyeWeChatEnum qwEnum)
  510. {
  511. string chatId = qwEnum.GetEnumDescription();
  512. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToCaiwuChat(list_7day, list_3day, list_minus1day));
  513. if (result.errcode != 0)
  514. {
  515. //抄送日志
  516. return false;
  517. }
  518. return true;
  519. }
  520. #endregion
  521. #region 团组结束提醒(国交群)
  522. public static async Task<bool> SendChatMsg_GroupRemindersToGuojiao(List<Grp_DelegationInfo> list_3day, QiyeWeChatEnum qwEnum)
  523. {
  524. string chatId = qwEnum.GetEnumDescription();
  525. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToGuojiao(list_3day));
  526. if (result.errcode != 0)
  527. {
  528. //抄送日志
  529. return false;
  530. }
  531. return true;
  532. }
  533. #endregion
  534. #region 团组出发提醒(HR)
  535. public static async Task<bool> SendUserMsg_DelegationVisit_ToHR(List<Grp_DelegationInfo> list_3day, List<string> userId)
  536. {
  537. //发送信息
  538. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  539. if (qwUserIdList.Count > 0)
  540. {
  541. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupRemindersToHR(list_3day));
  542. if (result.errcode != 0)
  543. {
  544. //抄送日志
  545. return false;
  546. }
  547. }
  548. return true;
  549. }
  550. #endregion
  551. #region 市场部新增客户资源统计
  552. /// <summary>
  553. /// 周统计
  554. /// </summary>
  555. /// <param name="sourceList"></param>
  556. /// <param name="userId"></param>
  557. /// <param name="begin"></param>
  558. /// <param name="end"></param>
  559. /// <returns></returns>
  560. public static async Task<bool> SendUserMsg_CRMStatistics_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end)
  561. {
  562. //发送信息
  563. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  564. if (qwUserIdList.Count > 0)
  565. {
  566. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_ToUser(sourceList, begin, end));
  567. if (result.errcode != 0)
  568. {
  569. //抄送日志
  570. return false;
  571. }
  572. }
  573. return true;
  574. }
  575. /// <summary>
  576. /// 月统计
  577. /// </summary>
  578. /// <param name="sourceList"></param>
  579. /// <param name="userId"></param>
  580. /// <param name="begin"></param>
  581. /// <param name="end"></param>
  582. /// <param name="totalInsert"></param>
  583. /// <param name="totalDelete"></param>
  584. /// <returns></returns>
  585. public static async Task<bool> SendUserMsg_CRMStatistics_Month_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end, int totalInsert, int totalDelete)
  586. {
  587. //发送信息
  588. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  589. if (qwUserIdList.Count > 0)
  590. {
  591. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_Month_ToUser(sourceList, begin, end, totalInsert, totalDelete));
  592. if (result.errcode != 0)
  593. {
  594. //抄送日志
  595. return false;
  596. }
  597. }
  598. return true;
  599. }
  600. #endregion
  601. #region 日付申请审核
  602. /// <summary>
  603. /// 日付申请提交时推送财务群
  604. /// </summary>
  605. /// <param name="dailyPayId"></param>
  606. /// <param name="sign"></param>
  607. /// <param name="qwEnum"></param>
  608. /// <returns></returns>
  609. public static async Task<bool> DailyPayReminders_Create_ToCaiwuChat(int dailyPayId, int sign, QiyeWeChatEnum qwEnum)
  610. {
  611. string chatId = qwEnum.GetEnumDescription();
  612. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  613. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
  614. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  615. string users = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  616. string[] companyArr = new string[] { "未知", "成都泛美商务有限公司", "四川泛美交流有限公司", "成都纽茵教育科技有限公司", "成都鸿企中元科技有限公司", "测试公司1" };
  617. string companyStr = "未知";
  618. if (fin_DailyFeePayment.CompanyId < companyArr.Length)
  619. {
  620. companyStr = companyArr[fin_DailyFeePayment.CompanyId];
  621. }
  622. Sys_SetData sd_tansferType = _grpDeleRep.Query<Sys_SetData>(s => s.Id == fin_DailyFeePayment.TransferTypeId).First();
  623. Sys_SetData sd_priceType = _grpDeleRep.Query<Sys_SetData>(s => s.Id == fin_DailyFeePayment.PriceTypeId).First();
  624. string feeSignStr = string.Format(@"{0}-{1}", sd_tansferType.Name, sd_priceType?.Name ?? "");
  625. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  626. DailyPayReminders_Create_ToCaiwuChatModel info = new DailyPayReminders_Create_ToCaiwuChatModel()
  627. {
  628. CreateDt = fin_DailyFeePayment.CreateTime.ToString("yyyy-MM-dd HH:mm"),
  629. CreateUser = users,
  630. Price = priceStr,
  631. Company = companyStr,
  632. FeeSign = feeSignStr,
  633. PriceName = fin_DailyFeePayment.Instructions
  634. };
  635. if (sign == 2) info.TitleStr = "[更新]一项费用待审核";
  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. /// 三公费用汇率大于实时汇率 通知发送(22、208、5)
  736. /// </summary>
  737. /// <param name="diId"></param>
  738. /// <param name="operationId"></param>
  739. /// <returns></returns>
  740. public static async Task<bool> SendUserMsg_GroupShare_ToFin(int diId,int operationId, string msgContent)
  741. {
  742. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  743. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  744. var defaultUserIds = new List<string>() { "208", "22", "5" };
  745. if (defaultUserIds.Count > 0)
  746. {
  747. List<string> qwUserIdList = GetQiyeChatUserIdList(defaultUserIds);
  748. string resMsg = string.Format(@" `出入境费用汇率变更通知`
  749. >团组:<font color='info'>{0}</font>
  750. >**汇率明细**
  751. {1}
  752. >操作人员:<font color='comment'>{2}</font>
  753. >操作时间:<font color='comment'>{3}</font>
  754. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, msgContent, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  755. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  756. if (result.errcode != 0)
  757. {
  758. //抄送日志
  759. return false;
  760. }
  761. }
  762. return true;
  763. }
  764. #endregion
  765. #region 三公费用更改通知
  766. /// <summary>
  767. /// 三公费用更改通知发送总经理(21)
  768. /// </summary>
  769. /// <param name="diId"></param>
  770. /// <param name="receivedUserIds"></param>
  771. /// <param name="updateUserId"></param>
  772. /// <param name="url"></param>
  773. /// <returns></returns>
  774. public static async Task<bool> SendUserMsg_GroupShare_ToGM(int diId, List<string> receivedUserIds, int updateUserId, string url)
  775. {
  776. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  777. GroupShare_ToGMModel info = new GroupShare_ToGMModel()
  778. {
  779. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  780. TeamName = groupInfo.TeamName,
  781. CreateUser = _grpDeleRep.Query<Sys_Users>(s => s.Id == updateUserId).First()?.CnName ?? "-",
  782. Url = url
  783. };
  784. if (receivedUserIds.Count > 0)
  785. {
  786. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  787. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToGM(info));
  788. if (result.errcode != 0)
  789. {
  790. //抄送日志
  791. return false;
  792. }
  793. }
  794. return true;
  795. }
  796. /// <summary>
  797. /// 三公费用确认通知发送财务部人员
  798. /// </summary>
  799. /// <param name="diId"></param>
  800. /// <returns></returns>
  801. public static async Task<bool> SendUserMsg_GroupShare_ToFinance(int diId)
  802. {
  803. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  804. GroupShare_ToUserModel info = new GroupShare_ToUserModel()
  805. {
  806. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  807. TeamName = groupInfo.TeamName
  808. };
  809. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 3).Select(x => x.Id.ToString()).ToList();
  810. var defaultUserIds = new List<string>() { "208", "233" };
  811. receivedUserIds.AddRange(defaultUserIds);
  812. if (receivedUserIds.Contains("150")) receivedUserIds.Remove("150");
  813. if (receivedUserIds.Count > 0)
  814. {
  815. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  816. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToFinance(info));
  817. if (result.errcode != 0)
  818. {
  819. //抄送日志
  820. return false;
  821. }
  822. }
  823. return true;
  824. }
  825. #endregion
  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_ToDP(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>() { 22, 32 };
  837. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && defaultJobPostIds.Contains(s.JobPostId)).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. #region 公务出访数据变更发送通知
  858. /// <summary>
  859. /// 机票行程代码录入变更通知发送国交经理、主管、王鸽
  860. /// </summary>
  861. /// <param name="diId"></param>
  862. /// <param name="operationId"></param>
  863. /// <returns></returns>
  864. public static async Task<bool> SendUserMsg_GroupShare_ToOP(int diId, int operationId)
  865. {
  866. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  867. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  868. var defaultJobPostIds = new List<int>();
  869. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && s.JobPostId == 28).Select(x => x.Id.ToString()).ToList();
  870. var defaultUserIds = new List<string>() { "208", "233" };
  871. receivedUserIds.AddRange(defaultUserIds);
  872. if (receivedUserIds.Count > 0)
  873. {
  874. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  875. string resMsg = string.Format(@" `公务出访有数据更新通知`
  876. >团组:<font color='info'>{0}</font>
  877. >操作人员:<font color='comment'>{1}</font>
  878. >操作时间:<font color='comment'>{2}</font>
  879. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  880. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  881. if (result.errcode != 0)
  882. {
  883. //抄送日志
  884. return false;
  885. }
  886. }
  887. return true;
  888. }
  889. #endregion
  890. #endregion
  891. #region 成本通知
  892. /// <summary>
  893. /// 成本通知发送给对应岗位用户
  894. /// </summary>
  895. /// <param name="diId"></param>
  896. /// <returns></returns>
  897. public static async Task<bool> SendUserMsg_GroupShare_ToJob(int diId)
  898. {
  899. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  900. List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 24 || s.JobPostId == 25 || s.JobPostId == 28)).ToList();
  901. //List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 40 || s.JobPostId == 41)).ToList();
  902. List<string> userIds = new List<string>();
  903. list_user.ForEach(s => userIds.Add(s.Id.ToString()));
  904. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  905. GroupShare_ToUserModel info = new GroupShare_ToUserModel()
  906. {
  907. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  908. TeamName = groupInfo.TeamName
  909. };
  910. if (qwUserIdList.Count > 0)
  911. {
  912. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToUser(info));
  913. if (result.errcode != 0)
  914. {
  915. //抄送日志
  916. return false;
  917. }
  918. }
  919. return true;
  920. }
  921. public static async Task<bool> SendUserMsg_blackAirInfo_ToVisaUser(int diId, List<CountryDataTime> arr)
  922. {
  923. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  924. var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
  925. .Select(x => x.Id)
  926. .ToList();
  927. List<string> userIds = new List<string>() { "235" };
  928. userIds.AddRange(visaUser.Select(x => x.ToString()));
  929. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  930. BlackCodeInfo_ToVisaUser info = new BlackCodeInfo_ToVisaUser()
  931. {
  932. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  933. TeamName = groupInfo.TeamName,
  934. info = arr
  935. };
  936. if (qwUserIdList.Count > 0)
  937. {
  938. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.BlackCodeInfo_ToVisaUser(info));
  939. if (result.errcode != 0)
  940. {
  941. //抄送日志
  942. return false;
  943. }
  944. }
  945. return true;
  946. }
  947. public static async Task<bool> SendUserMsg_GroupTimeInfo_ToVisaUser(int diId, string startTime, string endTime)
  948. {
  949. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  950. var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
  951. .Select(x => x.Id)
  952. .ToList();
  953. List<string> userIds = new List<string>() { "235" };
  954. userIds.AddRange(visaUser.Select(x => x.ToString()));
  955. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  956. GroupDateTime_ToVisaUser info = new GroupDateTime_ToVisaUser()
  957. {
  958. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  959. TeamName = groupInfo.TeamName,
  960. EndTime = endTime,
  961. StartTime = startTime,
  962. };
  963. if (qwUserIdList.Count > 0)
  964. {
  965. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupDateTime_ToVisaUser(info));
  966. if (result.errcode != 0)
  967. {
  968. //抄送日志
  969. return false;
  970. }
  971. }
  972. return true;
  973. }
  974. #endregion
  975. #region 任务通知
  976. /// <summary>
  977. /// 任务通知
  978. /// </summary>
  979. /// <param name="userIds"></param>
  980. /// <param name="groupId"></param>
  981. /// <param name="title"></param>
  982. /// <param name="currUserId"></param>
  983. /// <returns></returns>
  984. public static async Task<bool> SendUserMsg_Task_ToUser(List<string> userIds, int groupId, string title, int currUserId)
  985. {
  986. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  987. if (qwUserIdList.Any())
  988. {
  989. var groupName = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.IsDel == 0 && s.Id == groupId).First()?.TeamName ?? "未选择";
  990. var userName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == currUserId).First()?.CnName ?? "Unknown";
  991. var model = new TaskAssignment_Create_ToUserModel()
  992. {
  993. GroupName = groupName,
  994. Title = title,
  995. CreateUser = userName,
  996. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm")
  997. };
  998. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskAssignment_Create_ToUser(model));
  999. if (result.errcode != 0)
  1000. {
  1001. //抄送日志
  1002. return false;
  1003. }
  1004. }
  1005. return true;
  1006. }
  1007. #endregion
  1008. #region 物资通知
  1009. /// <summary>
  1010. /// 物资领用通知
  1011. /// 接收者:审核节点相关审核人
  1012. /// </summary>
  1013. /// <param name="dataId"></param>
  1014. /// <param name="diId"></param>
  1015. /// <param name="operationId"></param>
  1016. /// <returns></returns>
  1017. public static async Task<bool> SendUserMsg_CompanyShare_ToHR(int dataId,int diId, int operationId)
  1018. {
  1019. //企微通知
  1020. var userIds = new List<string>()
  1021. {
  1022. "208", //雷怡
  1023. "374", //罗颖
  1024. };
  1025. var isCheckValuable = false;
  1026. var valuableUserNames = new List<string>();
  1027. //根据审核节点的审核人,发送通知
  1028. var flow = _grpDeleRep._sqlSugar.Queryable<Sys_AuditFlow>().First(x => x.IsDel == 0 && x.BusinessType == 1 && x.BusinessId == dataId);
  1029. if (flow != null)
  1030. {
  1031. var auditNode = _grpDeleRep._sqlSugar
  1032. .Queryable<Sys_AuditTemplateNode>()
  1033. .First(x => x.IsDel == 0 && x.TemplateId == flow.TemplateId && x.Id == flow.CurrentNodeId);
  1034. if (auditNode != null)
  1035. {
  1036. var auditUserList = _grpDeleRep._sqlSugar.Queryable<Sys_AuditTemplateNodeUser>()
  1037. .Where(x => x.IsDel == 0 && x.NodeId == auditNode.Id)
  1038. .Select(x => new {
  1039. x.UserId,
  1040. x.UserName
  1041. })
  1042. .ToList();
  1043. if (auditUserList.Any())
  1044. {
  1045. if (auditUserList.Count > 1) isCheckValuable = true;
  1046. userIds.AddRange(auditUserList.Select(x => x.UserId.ToString()).ToList());
  1047. userIds = userIds.Distinct().ToList();
  1048. valuableUserNames.AddRange( auditUserList.Select(x => x.UserName).ToList());
  1049. }
  1050. }
  1051. }
  1052. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  1053. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  1054. var groupName = diId switch
  1055. {
  1056. 0 => "其他物资(公司内部物资)",
  1057. -1 => "拜访客户所使用的物资",
  1058. -2 => "库存调整",
  1059. _ => groupInfo?.TeamName ?? "-"
  1060. };
  1061. var receiveInfo = _grpDeleRep._sqlSugar.Queryable<Pm_GoodsReceive>().First(x => x.IsDel == 0 && x.Id == dataId);
  1062. if (receiveInfo == null) return false;
  1063. var receiveDetails = _grpDeleRep._sqlSugar
  1064. .Queryable<Pm_GoodsReceiveDetails>()
  1065. .LeftJoin<Pm_GoodsInfo>((x,y) => x.GoodsId == y.Id)
  1066. .Where(x => x.IsDel == 0 && x.GoodsReceiveId == dataId)
  1067. .Select((x,y) => new {
  1068. y.Name,
  1069. x.Quantity,
  1070. y.Unit
  1071. })
  1072. .ToList();
  1073. if (!receiveDetails.Any()) return false;
  1074. var goodsMsg = new StringBuilder();
  1075. foreach (var info in receiveDetails)
  1076. {
  1077. goodsMsg.AppendLine($">- {info.Name}:{info.Quantity:#0.00} {info.Unit}");
  1078. }
  1079. var groupLabel = string.Empty;
  1080. if (string.IsNullOrEmpty(groupName) || !groupName.Equals("-"))
  1081. {
  1082. groupLabel = $">团组归属:<font color='info'>{groupName}</font>";
  1083. }
  1084. //普通物品审批消息通知
  1085. string resMsg = string.Format(@" ` 物资领用申请通知 `
  1086. > ` {0} `提交物资领用申请:
  1087. {1}
  1088. >**物资明细**
  1089. {2}
  1090. >用途:<font color='comment'>{3}</font>
  1091. >申请时间:<font color='comment'>{4}</font>
  1092. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1093. operationName,
  1094. groupLabel,
  1095. goodsMsg,
  1096. receiveInfo.Reason,
  1097. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1098. //贵重物品审批消息通知
  1099. if (isCheckValuable)
  1100. {
  1101. var auditUserLabel = string.Empty;
  1102. foreach (var userName in valuableUserNames)
  1103. {
  1104. auditUserLabel += $"@{userName} ";
  1105. }
  1106. resMsg = string.Format(@" ` 【或签审批】物资领用(任一人审批即可)通知 `
  1107. >{0}
  1108. > ` {1} `提交物资领用申请,您被列为或签审批人:
  1109. **或签规则**
  1110. • 您与其他{2}人并行审批
  1111. • 任意一人通过即视为本环节通过
  1112. • 任意一人拒绝即视为终止流程
  1113. {3}
  1114. >**物资明细**
  1115. {4}
  1116. >用途:<font color='comment'>{5}</font>
  1117. >申请时间:<font color='comment'>{6}</font>
  1118. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1119. auditUserLabel,
  1120. operationName,
  1121. valuableUserNames.Count - 1 ,
  1122. groupLabel,
  1123. goodsMsg,
  1124. receiveInfo.Reason,
  1125. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1126. }
  1127. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  1128. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1129. if (result.errcode != 0)
  1130. {
  1131. //抄送日志
  1132. return false;
  1133. }
  1134. return true;
  1135. }
  1136. #endregion
  1137. #region 日服申请
  1138. /// <summary>
  1139. /// 日服申请、编辑通知
  1140. /// 接收者:指定接收者
  1141. /// </summary>
  1142. /// <param name="dataId"></param>
  1143. /// <param name="operationId">操作人Id</param>
  1144. /// <param name="recipients">接收者Id集合</param>
  1145. /// <returns></returns>
  1146. public static async Task<bool> SendUserMsg_CompanyShare_ToDailtPay(int dataId, int operationId,List<string> recipients)
  1147. {
  1148. //企微通知
  1149. var userIds = recipients;
  1150. string operationName = _grpDeleRep._sqlSugar.Queryable<Sys_Users>().First(x => x.IsDel
  1151. == 0 && x.Id == operationId).CnName ?? "Unknown";
  1152. var dailyPaymentInfo = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePayment>()
  1153. .FirstAsync(x => x.IsDel == 0 && x.Id == dataId);
  1154. var details = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePaymentContent>()
  1155. .Where(x => x.IsDel == 0 && x.DFPId == dataId)
  1156. .Select(x => new { x.PriceName, x.Quantity, x.Price })
  1157. .ToListAsync();
  1158. var detailsMsg = new StringBuilder();
  1159. foreach (var info in details)
  1160. {
  1161. detailsMsg.AppendLine($">- {info.PriceName}:{info.Quantity:#0.00} * {info.Price:#0.00} = {info.Quantity * info.Price:#0.00} 元");
  1162. }
  1163. if (detailsMsg.Length == 0 || detailsMsg == null)
  1164. {
  1165. detailsMsg.Append("无费用明细");
  1166. }
  1167. //普通物品审批消息通知
  1168. string resMsg = string.Format(@" ` 日付申请通知 `
  1169. > ` {0} `提交费用申请:
  1170. >**费用明细**
  1171. {1}
  1172. >总金额:<font color='comment'>{2} 元</font>
  1173. >申请说明:<font color='comment'>{3}</font>
  1174. >申请时间:<font color='comment'>{4}</font>
  1175. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1176. operationName,
  1177. detailsMsg.ToString(),
  1178. dailyPaymentInfo?.SumPrice.ToString("#0.00") ?? "0.00",
  1179. dailyPaymentInfo?.Instructions ?? "无申请说明",
  1180. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1181. List<string> qwUserIdList = GetQiyeChatUserIdList(recipients);
  1182. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1183. if (result.errcode != 0)
  1184. {
  1185. //抄送日志
  1186. return false;
  1187. }
  1188. return true;
  1189. }
  1190. #endregion
  1191. #region Helper
  1192. private static string getClientNameStr(List<SimplClientInfo> list, string origin)
  1193. {
  1194. string result = origin;
  1195. if (Regex.Match(origin, @"\d +,?").Value.Length > 0)
  1196. {
  1197. string[] temparr = origin.Split(',');
  1198. string fistrStr = temparr[0];
  1199. int count = temparr.Length;
  1200. int tempId;
  1201. bool success = int.TryParse(fistrStr, out tempId);
  1202. if (success)
  1203. {
  1204. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1205. if (tempInfo != null)
  1206. {
  1207. if (count > 1)
  1208. {
  1209. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1210. }
  1211. else
  1212. {
  1213. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1214. }
  1215. }
  1216. }
  1217. }
  1218. return result;
  1219. }
  1220. private static List<SimplClientInfo> getSimplClientList(int diId)
  1221. {
  1222. 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);
  1223. List<SimplClientInfo> arr = _grpDeleRep._sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1224. return arr;
  1225. }
  1226. #endregion
  1227. }
  1228. }