SycnSpActiveService.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using MySystem.SpModels;
  5. using Library;
  6. using LitJson;
  7. namespace MySystem
  8. {
  9. public class SycnSpActiveService
  10. {
  11. public readonly static SycnSpActiveService Instance = new SycnSpActiveService();
  12. private SycnSpActiveService()
  13. { }
  14. public void Start()
  15. {
  16. WebCMSEntities spdb = new WebCMSEntities();
  17. PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
  18. string Month = DateTime.Now.ToString("yyyyMM");
  19. string Date = DateTime.Now.ToString("yyyyMMdd");
  20. DateTime start = DateTime.Now.AddDays(-2);
  21. List<ActivateRecord> acts = spdb.ActivateRecord.Where(m => m.ActivateDate >= start && m.Status == 1).OrderByDescending(m => m.Id).ToList();
  22. foreach (ActivateRecord act in acts)
  23. {
  24. if (act.ActivateStatus == "00")
  25. {
  26. PxcModels.MachineForSnNo posFor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == act.SnNo) ?? new PxcModels.MachineForSnNo();
  27. PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == posFor.SnId && m.ActivationState == 0);
  28. if (pos != null)
  29. {
  30. pos.ActivationState = 1;
  31. pos.ActivationTime = DateTime.Now;
  32. BothdisDbconn.Instance.SendMq("Pop:PosMachinesTwo", pos);
  33. PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
  34. if (merchant != null)
  35. {
  36. merchant.ActiveStatus = 1;
  37. merchant.MerStandardDate = DateTime.Now;
  38. BothdisDbconn.Instance.SendMq("Pop:PosMerchantInfo", merchant);
  39. }
  40. // 激活奖励
  41. // ProfitHelper.Instance.StartListenActiveDo(pos);
  42. }
  43. }
  44. ActivateRecord edit = spdb.ActivateRecord.FirstOrDefault(m => m.Id == act.Id);
  45. if (edit != null)
  46. {
  47. edit.Status = 2;
  48. }
  49. }
  50. spdb.SaveChanges();
  51. spdb.Dispose();
  52. db.SaveChanges();
  53. db.Dispose();
  54. }
  55. }
  56. }