| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using System;
- using System.Collections.Generic;
- using Library;
- using LitJson;
- using System.Linq;
- using System.Data;
- using System.Threading;
- using MySystem.PxcModels;
- namespace MySystem
- {
- public class WifiWithholdService
- {
- public readonly static WifiWithholdService Instance = new WifiWithholdService();
- private WifiWithholdService()
- { }
- public void Start()
- {
- Thread th = new Thread(dosomething);
- th.IsBackground = true;
- th.Start();
- }
- public void dosomething()
- {
- while (true)
- {
- try
- {
- // if(DateTime.Now.Hour > 3 && DateTime.Now.Hour < 5 && DateTime.Now >= DateTime.Parse("2024-10-30 00:00:00"))
- // {
- // string chk = function.ReadInstance("/WifiWithhold/" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
- // if(string.IsNullOrEmpty(chk))
- // {
- // function.WritePage("/WifiWithhold/", "" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTime.Now.ToString());
- WifiWithhold();
- // }
- // }
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "WIFI提醒异常");
- }
- Thread.Sleep(30000);
- }
- }
- //WIFI30天未完成申请时向预发创客增加一条预扣款
- private void WifiWithhold()
- {
- WebCMSEntities db = new WebCMSEntities();
- DateTime end = DateTime.Parse(DateTime.Now.AddDays(-29).ToString("yyyy-MM-dd") + " 00:00:00");
- int Id = 0;
- bool op = true;
- while(op)
- {
- List<int> BrandIds = new List<int>();
- BrandIds.Add(23);
- BrandIds.Add(24);
- BrandIds.Add(25);
- BrandIds.Add(26);
- DateTime time = DateTime.Now.AddDays(-35);
- List<PosMachinesTwo> WifiList = db.PosMachinesTwo.Where(m => m.Id > Id && BrandIds.Contains(m.BrandId) && m.ActivationState == 0 && m.TransferTime < time && m.Sort == 1).OrderBy(m => m.Id).Take(20).ToList();
- if(WifiList.Count > 0)
- {
- foreach(var Pos in WifiList)
- {
- KqProducts brand = db.KqProducts.FirstOrDefault(m => m.Id == Pos.BrandId) ?? new KqProducts();
- decimal ChargeAmount = decimal.Parse(function.CheckNum(Pos.SeoKeyword));
- db.ToChargeBackRecord.Add(new ToChargeBackRecord
- {
- CreateDate = DateTime.Now,
- SeoTitle = "系统",
- SeoDescription = "WIFI超时未激活扣款",
- Remark = "WIFI超时未激活扣款",
- ChargeType = 1,
- ChargeAmount = ChargeAmount,
- UserId = Pos.BuyUserId,
- Field1 = Pos.PosSn,
- });
- PosMachinesTwo edit = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Pos.Id);
- if(edit != null)
- {
- edit.Sort = 2;
- }
- //增加账户预扣总额
- Utils.Instance.ToChargeAmount(Pos.BuyUserId, ChargeAmount);
- Id = Pos.Id;
- }
- db.SaveChanges();
- }
- else
- {
- op = false;
- }
- }
- db.Dispose();
- }
- }
- }
|