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