SynWeChatPayStatusJob.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Autofac;
  2. using Bowin.Common.Log;
  3. using EMIS.CommonLogic.SystemServices;
  4. using EMIS.Web.Controls;
  5. using Senparc.Weixin.TenPay.V3;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. namespace EMIS.Services.ScheduleJob
  11. {
  12. public class SynWeChatPayStatusJob : EAPServiceJob
  13. {
  14. #region 运行JOB
  15. /// <summary>
  16. /// 重写 MyJob 方法
  17. /// </summary>
  18. /// <returns></returns>
  19. protected override bool MyJob()
  20. {
  21. var result = true;
  22. try
  23. {
  24. LogHelper.WriteLog(LogType.ServiceLog, "----开始根据微信订单同步缴费状态-----");
  25. using (var scop = Program.AutofacContainer.BeginLifetimeScope())
  26. {
  27. IWechatPayServices WechatPayServices = scop.Resolve<IWechatPayServices>();
  28. var wecharPayList = WechatPayServices.SearchWeChatPayList();
  29. List<OrderQueryResult> orderList = new List<OrderQueryResult>();
  30. foreach (var wecharPay in wecharPayList)
  31. {
  32. OrderQueryResult query = WechatHelper.OrderQuery(wecharPay.OrderID);
  33. orderList.Add(query);
  34. }
  35. WechatPayServices.UpdateWeChatPay(orderList);
  36. }
  37. LogHelper.WriteLog(LogType.ServiceLog, "----结束根据微信订单同步缴费状态-----");
  38. }
  39. catch (System.Exception err)
  40. {
  41. LogHelper.WriteLog(LogType.ServiceLog, "----根据微信订单同步缴费状态处理异常-----");
  42. LogHelper.WriteLog(LogType.ServiceLog, err.Message);
  43. result = false;
  44. }
  45. return result;
  46. }
  47. #endregion
  48. }
  49. }