123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using System.Linq;
- using System.Data;
- using MySystem;
- using MySystem.PxcModels;
- using Library;
- using LitJson;
- public class WifiRefundHelper
- {
- public readonly static WifiRefundHelper Instance = new WifiRefundHelper();
- private WifiRefundHelper()
- {
- }
- public void Start()
- {
- Thread th = new Thread(DoWorks);
- th.IsBackground = true;
- th.Start();
- }
- private void DoWorks()
- {
- while (true)
- {
- try
- {
- string content = RedisDbconn.Instance.RPop<string>("WifiRefundQueue");
- if(!string.IsNullOrEmpty(content))
- {
- DoSomething(content);
- }
- else
- {
- Thread.Sleep(60000);
- }
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "WIFI退款异常");
- }
- }
- }
- public void DoSomething(string OrderNo)
- {
- WebCMSEntities db = new WebCMSEntities();
- WifiTradeRecord edit = db.WifiTradeRecord.FirstOrDefault(m => m.OrderNo == OrderNo);
- if(edit != null)
- {
- edit.DoMonths = edit.Duration + 1;
- edit.Status = -1;
- db.SaveChanges();
- }
- db.Dispose();
- }
- }
|