using System; using System.Collections.Generic; using Library; using LitJson; using System.Linq; using System.Threading; using MySystem.PxcModels; namespace MySystem { public class HyfAddPrizeService { public readonly static HyfAddPrizeService Instance = new HyfAddPrizeService(); private HyfAddPrizeService() { } public void Start() { Thread th = new Thread(StartDo); th.IsBackground = true; th.Start(); } public void StartDo() { while(true) { try { DoSomething(); } catch(Exception ex) { function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "盒力四射加码奖励异常"); } Thread.Sleep(600000); } } public void DoSomething() { WebCMSEntities db = new WebCMSEntities(); DateTime online = DateTime.Parse("2024-07-04 00:00:00"); DateTime end = DateTime.Parse("2025-01-01 00:00:00"); DateTime leftTime = DateTime.Now.AddDays(-30); DateTime rightTime = DateTime.Now.AddDays(-7); if(DateTime.Now > end) return; IQueryable posList = db.PosMachinesTwo.Where(m => m.BindingState == 1 && m.ActivationState == 1 && m.CreditTrade >= 1000 && m.BindingTime >= online && m.BindingTime >= leftTime && m.BindingTime <= rightTime && (m.BrandId == 12 || m.BrandId == 13)); foreach (PosMachinesTwo pos in posList.ToList()) { function.WriteLog(str: "机具号:" + pos.PosSn, "盒力四射加码奖励日志"); Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId); if (user != null) { function.WriteLog("机具所属人:" + user.Id, "盒力四射加码奖励日志"); int GetUserId = user.Id; AlipayPayBack2Service.Instance.ChangeAccount(db, new Orders(), GetUserId, 50, 150); } function.WriteLog("\n\n\n", "盒力四射加码奖励日志"); } db.Dispose(); } } }