using System;
using System.Collections.Generic;
using System.Linq;
using MySystem.SpModels;
using Library;
using LitJson;
using System.Threading;

namespace MySystem
{
    public class SycnSpTradeService
    {
        public readonly static SycnSpTradeService Instance = new SycnSpTradeService();
        private SycnSpTradeService()
        { }

        public void Start()
        {
            Thread th = new Thread(StartDo);
            th.IsBackground = true;
            th.Start();
        }

        public void StartDo()
        {
            while (true)
            {
                try
                {
                    List<string> BrandIds = new List<string>();
                    BrandIds.Add("14");
                    BrandIds.Add("17");
                    BrandIds.Add("23");
                    BrandIds.Add("24");
                    BrandIds.Add("25");
                    BrandIds.Add("26");
                    BrandIds.Add("32");
                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
                    WebCMSEntities spdb = new WebCMSEntities();
                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
                    JavaProductModels.WebCMSEntities pdb = new JavaProductModels.WebCMSEntities();
                    DateTime start = DateTime.Now.AddDays(-60);
                    DateTime end = DateTime.Now.AddMinutes(-3);
                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/TradeRecordId.txt")));
                    IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id >= StartId && !BrandIds.Contains(m.ProductType) && SaveDataBindIds.Contains(m.ProductType) && m.CreateDate >= start && m.Status == 1).OrderBy(m => m.CreateDate).Take(20);
                    foreach (TradeRecord trade in trades.ToList())
                    {
                        DoQueueTrade(db, pdb, trade);
                        TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
                        if (edit != null)
                        {
                            edit.Status = 2;
                        }
                        spdb.SaveChanges(); 
                    }
                    spdb.Dispose();
                    db.Dispose();
                    pdb.Dispose();
                }
                catch (Exception ex)
                {
                    Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "同步SP交易数据到MAIN异常");
                }
                Thread.Sleep(500);
            }
        }

        public void DoQueueTrade(PxcModels.WebCMSEntities db, JavaProductModels.WebCMSEntities pdb, TradeRecord trade)
        {
            string TradeSnNo = trade.TradeSnNo;
            if(trade.ProductType == "30")
            {
                trade.MerNo = trade.Field2;
            }

            bool op = true;
            //判断盒易付吱码交易
            if(trade.ProductType == "12" && trade.TradeType == "2")
            {
                JavaProductModels.KxsMerchant merchant = pdb.KxsMerchant.FirstOrDefault(m => m.MerchantNo == trade.MerNo);
                if(merchant != null)
                {
                    JavaProductModels.KxsMachine pos = pdb.KxsMachine.FirstOrDefault(m => m.Id == merchant.MachineId);
                    if(pos != null)
                    {
                        trade.TradeSnNo = pos.PosSn;
                    }
                }
            }
            if (trade.SerEntryMode == "N" && trade.ProductType == "1") //金控押金获取
            {
                if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
                {
                    op = false;
                    PosPushDataNewHelper.Deposit(trade);
                }
            }
            else if (trade.SerEntryMode == "1" && trade.ProductType == "27") //金控押金获取
            {
                if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
                {
                    op = false;
                    PosPushDataNewHelper.Deposit(trade);
                }
            }
            else if ((trade.ProductType == "4" || trade.ProductType == "8" || trade.ProductType == "9") && (trade.ErrorCode == "5200" || trade.ErrorCode == "5800")) //乐刷海科费率0.52,0.58的不入库
            {
                op = false;
            }
            else if (trade.SerEntryMode == "1" && trade.ProductType == "10") //联动押金获取
            {
                if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
                {
                    op = false;
                    PosPushDataNewHelper.Deposit(trade);
                }
            }
            else if (trade.SerEntryMode == "40" && trade.ProductType == "12") //盒易付押金获取
            {
                if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
                {
                    op = false;
                    PosPushDataNewHelper.Deposit(trade);
                    //创业帮押金数据推送
                    string conn = ConfigurationManager.AppSettings["PushSqlConnStr"].ToString();
                    CustomerSqlConn.op("INSERT INTO `u_kxs_trade_info_" + trade.CreateDate.Value.ToString("yyyyMM") + "` (`user_id`, `cash_flag`, `merch_no`, `agent_id`, `pos_sn`, `order_id`, `amount`, `trans_time`, `card_type`, `pay_type`) VALUES (123005, 1, '" + trade.MerNo + "', '01', '" + trade.TradeSnNo + "', '" + trade.TradeSerialNo + "', " + trade.TradeAmount + ", '" + trade.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 1, 0);", conn);
                }
            }
            else if (trade.SettleFee == 0 && trade.ProductType == "15") //联客宝押金获取
            {
                if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
                {
                    op = false;
                }
            }
            else if (trade.Field2 == "1590" && trade.ProductType == "22") //立刷微智能押金获取
            {
                if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
                {
                    op = false;
                }
            }
            else if (trade.SerEntryMode == "DEPOSIT" && trade.ProductType == "30") //拉卡拉押金获取
            {
                if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
                {
                    op = false;
                    if(trade.ProductType == "30")
                    {
                        PxcModels.LklMerNo mer = db.LklMerNo.FirstOrDefault(m => m.ExtMerNo == trade.MerNo);
                        if(mer != null)
                        {
                            trade.MerNo = mer.MerNo;
                        }
                    }
                    PosPushDataNewHelper.Deposit(trade);
                }
            }
            else if (trade.SerEntryMode == "MACHINE" && trade.ProductType == "34") //联动掌中宝押金获取
            {
                PosPushDataNewHelper.Deposit(trade);
                op = false;
            }
            if (trade.DiscountRateFlag == "True")
            {
                op = false;
            }
            if(trade.ProductType == "7" && trade.TradeStatus != "00")
            {
                op = false;
            }
            if(trade.ProductType == "34" && trade.TradeStatus != "SUCCESS")
            {
                op = false;
            }
            if (op)
            {
                bool check = db.SpOrderNos.Any(m => m.OrderNo == trade.TradeSerialNo);
                if (!check)
                {
                    PosPushDataNewHelper.Trade(trade);
                    //创业帮交易数据推送
                    if(trade.ProductType == "12")
                    {
                        int BankCardType = 1;
                        if (trade.BankCardType == "C")
                        {
                            BankCardType = 1;
                        }
                        else if (trade.BankCardType == "D")
                        {
                            BankCardType = 0;
                        }
                        string conn = ConfigurationManager.AppSettings["PushSqlConnStr"].ToString();
                        CustomerSqlConn.op("INSERT INTO `u_kxs_trade_info_" + trade.CreateDate.Value.ToString("yyyyMM") + "` (`user_id`, `cash_flag`, `merch_no`, `agent_id`, `pos_sn`, `order_id`, `amount`, `trans_time`, `card_type`, `pay_type`) VALUES (123005, 0, '" + trade.MerNo + "', '01', '" + trade.TradeSnNo + "', '" + trade.TradeSerialNo + "', " + trade.TradeAmount + ", '" + trade.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', " + BankCardType + ", 0);", conn);
                    }
                }
            }
        }

        public void StartSim()
        {
            Thread th = new Thread(StartSimDo);
            th.IsBackground = true;
            th.Start();
        }

        public void StartSimDo()
        {
            while (true)
            {
                try
                {
                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
                    WebCMSEntities spdb = new WebCMSEntities();
                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
                    DateTime start = DateTime.Now.AddDays(-40);
                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/TradeRecordId.txt")));
                    IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id >= StartId && m.ProductType == "14" && SaveDataBindIds.Contains(m.ProductType) && m.CreateDate >= start && m.Status == 1).OrderBy(m => m.CreateDate).Take(20);
                    foreach (TradeRecord trade in trades.ToList())
                    {
                        PosPushDataNewHelper.Trade(trade);
                        
                        TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
                        if (edit != null)
                        {
                            edit.Status = 2;
                        }
                        spdb.SaveChanges();
                    }
                    spdb.Dispose();
                    db.Dispose();
                }
                catch (Exception ex)
                {
                    Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "同步SP交易数据到MAIN异常");
                }
                Thread.Sleep(500);
            }
        }










        public void StartTradeStatus()
        {
            Thread th = new Thread(StartTradeStatusDo);
            th.IsBackground = true;
            th.Start();
        }

        public void StartTradeStatusDo()
        {
            while (true)
            {
                try
                {
                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
                    WebCMSEntities spdb = new WebCMSEntities();
                    DateTime start = DateTime.Now.AddDays(-10);
                    DateTime end = DateTime.Now.AddMinutes(-10);
                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/TradeRecordId.txt")));
                    IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id >= StartId && m.CreateDate >= start && m.CreateDate < end && SaveDataBindIds.Contains(m.ProductType) && m.Status == 0).OrderBy(m => m.CreateDate).Take(20);
                    foreach (TradeRecord trade in trades.ToList())
                    {
                        int Status = 1;
                        bool op = db.PosMachinesTwo.Any(m => m.PosSn == trade.TradeSnNo);
                        if(!op)
                        {
                            Status = -1;
                        }
                        else
                        {
                            op = db.PosMerchantInfo.Any(m => m.KqSnNo == trade.TradeSnNo);
                            if(!op)
                            {
                                Status = -2;
                            }
                        }
                        TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
                        if (edit != null)
                        {
                            edit.Status = Status;
                            spdb.SaveChanges();
                        }
                    }
                    db.Dispose();
                    spdb.Dispose();
                }
                catch (Exception ex)
                {
                    Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "恢复原始交易没有统计上的数据异常");
                }
                Thread.Sleep(10000);
            }
        }





        //机具激活逻辑
        public void ActPos(PxcModels.WebCMSEntities db, PxcModels.PosMachinesTwo pos, decimal CheckMoney, int CheckDays, bool PrizeFlag = true, string ActivationTime = "")
        {
            DateTime now = DateTime.Now;
            if(!string.IsNullOrEmpty(ActivationTime))
            {
                now = DateTime.Parse(ActivationTime);
            }
            DateTime TransferTime = pos.TransferTime == null ? DateTime.Parse("2050-01-01") : pos.TransferTime.Value;
            int minute = 30;
            if(pos.BrandId == 14 && pos.PosSn.StartsWith("CS"))
            {
                minute = 60 * 24 * 30;
            }
            Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:贷记卡是否刷满" + CheckMoney + ";贷记卡交易:" + pos.CreditTrade + "");
            Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:是否有机具所属人;机具所属人Id:" + pos.BuyUserId + "");
            Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:是否未激活;机具激活状态:" + pos.ActivationState + "");
            Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:划拨时间不能超过绑定时间" + minute + "分钟;划拨时间:" + TransferTime.ToString() + ",绑定时间:" + pos.BindingTime.Value.ToString());
            if (pos.CreditTrade >= CheckMoney && pos.BuyUserId > 0 && pos.ActivationState == 0 && TransferTime.AddMinutes(-minute) < pos.BindingTime)
            {
                Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件");
                pos.ActivationState = 1;
                pos.ActivationTime = now;
                Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:是否营训");
                if(pos.CardType == 101)
                {
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "是营训");
                    pos.IsPurchase = 1;
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "取消循环资格");
                }
                Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:是否关联商户信息");
                PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
                if (merchant != null)
                {
                    merchant.ActiveStatus = 1;
                    merchant.MerStandardDate = now;
                    db.SaveChanges();

                    if(pos.BrandId != 14)
                    {
                        //发放奖励MQ
                        PrizeSetHelper.Do("1", pos.PosSn);
                    }

                    Utils.Instance.PrizeRecord(1, pos.PosSn, "已关联");
                    //发放开机奖励
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:绑定时间不超过" + CheckDays + "天;当前绑定时间:" + pos.BindingTime.ToString() + "");
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:非营训;当前类型:" + pos.CardType);
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:奖励开关;当前:" + PrizeFlag);
                    if(pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
                    {
                        Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件，发放开机奖励");
                        RedisDbconn.Instance.AddList("OpenRewardQueue", pos.Id.ToString());
                        if(pos.BrandId == 14)
                        {
                            Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件，发放运营中心奖励");
                            RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
                            Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:大盟主标记;当前大盟主Id:" + pos.LeaderUserId);
                            PxcModels.Leaders leader = db.Leaders.FirstOrDefault(m => m.Id == pos.LeaderUserId) ?? new PxcModels.Leaders();
                            DateTime ExpiredDate = leader.ExpiredDate == null ? DateTime.Parse("1900-01-01") : leader.ExpiredDate.Value;
                            Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:盟主是否过期;过期时间:" + pos.LeaderUserId);
                            if(pos.LeaderUserId > 0 && ExpiredDate > now)
                            {
                                Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件，发放大盟主奖励");
                                RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
                            }
                        }
                    }
                }
                //发放大盟主奖励
                decimal Deposit = decimal.Parse(function.CheckNum(pos.SeoKeyword));
                if(pos.BrandId != 14)
                {
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:有押金;当前押金:" + Deposit);
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:大盟主标记;当前大盟主Id:" + pos.LeaderUserId);
                    PxcModels.Leaders leader = db.Leaders.FirstOrDefault(m => m.Id == pos.LeaderUserId) ?? new PxcModels.Leaders();
                    DateTime ExpiredDate = leader.ExpiredDate == null ? DateTime.Parse("1900-01-01") : leader.ExpiredDate.Value;
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:盟主是否过期;过期时间:" + pos.LeaderUserId);
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:绑定时间不超过" + CheckDays + "天;绑定时间:" + pos.BindingTime.Value.ToString() + "");
                }
                if (Deposit > 0 && pos.LeaderUserId > 0 && db.Leaders.Any(m => m.Id == pos.LeaderUserId && m.ExpiredDate > now) && pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
                {
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件，发放大盟主奖励");
                    RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
                }
                //发放运营中心奖励
                if (Deposit > 0 && pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
                {
                    Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件，发放运营中心奖励");
                    RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
                }
                if(pos.CardType < 100)
                {
                    //统计激活数
                    RedisDbconn.Instance.AddList("StatActQueue", "{\"TradeDate\":\"" + now.ToString("yyyyMMdd") + "\",\"UserId\":\"" + pos.BuyUserId + "\",\"BrandId\":\"" + pos.BrandId + "\"}");
                    //运营中心额度变更
                    OpAmountItem item = new OpAmountItem()
                    {
                        UserId = pos.OpId,
                        OperateType = 1,
                        ChangeType = 9,
                        Remark = "机具激活",
                        UseAmount = pos.OpReserve1 + pos.OpReserve2 + pos.OpReserve3,
                        UseValidForGetAmount = pos.OpReserve2,
                        UseTotalAmt = pos.OpReserve1,
                        UseValidAmount = pos.OpReserve3,
                        DataType = 2,
                        DataId = pos.Id,
                    };
                    RedisDbconn.Instance.AddList("OperateAmountRecordServiceQueue", item);
                }
                //清理预扣款
                RedisDbconn.Instance.AddList("PosWithholdQueue", "{\"UserId\":\"" + pos.BuyUserId + "\",\"SnNo\":\"" + pos.PosSn + "\"}");

                //推送激活数据
                if(Deposit == 0) Utils.Instance.SendActData(pos);
            }
            else if (pos.ActivationState == 1 && pos.BrandId == 14)
            {
                if(pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
                {
                    RedisDbconn.Instance.AddList("OpenRewardQueue", pos.Id.ToString());
                    if(pos.BrandId == 14)
                    {
                        RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
                        PxcModels.Leaders leader = db.Leaders.FirstOrDefault(m => m.Id == pos.LeaderUserId) ?? new PxcModels.Leaders();
                        DateTime ExpiredDate = leader.ExpiredDate == null ? DateTime.Parse("1900-01-01") : leader.ExpiredDate.Value;
                        if(pos.LeaderUserId > 0 && ExpiredDate > now)
                        {
                            RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
                        }
                    }
                }
            }
            Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:已激活;当前状态:" + pos.ActivationState);
            Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:绑定后台30天到60天之间;绑定时间:" + pos.BindingTime.Value.ToString() + "");
            Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:贷记卡是否刷满10000;贷记卡交易:" + pos.CreditTrade + "");
            Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:非营训;当前类型:" + pos.CardType);
            if(pos.ActivationState == 1 && pos.BindingTime.Value.AddDays(30) <= DateTime.Now && pos.BindingTime.Value.AddDays(60) > DateTime.Now && pos.CreditTrade >= 10000 && pos.CardType < 100)
            {
                Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件，发放盟主开机奖励");
                RedisDbconn.Instance.AddList("LeaderRewardQueue", pos.Id.ToString());

                //发放奖励MQ
                PrizeSetHelper.Do("1", pos.PosSn);
            }
        }

        //立刷格外奖励
        public void LiShuaActPrize(PxcModels.WebCMSEntities db, PxcModels.PosMachinesTwo pos, int prize)
        {
            PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
            if(merchant != null)
            {
                PxcModels.Users getUser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new PxcModels.Users();
                int BuyTopUserId = 0;
                string ParentNav = getUser.ParentNav;
                if (!string.IsNullOrEmpty(ParentNav))
                {
                    string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
                    if (ParentNavList.Length > 1)
                    {
                        BuyTopUserId = int.Parse(ParentNavList[1]);
                    }
                    else if (ParentNavList.Length == 1)
                    {
                        BuyTopUserId = int.Parse(ParentNavList[0]);
                    }
                }
                if(prize == 50)
                {
                    StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize);
                }
                if(prize == 40)
                {
                    StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize, 12);
                }
                if(prize == 30)
                {
                    StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize, 133);
                }
            }
        }

        private int GetLeShuaHaiKe(int UserId, int BrandId)
        {
            if(DateTime.Now >= DateTime.Parse("2023-08-01 00:00:00"))
            {
                return 0;
            }
            int ActStatus = 1;
            try
            {
                string Date = DateTime.Now.ToString("yyyyMMdd");
                int checkNum = 0;
                if(Date == "20230720") checkNum = 12;
                if(Date == "20230721") checkNum = 11;
                if(Date == "20230722") checkNum = 10;
                if(Date == "20230723") checkNum = 9;
                if(Date == "20230724") checkNum = 8;
                if(Date == "20230725") checkNum = 7;
                if(Date == "20230726") checkNum = 6;
                if(Date == "20230727") checkNum = 5;
                if(Date == "20230728") checkNum = 4;
                if(Date == "20230729") checkNum = 3;
                if(Date == "20230730") checkNum = 2;
                if(Date == "20230731") checkNum = 1;
                int check = int.Parse(function.CheckInt(RedisDbconn.Instance.Get<string>("lscut:" + UserId + ":" + BrandId + ":" + Date)));
                if(check <= checkNum)
                {
                    check += 1;
                    RedisDbconn.Instance.Set("lscut:" + UserId + ":" + BrandId + ":" + Date, check.ToString());
                }
                else
                {
                    ActStatus = -1;
                    RedisDbconn.Instance.Set("lscut:" + UserId + ":" + BrandId + ":" + Date, "0");
                }
            }
            catch(Exception ex)
            {
                Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "乐刷海科计数异常");
            }
            return ActStatus;
        }
    }
}