Library.cs 69 KB

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