using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Threading; using MySystem.Models; using Library; namespace MySystem { /// /// 设置机具费率标记并推送消息 /// public class SetSftFeeService { public readonly static SetSftFeeService Instance = new SetSftFeeService(); private SetSftFeeService() { } public void Start() { Thread th = new Thread(doSomething); th.IsBackground = true; th.Start(); } public void doSomething() { while (true) { if (DateTime.Now.Hour > 0 && DateTime.Now.Hour < 19) { try { string check = function.ReadInstance("/SftFee/check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"); if (string.IsNullOrEmpty(check)) { function.WritePage("/SftFee/", "check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", DateTime.Now.ToString("HH:mm:ss")); WebCMSEntities db = new WebCMSEntities(); var date = DateTime.Now.AddDays(-420); var checkDate = DateTime.Parse("2024-06-01 00:00:00").AddDays(-420); bool op = true; int StartId = 0; while(op) { var posList = db.PosMachinesTwo.Select(m => new { m.Id, m.Status, m.BindingState, m.BindingTime, m.UpFeeFlag, m.DownFeeFlag, m.BrandId }).Where(m => m.Id > StartId && m.Status > -1 && m.BindingTime <= date && m.BindingState == 1 && m.BrandId == 7 && m.BindingTime >= checkDate).OrderBy(m => m.Id).Take(100).ToList(); function.WriteLog(DateTime.Now.ToString(), "420天盛付通费率加万2"); function.WriteLog(posList.Count.ToString(), "420天盛付通费率加万2"); if(posList.Count > 0) { //循环修改机具费率调升标记 //统计需要推送消息的用户Id foreach (var item in posList) { string Fee = "0.62"; function.WriteLog(item.Id.ToString(), "420天盛付通费率加万2"); string info = "{\"RecordId\":\"\",\"PosId\":\"" + item.Id + "\",\"Fee\": \"" + Fee + "\",\"Kind\": \"4\",\"OpMan\": \""+"系统"+"\"}"; RedisDbconn.Instance.AddList("SetDepositQueue", info); StartId = item.Id; } } else { op = false; } } db.Dispose(); } } catch (Exception ex) { function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "425天盛付通费率加万2异常"); } } Thread.Sleep(800000); } } } }