Library.cs 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627
  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.Query<Sys_Users>(s => s.Id == uid).First();
  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. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  378. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _InvitationOfficialActivities.CreateUserId).First();
  379. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  380. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  381. info.PriceModule = "邀请/公务活动";
  382. info.PriceName = _InvitationOfficialActivities.InviterArea;
  383. }
  384. else if (ccp.CTable == 82)//团组客户保险
  385. {
  386. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  387. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  388. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _Customers.CreateUserId).First();
  389. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  390. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  391. info.PriceModule = "团组客户保险";
  392. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  393. }
  394. else if (ccp.CTable == 85) //机票预订
  395. {
  396. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  397. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _AirTicketReservations.CreateUserId).First();
  398. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  399. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  400. info.PriceModule = "机票预订";
  401. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  402. }
  403. else if (ccp.CTable == 98) //其他款项
  404. {
  405. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  406. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == _DecreasePayments.CreateUserId).First();
  407. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  408. info.CreateUser = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  409. info.PriceModule = "其他款项";
  410. info.PriceName = _DecreasePayments.PriceName;
  411. }
  412. #endregion
  413. //发送信息
  414. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  415. if (qwUserIdList.Count > 0)
  416. {
  417. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.AuditResult_ApplyFee_User(info));
  418. if (ccp.IsAuditGM == 1)
  419. {
  420. await SendChatMsg_GroupStatus_AuditFee(Grp_CreditCardPaymentId, qwEnum);
  421. }
  422. if (result.errcode != 0)
  423. {
  424. //抄送日志
  425. return false;
  426. }
  427. }
  428. return true;
  429. }
  430. /// <summary>
  431. /// 向指定用户发送-团组费用支付结果
  432. /// </summary>
  433. /// <param name="Grp_CreditCardPaymentId"></param>
  434. /// <param name="userId"></param>
  435. /// <returns></returns>
  436. public static async Task<bool> SendUserMsg_GroupStatus_PayResult(int Grp_CreditCardPaymentId, List<string> userId)
  437. {
  438. //, QiyeWeChatEnum qiyeWeChat
  439. Grp_CreditCardPayment ccp = _grpDeleRep.Query<Grp_CreditCardPayment>(s => s.Id == Grp_CreditCardPaymentId).First();
  440. Grp_DelegationInfo group = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == ccp.DIId).First();
  441. Sys_SetData payMoneyCurrencySetData = _grpDeleRep.Query<Sys_SetData>(s => s.Id == ccp.PaymentCurrency).First();
  442. string priceStr = string.Format(@"{0} {1}", ccp.PayMoney, payMoneyCurrencySetData.Name);
  443. PayResult_Group_ToUserModel info = new PayResult_Group_ToUserModel()
  444. {
  445. PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  446. Price = priceStr,
  447. TeamName = group.TeamName
  448. };
  449. #region CTable
  450. if (ccp.CTable == 76)//76,酒店预订
  451. {
  452. Grp_HotelReservations _HotelReservations = _grpDeleRep.Query<Grp_HotelReservations>(s => s.Id == ccp.CId).First();
  453. info.PriceModule = "酒店预订";
  454. info.PriceName = _HotelReservations.HotelName;
  455. }
  456. else if (ccp.CTable == 79) //79://车/导游地接
  457. {
  458. Grp_CarTouristGuideGroundReservations _CarTouristGuideGroundReservations = _grpDeleRep.Query<Grp_CarTouristGuideGroundReservations>(s => s.Id == ccp.CId).First();
  459. info.PriceModule = "车/导游地接";
  460. info.PriceName = _CarTouristGuideGroundReservations.PriceName;
  461. }
  462. else if (ccp.CTable == 80) //签证
  463. {
  464. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  465. Grp_VisaInfo _VisaInfos = _grpDeleRep.Query<Grp_VisaInfo>(s => s.Id == ccp.CId).First();
  466. info.PriceModule = "签证";
  467. info.PriceName = getClientNameStr(clientNameList, _VisaInfos.VisaClient);
  468. }
  469. else if (ccp.CTable == 81)//邀请/公务活动
  470. {
  471. Grp_InvitationOfficialActivities _InvitationOfficialActivities = _grpDeleRep.Query<Grp_InvitationOfficialActivities>(s => s.Id == ccp.CId).First();
  472. info.PriceModule = "邀请/公务活动";
  473. info.PriceName = _InvitationOfficialActivities.InviterArea;
  474. }
  475. else if (ccp.CTable == 82)//团组客户保险
  476. {
  477. List<SimplClientInfo> clientNameList = getSimplClientList(group.Id);
  478. Grp_Customers _Customers = _grpDeleRep.Query<Grp_Customers>(s => s.Id == ccp.CId).First();
  479. info.PriceModule = "团组客户保险";
  480. info.PriceName = getClientNameStr(clientNameList, _Customers.ClientName);
  481. }
  482. else if (ccp.CTable == 85) //机票预订
  483. {
  484. Grp_AirTicketReservations _AirTicketReservations = _grpDeleRep.Query<Grp_AirTicketReservations>(s => s.Id == ccp.CId).First();
  485. info.PriceModule = "机票预订";
  486. info.PriceName = "(" + _AirTicketReservations.FlightsCode + ")";
  487. }
  488. else if (ccp.CTable == 98) //其他款项
  489. {
  490. Grp_DecreasePayments _DecreasePayments = _grpDeleRep.Query<Grp_DecreasePayments>(s => s.Id == ccp.CId).First();
  491. info.PriceModule = "其他款项";
  492. info.PriceName = _DecreasePayments.PriceName;
  493. }
  494. #endregion
  495. //发送信息
  496. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  497. if (qwUserIdList.Count > 0)
  498. {
  499. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.PayResult_Group_ToUser(info));
  500. if (result.errcode != 0)
  501. {
  502. //抄送日志
  503. return false;
  504. }
  505. }
  506. return true;
  507. }
  508. #endregion
  509. #region 团组出发、结束提醒(财务群)
  510. public static async Task<bool> SendChatMsg_GroupRemindersToCaiwu(List<Grp_DelegationInfo> list_7day, List<Grp_DelegationInfo> list_3day, List<Grp_DelegationInfo> list_minus1day, QiyeWeChatEnum qwEnum)
  511. {
  512. string chatId = qwEnum.GetEnumDescription();
  513. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToCaiwuChat(list_7day, list_3day, list_minus1day));
  514. if (result.errcode != 0)
  515. {
  516. //抄送日志
  517. return false;
  518. }
  519. return true;
  520. }
  521. #endregion
  522. #region 团组结束提醒(国交群)
  523. public static async Task<bool> SendChatMsg_GroupRemindersToGuojiao(List<Grp_DelegationInfo> list_3day, QiyeWeChatEnum qwEnum)
  524. {
  525. string chatId = qwEnum.GetEnumDescription();
  526. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.GroupRemindersToGuojiao(list_3day));
  527. if (result.errcode != 0)
  528. {
  529. //抄送日志
  530. return false;
  531. }
  532. return true;
  533. }
  534. #endregion
  535. #region 团组出发提醒(HR)
  536. public static async Task<bool> SendUserMsg_DelegationVisit_ToHR(List<Grp_DelegationInfo> list_3day, List<string> userId)
  537. {
  538. //发送信息
  539. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  540. if (qwUserIdList.Count > 0)
  541. {
  542. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupRemindersToHR(list_3day));
  543. if (result.errcode != 0)
  544. {
  545. //抄送日志
  546. return false;
  547. }
  548. }
  549. return true;
  550. }
  551. #endregion
  552. #region 市场部新增客户资源统计
  553. /// <summary>
  554. /// 周统计
  555. /// </summary>
  556. /// <param name="sourceList"></param>
  557. /// <param name="userId"></param>
  558. /// <param name="begin"></param>
  559. /// <param name="end"></param>
  560. /// <returns></returns>
  561. public static async Task<bool> SendUserMsg_CRMStatistics_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end)
  562. {
  563. //发送信息
  564. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  565. if (qwUserIdList.Count > 0)
  566. {
  567. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_ToUser(sourceList, begin, end));
  568. if (result.errcode != 0)
  569. {
  570. //抄送日志
  571. return false;
  572. }
  573. }
  574. return true;
  575. }
  576. /// <summary>
  577. /// 月统计
  578. /// </summary>
  579. /// <param name="sourceList"></param>
  580. /// <param name="userId"></param>
  581. /// <param name="begin"></param>
  582. /// <param name="end"></param>
  583. /// <param name="totalInsert"></param>
  584. /// <param name="totalDelete"></param>
  585. /// <returns></returns>
  586. public static async Task<bool> SendUserMsg_CRMStatistics_Month_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end, int totalInsert, int totalDelete)
  587. {
  588. //发送信息
  589. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  590. if (qwUserIdList.Count > 0)
  591. {
  592. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_Month_ToUser(sourceList, begin, end, totalInsert, totalDelete));
  593. if (result.errcode != 0)
  594. {
  595. //抄送日志
  596. return false;
  597. }
  598. }
  599. return true;
  600. }
  601. #endregion
  602. #region 日付申请审核
  603. /// <summary>
  604. /// 日付申请提交时推送财务群
  605. /// </summary>
  606. /// <param name="dailyPayId"></param>
  607. /// <param name="sign"></param>
  608. /// <param name="qwEnum"></param>
  609. /// <returns></returns>
  610. public static async Task<bool> DailyPayReminders_Create_ToCaiwuChat(int dailyPayId, int sign, QiyeWeChatEnum qwEnum)
  611. {
  612. string chatId = qwEnum.GetEnumDescription();
  613. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  614. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
  615. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  616. string users = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  617. string[] companyArr = new string[] { "未知", "成都泛美商务有限公司", "四川泛美交流有限公司", "成都纽茵教育科技有限公司", "成都鸿企中元科技有限公司", "测试公司1" };
  618. string companyStr = "未知";
  619. if (fin_DailyFeePayment.CompanyId < companyArr.Length)
  620. {
  621. companyStr = companyArr[fin_DailyFeePayment.CompanyId];
  622. }
  623. Sys_SetData sd_tansferType = _grpDeleRep.Query<Sys_SetData>(s => s.Id == fin_DailyFeePayment.TransferTypeId).First();
  624. Sys_SetData sd_priceType = _grpDeleRep.Query<Sys_SetData>(s => s.Id == fin_DailyFeePayment.PriceTypeId).First();
  625. string feeSignStr = string.Format(@"{0}-{1}", sd_tansferType.Name, sd_priceType?.Name ?? "");
  626. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  627. DailyPayReminders_Create_ToCaiwuChatModel info = new DailyPayReminders_Create_ToCaiwuChatModel()
  628. {
  629. CreateDt = fin_DailyFeePayment.CreateTime.ToString("yyyy-MM-dd HH:mm"),
  630. CreateUser = users,
  631. Price = priceStr,
  632. Company = companyStr,
  633. FeeSign = feeSignStr,
  634. PriceName = fin_DailyFeePayment.Instructions
  635. };
  636. if (sign == 2) info.TitleStr = "[更新]一项费用待审核";
  637. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.DailyPayReminders_Create_ToCaiwuChat(info));
  638. if (result.errcode != 0)
  639. {
  640. //抄送日志
  641. return false;
  642. }
  643. return true;
  644. }
  645. /// <summary>
  646. /// 日付申请审核结果推送给申请人
  647. /// </summary>
  648. /// <param name="dailyPayId"></param>
  649. /// <param name="userId"></param>
  650. /// <param name="qwEnum"></param>
  651. /// <returns></returns>
  652. public static async Task<bool> DailyPayReminder_Audit_ToUser(int dailyPayId, List<string> userId, QiyeWeChatEnum qwEnum)
  653. {
  654. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  655. Sys_Users user = _grpDeleRep.Query<Sys_Users>(s => s.Id == fin_DailyFeePayment.CreateUserId).First();
  656. Sys_JobPost job = _grpDeleRep.Query<Sys_JobPost>(s => s.Id == user.JobPostId).First();
  657. string users = string.Format(@"{0}-{1}", job.JobName, user.CnName);
  658. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  659. DailyPayReminder_Audit_ToUserModel info = new DailyPayReminder_Audit_ToUserModel()
  660. {
  661. Price = priceStr,
  662. PriceName = fin_DailyFeePayment.Instructions
  663. };
  664. if (fin_DailyFeePayment.FAudit == 1)
  665. {
  666. info.AuditDate = fin_DailyFeePayment.MAuditDate.ToString("yyyy-MM-dd HH:mm");
  667. if (fin_DailyFeePayment.MAudit == 1)
  668. {
  669. info.Result = "你有一笔日付申请已通过审核";
  670. info.ResultColor = "info";
  671. //发送至财务群
  672. DailyPayReminder_Audit_ToCaiwuChatModel chatInfo = new DailyPayReminder_Audit_ToCaiwuChatModel()
  673. {
  674. AuditDate = info.AuditDate,
  675. CreateUser = users,
  676. Price = priceStr,
  677. PriceName = fin_DailyFeePayment.Instructions
  678. };
  679. string chatId = qwEnum.GetEnumDescription();
  680. await _qiYeWeChatApiService.GroupStatus_SendChatMsg_Markdown(chatId, MarkdownLib.DailyPayReminder_Audit_ToCaiwuChat(chatInfo));
  681. }
  682. else if (fin_DailyFeePayment.MAudit == 2)
  683. {
  684. info.Result = "你有一笔日付申请未通过总经理审核";
  685. info.ResultColor = "warning";
  686. }
  687. }
  688. else if (fin_DailyFeePayment.FAudit == 2)
  689. {
  690. info.AuditDate = fin_DailyFeePayment.FAuditDate.ToString("yyyy-MM-dd HH:mm");
  691. info.Result = "你有一笔日付申请未通过财务审核";
  692. info.ResultColor = "warning";
  693. }
  694. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  695. if (qwUserIdList.Count > 0)
  696. {
  697. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.DailyPayReminder_Audit_ToUser(info));
  698. if (result.errcode != 0)
  699. {
  700. //抄送日志
  701. return false;
  702. }
  703. }
  704. return true;
  705. }
  706. /// <summary>
  707. /// 日付申请已付款推送给申请人
  708. /// </summary>
  709. /// <returns></returns>
  710. public static async Task<bool> DailyPayReminder_Pay_ToUser(int dailyPayId, List<string> userId)
  711. {
  712. Fin_DailyFeePayment fin_DailyFeePayment = _grpDeleRep.Query<Fin_DailyFeePayment>(s => s.Id == dailyPayId).First();
  713. string priceStr = fin_DailyFeePayment.SumPrice.ToString("#0.00");
  714. DailyPayReminder_Pay_ToUserModel info = new DailyPayReminder_Pay_ToUserModel()
  715. {
  716. PayDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  717. PriceName = fin_DailyFeePayment.Instructions,
  718. Price = priceStr
  719. };
  720. List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
  721. if (qwUserIdList.Count > 0)
  722. {
  723. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.DailyPayReminder_Pay_ToUser(info));
  724. if (result.errcode != 0)
  725. {
  726. //抄送日志
  727. return false;
  728. }
  729. }
  730. return true;
  731. }
  732. #endregion
  733. #region 费用保存发送消息
  734. #region 三公费用更改通知
  735. /// <summary>
  736. /// 三公费用汇率大于实时汇率 通知发送(22、208、5)
  737. /// </summary>
  738. /// <param name="diId"></param>
  739. /// <param name="operationId"></param>
  740. /// <param name="msgContent"></param>
  741. /// <returns></returns>
  742. public static async Task<bool> SendUserMsg_GroupShare_ToFin(int diId, int operationId, string msgContent)
  743. {
  744. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  745. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  746. var defaultUserIds = new List<string>() { "208", "22", "5" };
  747. if (defaultUserIds.Count > 0)
  748. {
  749. List<string> qwUserIdList = GetQiyeChatUserIdList(defaultUserIds);
  750. string resMsg = string.Format(@" `三公费用异常通知 - 汇率预警`
  751. >团组:<font color='info'>{0}</font>
  752. >**汇率明细**
  753. {1}
  754. >操作人员:<font color='comment'>{2}</font> l
  755. >操作时间:<font color='comment'>{3}</font>
  756. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, msgContent, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  757. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  758. if (result.errcode != 0)
  759. {
  760. //抄送日志
  761. return false;
  762. }
  763. }
  764. return true;
  765. }
  766. #endregion
  767. #region 三公费用更改通知
  768. /// <summary>
  769. /// 三公费用更改通知发送总经理(21)
  770. /// </summary>
  771. /// <param name="diId"></param>
  772. /// <param name="receivedUserIds"></param>
  773. /// <param name="updateUserId"></param>
  774. /// <param name="url"></param>
  775. /// <returns></returns>
  776. public static async Task<bool> SendUserMsg_GroupShare_ToGM(int diId, List<string> receivedUserIds, int updateUserId, string url)
  777. {
  778. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  779. GroupShare_ToGMModel info = new GroupShare_ToGMModel()
  780. {
  781. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  782. TeamName = groupInfo.TeamName,
  783. CreateUser = _grpDeleRep.Query<Sys_Users>(s => s.Id == updateUserId).First()?.CnName ?? "-",
  784. Url = url
  785. };
  786. if (receivedUserIds.Count > 0)
  787. {
  788. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  789. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToGM(info));
  790. if (result.errcode != 0)
  791. {
  792. //抄送日志
  793. return false;
  794. }
  795. }
  796. return true;
  797. }
  798. /// <summary>
  799. /// 三公费用确认通知发送财务部人员
  800. /// </summary>
  801. /// <param name="diId"></param>
  802. /// <returns></returns>
  803. public static async Task<bool> SendUserMsg_GroupShare_ToFinance(int diId)
  804. {
  805. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  806. GroupShare_ToUserModel info = new GroupShare_ToUserModel()
  807. {
  808. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  809. TeamName = groupInfo.TeamName
  810. };
  811. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 3).Select(x => x.Id.ToString()).ToList();
  812. var defaultUserIds = new List<string>() { "208", "233" };
  813. receivedUserIds.AddRange(defaultUserIds);
  814. if (receivedUserIds.Contains("150")) receivedUserIds.Remove("150");
  815. if (receivedUserIds.Count > 0)
  816. {
  817. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  818. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToFinance(info));
  819. if (result.errcode != 0)
  820. {
  821. //抄送日志
  822. return false;
  823. }
  824. }
  825. return true;
  826. }
  827. #endregion
  828. /// <summary>
  829. /// 机票行程代码录入变更通知发送国交经理、主管、王鸽
  830. /// </summary>
  831. /// <param name="diId"></param>
  832. /// <param name="operationId"></param>
  833. /// <returns></returns>
  834. public static async Task<bool> SendUserMsg_GroupShare_ToDP(int diId, int operationId)
  835. {
  836. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  837. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  838. var defaultJobPostIds = new List<int>() { 22, 32 };
  839. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && defaultJobPostIds.Contains(s.JobPostId)).Select(x => x.Id.ToString()).ToList();
  840. var defaultUserIds = new List<string>() { "208", "233" };
  841. receivedUserIds.AddRange(defaultUserIds);
  842. if (receivedUserIds.Count > 0)
  843. {
  844. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  845. string resMsg = string.Format(@" `机票行程代码已调整更新通知`
  846. >团组:<font color='info'>{0}</font>
  847. >操作人员:<font color='comment'>{1}</font>
  848. >操作时间:<font color='comment'>{2}</font>
  849. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  850. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  851. if (result.errcode != 0)
  852. {
  853. //抄送日志
  854. return false;
  855. }
  856. }
  857. return true;
  858. }
  859. #region 公务出访数据变更发送通知
  860. /// <summary>
  861. /// 机票行程代码录入变更通知发送国交经理、主管、王鸽
  862. /// </summary>
  863. /// <param name="diId"></param>
  864. /// <param name="operationId"></param>
  865. /// <returns></returns>
  866. public static async Task<bool> SendUserMsg_GroupShare_ToOP(int diId, int operationId)
  867. {
  868. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  869. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  870. var defaultJobPostIds = new List<int>();
  871. List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && s.JobPostId == 28).Select(x => x.Id.ToString()).ToList();
  872. var defaultUserIds = new List<string>() { "208", "233" };
  873. receivedUserIds.AddRange(defaultUserIds);
  874. if (receivedUserIds.Count > 0)
  875. {
  876. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  877. string resMsg = string.Format(@" `公务出访有数据更新通知`
  878. >团组:<font color='info'>{0}</font>
  879. >操作人员:<font color='comment'>{1}</font>
  880. >操作时间:<font color='comment'>{2}</font>
  881. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  882. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  883. if (result.errcode != 0)
  884. {
  885. //抄送日志
  886. return false;
  887. }
  888. }
  889. return true;
  890. }
  891. #endregion
  892. #endregion
  893. #region 成本通知
  894. /// <summary>
  895. /// 成本通知发送给对应岗位用户
  896. /// </summary>
  897. /// <param name="diId"></param>
  898. /// <returns></returns>
  899. public static async Task<bool> SendUserMsg_GroupShare_ToJob(int diId)
  900. {
  901. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  902. List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 24 || s.JobPostId == 25 || s.JobPostId == 28)).ToList();
  903. //List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 40 || s.JobPostId == 41)).ToList();
  904. List<string> userIds = new List<string>();
  905. list_user.ForEach(s => userIds.Add(s.Id.ToString()));
  906. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  907. GroupShare_ToUserModel info = new GroupShare_ToUserModel()
  908. {
  909. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  910. TeamName = groupInfo.TeamName
  911. };
  912. if (qwUserIdList.Count > 0)
  913. {
  914. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToUser(info));
  915. if (result.errcode != 0)
  916. {
  917. //抄送日志
  918. return false;
  919. }
  920. }
  921. return true;
  922. }
  923. public static async Task<bool> SendUserMsg_blackAirInfo_ToVisaUser(int diId, List<CountryDataTime> arr)
  924. {
  925. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  926. var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
  927. .Select(x => x.Id)
  928. .ToList();
  929. List<string> userIds = new List<string>() { "235" };
  930. userIds.AddRange(visaUser.Select(x => x.ToString()));
  931. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  932. BlackCodeInfo_ToVisaUser info = new BlackCodeInfo_ToVisaUser()
  933. {
  934. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  935. TeamName = groupInfo.TeamName,
  936. info = arr
  937. };
  938. if (qwUserIdList.Count > 0)
  939. {
  940. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.BlackCodeInfo_ToVisaUser(info));
  941. if (result.errcode != 0)
  942. {
  943. //抄送日志
  944. return false;
  945. }
  946. }
  947. return true;
  948. }
  949. public static async Task<bool> SendUserMsg_GroupTimeInfo_ToVisaUser(int diId, string startTime, string endTime)
  950. {
  951. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  952. var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
  953. .Select(x => x.Id)
  954. .ToList();
  955. List<string> userIds = new List<string>() { "235" };
  956. userIds.AddRange(visaUser.Select(x => x.ToString()));
  957. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  958. GroupDateTime_ToVisaUser info = new GroupDateTime_ToVisaUser()
  959. {
  960. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  961. TeamName = groupInfo.TeamName,
  962. EndTime = endTime,
  963. StartTime = startTime,
  964. };
  965. if (qwUserIdList.Count > 0)
  966. {
  967. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupDateTime_ToVisaUser(info));
  968. if (result.errcode != 0)
  969. {
  970. //抄送日志
  971. return false;
  972. }
  973. }
  974. return true;
  975. }
  976. #endregion
  977. #region 任务通知
  978. /// <summary>
  979. /// 任务通知
  980. /// </summary>
  981. /// <param name="userIds"></param>
  982. /// <param name="groupId"></param>
  983. /// <param name="title"></param>
  984. /// <param name="currUserId"></param>
  985. /// <returns></returns>
  986. public static async Task<bool> SendUserMsg_Task_ToUser(List<string> userIds, int groupId, string title, int currUserId)
  987. {
  988. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  989. if (qwUserIdList.Any())
  990. {
  991. var groupName = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.IsDel == 0 && s.Id == groupId).First()?.TeamName ?? "未选择";
  992. var userName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == currUserId).First()?.CnName ?? "Unknown";
  993. var model = new TaskAssignment_Create_ToUserModel()
  994. {
  995. GroupName = groupName,
  996. Title = title,
  997. CreateUser = userName,
  998. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm")
  999. };
  1000. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskAssignment_Create_ToUser(model));
  1001. if (result.errcode != 0)
  1002. {
  1003. //抄送日志
  1004. return false;
  1005. }
  1006. }
  1007. return true;
  1008. }
  1009. #endregion
  1010. #region 物资通知
  1011. /// <summary>
  1012. /// 物资领用通知
  1013. /// 接收者:审核节点相关审核人
  1014. /// </summary>
  1015. /// <param name="dataId"></param>
  1016. /// <param name="diId"></param>
  1017. /// <param name="operationId"></param>
  1018. /// <returns></returns>
  1019. public static async Task<bool> SendUserMsg_CompanyShare_ToHR(int dataId, int diId, int operationId)
  1020. {
  1021. //企微通知
  1022. var userIds = new List<string>()
  1023. {
  1024. "208", //雷怡
  1025. "374", //罗颖
  1026. };
  1027. var isCheckValuable = false;
  1028. var valuableUserNames = new List<string>();
  1029. //根据审核节点的审核人,发送通知
  1030. var flow = _grpDeleRep._sqlSugar.Queryable<Sys_AuditFlow>().First(x => x.IsDel == 0 && x.BusinessType == 1 && x.BusinessId == dataId);
  1031. if (flow != null)
  1032. {
  1033. var auditNode = _grpDeleRep._sqlSugar
  1034. .Queryable<Sys_AuditTemplateNode>()
  1035. .First(x => x.IsDel == 0 && x.TemplateId == flow.TemplateId && x.Id == flow.CurrentNodeId);
  1036. if (auditNode != null)
  1037. {
  1038. var auditUserList = _grpDeleRep._sqlSugar.Queryable<Sys_AuditTemplateNodeUser>()
  1039. .Where(x => x.IsDel == 0 && x.NodeId == auditNode.Id)
  1040. .Select(x => new
  1041. {
  1042. x.UserId,
  1043. x.UserName
  1044. })
  1045. .ToList();
  1046. if (auditUserList.Any())
  1047. {
  1048. if (auditUserList.Count > 1) isCheckValuable = true;
  1049. userIds.AddRange(auditUserList.Select(x => x.UserId.ToString()).ToList());
  1050. userIds = userIds.Distinct().ToList();
  1051. valuableUserNames.AddRange(auditUserList.Select(x => x.UserName).ToList());
  1052. }
  1053. }
  1054. }
  1055. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  1056. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  1057. var groupName = diId switch
  1058. {
  1059. 0 => "其他物资(公司内部物资)",
  1060. -1 => "拜访客户所使用的物资",
  1061. -2 => "库存调整",
  1062. _ => groupInfo?.TeamName ?? "-"
  1063. };
  1064. var receiveInfo = _grpDeleRep._sqlSugar.Queryable<Pm_GoodsReceive>().First(x => x.IsDel == 0 && x.Id == dataId);
  1065. if (receiveInfo == null) return false;
  1066. var receiveDetails = _grpDeleRep._sqlSugar
  1067. .Queryable<Pm_GoodsReceiveDetails>()
  1068. .LeftJoin<Pm_GoodsInfo>((x, y) => x.GoodsId == y.Id)
  1069. .Where(x => x.IsDel == 0 && x.GoodsReceiveId == dataId)
  1070. .Select((x, y) => new
  1071. {
  1072. y.Name,
  1073. x.Quantity,
  1074. y.Unit
  1075. })
  1076. .ToList();
  1077. if (!receiveDetails.Any()) return false;
  1078. var goodsMsg = new StringBuilder();
  1079. foreach (var info in receiveDetails)
  1080. {
  1081. goodsMsg.AppendLine($">- {info.Name}:{info.Quantity:#0.00} {info.Unit}");
  1082. }
  1083. var groupLabel = string.Empty;
  1084. if (string.IsNullOrEmpty(groupName) || !groupName.Equals("-"))
  1085. {
  1086. groupLabel = $">团组归属:<font color='info'>{groupName}</font>";
  1087. }
  1088. //普通物品审批消息通知
  1089. string resMsg = string.Format(@" ` 物资领用申请通知 `
  1090. > ` {0} `提交物资领用申请:
  1091. {1}
  1092. >**物资明细**
  1093. {2}
  1094. >用途:<font color='comment'>{3}</font>
  1095. >申请时间:<font color='comment'>{4}</font>
  1096. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1097. operationName,
  1098. groupLabel,
  1099. goodsMsg,
  1100. receiveInfo.Reason,
  1101. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1102. //贵重物品审批消息通知
  1103. if (isCheckValuable)
  1104. {
  1105. var auditUserLabel = string.Empty;
  1106. foreach (var userName in valuableUserNames)
  1107. {
  1108. auditUserLabel += $"@{userName} ";
  1109. }
  1110. resMsg = string.Format(@" ` 【或签审批】物资领用(任一人审批即可)通知 `
  1111. >{0}
  1112. > ` {1} `提交物资领用申请,您被列为或签审批人:
  1113. **或签规则**
  1114. • 您与其他{2}人并行审批
  1115. • 任意一人通过即视为本环节通过
  1116. • 任意一人拒绝即视为终止流程
  1117. {3}
  1118. >**物资明细**
  1119. {4}
  1120. >用途:<font color='comment'>{5}</font>
  1121. >申请时间:<font color='comment'>{6}</font>
  1122. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1123. auditUserLabel,
  1124. operationName,
  1125. valuableUserNames.Count - 1,
  1126. groupLabel,
  1127. goodsMsg,
  1128. receiveInfo.Reason,
  1129. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1130. }
  1131. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  1132. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1133. if (result.errcode != 0)
  1134. {
  1135. //抄送日志
  1136. return false;
  1137. }
  1138. return true;
  1139. }
  1140. #endregion
  1141. #region 日服申请
  1142. /// <summary>
  1143. /// 日服申请、编辑通知
  1144. /// 接收者:指定接收者
  1145. /// </summary>
  1146. /// <param name="dataId"></param>
  1147. /// <param name="operationId">操作人Id</param>
  1148. /// <param name="recipients">接收者Id集合</param>
  1149. /// <returns></returns>
  1150. public static async Task<bool> SendUserMsg_CompanyShare_ToDailtPay(int dataId, int operationId, List<string> recipients)
  1151. {
  1152. //企微通知
  1153. var userIds = recipients;
  1154. string operationName = _grpDeleRep._sqlSugar.Queryable<Sys_Users>().First(x => x.IsDel
  1155. == 0 && x.Id == operationId).CnName ?? "Unknown";
  1156. var dailyPaymentInfo = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePayment>()
  1157. .FirstAsync(x => x.IsDel == 0 && x.Id == dataId);
  1158. var details = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePaymentContent>()
  1159. .Where(x => x.IsDel == 0 && x.DFPId == dataId)
  1160. .Select(x => new { x.PriceName, x.Quantity, x.Price })
  1161. .ToListAsync();
  1162. var detailsMsg = new StringBuilder();
  1163. foreach (var info in details)
  1164. {
  1165. detailsMsg.AppendLine($">- {info.PriceName}:{info.Quantity:#0.00} * {info.Price:#0.00} = {info.Quantity * info.Price:#0.00} 元");
  1166. }
  1167. if (detailsMsg.Length == 0 || detailsMsg == null)
  1168. {
  1169. detailsMsg.Append("无费用明细");
  1170. }
  1171. //普通物品审批消息通知
  1172. string resMsg = string.Format(@" ` 日付申请通知 `
  1173. > ` {0} `提交费用申请:
  1174. >**费用明细**
  1175. {1}
  1176. >总金额:<font color='comment'>{2} 元</font>
  1177. >申请说明:<font color='comment'>{3}</font>
  1178. >申请时间:<font color='comment'>{4}</font>
  1179. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1180. operationName,
  1181. detailsMsg.ToString(),
  1182. dailyPaymentInfo?.SumPrice.ToString("#0.00") ?? "0.00",
  1183. dailyPaymentInfo?.Instructions ?? "无申请说明",
  1184. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1185. List<string> qwUserIdList = GetQiyeChatUserIdList(recipients);
  1186. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1187. if (result.errcode != 0)
  1188. {
  1189. //抄送日志
  1190. return false;
  1191. }
  1192. return true;
  1193. }
  1194. #endregion
  1195. #region OA任务通知
  1196. public static async Task<bool> SendUserMsg_Task_ToUser(int taskOrderId, List<string> msgUserList, bool isNew)
  1197. {
  1198. msgUserList.Add("235");
  1199. msgUserList = msgUserList.Distinct().ToList();
  1200. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1201. var workOrder = _grpDeleRep._sqlSugar.Queryable<Task_WorkOrder>().First(x => x.IsDel == 0 && x.Id == taskOrderId);
  1202. var task = _grpDeleRep._sqlSugar.Queryable<Task_WorkTask>().Where(x => x.IsDel == 0 && x.WorkOrderId == taskOrderId).ToList();
  1203. TaskInfo_ToUser info = new TaskInfo_ToUser
  1204. {
  1205. isNew = isNew,
  1206. TaskName = workOrder.Name,
  1207. StartTime = workOrder.StartTime.ToString("yyyy-MM-dd HH:mm"),
  1208. TaskCount = task.Count,
  1209. UrgentCount = task.Count(x => x.IsUrgent)
  1210. };
  1211. if (qwUserIdList.Count > 0)
  1212. {
  1213. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_ToUser(info));
  1214. if (result.errcode != 0)
  1215. {
  1216. //抄送日志
  1217. return false;
  1218. }
  1219. }
  1220. return true;
  1221. }
  1222. public static async Task<bool> SendUserMsg_TaskSubMit_ToUser(int taskId, List<string> msgUserList)
  1223. {
  1224. msgUserList.Add("235");
  1225. msgUserList = msgUserList.Distinct().ToList();
  1226. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1227. var task = _grpDeleRep._sqlSugar.
  1228. Queryable<Task_WorkTask>().
  1229. Includes(x => x.WorkOrder).
  1230. First(x => x.IsDel == 0 && x.Id == taskId);
  1231. TaskInfo_SubMit_ToUser info = new TaskInfo_SubMit_ToUser
  1232. {
  1233. TaskName = task.WorkOrder.Name + " - " + task.Name,
  1234. StartTime = task.StartTime.ToString("yyyy-MM-dd HH:mm"),
  1235. EndTime = task.EndTime?.ToString("yyyy-MM-dd HH:mm") ?? ""
  1236. };
  1237. if (qwUserIdList.Count > 0)
  1238. {
  1239. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_SubMit_ToUser(info));
  1240. if (result.errcode != 0)
  1241. {
  1242. //抄送日志
  1243. return false;
  1244. }
  1245. }
  1246. return true;
  1247. }
  1248. public static async Task<bool> SendUserMsg_TaskAudit_ToUser(int taskId, bool auditResult, string message, List<string> msgUserList)
  1249. {
  1250. msgUserList.Add("235");
  1251. msgUserList = msgUserList.Distinct().ToList();
  1252. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1253. var task = _grpDeleRep._sqlSugar.
  1254. Queryable<Task_WorkTask>().
  1255. Includes(x => x.WorkOrder).
  1256. First(x => x.IsDel == 0 && x.Id == taskId);
  1257. TaskInfo_Audit_ToUser info = new TaskInfo_Audit_ToUser
  1258. {
  1259. TaskName = task.WorkOrder.Name + " - " + task.Name,
  1260. auditResult = auditResult,
  1261. Message = message
  1262. };
  1263. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_Audit_ToUser(info));
  1264. if (result.errcode != 0)
  1265. {
  1266. //抄送日志
  1267. return false;
  1268. }
  1269. return true;
  1270. }
  1271. #endregion
  1272. #region 报批通知
  1273. public static async Task<bool> SendUserMsg_BaoPi_ToUser(List<string> msgUserList, int diid)
  1274. {
  1275. var di = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.IsDel == 0 && s.Id == diid).First();
  1276. if (di == null) return false;
  1277. msgUserList.Add("235");
  1278. msgUserList = msgUserList.Distinct().ToList();
  1279. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1280. var resMsg = string.Format(@" ` 团组确认通知 `
  1281. > “{0}团组已确认,请进行下一步业务操作”
  1282. - 客户单位:{1}
  1283. - 出访日期:{2}
  1284. - 天数:{3}
  1285. - 人数:{4}
  1286. ",
  1287. di.TeamName,
  1288. di.ClientName,
  1289. di.VisitDate.ToString("yyyy-MM-dd"),
  1290. di.VisitDays,
  1291. di.VisitPNumber);
  1292. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1293. if (result.errcode != 0)
  1294. {
  1295. throw new Exception(result.errmsg);
  1296. }
  1297. return true;
  1298. }
  1299. #endregion
  1300. #region Helper
  1301. private static string getClientNameStr(List<SimplClientInfo> list, string origin)
  1302. {
  1303. string result = origin;
  1304. if (Regex.Match(origin, @"\d +,?").Value.Length > 0)
  1305. {
  1306. string[] temparr = origin.Split(',');
  1307. string fistrStr = temparr[0];
  1308. int count = temparr.Length;
  1309. int tempId;
  1310. bool success = int.TryParse(fistrStr, out tempId);
  1311. if (success)
  1312. {
  1313. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1314. if (tempInfo != null)
  1315. {
  1316. if (count > 1)
  1317. {
  1318. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1319. }
  1320. else
  1321. {
  1322. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1323. }
  1324. }
  1325. }
  1326. }
  1327. return result;
  1328. }
  1329. private static List<SimplClientInfo> getSimplClientList(int diId)
  1330. {
  1331. 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);
  1332. List<SimplClientInfo> arr = _grpDeleRep._sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1333. return arr;
  1334. }
  1335. #endregion
  1336. }
  1337. }