Library.cs 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593
  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. using OASystem.Domain.Entities.WorkOrder;
  10. namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
  11. {
  12. public static class AppNoticeLibrary
  13. {
  14. private static readonly IQiYeWeChatApiService _qiYeWeChatApiService = AutofacIocManager.Instance.GetService<IQiYeWeChatApiService>();
  15. private static readonly DelegationInfoRepository _grpDeleRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
  16. #region 获取企微Id
  17. public static List<string> GetQiyeChatUserIdList(List<string> userId)
  18. {
  19. List<string> result = new List<string>();
  20. try
  21. {
  22. foreach (string item in userId)
  23. {
  24. int uid = int.Parse(item);
  25. Sys_Users users = _grpDeleRep.Query<Sys_Users>(s => s.Id == uid).First();
  26. if (!string.IsNullOrEmpty(users.QiyeChatUserId))
  27. {
  28. result.Add(users.QiyeChatUserId);
  29. }
  30. }
  31. }
  32. catch (Exception ex)
  33. {
  34. }
  35. return result;
  36. }
  37. #endregion
  38. #region 确认出团
  39. /// <summary>
  40. /// 向指定群聊发送- 确认出团 -通知
  41. /// </summary>
  42. /// <param name="diId"></param>
  43. /// <param name="qwEnum"></param>
  44. /// <returns></returns>
  45. public static async Task<bool> SendChatMsg_GroupStatus_Create(int diId, QiyeWeChatEnum qwEnum)
  46. {
  47. Grp_DelegationInfo entity = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  48. string dateRange = string.Format(@"{0}至{1}", entity.VisitStartDate.ToString("yyyy-MM-dd"), entity.VisitEndDate.ToString("yyyy-MM-dd"));
  49. string grpTypeStr = (_grpDeleRep.Query<Sys_SetData>(s => s.Id == entity.TeamDid).First()).Name;
  50. GroupStatus_CreateModel info = new GroupStatus_CreateModel()
  51. {
  52. ClientName = entity.ClientName,
  53. ClientUnit = entity.ClientUnit,
  54. TeamName = entity.TeamName,
  55. VisitDays = entity.VisitDays,
  56. VisitPNumber = entity.VisitPNumber,
  57. VisitDateRange = dateRange,
  58. TeamDid_Text = grpTypeStr
  59. };
  60. string chatId = qwEnum.GetEnumDescription();
  61. //发送信息
  62. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupStatus_Create(info));
  63. if (result.errcode != 0)
  64. {
  65. //抄送日志
  66. return false;
  67. }
  68. return true;
  69. }
  70. /// <summary>
  71. /// 向指定用户发送- 确认出团 -通知
  72. /// </summary>
  73. /// <param name="diId"></param>
  74. /// <param name="userId"></param>
  75. /// <returns></returns>
  76. public static async Task<bool> SendUserMsg_GroupStatus_Create(int diId, List<string> userId)
  77. {
  78. Grp_DelegationInfo entity = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  79. string dateRange = string.Format(@"{0}至{1}", entity.VisitStartDate.ToString("yyyy-MM-dd"), entity.VisitEndDate.ToString("yyyy-MM-dd"));
  80. string grpTypeStr = (_grpDeleRep.Query<Sys_SetData>(s => s.Id == entity.TeamDid).First()).Name;
  81. GroupStatus_CreateModel info = new GroupStatus_CreateModel()
  82. {
  83. ClientName = entity.ClientName,
  84. ClientUnit = entity.ClientUnit,
  85. TeamName = entity.TeamName,
  86. VisitDays = entity.VisitDays,
  87. VisitPNumber = entity.VisitPNumber,
  88. VisitDateRange = dateRange,
  89. TeamDid_Text = grpTypeStr
  90. };
  91. //发送信息
  92. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  93. if (qwUserIdList.Count > 0)
  94. {
  95. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupStatus_Create(info));
  96. if (result.errcode != 0)
  97. {
  98. //抄送日志
  99. return false;
  100. }
  101. }
  102. return true;
  103. }
  104. #endregion
  105. #region 团组费用审核
  106. /// <summary>
  107. /// 向指定群聊发送- 费用申请 -通知
  108. /// </summary>
  109. /// <param name="Grp_CreditCardPaymentId"></param>
  110. /// <param name="sign"></param>
  111. /// <param name="qwEnum"></param>
  112. /// <returns></returns>
  113. public static async Task<bool> SendChatMsg_GroupStatus_ApplyFee(int Grp_CreditCardPaymentId, int sign, QiyeWeChatEnum qwEnum)
  114. {
  115. string chatId = qwEnum.GetEnumDescription();
  116. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  117. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  118. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  119. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  120. List<Grp_CreditCardPayment> entityList = _grpDeleRep
  121. .Query<Grp_CreditCardPayment>(s => s.DIId == ccp.DIId && s.IsDel == 0 && s.CreateUserId > 0 && s.IsAuditGM == 0)
  122. .ToList();
  123. GroupStatus_ApplyFeeModel info = new GroupStatus_ApplyFeeModel()
  124. {
  125. QueueCount = entityList.Count,
  126. TeamName = group.TeamName,
  127. Price = priceStr
  128. };
  129. if (sign == 2)
  130. {
  131. info.TitleStr = "[更新]一项费用待审核";
  132. }
  133. //CTable
  134. #region CTable
  135. if (ccp.CTable == 76)//76,酒店预订
  136. {
  137. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  138. info.CreateDt = _HotelReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  139. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  140. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  141. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  142. info.PriceModule = "酒店预订";
  143. info.PriceName = _HotelReservations.HotelName;
  144. }
  145. else if (ccp.CTable == 79) //79://车/导游地接
  146. {
  147. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  148. info.CreateDt = _CarTouristGuideGroundReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  149. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  150. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  151. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  152. info.PriceModule = "车/导游地接";
  153. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  154. }
  155. else if (ccp.CTable == 80) //签证
  156. {
  157. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  158. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  159. info.CreateDt = _VisaInfos.CreateTime.ToString("yyyy-MM-dd HH:mm");
  160. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  161. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  162. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  163. info.PriceModule = "签证";
  164. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  165. }
  166. else if (ccp.CTable == 81)//邀请/公务活动
  167. {
  168. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  169. info.CreateDt = _InvitationOfficialActivities.CreateTime.ToString("yyyy-MM-dd HH:mm");
  170. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  171. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  172. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  173. info.PriceModule = "邀请/公务活动";
  174. info.PriceName = _InvitationOfficialActivities.InviterArea;
  175. }
  176. else if (ccp.CTable == 82)//团组客户保险
  177. {
  178. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  179. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  180. info.CreateDt = _Customers.CreateTime.ToString("yyyy-MM-dd HH:mm");
  181. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  182. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  183. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  184. info.PriceModule = "团组客户保险";
  185. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  186. }
  187. else if (ccp.CTable == 85) //机票预订
  188. {
  189. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  190. info.CreateDt = _AirTicketReservations.CreateTime.ToString("yyyy-MM-dd HH:mm");
  191. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  192. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  193. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  194. info.PriceModule = "机票预订";
  195. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  196. }
  197. else if (ccp.CTable == 98) //其他款项
  198. {
  199. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  200. info.CreateDt = _DecreasePayments.CreateTime.ToString("yyyy-MM-dd HH:mm");
  201. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  202. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  203. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  204. info.PriceModule = "其他款项";
  205. info.PriceName = _DecreasePayments.PriceName;
  206. }
  207. #endregion
  208. //发送信息
  209. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupStatus_ApplyFee(info));
  210. if (result.errcode != 0)
  211. {
  212. //抄送日志
  213. return false;
  214. }
  215. return true;
  216. }
  217. /// <summary>
  218. /// 向财务群发送费用审核结果通知(审核通过条件下发送)
  219. /// </summary>
  220. /// <param name="Grp_CreditCardPaymentId"></param>
  221. /// <param name="qwEnum"></param>
  222. /// <returns></returns>
  223. public static async Task<bool> SendChatMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, QiyeWeChatEnum qwEnum)
  224. {
  225. string chatId = qwEnum.GetEnumDescription();
  226. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  227. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  228. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  229. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  230. AuditResult_ApplyFee_GroupModel info = new AuditResult_ApplyFee_GroupModel()
  231. {
  232. TeamName = group.TeamName,
  233. Price = priceStr,
  234. GMAuditDate = "-"
  235. };
  236. DateTime gmAuditDt;
  237. bool bGMAuditDt = DateTime.TryParse(ccp.AuditGMDate, out gmAuditDt);
  238. info.GMAuditDate = gmAuditDt.ToString("yyyy-MM-dd HH:mm");
  239. //CTable
  240. #region CTable
  241. if (ccp.CTable == 76)//76,酒店预订
  242. {
  243. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  244. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  245. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  246. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  247. info.PriceModule = "酒店预订";
  248. info.PriceName = _HotelReservations.HotelName;
  249. }
  250. else if (ccp.CTable == 79) //79://车/导游地接
  251. {
  252. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  253. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  254. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  255. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  256. info.PriceModule = "车/导游地接";
  257. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  258. }
  259. else if (ccp.CTable == 80) //签证
  260. {
  261. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  262. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  263. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  264. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  265. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  266. info.PriceModule = "签证";
  267. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  268. }
  269. else if (ccp.CTable == 81)//邀请/公务活动
  270. {
  271. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  272. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  273. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  274. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  275. info.PriceModule = "邀请/公务活动";
  276. info.PriceName = _InvitationOfficialActivities.InviterArea;
  277. }
  278. else if (ccp.CTable == 82)//团组客户保险
  279. {
  280. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  281. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  282. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  283. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  284. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  285. info.PriceModule = "团组客户保险";
  286. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  287. }
  288. else if (ccp.CTable == 85) //机票预订
  289. {
  290. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  291. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  292. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  293. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  294. info.PriceModule = "机票预订";
  295. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  296. }
  297. else if (ccp.CTable == 98) //其他款项
  298. {
  299. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  300. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  301. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  302. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  303. info.PriceModule = "其他款项";
  304. info.PriceName = _DecreasePayments.PriceName;
  305. }
  306. #endregion
  307. //发送信息
  308. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.AuditResult_ApplyFee_Chat(info));
  309. if (result.errcode != 0)
  310. {
  311. //抄送日志
  312. return false;
  313. }
  314. return true;
  315. }
  316. /// <summary>
  317. /// 向指定用户发送-团组费用审核结果
  318. /// </summary>
  319. /// <param name="Grp_CreditCardPaymentId"></param>
  320. /// <param name="userId"></param>
  321. /// <param name="qwEnum"></param>
  322. /// <returns></returns>
  323. public static async Task<bool> SendUserMsg_GroupStatus_AuditFee(int Grp_CreditCardPaymentId, List<string> userId, QiyeWeChatEnum qwEnum)
  324. {
  325. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  326. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  327. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  328. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  329. AuditResult_ApplyFee_GroupModel info = new AuditResult_ApplyFee_GroupModel()
  330. {
  331. TeamName = group.TeamName,
  332. Price = priceStr,
  333. GMAuditDate = "-"
  334. };
  335. DateTime gmAuditDt;
  336. bool bGMAuditDt = DateTime.TryParse(ccp.AuditGMDate, out gmAuditDt);
  337. info.GMAuditDate = gmAuditDt.ToString("yyyy-MM-dd HH:mm");
  338. if (ccp.IsAuditGM == 2)
  339. {
  340. info.Result = "总经理审核未通过";
  341. info.ResultColor = "warning";
  342. }
  343. //CTable
  344. #region CTable
  345. if (ccp.CTable == 76)//76,酒店预订
  346. {
  347. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  348. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _HotelReservations.CreateUserId).First();
  349. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  350. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  351. info.PriceModule = "酒店预订";
  352. info.PriceName = _HotelReservations.HotelName;
  353. }
  354. else if (ccp.CTable == 79) //79://车/导游地接
  355. {
  356. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  357. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _CarTouristGuideGroundReservations.CreateUserId).First();
  358. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  359. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  360. info.PriceModule = "车/导游地接";
  361. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  362. }
  363. else if (ccp.CTable == 80) //签证
  364. {
  365. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  366. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  367. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _VisaInfos.CreateUserId).First();
  368. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  369. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  370. info.PriceModule = "签证";
  371. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  372. }
  373. else if (ccp.CTable == 81)//邀请/公务活动
  374. {
  375. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  376. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  377. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  378. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  379. info.PriceModule = "邀请/公务活动";
  380. info.PriceName = _InvitationOfficialActivities.InviterArea;
  381. }
  382. else if (ccp.CTable == 82)//团组客户保险
  383. {
  384. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  385. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  386. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  387. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  388. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  389. info.PriceModule = "团组客户保险";
  390. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  391. }
  392. else if (ccp.CTable == 85) //机票预订
  393. {
  394. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  395. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  396. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  397. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  398. info.PriceModule = "机票预订";
  399. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  400. }
  401. else if (ccp.CTable == 98) //其他款项
  402. {
  403. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  404. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  405. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  406. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  407. info.PriceModule = "其他款项";
  408. info.PriceName = _DecreasePayments.PriceName;
  409. }
  410. #endregion
  411. //发送信息
  412. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  413. if (qwUserIdList.Count > 0)
  414. {
  415. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.AuditResult_ApplyFee_User(info));
  416. if (ccp.IsAuditGM == 1)
  417. {
  418. await SendChatMsg_GroupStatus_AuditFee(Grp_CreditCardPaymentId, qwEnum);
  419. }
  420. if (result.errcode != 0)
  421. {
  422. //抄送日志
  423. return false;
  424. }
  425. }
  426. return true;
  427. }
  428. /// <summary>
  429. /// 向指定用户发送-团组费用支付结果
  430. /// </summary>
  431. /// <param name="Grp_CreditCardPaymentId"></param>
  432. /// <param name="userId"></param>
  433. /// <returns></returns>
  434. public static async Task<bool> SendUserMsg_GroupStatus_PayResult(int Grp_CreditCardPaymentId, List<string> userId)
  435. {
  436. //, QiyeWeChatEnum qiyeWeChat
  437. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  438. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  439. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  440. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  441. PayResult_Group_ToUserModel info = new PayResult_Group_ToUserModel()
  442. {
  443. PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  444. Price = priceStr,
  445. TeamName = group.TeamName
  446. };
  447. #region CTable
  448. if (ccp.CTable == 76)//76,酒店预订
  449. {
  450. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  451. info.PriceModule = "酒店预订";
  452. info.PriceName = _HotelReservations.HotelName;
  453. }
  454. else if (ccp.CTable == 79) //79://车/导游地接
  455. {
  456. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  457. info.PriceModule = "车/导游地接";
  458. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  459. }
  460. else if (ccp.CTable == 80) //签证
  461. {
  462. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  463. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  464. info.PriceModule = "签证";
  465. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  466. }
  467. else if (ccp.CTable == 81)//邀请/公务活动
  468. {
  469. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  470. info.PriceModule = "邀请/公务活动";
  471. info.PriceName = _InvitationOfficialActivities.InviterArea;
  472. }
  473. else if (ccp.CTable == 82)//团组客户保险
  474. {
  475. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  476. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  477. info.PriceModule = "团组客户保险";
  478. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  479. }
  480. else if (ccp.CTable == 85) //机票预订
  481. {
  482. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  483. info.PriceModule = "机票预订";
  484. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  485. }
  486. else if (ccp.CTable == 98) //其他款项
  487. {
  488. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  489. info.PriceModule = "其他款项";
  490. info.PriceName = _DecreasePayments.PriceName;
  491. }
  492. #endregion
  493. //发送信息
  494. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  495. if (qwUserIdList.Count > 0)
  496. {
  497. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.PayResult_Group_ToUser(info));
  498. if (result.errcode != 0)
  499. {
  500. //抄送日志
  501. return false;
  502. }
  503. }
  504. return true;
  505. }
  506. #endregion
  507. #region 团组出发、结束提醒(财务群)
  508. public static async Task<bool> SendChatMsg_GroupRemindersToCaiwu(List<Grp_DelegationInfo> list_7day, List<Grp_DelegationInfo> list_3day, List<Grp_DelegationInfo> list_minus1day, QiyeWeChatEnum qwEnum)
  509. {
  510. string chatId = qwEnum.GetEnumDescription();
  511. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToCaiwuChat(list_7day, list_3day, list_minus1day));
  512. if (result.errcode != 0)
  513. {
  514. //抄送日志
  515. return false;
  516. }
  517. return true;
  518. }
  519. #endregion
  520. #region 团组结束提醒(国交群)
  521. public static async Task<bool> SendChatMsg_GroupRemindersToGuojiao(List<Grp_DelegationInfo> list_3day, QiyeWeChatEnum qwEnum)
  522. {
  523. string chatId = qwEnum.GetEnumDescription();
  524. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToGuojiao(list_3day));
  525. if (result.errcode != 0)
  526. {
  527. //抄送日志
  528. return false;
  529. }
  530. return true;
  531. }
  532. #endregion
  533. #region 团组出发提醒(HR)
  534. public static async Task<bool> SendUserMsg_DelegationVisit_ToHR(List<Grp_DelegationInfo> list_3day, List<string> userId)
  535. {
  536. //发送信息
  537. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  538. if (qwUserIdList.Count > 0)
  539. {
  540. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupRemindersToHR(list_3day));
  541. if (result.errcode != 0)
  542. {
  543. //抄送日志
  544. return false;
  545. }
  546. }
  547. return true;
  548. }
  549. #endregion
  550. #region 市场部新增客户资源统计
  551. /// <summary>
  552. /// 周统计
  553. /// </summary>
  554. /// <param name="sourceList"></param>
  555. /// <param name="userId"></param>
  556. /// <param name="begin"></param>
  557. /// <param name="end"></param>
  558. /// <returns></returns>
  559. public static async Task<bool> SendUserMsg_CRMStatistics_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end)
  560. {
  561. //发送信息
  562. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  563. if (qwUserIdList.Count > 0)
  564. {
  565. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_ToUser(sourceList, begin, end));
  566. if (result.errcode != 0)
  567. {
  568. //抄送日志
  569. return false;
  570. }
  571. }
  572. return true;
  573. }
  574. /// <summary>
  575. /// 月统计
  576. /// </summary>
  577. /// <param name="sourceList"></param>
  578. /// <param name="userId"></param>
  579. /// <param name="begin"></param>
  580. /// <param name="end"></param>
  581. /// <param name="totalInsert"></param>
  582. /// <param name="totalDelete"></param>
  583. /// <returns></returns>
  584. public static async Task<bool> SendUserMsg_CRMStatistics_Month_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end, int totalInsert, int totalDelete)
  585. {
  586. //发送信息
  587. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  588. if (qwUserIdList.Count > 0)
  589. {
  590. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_Month_ToUser(sourceList, begin, end, totalInsert, totalDelete));
  591. if (result.errcode != 0)
  592. {
  593. //抄送日志
  594. return false;
  595. }
  596. }
  597. return true;
  598. }
  599. #endregion
  600. #region 日付申请审核
  601. /// <summary>
  602. /// 日付申请提交时推送财务群
  603. /// </summary>
  604. /// <param name="dailyPayId"></param>
  605. /// <param name="sign"></param>
  606. /// <param name="qwEnum"></param>
  607. /// <returns></returns>
  608. public static async Task<bool> DailyPayReminders_Create_ToCaiwuChat(int dailyPayId, int sign, QiyeWeChatEnum qwEnum)
  609. {
  610. string chatId = qwEnum.GetEnumDescription();
  611. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  612. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
  613. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  614. string users = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  615. string[] companyArr = new string[] { "未知", "成都泛美商务有限公司", "四川泛美交流有限公司", "成都纽茵教育科技有限公司", "成都鸿企中元科技有限公司", "测试公司1" };
  616. string companyStr = "未知";
  617. if (fin_DailyFeePayment.CompanyId < companyArr.Length)
  618. {
  619. companyStr = companyArr[fin_DailyFeePayment.CompanyId];
  620. }
  621. Sys_SetData sd_tansferType = _grpDeleRep.Query<Sys_SetData>(s => s.Id == fin_DailyFeePayment.TransferTypeId).First();
  622. Sys_SetData sd_priceType = _grpDeleRep.Query<Sys_SetData>(s => s.Id == fin_DailyFeePayment.PriceTypeId).First();
  623. string feeSignStr = string.Format(@"{0}-{1}", sd_tansferType.Name, sd_priceType?.Name ?? "");
  624. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  625. DailyPayReminders_Create_ToCaiwuChatModel info = new DailyPayReminders_Create_ToCaiwuChatModel()
  626. {
  627. CreateDt = fin_DailyFeePayment.CreateTime.ToString("yyyy-MM-dd HH:mm"),
  628. CreateUser = users,
  629. Price = priceStr,
  630. Company = companyStr,
  631. FeeSign = feeSignStr,
  632. PriceName = fin_DailyFeePayment.Instructions
  633. };
  634. if (sign == 2) info.TitleStr = "[更新]一项费用待审核";
  635. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.DailyPayReminders_Create_ToCaiwuChat(info));
  636. if (result.errcode != 0)
  637. {
  638. //抄送日志
  639. return false;
  640. }
  641. return true;
  642. }
  643. /// <summary>
  644. /// 日付申请审核结果推送给申请人
  645. /// </summary>
  646. /// <param name="dailyPayId"></param>
  647. /// <param name="userId"></param>
  648. /// <param name="qwEnum"></param>
  649. /// <returns></returns>
  650. public static async Task<bool> DailyPayReminder_Audit_ToUser(int dailyPayId, List<string> userId, QiyeWeChatEnum qwEnum)
  651. {
  652. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  653. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
  654. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  655. string users = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  656. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  657. DailyPayReminder_Audit_ToUserModel info = new DailyPayReminder_Audit_ToUserModel()
  658. {
  659. Price = priceStr,
  660. PriceName = fin_DailyFeePayment.Instructions
  661. };
  662. if (fin_DailyFeePayment.FAudit == 1)
  663. {
  664. info.AuditDate = fin_DailyFeePayment.MAuditDate.ToString("yyyy-MM-dd HH:mm");
  665. if (fin_DailyFeePayment.MAudit == 1)
  666. {
  667. info.Result = "你有一笔日付申请已通过审核";
  668. info.ResultColor = "info";
  669. //发送至财务群
  670. DailyPayReminder_Audit_ToCaiwuChatModel chatInfo = new DailyPayReminder_Audit_ToCaiwuChatModel()
  671. {
  672. AuditDate = info.AuditDate,
  673. CreateUser = users,
  674. Price = priceStr,
  675. PriceName = fin_DailyFeePayment.Instructions
  676. };
  677. string chatId = qwEnum.GetEnumDescription();
  678. await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.DailyPayReminder_Audit_ToCaiwuChat(chatInfo));
  679. }
  680. else if (fin_DailyFeePayment.MAudit == 2)
  681. {
  682. info.Result = "你有一笔日付申请未通过总经理审核";
  683. info.ResultColor = "warning";
  684. }
  685. }
  686. else if (fin_DailyFeePayment.FAudit == 2)
  687. {
  688. info.AuditDate = fin_DailyFeePayment.FAuditDate.ToString("yyyy-MM-dd HH:mm");
  689. info.Result = "你有一笔日付申请未通过财务审核";
  690. info.ResultColor = "warning";
  691. }
  692. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  693. if (qwUserIdList.Count > 0)
  694. {
  695. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.DailyPayReminder_Audit_ToUser(info));
  696. if (result.errcode != 0)
  697. {
  698. //抄送日志
  699. return false;
  700. }
  701. }
  702. return true;
  703. }
  704. /// <summary>
  705. /// 日付申请已付款推送给申请人
  706. /// </summary>
  707. /// <returns></returns>
  708. public static async Task<bool> DailyPayReminder_Pay_ToUser(int dailyPayId, List<string> userId)
  709. {
  710. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  711. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  712. DailyPayReminder_Pay_ToUserModel info = new DailyPayReminder_Pay_ToUserModel()
  713. {
  714. PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  715. PriceName = fin_DailyFeePayment.Instructions,
  716. Price = priceStr
  717. };
  718. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  719. if (qwUserIdList.Count > 0)
  720. {
  721. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.DailyPayReminder_Pay_ToUser(info));
  722. if (result.errcode != 0)
  723. {
  724. //抄送日志
  725. return false;
  726. }
  727. }
  728. return true;
  729. }
  730. #endregion
  731. #region 费用保存发送消息
  732. #region 三公费用更改通知
  733. /// <summary>
  734. /// 三公费用汇率大于实时汇率 通知发送(22、208、5)
  735. /// </summary>
  736. /// <param name="diId"></param>
  737. /// <param name="operationId"></param>
  738. /// <param name="msgContent"></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> l
  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. {
  1040. x.UserId,
  1041. x.UserName
  1042. })
  1043. .ToList();
  1044. if (auditUserList.Any())
  1045. {
  1046. if (auditUserList.Count > 1) isCheckValuable = true;
  1047. userIds.AddRange(auditUserList.Select(x => x.UserId.ToString()).ToList());
  1048. userIds = userIds.Distinct().ToList();
  1049. valuableUserNames.AddRange(auditUserList.Select(x => x.UserName).ToList());
  1050. }
  1051. }
  1052. }
  1053. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  1054. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  1055. var groupName = diId switch
  1056. {
  1057. 0 => "其他物资(公司内部物资)",
  1058. -1 => "拜访客户所使用的物资",
  1059. -2 => "库存调整",
  1060. _ => groupInfo?.TeamName ?? "-"
  1061. };
  1062. var receiveInfo = _grpDeleRep._sqlSugar.Queryable<Pm_GoodsReceive>().First(x => x.IsDel == 0 && x.Id == dataId);
  1063. if (receiveInfo == null) return false;
  1064. var receiveDetails = _grpDeleRep._sqlSugar
  1065. .Queryable<Pm_GoodsReceiveDetails>()
  1066. .LeftJoin<Pm_GoodsInfo>((x, y) => x.GoodsId == y.Id)
  1067. .Where(x => x.IsDel == 0 && x.GoodsReceiveId == dataId)
  1068. .Select((x, y) => new
  1069. {
  1070. y.Name,
  1071. x.Quantity,
  1072. y.Unit
  1073. })
  1074. .ToList();
  1075. if (!receiveDetails.Any()) return false;
  1076. var goodsMsg = new StringBuilder();
  1077. foreach (var info in receiveDetails)
  1078. {
  1079. goodsMsg.AppendLine($">- {info.Name}:{info.Quantity:#0.00} {info.Unit}");
  1080. }
  1081. var groupLabel = string.Empty;
  1082. if (string.IsNullOrEmpty(groupName) || !groupName.Equals("-"))
  1083. {
  1084. groupLabel = $">团组归属:<font color='info'>{groupName}</font>";
  1085. }
  1086. //普通物品审批消息通知
  1087. string resMsg = string.Format(@" ` 物资领用申请通知 `
  1088. > ` {0} `提交物资领用申请:
  1089. {1}
  1090. >**物资明细**
  1091. {2}
  1092. >用途:<font color='comment'>{3}</font>
  1093. >申请时间:<font color='comment'>{4}</font>
  1094. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1095. operationName,
  1096. groupLabel,
  1097. goodsMsg,
  1098. receiveInfo.Reason,
  1099. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1100. //贵重物品审批消息通知
  1101. if (isCheckValuable)
  1102. {
  1103. var auditUserLabel = string.Empty;
  1104. foreach (var userName in valuableUserNames)
  1105. {
  1106. auditUserLabel += $"@{userName} ";
  1107. }
  1108. resMsg = string.Format(@" ` 【或签审批】物资领用(任一人审批即可)通知 `
  1109. >{0}
  1110. > ` {1} `提交物资领用申请,您被列为或签审批人:
  1111. **或签规则**
  1112. • 您与其他{2}人并行审批
  1113. • 任意一人通过即视为本环节通过
  1114. • 任意一人拒绝即视为终止流程
  1115. {3}
  1116. >**物资明细**
  1117. {4}
  1118. >用途:<font color='comment'>{5}</font>
  1119. >申请时间:<font color='comment'>{6}</font>
  1120. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1121. auditUserLabel,
  1122. operationName,
  1123. valuableUserNames.Count - 1,
  1124. groupLabel,
  1125. goodsMsg,
  1126. receiveInfo.Reason,
  1127. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1128. }
  1129. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  1130. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1131. if (result.errcode != 0)
  1132. {
  1133. //抄送日志
  1134. return false;
  1135. }
  1136. return true;
  1137. }
  1138. #endregion
  1139. #region 日服申请
  1140. /// <summary>
  1141. /// 日服申请、编辑通知
  1142. /// 接收者:指定接收者
  1143. /// </summary>
  1144. /// <param name="dataId"></param>
  1145. /// <param name="operationId">操作人Id</param>
  1146. /// <param name="recipients">接收者Id集合</param>
  1147. /// <returns></returns>
  1148. public static async Task<bool> SendUserMsg_CompanyShare_ToDailtPay(int dataId, int operationId, List<string> recipients)
  1149. {
  1150. //企微通知
  1151. var userIds = recipients;
  1152. string operationName = _grpDeleRep._sqlSugar.Queryable<Sys_Users>().First(x => x.IsDel
  1153. == 0 && x.Id == operationId).CnName ?? "Unknown";
  1154. var dailyPaymentInfo = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePayment>()
  1155. .FirstAsync(x => x.IsDel == 0 && x.Id == dataId);
  1156. var details = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePaymentContent>()
  1157. .Where(x => x.IsDel == 0 && x.DFPId == dataId)
  1158. .Select(x => new { x.PriceName, x.Quantity, x.Price })
  1159. .ToListAsync();
  1160. var detailsMsg = new StringBuilder();
  1161. foreach (var info in details)
  1162. {
  1163. detailsMsg.AppendLine($">- {info.PriceName}:{info.Quantity:#0.00} * {info.Price:#0.00} = {info.Quantity * info.Price:#0.00} 元");
  1164. }
  1165. if (detailsMsg.Length == 0 || detailsMsg == null)
  1166. {
  1167. detailsMsg.Append("无费用明细");
  1168. }
  1169. //普通物品审批消息通知
  1170. string resMsg = string.Format(@" ` 日付申请通知 `
  1171. > ` {0} `提交费用申请:
  1172. >**费用明细**
  1173. {1}
  1174. >总金额:<font color='comment'>{2} 元</font>
  1175. >申请说明:<font color='comment'>{3}</font>
  1176. >申请时间:<font color='comment'>{4}</font>
  1177. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1178. operationName,
  1179. detailsMsg.ToString(),
  1180. dailyPaymentInfo?.SumPrice.ToString("#0.00") ?? "0.00",
  1181. dailyPaymentInfo?.Instructions ?? "无申请说明",
  1182. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1183. List<string> qwUserIdList = GetQiyeChatUserIdList(recipients);
  1184. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1185. if (result.errcode != 0)
  1186. {
  1187. //抄送日志
  1188. return false;
  1189. }
  1190. return true;
  1191. }
  1192. #endregion
  1193. #region OA任务通知
  1194. public static async Task<bool> SendUserMsg_Task_ToUser(int taskOrderId, List<string> msgUserList, bool isNew)
  1195. {
  1196. msgUserList.Add("235");
  1197. msgUserList = msgUserList.Distinct().ToList();
  1198. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1199. var workOrder = _grpDeleRep._sqlSugar.Queryable<Task_WorkOrder>().First(x => x.IsDel == 0 && x.Id == taskOrderId);
  1200. var task = _grpDeleRep._sqlSugar.Queryable<Task_WorkTask>().Where(x => x.IsDel == 0 && x.WorkOrderId == taskOrderId).ToList();
  1201. TaskInfo_ToUser info = new TaskInfo_ToUser
  1202. {
  1203. isNew = isNew,
  1204. TaskName = workOrder.Name,
  1205. StartTime = workOrder.StartTime.ToString("yyyy-MM-dd HH:mm"),
  1206. TaskCount = task.Count,
  1207. UrgentCount = task.Count(x => x.IsUrgent)
  1208. };
  1209. if (qwUserIdList.Count > 0)
  1210. {
  1211. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_ToUser(info));
  1212. if (result.errcode != 0)
  1213. {
  1214. //抄送日志
  1215. return false;
  1216. }
  1217. }
  1218. return true;
  1219. }
  1220. public static async Task<bool> SendUserMsg_TaskSubMit_ToUser(int taskId, List<string> msgUserList)
  1221. {
  1222. msgUserList.Add("235");
  1223. msgUserList = msgUserList.Distinct().ToList();
  1224. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1225. var task = _grpDeleRep._sqlSugar.
  1226. Queryable<Task_WorkTask>().
  1227. Includes(x => x.WorkOrder).
  1228. First(x => x.IsDel == 0 && x.Id == taskId);
  1229. TaskInfo_SubMit_ToUser info = new TaskInfo_SubMit_ToUser
  1230. {
  1231. TaskName = task.WorkOrder.Name + " - " + task.Name,
  1232. StartTime = task.StartTime.ToString("yyyy-MM-dd HH:mm"),
  1233. EndTime = task.EndTime?.ToString("yyyy-MM-dd HH:mm") ?? ""
  1234. };
  1235. if (qwUserIdList.Count > 0)
  1236. {
  1237. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_SubMit_ToUser(info));
  1238. if (result.errcode != 0)
  1239. {
  1240. //抄送日志
  1241. return false;
  1242. }
  1243. }
  1244. return true;
  1245. }
  1246. public static async Task<bool> SendUserMsg_TaskAudit_ToUser(int taskId, bool auditResult, string message, List<string> msgUserList)
  1247. {
  1248. msgUserList.Add("235");
  1249. msgUserList = msgUserList.Distinct().ToList();
  1250. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1251. var task = _grpDeleRep._sqlSugar.
  1252. Queryable<Task_WorkTask>().
  1253. Includes(x => x.WorkOrder).
  1254. First(x => x.IsDel == 0 && x.Id == taskId);
  1255. TaskInfo_Audit_ToUser info = new TaskInfo_Audit_ToUser
  1256. {
  1257. TaskName = task.WorkOrder.Name + " - " + task.Name,
  1258. auditResult = auditResult,
  1259. Message = message
  1260. };
  1261. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_Audit_ToUser(info));
  1262. if (result.errcode != 0)
  1263. {
  1264. //抄送日志
  1265. return false;
  1266. }
  1267. return true;
  1268. }
  1269. #endregion
  1270. #region Helper
  1271. private static string getClientNameStr(List<SimplClientInfo> list, string origin)
  1272. {
  1273. string result = origin;
  1274. if (Regex.Match(origin, @"\d +,?").Value.Length > 0)
  1275. {
  1276. string[] temparr = origin.Split(',');
  1277. string fistrStr = temparr[0];
  1278. int count = temparr.Length;
  1279. int tempId;
  1280. bool success = int.TryParse(fistrStr, out tempId);
  1281. if (success)
  1282. {
  1283. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1284. if (tempInfo != null)
  1285. {
  1286. if (count > 1)
  1287. {
  1288. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1289. }
  1290. else
  1291. {
  1292. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1293. }
  1294. }
  1295. }
  1296. }
  1297. return result;
  1298. }
  1299. private static List<SimplClientInfo> getSimplClientList(int diId)
  1300. {
  1301. 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);
  1302. List<SimplClientInfo> arr = _grpDeleRep._sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1303. return arr;
  1304. }
  1305. #endregion
  1306. }
  1307. }