| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using MySystem.SpModels;
- using Library;
- using LitJson;
- namespace MySystem
- {
- public class SycnSpActiveService
- {
- public readonly static SycnSpActiveService Instance = new SycnSpActiveService();
- private SycnSpActiveService()
- { }
- public void Start()
- {
- WebCMSEntities spdb = new WebCMSEntities();
- PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
- string Month = DateTime.Now.ToString("yyyyMM");
- string Date = DateTime.Now.ToString("yyyyMMdd");
- DateTime start = DateTime.Now.AddDays(-2);
- List<ActivateRecord> acts = spdb.ActivateRecord.Where(m => m.ActivateDate >= start && m.Status == 1).OrderByDescending(m => m.Id).ToList();
- foreach (ActivateRecord act in acts)
- {
- if (act.ActivateStatus == "00")
- {
- PxcModels.MachineForSnNo posFor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == act.SnNo) ?? new PxcModels.MachineForSnNo();
- PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == posFor.SnId && m.ActivationState == 0);
- if (pos != null)
- {
- pos.ActivationState = 1;
- pos.ActivationTime = DateTime.Now;
- BothdisDbconn.Instance.SendMq("Pop:PosMachinesTwo", pos);
- PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
- if (merchant != null)
- {
- merchant.ActiveStatus = 1;
- merchant.MerStandardDate = DateTime.Now;
- BothdisDbconn.Instance.SendMq("Pop:PosMerchantInfo", merchant);
- }
- // 激活奖励
- // ProfitHelper.Instance.StartListenActiveDo(pos);
- }
- }
- ActivateRecord edit = spdb.ActivateRecord.FirstOrDefault(m => m.Id == act.Id);
- if (edit != null)
- {
- edit.Status = 2;
- }
- }
- spdb.SaveChanges();
- spdb.Dispose();
- db.SaveChanges();
- db.Dispose();
- }
- }
- }
|