Library.cs 68 KB

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