Library.cs 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647
  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. /// 机票行程代码录入变更通知发送国交经理、主管、王鸽、OP操作人员
  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", "235" };
  880. receivedUserIds.AddRange(defaultUserIds);
  881. #region 添加对应的OP操作人员
  882. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diId);
  883. var opUserIds = groupModuleOperators
  884. .Where(x => x.CTableId == 79)
  885. .FirstOrDefault()?
  886. .OperationUsers.Select(x => x.UserId.ToString())
  887. .ToList();
  888. receivedUserIds.AddRange(opUserIds ?? new List<string>());
  889. receivedUserIds = receivedUserIds.Distinct().ToList();
  890. #endregion
  891. if (receivedUserIds.Count > 0)
  892. {
  893. List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
  894. string resMsg = string.Format(@" `公务出访有数据更新通知`
  895. >团组:<font color='info'>{0}</font>
  896. >操作人员:<font color='comment'>{1}</font>
  897. >操作时间:<font color='comment'>{2}</font>
  898. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  899. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  900. if (result.errcode != 0)
  901. {
  902. //抄送日志
  903. return false;
  904. }
  905. }
  906. return true;
  907. }
  908. #endregion
  909. #endregion
  910. #region 成本通知
  911. /// <summary>
  912. /// 成本通知发送给对应岗位用户
  913. /// </summary>
  914. /// <param name="diId"></param>
  915. /// <returns></returns>
  916. public static async Task<bool> SendUserMsg_GroupShare_ToJob(int diId)
  917. {
  918. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  919. List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 24 || s.JobPostId == 25 || s.JobPostId == 28)).ToList();
  920. //List<Sys_Users> list_user = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && (s.JobPostId == 40 || s.JobPostId == 41)).ToList();
  921. List<string> userIds = new List<string>();
  922. list_user.ForEach(s => userIds.Add(s.Id.ToString()));
  923. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  924. GroupShare_ToUserModel info = new GroupShare_ToUserModel()
  925. {
  926. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  927. TeamName = groupInfo.TeamName
  928. };
  929. if (qwUserIdList.Count > 0)
  930. {
  931. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupShare_ToUser(info));
  932. if (result.errcode != 0)
  933. {
  934. //抄送日志
  935. return false;
  936. }
  937. }
  938. return true;
  939. }
  940. public static async Task<bool> SendUserMsg_blackAirInfo_ToVisaUser(int diId, List<CountryDataTime> arr)
  941. {
  942. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  943. var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
  944. .Select(x => x.Id)
  945. .ToList();
  946. List<string> userIds = new List<string>() { "235" };
  947. userIds.AddRange(visaUser.Select(x => x.ToString()));
  948. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  949. BlackCodeInfo_ToVisaUser info = new BlackCodeInfo_ToVisaUser()
  950. {
  951. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  952. TeamName = groupInfo.TeamName,
  953. info = arr
  954. };
  955. if (qwUserIdList.Count > 0)
  956. {
  957. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.BlackCodeInfo_ToVisaUser(info));
  958. if (result.errcode != 0)
  959. {
  960. //抄送日志
  961. return false;
  962. }
  963. }
  964. return true;
  965. }
  966. public static async Task<bool> SendUserMsg_GroupTimeInfo_ToVisaUser(int diId, string startTime, string endTime)
  967. {
  968. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  969. var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
  970. .Select(x => x.Id)
  971. .ToList();
  972. List<string> userIds = new List<string>() { "235" };
  973. userIds.AddRange(visaUser.Select(x => x.ToString()));
  974. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  975. GroupDateTime_ToVisaUser info = new GroupDateTime_ToVisaUser()
  976. {
  977. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
  978. TeamName = groupInfo.TeamName,
  979. EndTime = endTime,
  980. StartTime = startTime,
  981. };
  982. if (qwUserIdList.Count > 0)
  983. {
  984. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupDateTime_ToVisaUser(info));
  985. if (result.errcode != 0)
  986. {
  987. //抄送日志
  988. return false;
  989. }
  990. }
  991. return true;
  992. }
  993. #endregion
  994. #region 任务通知
  995. /// <summary>
  996. /// 任务通知
  997. /// </summary>
  998. /// <param name="userIds"></param>
  999. /// <param name="groupId"></param>
  1000. /// <param name="title"></param>
  1001. /// <param name="currUserId"></param>
  1002. /// <returns></returns>
  1003. public static async Task<bool> SendUserMsg_Task_ToUser(List<string> userIds, int groupId, string title, int currUserId)
  1004. {
  1005. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  1006. if (qwUserIdList.Any())
  1007. {
  1008. var groupName = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.IsDel == 0 && s.Id == groupId).First()?.TeamName ?? "未选择";
  1009. var userName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == currUserId).First()?.CnName ?? "Unknown";
  1010. var model = new TaskAssignment_Create_ToUserModel()
  1011. {
  1012. GroupName = groupName,
  1013. Title = title,
  1014. CreateUser = userName,
  1015. RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm")
  1016. };
  1017. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskAssignment_Create_ToUser(model));
  1018. if (result.errcode != 0)
  1019. {
  1020. //抄送日志
  1021. return false;
  1022. }
  1023. }
  1024. return true;
  1025. }
  1026. #endregion
  1027. #region 物资通知
  1028. /// <summary>
  1029. /// 物资领用通知
  1030. /// 接收者:审核节点相关审核人
  1031. /// </summary>
  1032. /// <param name="dataId"></param>
  1033. /// <param name="diId"></param>
  1034. /// <param name="operationId"></param>
  1035. /// <returns></returns>
  1036. public static async Task<bool> SendUserMsg_CompanyShare_ToHR(int dataId, int diId, int operationId)
  1037. {
  1038. //企微通知
  1039. var userIds = new List<string>()
  1040. {
  1041. "208", //雷怡
  1042. "374", //罗颖
  1043. };
  1044. var isCheckValuable = false;
  1045. var valuableUserNames = new List<string>();
  1046. //根据审核节点的审核人,发送通知
  1047. var flow = _grpDeleRep._sqlSugar.Queryable<Sys_AuditFlow>().First(x => x.IsDel == 0 && x.BusinessType == 1 && x.BusinessId == dataId);
  1048. if (flow != null)
  1049. {
  1050. var auditNode = _grpDeleRep._sqlSugar
  1051. .Queryable<Sys_AuditTemplateNode>()
  1052. .First(x => x.IsDel == 0 && x.TemplateId == flow.TemplateId && x.Id == flow.CurrentNodeId);
  1053. if (auditNode != null)
  1054. {
  1055. var auditUserList = _grpDeleRep._sqlSugar.Queryable<Sys_AuditTemplateNodeUser>()
  1056. .Where(x => x.IsDel == 0 && x.NodeId == auditNode.Id)
  1057. .Select(x => new
  1058. {
  1059. x.UserId,
  1060. x.UserName
  1061. })
  1062. .ToList();
  1063. if (auditUserList.Any())
  1064. {
  1065. if (auditUserList.Count > 1) isCheckValuable = true;
  1066. userIds.AddRange(auditUserList.Select(x => x.UserId.ToString()).ToList());
  1067. userIds = userIds.Distinct().ToList();
  1068. valuableUserNames.AddRange(auditUserList.Select(x => x.UserName).ToList());
  1069. }
  1070. }
  1071. }
  1072. Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
  1073. var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
  1074. var groupName = diId switch
  1075. {
  1076. 0 => "其他物资(公司内部物资)",
  1077. -1 => "拜访客户所使用的物资",
  1078. -2 => "库存调整",
  1079. _ => groupInfo?.TeamName ?? "-"
  1080. };
  1081. var receiveInfo = _grpDeleRep._sqlSugar.Queryable<Pm_GoodsReceive>().First(x => x.IsDel == 0 && x.Id == dataId);
  1082. if (receiveInfo == null) return false;
  1083. var receiveDetails = _grpDeleRep._sqlSugar
  1084. .Queryable<Pm_GoodsReceiveDetails>()
  1085. .LeftJoin<Pm_GoodsInfo>((x, y) => x.GoodsId == y.Id)
  1086. .Where(x => x.IsDel == 0 && x.GoodsReceiveId == dataId)
  1087. .Select((x, y) => new
  1088. {
  1089. y.Name,
  1090. x.Quantity,
  1091. y.Unit
  1092. })
  1093. .ToList();
  1094. if (!receiveDetails.Any()) return false;
  1095. var goodsMsg = new StringBuilder();
  1096. foreach (var info in receiveDetails)
  1097. {
  1098. goodsMsg.AppendLine($">- {info.Name}:{info.Quantity:#0.00} {info.Unit}");
  1099. }
  1100. var groupLabel = string.Empty;
  1101. if (string.IsNullOrEmpty(groupName) || !groupName.Equals("-"))
  1102. {
  1103. groupLabel = $">团组归属:<font color='info'>{groupName}</font>";
  1104. }
  1105. //普通物品审批消息通知
  1106. string resMsg = string.Format(@" ` 物资领用申请通知 `
  1107. > ` {0} `提交物资领用申请:
  1108. {1}
  1109. >**物资明细**
  1110. {2}
  1111. >用途:<font color='comment'>{3}</font>
  1112. >申请时间:<font color='comment'>{4}</font>
  1113. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1114. operationName,
  1115. groupLabel,
  1116. goodsMsg,
  1117. receiveInfo.Reason,
  1118. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1119. //贵重物品审批消息通知
  1120. if (isCheckValuable)
  1121. {
  1122. var auditUserLabel = string.Empty;
  1123. foreach (var userName in valuableUserNames)
  1124. {
  1125. auditUserLabel += $"@{userName} ";
  1126. }
  1127. resMsg = string.Format(@" ` 【或签审批】物资领用(任一人审批即可)通知 `
  1128. >{0}
  1129. > ` {1} `提交物资领用申请,您被列为或签审批人:
  1130. **或签规则**
  1131. • 您与其他{2}人并行审批
  1132. • 任意一人通过即视为本环节通过
  1133. • 任意一人拒绝即视为终止流程
  1134. {3}
  1135. >**物资明细**
  1136. {4}
  1137. >用途:<font color='comment'>{5}</font>
  1138. >申请时间:<font color='comment'>{6}</font>
  1139. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1140. auditUserLabel,
  1141. operationName,
  1142. valuableUserNames.Count - 1,
  1143. groupLabel,
  1144. goodsMsg,
  1145. receiveInfo.Reason,
  1146. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1147. }
  1148. List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
  1149. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1150. if (result.errcode != 0)
  1151. {
  1152. //抄送日志
  1153. return false;
  1154. }
  1155. return true;
  1156. }
  1157. #endregion
  1158. #region 日服申请
  1159. /// <summary>
  1160. /// 日服申请、编辑通知
  1161. /// 接收者:指定接收者
  1162. /// </summary>
  1163. /// <param name="dataId"></param>
  1164. /// <param name="operationId">操作人Id</param>
  1165. /// <param name="recipients">接收者Id集合</param>
  1166. /// <returns></returns>
  1167. public static async Task<bool> SendUserMsg_CompanyShare_ToDailtPay(int dataId, int operationId, List<string> recipients)
  1168. {
  1169. //企微通知
  1170. var userIds = recipients;
  1171. string operationName = _grpDeleRep._sqlSugar.Queryable<Sys_Users>().First(x => x.IsDel
  1172. == 0 && x.Id == operationId).CnName ?? "Unknown";
  1173. var dailyPaymentInfo = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePayment>()
  1174. .FirstAsync(x => x.IsDel == 0 && x.Id == dataId);
  1175. var details = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePaymentContent>()
  1176. .Where(x => x.IsDel == 0 && x.DFPId == dataId)
  1177. .Select(x => new { x.PriceName, x.Quantity, x.Price })
  1178. .ToListAsync();
  1179. var detailsMsg = new StringBuilder();
  1180. foreach (var info in details)
  1181. {
  1182. detailsMsg.AppendLine($">- {info.PriceName}:{info.Quantity:#0.00} * {info.Price:#0.00} = {info.Quantity * info.Price:#0.00} 元");
  1183. }
  1184. if (detailsMsg.Length == 0 || detailsMsg == null)
  1185. {
  1186. detailsMsg.Append("无费用明细");
  1187. }
  1188. //普通物品审批消息通知
  1189. string resMsg = string.Format(@" ` 日付申请通知 `
  1190. > ` {0} `提交费用申请:
  1191. >**费用明细**
  1192. {1}
  1193. >总金额:<font color='comment'>{2} 元</font>
  1194. >申请说明:<font color='comment'>{3}</font>
  1195. >申请时间:<font color='comment'>{4}</font>
  1196. [详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/) ",
  1197. operationName,
  1198. detailsMsg.ToString(),
  1199. dailyPaymentInfo?.SumPrice.ToString("#0.00") ?? "0.00",
  1200. dailyPaymentInfo?.Instructions ?? "无申请说明",
  1201. DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
  1202. List<string> qwUserIdList = GetQiyeChatUserIdList(recipients);
  1203. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1204. if (result.errcode != 0)
  1205. {
  1206. //抄送日志
  1207. return false;
  1208. }
  1209. return true;
  1210. }
  1211. #endregion
  1212. #region OA任务通知
  1213. public static async Task<bool> SendUserMsg_Task_ToUser(int taskOrderId, List<string> msgUserList, bool isNew)
  1214. {
  1215. msgUserList.Add("235");
  1216. msgUserList = msgUserList.Distinct().ToList();
  1217. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1218. var workOrder = _grpDeleRep._sqlSugar.Queryable<Task_WorkOrder>().First(x => x.IsDel == 0 && x.Id == taskOrderId);
  1219. var task = _grpDeleRep._sqlSugar.Queryable<Task_WorkTask>().Where(x => x.IsDel == 0 && x.WorkOrderId == taskOrderId).ToList();
  1220. TaskInfo_ToUser info = new TaskInfo_ToUser
  1221. {
  1222. isNew = isNew,
  1223. TaskName = workOrder.Name,
  1224. StartTime = workOrder.StartTime.ToString("yyyy-MM-dd HH:mm"),
  1225. TaskCount = task.Count,
  1226. UrgentCount = task.Count(x => x.IsUrgent)
  1227. };
  1228. if (qwUserIdList.Count > 0)
  1229. {
  1230. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_ToUser(info));
  1231. if (result.errcode != 0)
  1232. {
  1233. //抄送日志
  1234. return false;
  1235. }
  1236. }
  1237. return true;
  1238. }
  1239. public static async Task<bool> SendUserMsg_TaskSubMit_ToUser(int taskId, List<string> msgUserList)
  1240. {
  1241. msgUserList.Add("235");
  1242. msgUserList = msgUserList.Distinct().ToList();
  1243. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1244. var task = _grpDeleRep._sqlSugar.
  1245. Queryable<Task_WorkTask>().
  1246. Includes(x => x.WorkOrder).
  1247. First(x => x.IsDel == 0 && x.Id == taskId);
  1248. TaskInfo_SubMit_ToUser info = new TaskInfo_SubMit_ToUser
  1249. {
  1250. TaskName = task.WorkOrder.Name + " - " + task.Name,
  1251. StartTime = task.StartTime.ToString("yyyy-MM-dd HH:mm"),
  1252. EndTime = task.EndTime?.ToString("yyyy-MM-dd HH:mm") ?? ""
  1253. };
  1254. if (qwUserIdList.Count > 0)
  1255. {
  1256. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_SubMit_ToUser(info));
  1257. if (result.errcode != 0)
  1258. {
  1259. //抄送日志
  1260. return false;
  1261. }
  1262. }
  1263. return true;
  1264. }
  1265. public static async Task<bool> SendUserMsg_TaskAudit_ToUser(int taskId, bool auditResult, string message, List<string> msgUserList)
  1266. {
  1267. msgUserList.Add("235");
  1268. msgUserList = msgUserList.Distinct().ToList();
  1269. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1270. var task = _grpDeleRep._sqlSugar.
  1271. Queryable<Task_WorkTask>().
  1272. Includes(x => x.WorkOrder).
  1273. First(x => x.IsDel == 0 && x.Id == taskId);
  1274. TaskInfo_Audit_ToUser info = new TaskInfo_Audit_ToUser
  1275. {
  1276. TaskName = task.WorkOrder.Name + " - " + task.Name,
  1277. auditResult = auditResult,
  1278. Message = message
  1279. };
  1280. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.TaskInfo_Audit_ToUser(info));
  1281. if (result.errcode != 0)
  1282. {
  1283. //抄送日志
  1284. return false;
  1285. }
  1286. return true;
  1287. }
  1288. #endregion
  1289. #region 报批通知
  1290. public static async Task<bool> SendUserMsg_BaoPi_ToUser(List<string> msgUserList, int diid)
  1291. {
  1292. var di = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.IsDel == 0 && s.Id == diid).First();
  1293. if (di == null) return false;
  1294. msgUserList.Add("235");
  1295. msgUserList = msgUserList.Distinct().ToList();
  1296. List<string> qwUserIdList = GetQiyeChatUserIdList(msgUserList);
  1297. var resMsg = string.Format(@" ` 团组确认通知 `
  1298. > {0}已确认,请进行下一步业务操作
  1299. - 客户单位:{1}
  1300. - 出访日期:{2}
  1301. - 天数:{3}
  1302. - 人数:{4}
  1303. ",
  1304. di.TeamName,
  1305. di.ClientName,
  1306. di.VisitDate.ToString("yyyy-MM-dd"),
  1307. di.VisitDays,
  1308. di.VisitPNumber);
  1309. ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
  1310. if (result.errcode != 0)
  1311. {
  1312. throw new Exception(result.errmsg);
  1313. }
  1314. return true;
  1315. }
  1316. #endregion
  1317. #region Helper
  1318. private static string getClientNameStr(List<SimplClientInfo> list, string origin)
  1319. {
  1320. string result = origin;
  1321. if (Regex.Match(origin, @"\d +,?").Value.Length > 0)
  1322. {
  1323. string[] temparr = origin.Split(',');
  1324. string fistrStr = temparr[0];
  1325. int count = temparr.Length;
  1326. int tempId;
  1327. bool success = int.TryParse(fistrStr, out tempId);
  1328. if (success)
  1329. {
  1330. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1331. if (tempInfo != null)
  1332. {
  1333. if (count > 1)
  1334. {
  1335. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1336. }
  1337. else
  1338. {
  1339. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1340. }
  1341. }
  1342. }
  1343. }
  1344. return result;
  1345. }
  1346. private static List<SimplClientInfo> getSimplClientList(int diId)
  1347. {
  1348. 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);
  1349. List<SimplClientInfo> arr = _grpDeleRep._sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1350. return arr;
  1351. }
  1352. #endregion
  1353. }
  1354. }