|
@@ -1,95 +0,0 @@
|
|
|
-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 WifiUnBindHelper
|
|
|
-{
|
|
|
- public readonly static WifiUnBindHelper Instance = new WifiUnBindHelper();
|
|
|
- private WifiUnBindHelper()
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
- 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>("WifiUnBindQueue");
|
|
|
- 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 SnNo)
|
|
|
- {
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
- PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo) ?? new PosMachinesTwo();
|
|
|
- PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
|
|
|
- if(merchant != null)
|
|
|
- {
|
|
|
- //备份解绑的商户信息
|
|
|
- CustomerSqlConn.op("insert into PosMerchantInfoBak select * from PosMerchantInfo where Id=" + pos.BindMerchantId, MysqlConn.SqlConnStr);
|
|
|
- MachineForMerNo forMerNo = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == merchant.KqMerNo);
|
|
|
- if (forMerNo != null)
|
|
|
- {
|
|
|
- db.MachineForMerNo.Remove(forMerNo);
|
|
|
- }
|
|
|
- pos.BindMerchantId = 0;
|
|
|
- pos.BindingState = 0;
|
|
|
- pos.BindingTime = null;
|
|
|
- db.PosMerchantInfo.Remove(merchant);
|
|
|
- db.SaveChanges();
|
|
|
- }
|
|
|
-
|
|
|
- WifiTradeRecord trade = db.WifiTradeRecord.FirstOrDefault(m => m.SnNo == SnNo);
|
|
|
- if(trade != null)
|
|
|
- {
|
|
|
- if(trade.Unit == "m" && trade.Duration > 0)
|
|
|
- {
|
|
|
- decimal TradeAmt = trade.TradeAmount / trade.Duration;
|
|
|
- string TradeMonth = trade.CreateDate.Value.ToString("yyyy-MM");
|
|
|
- DateTime StartMonth = DateTime.Parse(TradeMonth + "-01 00:00:00");
|
|
|
- for (int i = 1; i <= trade.Duration; i++)
|
|
|
- {
|
|
|
- StartMonth = StartMonth.AddMonths(1);
|
|
|
- SycnSpTradeWifiService.Instance.StatTrade(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), -TradeAmt);
|
|
|
- if (pos.BindingTime < trade.CreateDate.Value.AddMonths(-9))
|
|
|
- {
|
|
|
- SycnSpTradeWifiService.Instance.StatTradeBefore(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), -TradeAmt);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SycnSpTradeWifiService.Instance.StatTradeAfter(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), -TradeAmt);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- db.SaveChanges();
|
|
|
- }
|
|
|
- db.Dispose();
|
|
|
- }
|
|
|
-}
|