Ver código fonte

判断推送时间,2:15-2:25,14:15-14:25

lcl 5 meses atrás
pai
commit
3359f0ea01

+ 66 - 63
AppStart/Helper/SycnSpServer/SycnSpActiveService.cs

@@ -27,77 +27,80 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    SaveDataBindIds.Add("36");
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    MpMainModels2.WebCMSEntities mpdb = new MpMainModels2.WebCMSEntities();
-                    JavaProductModels.WebCMSEntities javaprodb = new JavaProductModels.WebCMSEntities();
-                    string Month = DateTime.Now.ToString("yyyyMM");
-                    string Date = DateTime.Now.ToString("yyyyMMdd");
-                    DateTime start = DateTime.Now.AddDays(-30);
-                    DateTime end = DateTime.Now.AddMinutes(-1);
-                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/ActivateRecordId.txt")));
-                    IQueryable<ActivateRecord> acts = spdb.ActivateRecord.Where(m => m.Id >= StartId && m.CreateDate >= start && m.CreateDate < end && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).Take(20);
-                    foreach (ActivateRecord act in acts.ToList())
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        PosPushDataNewHelper.Deposit(act);
-                        decimal PrizeAmt = decimal.Parse(function.CheckNum(act.Field3));
-                        if(Utils.Instance.IsHaoDa(int.Parse(function.CheckInt(act.ProductType))) && PrizeAmt > 0)
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        SaveDataBindIds.Add("36");
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        MpMainModels2.WebCMSEntities mpdb = new MpMainModels2.WebCMSEntities();
+                        JavaProductModels.WebCMSEntities javaprodb = new JavaProductModels.WebCMSEntities();
+                        string Month = DateTime.Now.ToString("yyyyMM");
+                        string Date = DateTime.Now.ToString("yyyyMMdd");
+                        DateTime start = DateTime.Now.AddDays(-30);
+                        DateTime end = DateTime.Now.AddMinutes(-1);
+                        int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/ActivateRecordId.txt")));
+                        IQueryable<ActivateRecord> acts = spdb.ActivateRecord.Where(m => m.Id >= StartId && m.CreateDate >= start && m.CreateDate < end && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).Take(20);
+                        foreach (ActivateRecord act in acts.ToList())
                         {
                         {
-                            string PrizeKind = act.SeoKeyword;
-                            if ((
-                                PrizeKind == "830_01" ||
-                                PrizeKind == "830_21" ||
-                                PrizeKind == "830_22" ||
-                                PrizeKind == "833_01" ||
-                                PrizeKind == "833_02" ||
-                                PrizeKind == "836_01" ||
-                                PrizeKind == "836_02" ||
-                                PrizeKind == "972" ||
-                                PrizeKind == "972_01" ||
-                                PrizeKind == "985" ||
-                                PrizeKind == "987" ||
-                                PrizeKind == "990" ||
-                                PrizeKind == "993" ||
-                                PrizeKind == "995_21" ||
-                                PrizeKind == "995_22" ||
-                                PrizeKind == "995"
-                                ) && PrizeAmt > 0)
+                            PosPushDataNewHelper.Deposit(act);
+                            decimal PrizeAmt = decimal.Parse(function.CheckNum(act.Field3));
+                            if (Utils.Instance.IsHaoDa(int.Parse(function.CheckInt(act.ProductType))) && PrizeAmt > 0)
                             {
                             {
-                                JavaProductModels.KxsMachine pos = javaprodb.KxsMachine.FirstOrDefault(m => m.PosSn == act.SnNo && m.UserId > 0);
-                                if(pos != null)
+                                string PrizeKind = act.SeoKeyword;
+                                if ((
+                                    PrizeKind == "830_01" ||
+                                    PrizeKind == "830_21" ||
+                                    PrizeKind == "830_22" ||
+                                    PrizeKind == "833_01" ||
+                                    PrizeKind == "833_02" ||
+                                    PrizeKind == "836_01" ||
+                                    PrizeKind == "836_02" ||
+                                    PrizeKind == "972" ||
+                                    PrizeKind == "972_01" ||
+                                    PrizeKind == "985" ||
+                                    PrizeKind == "987" ||
+                                    PrizeKind == "990" ||
+                                    PrizeKind == "993" ||
+                                    PrizeKind == "995_21" ||
+                                    PrizeKind == "995_22" ||
+                                    PrizeKind == "995"
+                                    ) && PrizeAmt > 0)
                                 {
                                 {
-                                    Dictionary<string, object> prizeData = new Dictionary<string, object>();
-                                    prizeData.Add("brand_id", int.Parse(function.CheckInt(act.ProductType)));
-                                    prizeData.Add("ext_field", PrizeKind);
-                                    prizeData.Add("pos_sn", act.SnNo);
-                                    prizeData.Add("user_id", pos.UserId);
-                                    prizeData.Add("prize", PrizeAmt);
-                                    string req = Newtonsoft.Json.JsonConvert.SerializeObject(prizeData);
-                                    string ids = PrizeKind == "833_02" ? "82" : "81";
-                                    function.GetWebRequest("http://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_HAODA_PRIZE_CONFIG_DIVISION&m=" + req + "&ids=" + ids + ",83");
+                                    JavaProductModels.KxsMachine pos = javaprodb.KxsMachine.FirstOrDefault(m => m.PosSn == act.SnNo && m.UserId > 0);
+                                    if (pos != null)
+                                    {
+                                        Dictionary<string, object> prizeData = new Dictionary<string, object>();
+                                        prizeData.Add("brand_id", int.Parse(function.CheckInt(act.ProductType)));
+                                        prizeData.Add("ext_field", PrizeKind);
+                                        prizeData.Add("pos_sn", act.SnNo);
+                                        prizeData.Add("user_id", pos.UserId);
+                                        prizeData.Add("prize", PrizeAmt);
+                                        string req = Newtonsoft.Json.JsonConvert.SerializeObject(prizeData);
+                                        string ids = PrizeKind == "833_02" ? "82" : "81";
+                                        function.GetWebRequest("http://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_HAODA_PRIZE_CONFIG_DIVISION&m=" + req + "&ids=" + ids + ",83");
+                                    }
                                 }
                                 }
+                                // JavaProductModels.KxsMachine pos = javaprodb.KxsMachine.FirstOrDefault(m => m.PosSn == act.SnNo && m.UserId > 0);
+                                // if(pos != null)
+                                // {
+                                //     RedisDbconn.Instance.AddList("HaoDaPrizeDataQueue", "{\"brand_id\":36,\"ext_field\":\"" + act.Field3 + "\",\"pos_sn\":\"" + act.SnNo + "\",\"user_id\":" + pos.UserId + "}");
+                                // }
+                            }
+
+                            ActivateRecord edit = spdb.ActivateRecord.FirstOrDefault(m => m.Id == act.Id);
+                            if (edit != null)
+                            {
+                                edit.Status = 2;
                             }
                             }
-                            // JavaProductModels.KxsMachine pos = javaprodb.KxsMachine.FirstOrDefault(m => m.PosSn == act.SnNo && m.UserId > 0);
-                            // if(pos != null)
-                            // {
-                            //     RedisDbconn.Instance.AddList("HaoDaPrizeDataQueue", "{\"brand_id\":36,\"ext_field\":\"" + act.Field3 + "\",\"pos_sn\":\"" + act.SnNo + "\",\"user_id\":" + pos.UserId + "}");
-                            // }
-                        }
-                        
-                        ActivateRecord edit = spdb.ActivateRecord.FirstOrDefault(m => m.Id == act.Id);
-                        if (edit != null)
-                        {
-                            edit.Status = 2;
                         }
                         }
+                        spdb.SaveChanges();
+                        spdb.Dispose();
+                        db.SaveChanges();
+                        db.Dispose();
+                        mpdb.Dispose();
+                        javaprodb.Dispose();
                     }
                     }
-                    spdb.SaveChanges();
-                    spdb.Dispose();
-                    db.SaveChanges();
-                    db.Dispose();
-                    mpdb.Dispose();
-                    javaprodb.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {

+ 113 - 107
AppStart/Helper/SycnSpServer/SycnSpBindService.cs

@@ -27,74 +27,77 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> BrandIds = new List<string>();
-                    BrandIds.Add("14");
-                    BrandIds.Add("17");
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime start = DateTime.Now.AddDays(-60);
-                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/BindRecordId.txt")));
-                    var Binds = spdb.BindRecord.Where(m => m.Id >= StartId && m.CreateTime >= start && !BrandIds.Contains(m.ProductType) && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).Take(20).ToList();
-                    foreach (var Bind in Binds)
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        var tran = db.Database.BeginTransaction();
-                        try
+                        List<string> BrandIds = new List<string>();
+                        BrandIds.Add("14");
+                        BrandIds.Add("17");
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime start = DateTime.Now.AddDays(-60);
+                        int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/BindRecordId.txt")));
+                        var Binds = spdb.BindRecord.Where(m => m.Id >= StartId && m.CreateTime >= start && !BrandIds.Contains(m.ProductType) && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).Take(20).ToList();
+                        foreach (var Bind in Binds)
                         {
                         {
-                            if((Bind.Field1 == "解绑" || Bind.Field1 == "UNBIND" || Bind.Field1 == "TRUE" || Bind.Field1 == "FORCED_UNBIND") && (Bind.ProductType == "1" || Bind.ProductType == "23" || Bind.ProductType == "27" || Bind.ProductType == "30" || Bind.ProductType == "34"))
+                            var tran = db.Database.BeginTransaction();
+                            try
                             {
                             {
-                                PosPushDataNewHelper.UnBind(new UnBindRecord()
+                                if ((Bind.Field1 == "解绑" || Bind.Field1 == "UNBIND" || Bind.Field1 == "TRUE" || Bind.Field1 == "FORCED_UNBIND") && (Bind.ProductType == "1" || Bind.ProductType == "23" || Bind.ProductType == "27" || Bind.ProductType == "30" || Bind.ProductType == "34"))
                                 {
                                 {
-                                    MerSnNo = Bind.MerSnNo,
-                                    MerNo = Bind.MerNo,
-                                    ProductType = Bind.ProductType,
-                                });
+                                    PosPushDataNewHelper.UnBind(new UnBindRecord()
+                                    {
+                                        MerSnNo = Bind.MerSnNo,
+                                        MerNo = Bind.MerNo,
+                                        ProductType = Bind.ProductType,
+                                    });
 
 
-                                //wifi解绑逻辑
-                                if(Utils.Instance.IsWifi(int.Parse(Bind.ProductType)))
+                                    //wifi解绑逻辑
+                                    if (Utils.Instance.IsWifi(int.Parse(Bind.ProductType)))
+                                    {
+                                        string fileName = function.MD5_16(Guid.NewGuid().ToString());
+                                        string content = "{\"posSn\":\"" + Bind.MerSnNo + "\"}";
+                                        RedisDbconn.Instance.AddList("kxs_unbindwifi_list", fileName + "#cut#" + content + "#cut#" + fileName);
+                                    }
+                                }
+                                else if (Bind.Field1 == "CHANGE_BIND" && Bind.ProductType == "34")
                                 {
                                 {
-                                    string fileName = function.MD5_16(Guid.NewGuid().ToString());
-                                    string content = "{\"posSn\":\"" + Bind.MerSnNo + "\"}";
-                                    RedisDbconn.Instance.AddList("kxs_unbindwifi_list", fileName + "#cut#" + content + "#cut#" + fileName);
+                                    PosPushDataNewHelper.ChangeBind(new ChangeBindRecord()
+                                    {
+                                        MerNo = Bind.MerNo,
+                                        MerSnNo = Bind.Field2,
+                                        ProductType = Bind.ProductType,
+                                        MerNewSnNo = Bind.MerSnNo,
+                                    });
                                 }
                                 }
-                            }
-                            else if(Bind.Field1 == "CHANGE_BIND" && Bind.ProductType == "34")
-                            {
-                                PosPushDataNewHelper.ChangeBind(new ChangeBindRecord()
+                                else
                                 {
                                 {
-                                    MerNo = Bind.MerNo,
-                                    MerSnNo = Bind.Field2,
-                                    ProductType = Bind.ProductType,
-                                    MerNewSnNo = Bind.MerSnNo,
-                                });
-                            }
-                            else
-                            {
-                                if(Utils.Instance.IsWifi(int.Parse(Bind.ProductType)))
+                                    if (Utils.Instance.IsWifi(int.Parse(Bind.ProductType)))
+                                    {
+                                        Bind.MerNo = Bind.MerSnNo;
+                                        PosPushDataNewHelper.Bind0(Bind);
+                                    }
+                                }
+                                BindRecord edit = spdb.BindRecord.FirstOrDefault(m => m.Id == Bind.Id);
+                                if (edit != null)
                                 {
                                 {
-                                    Bind.MerNo = Bind.MerSnNo;
-                                    PosPushDataNewHelper.Bind0(Bind);
+                                    edit.Status = 2;
+                                    spdb.SaveChanges();
                                 }
                                 }
+                                tran.Commit();
                             }
                             }
-                            BindRecord edit = spdb.BindRecord.FirstOrDefault(m => m.Id == Bind.Id);
-                            if (edit != null)
+                            catch (Exception ex)
                             {
                             {
-                                edit.Status = 2;
-                                spdb.SaveChanges();
+                                tran.Rollback();
+                                Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Bind.Id, "同步SP绑定数据到MAIN异常");
                             }
                             }
-                            tran.Commit();
+                            tran.Dispose();
                         }
                         }
-                        catch (Exception ex)
-                        {
-                            tran.Rollback();
-                            Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Bind.Id, "同步SP绑定数据到MAIN异常");
-                        }
-                        tran.Dispose();
+                        spdb.SaveChanges();
+                        spdb.Dispose();
+                        db.SaveChanges();
+                        db.Dispose();
                     }
                     }
-                    spdb.SaveChanges();
-                    spdb.Dispose();
-                    db.SaveChanges();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
@@ -118,69 +121,72 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime start = DateTime.Now.AddDays(-365);
-                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/BindRecordId.txt")));
-                    var Binds = spdb.BindRecord.Where(m => m.Id >= StartId && m.CreateTime >= start && m.ProductType == "14" && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).Take(20).ToList();
-                    foreach (var Bind in Binds)
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        try
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime start = DateTime.Now.AddDays(-365);
+                        int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/BindRecordId.txt")));
+                        var Binds = spdb.BindRecord.Where(m => m.Id >= StartId && m.CreateTime >= start && m.ProductType == "14" && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).Take(20).ToList();
+                        foreach (var Bind in Binds)
                         {
                         {
-                            string KindName = Bind.Remark; //商品类型名称
-                            string Name = Bind.Field3; //商品名称
-                            decimal ActualAmount = decimal.Parse(function.CheckNum(Bind.SeoTitle)); //实付金额
-                            if(ActualAmount >= 10000) ActualAmount = ActualAmount / 100;
-                            // PosPushDataNewHelper.Trade(new TradeRecord()
-                            // {
-                            //     TradeSnNo = Bind.MerSnNo,
-                            //     MerNo = Bind.MerNo,
-                            //     TradeAmount = 0,
-                            //     TradeSerialNo = function.MD5_16("sim:" + Bind.Id.ToString()),
-                            //     CreateDate = Bind.CreateTime,
-                            //     ProductType = Bind.ProductType,
-                            //     Field1 = Bind.Field3,
-                            //     Field2 = Bind.Field5,
-                            //     ErrorMsg = ActualAmount.ToString(),
-                            // });
-                            // bool op = false;
-                            // if(!Bind.MerSnNo.StartsWith("CS") && Bind.Field5 == "已激活" && Bind.Field3.Contains("双百套餐") && ActualAmount >= 100)
-                            // {
-                            //     op = true;
-                            // }
-                            // if(Bind.MerSnNo.StartsWith("CS") && Bind.Field5 == "已激活" && ActualAmount >= 100)
-                            // {
-                            //     op = true;
-                            // }
-                            if(Bind.Field5 == "已激活")
+                            try
                             {
                             {
-                                PosPushDataNewHelper.Deposit(new ActivateRecord()
+                                string KindName = Bind.Remark; //商品类型名称
+                                string Name = Bind.Field3; //商品名称
+                                decimal ActualAmount = decimal.Parse(function.CheckNum(Bind.SeoTitle)); //实付金额
+                                if (ActualAmount >= 10000) ActualAmount = ActualAmount / 100;
+                                // PosPushDataNewHelper.Trade(new TradeRecord()
+                                // {
+                                //     TradeSnNo = Bind.MerSnNo,
+                                //     MerNo = Bind.MerNo,
+                                //     TradeAmount = 0,
+                                //     TradeSerialNo = function.MD5_16("sim:" + Bind.Id.ToString()),
+                                //     CreateDate = Bind.CreateTime,
+                                //     ProductType = Bind.ProductType,
+                                //     Field1 = Bind.Field3,
+                                //     Field2 = Bind.Field5,
+                                //     ErrorMsg = ActualAmount.ToString(),
+                                // });
+                                // bool op = false;
+                                // if(!Bind.MerSnNo.StartsWith("CS") && Bind.Field5 == "已激活" && Bind.Field3.Contains("双百套餐") && ActualAmount >= 100)
+                                // {
+                                //     op = true;
+                                // }
+                                // if(Bind.MerSnNo.StartsWith("CS") && Bind.Field5 == "已激活" && ActualAmount >= 100)
+                                // {
+                                //     op = true;
+                                // }
+                                if (Bind.Field5 == "已激活")
+                                {
+                                    PosPushDataNewHelper.Deposit(new ActivateRecord()
+                                    {
+                                        SeoKeyword = Bind.Field3,
+                                        SeoTitle = ActualAmount.ToString(),
+                                        ProductType = Bind.ProductType,
+                                        SnNo = Bind.MerSnNo,
+                                        MerNo = Bind.MerNo,
+                                        Id = Bind.Id,
+                                    });
+                                }
+                                BindRecord edit = spdb.BindRecord.FirstOrDefault(m => m.Id == Bind.Id);
+                                if (edit != null)
                                 {
                                 {
-                                    SeoKeyword = Bind.Field3,
-                                    SeoTitle = ActualAmount.ToString(),
-                                    ProductType = Bind.ProductType,
-                                    SnNo = Bind.MerSnNo,
-                                    MerNo = Bind.MerNo,
-                                    Id = Bind.Id,
-                                });
+                                    edit.Status = 2;
+                                    spdb.SaveChanges();
+                                }
                             }
                             }
-                            BindRecord edit = spdb.BindRecord.FirstOrDefault(m => m.Id == Bind.Id);
-                            if (edit != null)
+                            catch (Exception ex)
                             {
                             {
-                                edit.Status = 2;
-                                spdb.SaveChanges();
+                                Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Bind.Id, "同步SP广电卡绑定数据到MAIN异常");
                             }
                             }
                         }
                         }
-                        catch (Exception ex)
-                        {
-                            Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Bind.Id, "同步SP广电卡绑定数据到MAIN异常");
-                        }
+                        spdb.SaveChanges();
+                        spdb.Dispose();
+                        db.SaveChanges();
+                        db.Dispose();
                     }
                     }
-                    spdb.SaveChanges();
-                    spdb.Dispose();
-                    db.SaveChanges();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {

+ 96 - 93
AppStart/Helper/SycnSpServer/SycnSpBindZkbService.cs

@@ -27,112 +27,115 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> BrandIds = new List<string>();
-                    BrandIds.Add("17");
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime start = DateTime.Now.AddDays(-30);
-                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/BindRecordId.txt")));
-                    var Binds = spdb.BindRecord.Where(m => m.Id >= StartId && m.CreateTime >= start && BrandIds.Contains(m.ProductType) && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).Take(20).ToList();
-                    foreach (var Bind in Binds)
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        var tran = db.Database.BeginTransaction();
-                        try
+                        List<string> BrandIds = new List<string>();
+                        BrandIds.Add("17");
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime start = DateTime.Now.AddDays(-30);
+                        int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/BindRecordId.txt")));
+                        var Binds = spdb.BindRecord.Where(m => m.Id >= StartId && m.CreateTime >= start && BrandIds.Contains(m.ProductType) && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).Take(20).ToList();
+                        foreach (var Bind in Binds)
                         {
                         {
-                            PxcModels.UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == Bind.Field3) ?? new PxcModels.UserForMakerCode();
-                            PxcModels.Users user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new PxcModels.Users();
-
-                            PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == Bind.MerSnNo);
-                            if (pos == null)
+                            var tran = db.Database.BeginTransaction();
+                            try
                             {
                             {
-                                pos = db.PosMachinesTwo.Add(new PxcModels.PosMachinesTwo()
+                                PxcModels.UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == Bind.Field3) ?? new PxcModels.UserForMakerCode();
+                                PxcModels.Users user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new PxcModels.Users();
+
+                                PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == Bind.MerSnNo);
+                                if (pos == null)
                                 {
                                 {
-                                    CreateDate = DateTime.Now,
-                                    PosSn = Bind.MerSnNo, //SN编号
-                                    BrandId = 17, //产品类型
-                                    BatchNo = Bind.Field1,
-                                    DeviceName = "吱客宝",
-                                    BuyUserId = user.Id,
-                                    UserId = user.Id,
-                                    BindingState = 1,
-                                    BindingTime = Bind.CreateTime,
-                                    ActivationState = 1,
-                                    ActivationTime = Bind.CreateTime,
-                                }).Entity;
-                                db.SaveChanges();
-                            }
+                                    pos = db.PosMachinesTwo.Add(new PxcModels.PosMachinesTwo()
+                                    {
+                                        CreateDate = DateTime.Now,
+                                        PosSn = Bind.MerSnNo, //SN编号
+                                        BrandId = 17, //产品类型
+                                        BatchNo = Bind.Field1,
+                                        DeviceName = "吱客宝",
+                                        BuyUserId = user.Id,
+                                        UserId = user.Id,
+                                        BindingState = 1,
+                                        BindingTime = Bind.CreateTime,
+                                        ActivationState = 1,
+                                        ActivationTime = Bind.CreateTime,
+                                    }).Entity;
+                                    db.SaveChanges();
+                                }
 
 
-                            PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.KqSnNo == Bind.MerSnNo);
-                            if (merchant == null)
-                            {
-                                merchant = db.PosMerchantInfo.Add(new PxcModels.PosMerchantInfo()
+                                PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.KqSnNo == Bind.MerSnNo);
+                                if (merchant == null)
                                 {
                                 {
-                                    CreateDate = DateTime.Now,
-                                    MerStandardDate = DateTime.Now,
-                                    KqSnNo = Bind.MerSnNo, //SN编号
-                                    KqMerNo = Bind.MerNo, //商户号
-                                    MerchantNo = Bind.MerNo,
-                                    MerchantName = Bind.MerName,
-                                    MerRealName = Bind.MerName,
-                                    MerStatus = 1,
-                                    ActiveStatus = 1,
-                                    BrandId = 17, //产品类型
-                                    UserId = user.Id,
-                                    MerIdcardNo = Bind.SeoKeyword,
-                                    MerchantMobile = Bind.MerNewSnNo,
-                                }).Entity;
-                                db.SaveChanges();
-                            }
-                            pos.BindMerchantId = merchant.Id;
+                                    merchant = db.PosMerchantInfo.Add(new PxcModels.PosMerchantInfo()
+                                    {
+                                        CreateDate = DateTime.Now,
+                                        MerStandardDate = DateTime.Now,
+                                        KqSnNo = Bind.MerSnNo, //SN编号
+                                        KqMerNo = Bind.MerNo, //商户号
+                                        MerchantNo = Bind.MerNo,
+                                        MerchantName = Bind.MerName,
+                                        MerRealName = Bind.MerName,
+                                        MerStatus = 1,
+                                        ActiveStatus = 1,
+                                        BrandId = 17, //产品类型
+                                        UserId = user.Id,
+                                        MerIdcardNo = Bind.SeoKeyword,
+                                        MerchantMobile = Bind.MerNewSnNo,
+                                    }).Entity;
+                                    db.SaveChanges();
+                                }
+                                pos.BindMerchantId = merchant.Id;
 
 
-                            PxcModels.MachineForSnNo posFor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == Bind.MerSnNo);
-                            if (posFor == null)
-                            {
-                                posFor = db.MachineForSnNo.Add(new PxcModels.MachineForSnNo()
+                                PxcModels.MachineForSnNo posFor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == Bind.MerSnNo);
+                                if (posFor == null)
                                 {
                                 {
-                                    SnNo = Bind.MerSnNo,
-                                    SnId = pos.Id,
-                                }).Entity;
-                            }
-                            else
-                            {
-                                posFor.SnId = pos.Id;
-                            }
-                            PxcModels.MachineForMerNo merFor = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == Bind.MerNo);
-                            if (merFor == null)
-                            {
-                                merFor = db.MachineForMerNo.Add(new PxcModels.MachineForMerNo()
+                                    posFor = db.MachineForSnNo.Add(new PxcModels.MachineForSnNo()
+                                    {
+                                        SnNo = Bind.MerSnNo,
+                                        SnId = pos.Id,
+                                    }).Entity;
+                                }
+                                else
                                 {
                                 {
-                                    MerNo = Bind.MerNo,
-                                    SnId = pos.Id,
-                                }).Entity;
-                            }
-                            else
-                            {
-                                merFor.SnId = pos.Id;
-                            }
-                            db.SaveChanges();
+                                    posFor.SnId = pos.Id;
+                                }
+                                PxcModels.MachineForMerNo merFor = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == Bind.MerNo);
+                                if (merFor == null)
+                                {
+                                    merFor = db.MachineForMerNo.Add(new PxcModels.MachineForMerNo()
+                                    {
+                                        MerNo = Bind.MerNo,
+                                        SnId = pos.Id,
+                                    }).Entity;
+                                }
+                                else
+                                {
+                                    merFor.SnId = pos.Id;
+                                }
+                                db.SaveChanges();
 
 
-                            BindRecord edit = spdb.BindRecord.FirstOrDefault(m => m.Id == Bind.Id);
-                            if (edit != null)
+                                BindRecord edit = spdb.BindRecord.FirstOrDefault(m => m.Id == Bind.Id);
+                                if (edit != null)
+                                {
+                                    edit.Status = 2;
+                                    spdb.SaveChanges();
+                                }
+                                tran.Commit();
+                            }
+                            catch (Exception ex)
                             {
                             {
-                                edit.Status = 2;
-                                spdb.SaveChanges();
+                                tran.Rollback();
+                                Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Bind.Id, "同步SP吱客宝绑定数据到MAIN异常");
                             }
                             }
-                            tran.Commit();
+                            tran.Dispose();
                         }
                         }
-                        catch (Exception ex)
-                        {
-                            tran.Rollback();
-                            Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Bind.Id, "同步SP吱客宝绑定数据到MAIN异常");
-                        }
-                        tran.Dispose();
+                        spdb.SaveChanges();
+                        spdb.Dispose();
+                        db.SaveChanges();
+                        db.Dispose();
                     }
                     }
-                    spdb.SaveChanges();
-                    spdb.Dispose();
-                    db.SaveChanges();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
@@ -141,6 +144,6 @@ namespace MySystem
                 Thread.Sleep(1000);
                 Thread.Sleep(1000);
             }
             }
         }
         }
-    
+
     }
     }
 }
 }

+ 27 - 24
AppStart/Helper/SycnSpServer/SycnSpChangeBindService.cs

@@ -27,36 +27,39 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime start = DateTime.Now.AddDays(-30);
-                    List<ChangeBindRecord> Binds = spdb.ChangeBindRecord.Where(m => m.ReBindTime >= start && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).ToList();
-                    foreach (ChangeBindRecord Bind in Binds)
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        var tran = db.Database.BeginTransaction();
-                        try
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime start = DateTime.Now.AddDays(-30);
+                        List<ChangeBindRecord> Binds = spdb.ChangeBindRecord.Where(m => m.ReBindTime >= start && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).ToList();
+                        foreach (ChangeBindRecord Bind in Binds)
                         {
                         {
-                            PosPushDataNewHelper.ChangeBind(Bind);
-                            
-                            ChangeBindRecord edit = spdb.ChangeBindRecord.FirstOrDefault(m => m.Id == Bind.Id);
-                            if (edit != null)
+                            var tran = db.Database.BeginTransaction();
+                            try
                             {
                             {
-                                edit.Status = 2;
-                                spdb.SaveChanges();
-                            }
+                                PosPushDataNewHelper.ChangeBind(Bind);
 
 
-                            tran.Commit();
-                        }
-                        catch (Exception ex)
-                        {
-                            tran.Rollback();
-                            Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Bind.Id, "同步SP换绑数据到MAIN异常");
+                                ChangeBindRecord edit = spdb.ChangeBindRecord.FirstOrDefault(m => m.Id == Bind.Id);
+                                if (edit != null)
+                                {
+                                    edit.Status = 2;
+                                    spdb.SaveChanges();
+                                }
+
+                                tran.Commit();
+                            }
+                            catch (Exception ex)
+                            {
+                                tran.Rollback();
+                                Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Bind.Id, "同步SP换绑数据到MAIN异常");
+                            }
+                            tran.Dispose();
                         }
                         }
-                        tran.Dispose();
+                        spdb.Dispose();
+                        db.Dispose();
                     }
                     }
-                    spdb.Dispose();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {

+ 27 - 24
AppStart/Helper/SycnSpServer/SycnSpMerchantRecordService.cs

@@ -27,36 +27,39 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime start = DateTime.Now.AddDays(-30);
-                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/MerchantRecordId.txt")));
-                    var Mers = spdb.MerchantRecord.Where(m => m.Id >= StartId && m.CreateTime >= start && m.Status == 1 && (m.ProductType == "12" || m.ProductType == "30") && SaveDataBindIds.Contains(m.ProductType)).OrderByDescending(m => m.Id).Take(10).ToList();
-                    foreach (var Mer in Mers)
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        var tran = db.Database.BeginTransaction();
-                        try
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime start = DateTime.Now.AddDays(-30);
+                        int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/MerchantRecordId.txt")));
+                        var Mers = spdb.MerchantRecord.Where(m => m.Id >= StartId && m.CreateTime >= start && m.Status == 1 && (m.ProductType == "12" || m.ProductType == "30") && SaveDataBindIds.Contains(m.ProductType)).OrderByDescending(m => m.Id).Take(10).ToList();
+                        foreach (var Mer in Mers)
                         {
                         {
-                            MerchantRecord edit = spdb.MerchantRecord.FirstOrDefault(m => m.Id == Mer.Id);
-                            if (edit != null)
+                            var tran = db.Database.BeginTransaction();
+                            try
                             {
                             {
-                                edit.Status = 2;
-                                spdb.SaveChanges();
+                                MerchantRecord edit = spdb.MerchantRecord.FirstOrDefault(m => m.Id == Mer.Id);
+                                if (edit != null)
+                                {
+                                    edit.Status = 2;
+                                    spdb.SaveChanges();
+                                }
+                                tran.Commit();
                             }
                             }
-                            tran.Commit();
-                        }
-                        catch (Exception ex)
-                        {
-                            tran.Rollback();
-                            Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Mer.Id, "同步SP商户记录数据到MAIN异常");
+                            catch (Exception ex)
+                            {
+                                tran.Rollback();
+                                Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Mer.Id, "同步SP商户记录数据到MAIN异常");
+                            }
+                            tran.Dispose();
                         }
                         }
-                        tran.Dispose();
+                        spdb.SaveChanges();
+                        spdb.Dispose();
+                        db.SaveChanges();
+                        db.Dispose();
                     }
                     }
-                    spdb.SaveChanges();
-                    spdb.Dispose();
-                    db.SaveChanges();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {

+ 100 - 94
AppStart/Helper/SycnSpServer/SycnSpMerchantService.cs

@@ -27,95 +27,98 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime start = DateTime.Now.AddDays(-100);
-                    DateTime end = DateTime.Now.AddMinutes(-2);
-                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/MerchantsId.txt")));
-                    var Mers = spdb.Merchants.Where(m => m.Id >= StartId && m.CreateTime >= start && m.CreateTime <= end && m.Status == 1 && m.ProductType != "14" && SaveDataBindIds.Contains(m.ProductType)).OrderByDescending(m => m.Id).Take(20).ToList();
-                    // var Mers = spdb.Merchants.Where(m => m.Id == 765841).ToList();
-                    foreach (var Mer in Mers)
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        var tran = db.Database.BeginTransaction();
-                        try
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime start = DateTime.Now.AddDays(-100);
+                        DateTime end = DateTime.Now.AddMinutes(-2);
+                        int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/MerchantsId.txt")));
+                        var Mers = spdb.Merchants.Where(m => m.Id >= StartId && m.CreateTime >= start && m.CreateTime <= end && m.Status == 1 && m.ProductType != "14" && SaveDataBindIds.Contains(m.ProductType)).OrderByDescending(m => m.Id).Take(20).ToList();
+                        // var Mers = spdb.Merchants.Where(m => m.Id == 765841).ToList();
+                        foreach (var Mer in Mers)
                         {
                         {
-                            if (Mer.Field2 != "解绑" && Mer.Field2 != "UNBIND" && Mer.Field2 != "CHANGE_BIND" && Mer.Field2 != "TRUE")
+                            var tran = db.Database.BeginTransaction();
+                            try
                             {
                             {
-                                string rnd = "";
-                                if (!Utils.Instance.IsWifi(int.Parse(Mer.ProductType)) && !Utils.Instance.IsHaoDa(int.Parse(Mer.ProductType)) && Mer.ProductType != "14")
+                                if (Mer.Field2 != "解绑" && Mer.Field2 != "UNBIND" && Mer.Field2 != "CHANGE_BIND" && Mer.Field2 != "TRUE")
                                 {
                                 {
-                                    rnd = GetRandom(spdb, Mer.SnNo, Mer.MerNo);
-                                }
-                                if (Utils.Instance.IsWifi(int.Parse(Mer.ProductType)))
-                                {
-                                    Mer.MerNo = Mer.SnNo;
-                                    PosPushDataNewHelper.Bind(Mer);
-                                    if (function.CheckNull(Mer.AgentName).StartsWith("YCJG"))
-                                    {
-                                        PosPushDataNewHelper.Deposit(new ActivateRecord()
-                                        {
-                                            SeoTitle = "0.00",
-                                            ProductType = Mer.ProductType,
-                                            SnNo = Mer.SnNo,
-                                            MerNo = Mer.SnNo,
-                                            Id = Mer.Id,
-                                        });
-                                    }
-                                }
-                                else if (Mer.ProductType == "12" || Mer.ProductType == "30" || Mer.ProductType == "34" || Mer.ProductType == "38")
-                                {
-                                    MerchantRecord merInfo = new MerchantRecord();
-                                    if (Mer.ProductType == "12" || Mer.ProductType == "34" || Mer.ProductType == "38") merInfo = spdb.MerchantRecord.FirstOrDefault(m => m.MerNo == Mer.MerNo);
-                                    if (Mer.ProductType == "30")
+                                    string rnd = "";
+                                    if (!Utils.Instance.IsWifi(int.Parse(Mer.ProductType)) && !Utils.Instance.IsHaoDa(int.Parse(Mer.ProductType)) && Mer.ProductType != "14")
                                     {
                                     {
-                                        merInfo = spdb.MerchantRecord.FirstOrDefault(m => m.Field3 == Mer.MerNo);
-                                        if (merInfo == null) merInfo = spdb.MerchantRecord.FirstOrDefault(m => m.MerNo == Mer.MerNo);
+                                        rnd = GetRandom(spdb, Mer.SnNo, Mer.MerNo);
                                     }
                                     }
-                                    if (merInfo != null)
+                                    if (Utils.Instance.IsWifi(int.Parse(Mer.ProductType)))
                                     {
                                     {
-                                        if(Mer.SeoTitle == "PAPER_CODE" && string.IsNullOrEmpty(Mer.Field5))
+                                        Mer.MerNo = Mer.SnNo;
+                                        PosPushDataNewHelper.Bind(Mer);
+                                        if (function.CheckNull(Mer.AgentName).StartsWith("YCJG"))
                                         {
                                         {
-                                            Mer.Field5 = Mer.MerNo;
+                                            PosPushDataNewHelper.Deposit(new ActivateRecord()
+                                            {
+                                                SeoTitle = "0.00",
+                                                ProductType = Mer.ProductType,
+                                                SnNo = Mer.SnNo,
+                                                MerNo = Mer.SnNo,
+                                                Id = Mer.Id,
+                                            });
                                         }
                                         }
-                                        Mer.MerNo = merInfo.MerNo;
-                                        Mer.MerIdcardNo = merInfo.LegalIdCard;
-                                        Mer.MerName = merInfo.MerName;
+                                    }
+                                    else if (Mer.ProductType == "12" || Mer.ProductType == "30" || Mer.ProductType == "34" || Mer.ProductType == "38")
+                                    {
+                                        MerchantRecord merInfo = new MerchantRecord();
+                                        if (Mer.ProductType == "12" || Mer.ProductType == "34" || Mer.ProductType == "38") merInfo = spdb.MerchantRecord.FirstOrDefault(m => m.MerNo == Mer.MerNo);
                                         if (Mer.ProductType == "30")
                                         if (Mer.ProductType == "30")
                                         {
                                         {
-                                            Mer.MerMobile = merInfo.Field2;
+                                            merInfo = spdb.MerchantRecord.FirstOrDefault(m => m.Field3 == Mer.MerNo);
+                                            if (merInfo == null) merInfo = spdb.MerchantRecord.FirstOrDefault(m => m.MerNo == Mer.MerNo);
                                         }
                                         }
-                                        if (Mer.ProductType == "34" || Mer.ProductType == "38")
+                                        if (merInfo != null)
                                         {
                                         {
-                                            Mer.MerMobile = merInfo.MerNewSnNo;
+                                            if (Mer.SeoTitle == "PAPER_CODE" && string.IsNullOrEmpty(Mer.Field5))
+                                            {
+                                                Mer.Field5 = Mer.MerNo;
+                                            }
+                                            Mer.MerNo = merInfo.MerNo;
+                                            Mer.MerIdcardNo = merInfo.LegalIdCard;
+                                            Mer.MerName = merInfo.MerName;
+                                            if (Mer.ProductType == "30")
+                                            {
+                                                Mer.MerMobile = merInfo.Field2;
+                                            }
+                                            if (Mer.ProductType == "34" || Mer.ProductType == "38")
+                                            {
+                                                Mer.MerMobile = merInfo.MerNewSnNo;
+                                            }
+                                            PosPushDataNewHelper.Bind(Mer, rnd);
                                         }
                                         }
+                                    }
+                                    else if (!Utils.Instance.IsHaoDa(int.Parse(Mer.ProductType)))
+                                    {
                                         PosPushDataNewHelper.Bind(Mer, rnd);
                                         PosPushDataNewHelper.Bind(Mer, rnd);
                                     }
                                     }
                                 }
                                 }
-                                else if (!Utils.Instance.IsHaoDa(int.Parse(Mer.ProductType)))
+                                Merchants edit = spdb.Merchants.FirstOrDefault(m => m.Id == Mer.Id);
+                                if (edit != null)
                                 {
                                 {
-                                    PosPushDataNewHelper.Bind(Mer, rnd);
+                                    edit.Status = 2;
+                                    spdb.SaveChanges();
                                 }
                                 }
+                                tran.Commit();
                             }
                             }
-                            Merchants edit = spdb.Merchants.FirstOrDefault(m => m.Id == Mer.Id);
-                            if (edit != null)
+                            catch (Exception ex)
                             {
                             {
-                                edit.Status = 2;
-                                spdb.SaveChanges();
+                                tran.Rollback();
+                                Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Mer.Id, "同步SP商户数据到MAIN异常");
                             }
                             }
-                            tran.Commit();
-                        }
-                        catch (Exception ex)
-                        {
-                            tran.Rollback();
-                            Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Mer.Id, "同步SP商户数据到MAIN异常");
+                            tran.Dispose();
                         }
                         }
-                        tran.Dispose();
+                        spdb.SaveChanges();
+                        spdb.Dispose();
+                        db.SaveChanges();
+                        db.Dispose();
                     }
                     }
-                    spdb.SaveChanges();
-                    spdb.Dispose();
-                    db.SaveChanges();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
@@ -128,7 +131,7 @@ namespace MySystem
         public string GetRandom(WebCMSEntities spdb, string sn, string merno)
         public string GetRandom(WebCMSEntities spdb, string sn, string merno)
         {
         {
             var list = spdb.BindRecord.Select(m => new { m.MerSnNo, m.MerNo, m.CreateTime }).Where(m => m.MerSnNo == sn && m.MerNo == merno).ToList().Select(m => m.CreateTime).Distinct().ToList();
             var list = spdb.BindRecord.Select(m => new { m.MerSnNo, m.MerNo, m.CreateTime }).Where(m => m.MerSnNo == sn && m.MerNo == merno).ToList().Select(m => m.CreateTime).Distinct().ToList();
-            if(list.Count > 1)
+            if (list.Count > 1)
             {
             {
                 return function.get_Random(5);
                 return function.get_Random(5);
             }
             }
@@ -177,44 +180,47 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime start = DateTime.Now.AddDays(-365);
-                    DateTime end = DateTime.Now.AddMinutes(-2);
-                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/MerchantsId.txt")));
-                    var Mers = spdb.Merchants.Where(m => m.Id >= StartId && m.CreateTime >= start && m.CreateTime <= end && m.Status == 1 && m.ProductType == "14" && SaveDataBindIds.Contains(m.ProductType)).OrderByDescending(m => m.Id).Take(20).ToList();
-                    foreach (var Mer in Mers)
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        var tran = db.Database.BeginTransaction();
-                        try
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime start = DateTime.Now.AddDays(-365);
+                        DateTime end = DateTime.Now.AddMinutes(-2);
+                        int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/MerchantsId.txt")));
+                        var Mers = spdb.Merchants.Where(m => m.Id >= StartId && m.CreateTime >= start && m.CreateTime <= end && m.Status == 1 && m.ProductType == "14" && SaveDataBindIds.Contains(m.ProductType)).OrderByDescending(m => m.Id).Take(20).ToList();
+                        foreach (var Mer in Mers)
                         {
                         {
-                            if (Mer.Field2 != "解绑" && Mer.Field2 != "UNBIND")
+                            var tran = db.Database.BeginTransaction();
+                            try
                             {
                             {
-                                if (!Utils.Instance.IsHaoDa(int.Parse(Mer.ProductType)))
+                                if (Mer.Field2 != "解绑" && Mer.Field2 != "UNBIND")
                                 {
                                 {
-                                    PosPushDataNewHelper.Bind(Mer);
+                                    if (!Utils.Instance.IsHaoDa(int.Parse(Mer.ProductType)))
+                                    {
+                                        PosPushDataNewHelper.Bind(Mer);
+                                    }
                                 }
                                 }
+                                Merchants edit = spdb.Merchants.FirstOrDefault(m => m.Id == Mer.Id);
+                                if (edit != null)
+                                {
+                                    edit.Status = 2;
+                                    spdb.SaveChanges();
+                                }
+                                tran.Commit();
                             }
                             }
-                            Merchants edit = spdb.Merchants.FirstOrDefault(m => m.Id == Mer.Id);
-                            if (edit != null)
+                            catch (Exception ex)
                             {
                             {
-                                edit.Status = 2;
-                                spdb.SaveChanges();
+                                tran.Rollback();
+                                Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Mer.Id, "同步SP广电卡商户数据到MAIN异常");
                             }
                             }
-                            tran.Commit();
-                        }
-                        catch (Exception ex)
-                        {
-                            tran.Rollback();
-                            Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Mer.Id, "同步SP广电卡商户数据到MAIN异常");
+                            tran.Dispose();
                         }
                         }
-                        tran.Dispose();
+                        spdb.SaveChanges();
+                        spdb.Dispose();
+                        db.SaveChanges();
+                        db.Dispose();
                     }
                     }
-                    spdb.SaveChanges();
-                    spdb.Dispose();
-                    db.SaveChanges();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {

+ 90 - 84
AppStart/Helper/SycnSpServer/SycnSpTradeService.cs

@@ -27,35 +27,38 @@ namespace MySystem
             {
             {
                 try
                 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())
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        DoQueueTrade(db, pdb, trade);
-                        TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
-                        if (edit != null)
+                        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())
                         {
                         {
-                            edit.Status = 2;
+                            DoQueueTrade(db, pdb, trade);
+                            TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
+                            if (edit != null)
+                            {
+                                edit.Status = 2;
+                            }
+                            spdb.SaveChanges();
                         }
                         }
-                        spdb.SaveChanges(); 
+                        spdb.Dispose();
+                        db.Dispose();
+                        pdb.Dispose();
                     }
                     }
-                    spdb.Dispose();
-                    db.Dispose();
-                    pdb.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
@@ -68,20 +71,20 @@ namespace MySystem
         public void DoQueueTrade(PxcModels.WebCMSEntities db, JavaProductModels.WebCMSEntities pdb, TradeRecord trade)
         public void DoQueueTrade(PxcModels.WebCMSEntities db, JavaProductModels.WebCMSEntities pdb, TradeRecord trade)
         {
         {
             string TradeSnNo = trade.TradeSnNo;
             string TradeSnNo = trade.TradeSnNo;
-            if(trade.ProductType == "30" && !trade.TradeSnNo.StartsWith("LKLYSMZCFYH"))
+            if (trade.ProductType == "30" && !trade.TradeSnNo.StartsWith("LKLYSMZCFYH"))
             {
             {
                 trade.MerNo = trade.Field2;
                 trade.MerNo = trade.Field2;
             }
             }
 
 
             bool op = true;
             bool op = true;
             //判断盒易付吱码交易
             //判断盒易付吱码交易
-            if(trade.ProductType == "12" && trade.TradeType == "2")
+            if (trade.ProductType == "12" && trade.TradeType == "2")
             {
             {
                 JavaProductModels.KxsMerchant merchant = pdb.KxsMerchant.FirstOrDefault(m => m.MerchantNo == trade.MerNo);
                 JavaProductModels.KxsMerchant merchant = pdb.KxsMerchant.FirstOrDefault(m => m.MerchantNo == trade.MerNo);
-                if(merchant != null)
+                if (merchant != null)
                 {
                 {
                     JavaProductModels.KxsMachine pos = pdb.KxsMachine.FirstOrDefault(m => m.Id == merchant.MachineId);
                     JavaProductModels.KxsMachine pos = pdb.KxsMachine.FirstOrDefault(m => m.Id == merchant.MachineId);
-                    if(pos != null)
+                    if (pos != null)
                     {
                     {
                         trade.TradeSnNo = pos.PosSn;
                         trade.TradeSnNo = pos.PosSn;
                     }
                     }
@@ -146,10 +149,10 @@ namespace MySystem
                 if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
                 if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
                 {
                 {
                     op = false;
                     op = false;
-                    if(trade.ProductType == "30")
+                    if (trade.ProductType == "30")
                     {
                     {
                         PxcModels.LklMerNo mer = db.LklMerNo.FirstOrDefault(m => m.ExtMerNo == trade.MerNo);
                         PxcModels.LklMerNo mer = db.LklMerNo.FirstOrDefault(m => m.ExtMerNo == trade.MerNo);
-                        if(mer != null)
+                        if (mer != null)
                         {
                         {
                             trade.MerNo = mer.MerNo;
                             trade.MerNo = mer.MerNo;
                         }
                         }
@@ -171,11 +174,11 @@ namespace MySystem
             {
             {
                 op = false;
                 op = false;
             }
             }
-            if(trade.ProductType == "7" && trade.TradeStatus != "00")
+            if (trade.ProductType == "7" && trade.TradeStatus != "00")
             {
             {
                 op = false;
                 op = false;
             }
             }
-            if(trade.ProductType == "34" && trade.TradeStatus != "SUCCESS")
+            if (trade.ProductType == "34" && trade.TradeStatus != "SUCCESS")
             {
             {
                 op = false;
                 op = false;
             }
             }
@@ -186,7 +189,7 @@ namespace MySystem
                 {
                 {
                     PosPushDataNewHelper.Trade(trade);
                     PosPushDataNewHelper.Trade(trade);
                     //创业帮交易数据推送
                     //创业帮交易数据推送
-                    if(trade.ProductType == "12")
+                    if (trade.ProductType == "12")
                     {
                     {
                         int BankCardType = 1;
                         int BankCardType = 1;
                         if (trade.BankCardType == "C")
                         if (trade.BankCardType == "C")
@@ -217,25 +220,28 @@ namespace MySystem
             {
             {
                 try
                 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())
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        PosPushDataNewHelper.Trade(trade);
-                        
-                        TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
-                        if (edit != null)
+                        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())
                         {
                         {
-                            edit.Status = 2;
+                            PosPushDataNewHelper.Trade(trade);
+
+                            TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
+                            if (edit != null)
+                            {
+                                edit.Status = 2;
+                            }
+                            spdb.SaveChanges();
                         }
                         }
-                        spdb.SaveChanges();
+                        spdb.Dispose();
+                        db.Dispose();
                     }
                     }
-                    spdb.Dispose();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
@@ -278,14 +284,14 @@ namespace MySystem
                     {
                     {
                         int Status = 1;
                         int Status = 1;
                         bool op = db.PosMachinesTwo.Any(m => m.PosSn == trade.TradeSnNo);
                         bool op = db.PosMachinesTwo.Any(m => m.PosSn == trade.TradeSnNo);
-                        if(!op)
+                        if (!op)
                         {
                         {
                             Status = -1;
                             Status = -1;
                         }
                         }
                         else
                         else
                         {
                         {
                             op = db.PosMerchantInfo.Any(m => m.KqSnNo == trade.TradeSnNo);
                             op = db.PosMerchantInfo.Any(m => m.KqSnNo == trade.TradeSnNo);
-                            if(!op)
+                            if (!op)
                             {
                             {
                                 Status = -2;
                                 Status = -2;
                             }
                             }
@@ -316,13 +322,13 @@ namespace MySystem
         public void ActPos(PxcModels.WebCMSEntities db, PxcModels.PosMachinesTwo pos, decimal CheckMoney, int CheckDays, bool PrizeFlag = true, string ActivationTime = "")
         public void ActPos(PxcModels.WebCMSEntities db, PxcModels.PosMachinesTwo pos, decimal CheckMoney, int CheckDays, bool PrizeFlag = true, string ActivationTime = "")
         {
         {
             DateTime now = DateTime.Now;
             DateTime now = DateTime.Now;
-            if(!string.IsNullOrEmpty(ActivationTime))
+            if (!string.IsNullOrEmpty(ActivationTime))
             {
             {
                 now = DateTime.Parse(ActivationTime);
                 now = DateTime.Parse(ActivationTime);
             }
             }
             DateTime TransferTime = pos.TransferTime == null ? DateTime.Parse("2050-01-01") : pos.TransferTime.Value;
             DateTime TransferTime = pos.TransferTime == null ? DateTime.Parse("2050-01-01") : pos.TransferTime.Value;
             int minute = 30;
             int minute = 30;
-            if(pos.BrandId == 14 && pos.PosSn.StartsWith("CS"))
+            if (pos.BrandId == 14 && pos.PosSn.StartsWith("CS"))
             {
             {
                 minute = 60 * 24 * 30;
                 minute = 60 * 24 * 30;
             }
             }
@@ -336,7 +342,7 @@ namespace MySystem
                 pos.ActivationState = 1;
                 pos.ActivationState = 1;
                 pos.ActivationTime = now;
                 pos.ActivationTime = now;
                 Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:是否营训");
                 Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:是否营训");
-                if(pos.CardType == 101)
+                if (pos.CardType == 101)
                 {
                 {
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "是营训");
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "是营训");
                     pos.IsPurchase = 1;
                     pos.IsPurchase = 1;
@@ -350,7 +356,7 @@ namespace MySystem
                     merchant.MerStandardDate = now;
                     merchant.MerStandardDate = now;
                     db.SaveChanges();
                     db.SaveChanges();
 
 
-                    if(pos.BrandId != 14)
+                    if (pos.BrandId != 14)
                     {
                     {
                         //发放奖励MQ
                         //发放奖励MQ
                         PrizeSetHelper.Do("1", pos.PosSn);
                         PrizeSetHelper.Do("1", pos.PosSn);
@@ -361,11 +367,11 @@ namespace MySystem
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:绑定时间不超过" + CheckDays + "天;当前绑定时间:" + pos.BindingTime.ToString() + "");
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:绑定时间不超过" + CheckDays + "天;当前绑定时间:" + pos.BindingTime.ToString() + "");
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:非营训;当前类型:" + pos.CardType);
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:非营训;当前类型:" + pos.CardType);
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:奖励开关;当前:" + PrizeFlag);
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:奖励开关;当前:" + PrizeFlag);
-                    if(pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
+                    if (pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
                     {
                     {
                         Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放开机奖励");
                         Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放开机奖励");
                         RedisDbconn.Instance.AddList("OpenRewardQueue", pos.Id.ToString());
                         RedisDbconn.Instance.AddList("OpenRewardQueue", pos.Id.ToString());
-                        if(pos.BrandId == 14)
+                        if (pos.BrandId == 14)
                         {
                         {
                             Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放运营中心奖励");
                             Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放运营中心奖励");
                             RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
                             RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
@@ -373,7 +379,7 @@ namespace MySystem
                             PxcModels.Leaders leader = db.Leaders.FirstOrDefault(m => m.Id == pos.LeaderUserId) ?? new PxcModels.Leaders();
                             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;
                             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, "条件:盟主是否过期;过期时间:" + pos.LeaderUserId);
-                            if(pos.LeaderUserId > 0 && ExpiredDate > now)
+                            if (pos.LeaderUserId > 0 && ExpiredDate > now)
                             {
                             {
                                 Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放大盟主奖励");
                                 Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放大盟主奖励");
                                 RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
                                 RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
@@ -383,7 +389,7 @@ namespace MySystem
                 }
                 }
                 //发放大盟主奖励
                 //发放大盟主奖励
                 decimal Deposit = decimal.Parse(function.CheckNum(pos.SeoKeyword));
                 decimal Deposit = decimal.Parse(function.CheckNum(pos.SeoKeyword));
-                if(pos.BrandId != 14)
+                if (pos.BrandId != 14)
                 {
                 {
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:有押金;当前押金:" + Deposit);
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:有押金;当前押金:" + Deposit);
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:大盟主标记;当前大盟主Id:" + pos.LeaderUserId);
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:大盟主标记;当前大盟主Id:" + pos.LeaderUserId);
@@ -403,7 +409,7 @@ namespace MySystem
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放运营中心奖励");
                     Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放运营中心奖励");
                     RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
                     RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
                 }
                 }
-                if(pos.CardType < 100)
+                if (pos.CardType < 100)
                 {
                 {
                     //统计激活数
                     //统计激活数
                     RedisDbconn.Instance.AddList("StatActQueue", "{\"TradeDate\":\"" + now.ToString("yyyyMMdd") + "\",\"UserId\":\"" + pos.BuyUserId + "\",\"BrandId\":\"" + pos.BrandId + "\"}");
                     RedisDbconn.Instance.AddList("StatActQueue", "{\"TradeDate\":\"" + now.ToString("yyyyMMdd") + "\",\"UserId\":\"" + pos.BuyUserId + "\",\"BrandId\":\"" + pos.BrandId + "\"}");
@@ -427,19 +433,19 @@ namespace MySystem
                 RedisDbconn.Instance.AddList("PosWithholdQueue", "{\"UserId\":\"" + pos.BuyUserId + "\",\"SnNo\":\"" + pos.PosSn + "\"}");
                 RedisDbconn.Instance.AddList("PosWithholdQueue", "{\"UserId\":\"" + pos.BuyUserId + "\",\"SnNo\":\"" + pos.PosSn + "\"}");
 
 
                 //推送激活数据
                 //推送激活数据
-                if(Deposit == 0) Utils.Instance.SendActData(pos);
+                if (Deposit == 0) Utils.Instance.SendActData(pos);
             }
             }
             else if (pos.ActivationState == 1 && pos.BrandId == 14)
             else if (pos.ActivationState == 1 && pos.BrandId == 14)
             {
             {
-                if(pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
+                if (pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
                 {
                 {
                     RedisDbconn.Instance.AddList("OpenRewardQueue", pos.Id.ToString());
                     RedisDbconn.Instance.AddList("OpenRewardQueue", pos.Id.ToString());
-                    if(pos.BrandId == 14)
+                    if (pos.BrandId == 14)
                     {
                     {
                         RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
                         RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
                         PxcModels.Leaders leader = db.Leaders.FirstOrDefault(m => m.Id == pos.LeaderUserId) ?? new PxcModels.Leaders();
                         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;
                         DateTime ExpiredDate = leader.ExpiredDate == null ? DateTime.Parse("1900-01-01") : leader.ExpiredDate.Value;
-                        if(pos.LeaderUserId > 0 && ExpiredDate > now)
+                        if (pos.LeaderUserId > 0 && ExpiredDate > now)
                         {
                         {
                             RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
                             RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
                         }
                         }
@@ -450,7 +456,7 @@ namespace MySystem
             Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:绑定后台30天到60天之间;绑定时间:" + pos.BindingTime.Value.ToString() + "");
             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, "条件:贷记卡是否刷满10000;贷记卡交易:" + pos.CreditTrade + "");
             Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:非营训;当前类型:" + pos.CardType);
             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)
+            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, "满足条件,发放盟主开机奖励");
                 Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放盟主开机奖励");
                 RedisDbconn.Instance.AddList("LeaderRewardQueue", pos.Id.ToString());
                 RedisDbconn.Instance.AddList("LeaderRewardQueue", pos.Id.ToString());
@@ -464,7 +470,7 @@ namespace MySystem
         public void LiShuaActPrize(PxcModels.WebCMSEntities db, PxcModels.PosMachinesTwo pos, int prize)
         public void LiShuaActPrize(PxcModels.WebCMSEntities db, PxcModels.PosMachinesTwo pos, int prize)
         {
         {
             PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
             PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
-            if(merchant != null)
+            if (merchant != null)
             {
             {
                 PxcModels.Users getUser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new PxcModels.Users();
                 PxcModels.Users getUser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new PxcModels.Users();
                 int BuyTopUserId = 0;
                 int BuyTopUserId = 0;
@@ -481,15 +487,15 @@ namespace MySystem
                         BuyTopUserId = int.Parse(ParentNavList[0]);
                         BuyTopUserId = int.Parse(ParentNavList[0]);
                     }
                     }
                 }
                 }
-                if(prize == 50)
+                if (prize == 50)
                 {
                 {
                     StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize);
                     StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize);
                 }
                 }
-                if(prize == 40)
+                if (prize == 40)
                 {
                 {
                     StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize, 12);
                     StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize, 12);
                 }
                 }
-                if(prize == 30)
+                if (prize == 30)
                 {
                 {
                     StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize, 133);
                     StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize, 133);
                 }
                 }
@@ -498,7 +504,7 @@ namespace MySystem
 
 
         private int GetLeShuaHaiKe(int UserId, int BrandId)
         private int GetLeShuaHaiKe(int UserId, int BrandId)
         {
         {
-            if(DateTime.Now >= DateTime.Parse("2023-08-01 00:00:00"))
+            if (DateTime.Now >= DateTime.Parse("2023-08-01 00:00:00"))
             {
             {
                 return 0;
                 return 0;
             }
             }
@@ -507,20 +513,20 @@ namespace MySystem
             {
             {
                 string Date = DateTime.Now.ToString("yyyyMMdd");
                 string Date = DateTime.Now.ToString("yyyyMMdd");
                 int checkNum = 0;
                 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;
+                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)));
                 int check = int.Parse(function.CheckInt(RedisDbconn.Instance.Get<string>("lscut:" + UserId + ":" + BrandId + ":" + Date)));
-                if(check <= checkNum)
+                if (check <= checkNum)
                 {
                 {
                     check += 1;
                     check += 1;
                     RedisDbconn.Instance.Set("lscut:" + UserId + ":" + BrandId + ":" + Date, check.ToString());
                     RedisDbconn.Instance.Set("lscut:" + UserId + ":" + BrandId + ":" + Date, check.ToString());
@@ -531,7 +537,7 @@ namespace MySystem
                     RedisDbconn.Instance.Set("lscut:" + UserId + ":" + BrandId + ":" + Date, "0");
                     RedisDbconn.Instance.Set("lscut:" + UserId + ":" + BrandId + ":" + Date, "0");
                 }
                 }
             }
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
             {
                 Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "乐刷海科计数异常");
                 Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "乐刷海科计数异常");
             }
             }

+ 264 - 261
AppStart/Helper/SycnSpServer/SycnSpTradeTmpService.cs

@@ -27,318 +27,321 @@ namespace MySystem
             {
             {
                 try
                 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");
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime root = DateTime.Parse("2025-01-01 00:00:00");
-                    DateTime start = DateTime.Now.AddDays(-30);
-                    DateTime end = DateTime.Now.AddMinutes(-3);
-                    int StartId = 139478000;
-                    // if(StartId == 0) StartId = 133391021;
-                    IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id > StartId && !BrandIds.Contains(m.ProductType) && SaveDataBindIds.Contains(m.ProductType) && m.CreateDate >= start && m.CreateDate >= root && m.Sort == 0).OrderBy(m => m.CreateDate).Take(20);
-                    foreach (TradeRecord trade in trades.ToList())
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        // StartId = trade.Id;
-                        string TradeSnNo = trade.TradeSnNo;
-
-                        bool op = true;
-                        if (trade.SerEntryMode == "N" && trade.ProductType == "1") //金控押金获取
+                        List<string> BrandIds = new List<string>();
+                        BrandIds.Add("14");
+                        BrandIds.Add("17");
+                        BrandIds.Add("23");
+                        BrandIds.Add("24");
+                        BrandIds.Add("25");
+                        BrandIds.Add("26");
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime root = DateTime.Parse("2025-01-01 00:00:00");
+                        DateTime start = DateTime.Now.AddDays(-30);
+                        DateTime end = DateTime.Now.AddMinutes(-3);
+                        int StartId = 139478000;
+                        // if(StartId == 0) StartId = 133391021;
+                        IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id > StartId && !BrandIds.Contains(m.ProductType) && SaveDataBindIds.Contains(m.ProductType) && m.CreateDate >= start && m.CreateDate >= root && m.Sort == 0).OrderBy(m => m.CreateDate).Take(20);
+                        foreach (TradeRecord trade in trades.ToList())
                         {
                         {
-                            if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
+                            // StartId = trade.Id;
+                            string TradeSnNo = trade.TradeSnNo;
+
+                            bool op = true;
+                            if (trade.SerEntryMode == "N" && trade.ProductType == "1") //金控押金获取
                             {
                             {
-                                op = false;                                
+                                if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
+                                {
+                                    op = false;
+                                }
                             }
                             }
-                        }
-                        else if (trade.SerEntryMode == "1" && trade.ProductType == "27") //金控押金获取
-                        {
-                            if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
+                            else if (trade.SerEntryMode == "1" && trade.ProductType == "27") //金控押金获取
                             {
                             {
-                                op = false;
+                                if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
+                                {
+                                    op = false;
+                                }
                             }
                             }
-                        }
-                        else if ((trade.ProductType == "4" || trade.ProductType == "8" || trade.ProductType == "9") && (trade.Field2 == "5200" || trade.Field2 == "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)
+                            else if ((trade.ProductType == "4" || trade.ProductType == "8" || trade.ProductType == "9") && (trade.Field2 == "5200" || trade.Field2 == "5800")) //乐刷海科费率0.52,0.58的不入库
                             {
                             {
                                 op = false;
                                 op = false;
                             }
                             }
-                        }
-                        else if (trade.SerEntryMode == "40" && trade.ProductType == "12") //盒易付押金获取
-                        {
-                            if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
+                            else if (trade.SerEntryMode == "1" && trade.ProductType == "10") //联动押金获取
                             {
                             {
-                                op = false;
+                                if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
+                                {
+                                    op = false;
+                                }
                             }
                             }
-                        }
-                        else if (trade.TradeType == "40" && trade.ProductType == "15") //联客宝押金获取
-                        {
-                            if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
+                            else if (trade.SerEntryMode == "40" && trade.ProductType == "12") //盒易付押金获取
+                            {
+                                if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
+                                {
+                                    op = false;
+                                }
+                            }
+                            else if (trade.TradeType == "40" && trade.ProductType == "15") //联客宝押金获取
+                            {
+                                if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
+                                {
+                                    op = false;
+                                }
+                            }
+                            else if (trade.SerEntryMode == "DEPOSIT" && trade.ProductType == "30") //拉卡拉押金获取
+                            {
+                                if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
+                                {
+                                    op = false;
+                                }
+                            }
+                            if (trade.DiscountRateFlag == "True")
                             {
                             {
                                 op = false;
                                 op = false;
                             }
                             }
-                        }
-                        else if (trade.SerEntryMode == "DEPOSIT" && trade.ProductType == "30") //拉卡拉押金获取
-                        {
-                            if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
+                            if (trade.ProductType == "7" && trade.TradeStatus != "00")
                             {
                             {
                                 op = false;
                                 op = false;
                             }
                             }
-                        }
-                        if (trade.DiscountRateFlag == "True")
-                        {
-                            op = false;
-                        }
-                        if(trade.ProductType == "7" && trade.TradeStatus != "00")
-                        {
-                            op = false;
-                        }
-                        if (op)
-                        {
-                            string check = RedisDbconn.Instance.Get<string>("helpprofit:" + trade.TradeSerialNo);
-                            if(string.IsNullOrEmpty(check))
+                            if (op)
                             {
                             {
-                                RedisDbconn.Instance.Set("helpprofit:" + trade.TradeSerialNo, trade.TradeSerialNo);
-                                RedisDbconn.Instance.SetExpire("helpprofit:" + trade.TradeSerialNo, 10);
-                                PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == TradeSnNo);
-                                if (pos != null)
+                                string check = RedisDbconn.Instance.Get<string>("helpprofit:" + trade.TradeSerialNo);
+                                if (string.IsNullOrEmpty(check))
                                 {
                                 {
-                                    PxcModels.KqProducts brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new PxcModels.KqProducts();
-                                    if (pos.BindMerchantId > 0)
+                                    RedisDbconn.Instance.Set("helpprofit:" + trade.TradeSerialNo, trade.TradeSerialNo);
+                                    RedisDbconn.Instance.SetExpire("helpprofit:" + trade.TradeSerialNo, 10);
+                                    PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == TradeSnNo);
+                                    if (pos != null)
                                     {
                                     {
-                                        PxcModels.Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new PxcModels.Users();
-                                        int TopUserId = 0;
-                                        if (!string.IsNullOrEmpty(user.ParentNav))
-                                        {
-                                            TopUserId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
-                                        }
-                                        decimal TradeAmount = trade.TradeAmount;
-                                        int BankCardType = -1;
-                                        int QrPayFlag = 0;
-                                        int VipFlag = 0;
-                                        int PayType = 0;
-                                        if (pos.BrandId == 1 || pos.BrandId == 3)
-                                        {
-                                            TradeAmount = TradeAmount / 100;
-                                            BankCardType = int.Parse(trade.BankCardType);
-                                            if (trade.TradeType == "02") QrPayFlag = 1;
-                                            else if (trade.TradeType == "NQ") PayType = 1;
-                                            if (trade.SettleMethod == "E") VipFlag = 1;
-                                        }
-                                        else if (pos.BrandId == 2)
+                                        PxcModels.KqProducts brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new PxcModels.KqProducts();
+                                        if (pos.BindMerchantId > 0)
                                         {
                                         {
-                                            if (trade.TradeType == "CREDIT_BY_CARD")
+                                            PxcModels.Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new PxcModels.Users();
+                                            int TopUserId = 0;
+                                            if (!string.IsNullOrEmpty(user.ParentNav))
                                             {
                                             {
-                                                BankCardType = 1;
+                                                TopUserId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
                                             }
                                             }
-                                            else
+                                            decimal TradeAmount = trade.TradeAmount;
+                                            int BankCardType = -1;
+                                            int QrPayFlag = 0;
+                                            int VipFlag = 0;
+                                            int PayType = 0;
+                                            if (pos.BrandId == 1 || pos.BrandId == 3)
                                             {
                                             {
-                                                BankCardType = 0;
+                                                TradeAmount = TradeAmount / 100;
+                                                BankCardType = int.Parse(trade.BankCardType);
+                                                if (trade.TradeType == "02") QrPayFlag = 1;
+                                                else if (trade.TradeType == "NQ") PayType = 1;
+                                                if (trade.SettleMethod == "E") VipFlag = 1;
                                             }
                                             }
-                                            if (trade.TradeType == "CLOUD_PAY") QrPayFlag = 1;
-                                        }
-                                        else if (pos.BrandId == 4 || pos.BrandId == 5)
-                                        {
-                                            TradeAmount = TradeAmount / 100;
-                                            if (trade.BankCardType == "100")
-                                            {
-                                                BankCardType = 1;
-                                            }
-                                            else if (trade.BankCardType == "200")
-                                            {
-                                                BankCardType = 0;
-                                            }
-                                            if (trade.TradeType == "200") QrPayFlag = 1;
-                                            if (trade.Field1 == "1") VipFlag = 1;
-                                        }
-                                        else if (pos.BrandId == 6 || pos.BrandId == 22)
-                                        {
-                                            TradeAmount = TradeAmount / 100;
-                                            if (trade.BankCardType == "02" || trade.BankCardType == "12")
-                                            {
-                                                BankCardType = 1;
-                                            }
-                                            else
-                                            {
-                                                BankCardType = 0;
-                                            }
-                                        }
-                                        else if (pos.BrandId == 7)
-                                        {
-                                            TradeAmount = TradeAmount / 100;
-                                            if (trade.BankCardType == "OA" || trade.BankCardType == "CC" || trade.BankCardType == "SCC")
+                                            else if (pos.BrandId == 2)
                                             {
                                             {
-                                                BankCardType = 1;
+                                                if (trade.TradeType == "CREDIT_BY_CARD")
+                                                {
+                                                    BankCardType = 1;
+                                                }
+                                                else
+                                                {
+                                                    BankCardType = 0;
+                                                }
+                                                if (trade.TradeType == "CLOUD_PAY") QrPayFlag = 1;
                                             }
                                             }
-                                            else
+                                            else if (pos.BrandId == 4 || pos.BrandId == 5)
                                             {
                                             {
-                                                BankCardType = 0;
+                                                TradeAmount = TradeAmount / 100;
+                                                if (trade.BankCardType == "100")
+                                                {
+                                                    BankCardType = 1;
+                                                }
+                                                else if (trade.BankCardType == "200")
+                                                {
+                                                    BankCardType = 0;
+                                                }
+                                                if (trade.TradeType == "200") QrPayFlag = 1;
+                                                if (trade.Field1 == "1") VipFlag = 1;
                                             }
                                             }
-                                        }
-                                        else if (pos.BrandId == 8 || pos.BrandId == 9)
-                                        {
-                                            TradeAmount = TradeAmount / 100;
-                                            if (trade.BankCardType == "100")
+                                            else if (pos.BrandId == 6 || pos.BrandId == 22)
                                             {
                                             {
-                                                BankCardType = 1;
+                                                TradeAmount = TradeAmount / 100;
+                                                if (trade.BankCardType == "02" || trade.BankCardType == "12")
+                                                {
+                                                    BankCardType = 1;
+                                                }
+                                                else
+                                                {
+                                                    BankCardType = 0;
+                                                }
                                             }
                                             }
-                                            else if (trade.BankCardType == "200")
+                                            else if (pos.BrandId == 7)
                                             {
                                             {
-                                                BankCardType = 0;
+                                                TradeAmount = TradeAmount / 100;
+                                                if (trade.BankCardType == "OA" || trade.BankCardType == "CC" || trade.BankCardType == "SCC")
+                                                {
+                                                    BankCardType = 1;
+                                                }
+                                                else
+                                                {
+                                                    BankCardType = 0;
+                                                }
                                             }
                                             }
-                                            if (trade.TradeType == "200") QrPayFlag = 1;
-                                            if (trade.Field1 == "1") VipFlag = 1;
-                                        }
-                                        else if (pos.BrandId == 10 || pos.BrandId == 11)
-                                        {
-                                            if (trade.BankCardType == "01")
+                                            else if (pos.BrandId == 8 || pos.BrandId == 9)
                                             {
                                             {
-                                                BankCardType = 1;
+                                                TradeAmount = TradeAmount / 100;
+                                                if (trade.BankCardType == "100")
+                                                {
+                                                    BankCardType = 1;
+                                                }
+                                                else if (trade.BankCardType == "200")
+                                                {
+                                                    BankCardType = 0;
+                                                }
+                                                if (trade.TradeType == "200") QrPayFlag = 1;
+                                                if (trade.Field1 == "1") VipFlag = 1;
                                             }
                                             }
-                                            else if (trade.BankCardType == "00")
+                                            else if (pos.BrandId == 10 || pos.BrandId == 11)
                                             {
                                             {
-                                                BankCardType = 0;
+                                                if (trade.BankCardType == "01")
+                                                {
+                                                    BankCardType = 1;
+                                                }
+                                                else if (trade.BankCardType == "00")
+                                                {
+                                                    BankCardType = 0;
+                                                }
+                                                if (trade.TradeType == "F010") QrPayFlag = 1;
                                             }
                                             }
-                                            if (trade.TradeType == "F010") QrPayFlag = 1;
-                                        }
-                                        else if (pos.BrandId == 12 || pos.BrandId == 13) //盒易付
-                                        {
-                                            if (trade.BankCardType == "C")
+                                            else if (pos.BrandId == 12 || pos.BrandId == 13) //盒易付
                                             {
                                             {
-                                                BankCardType = 1;
+                                                if (trade.BankCardType == "C")
+                                                {
+                                                    BankCardType = 1;
+                                                }
+                                                else if (trade.BankCardType == "D")
+                                                {
+                                                    BankCardType = 0;
+                                                }
+                                                if (trade.Field3 == "1") QrPayFlag = 1;
                                             }
                                             }
-                                            else if (trade.BankCardType == "D")
+                                            else if (pos.BrandId == 15 || pos.BrandId == 16) //联客宝
                                             {
                                             {
-                                                BankCardType = 0;
+                                                TradeAmount = TradeAmount / 100;
+                                                // 支付类型
+                                                // 01-内卡借记卡
+                                                // 02-内卡贷记卡
+                                                // 03-银联二维码
+                                                // 11-外卡借记卡
+                                                // 12-外卡贷记卡
+                                                // 30-微信
+                                                // 31-支付宝
+                                                // M3-扫码(银联二维码、微信、支付宝)
+                                                if (trade.BankCardType == "02")
+                                                {
+                                                    BankCardType = 1;
+                                                }
+                                                else
+                                                {
+                                                    BankCardType = 0;
+                                                }
                                             }
                                             }
-                                            if (trade.Field3 == "1") QrPayFlag = 1;
-                                        }
-                                        else if (pos.BrandId == 15 || pos.BrandId == 16) //联客宝
-                                        {
-                                            TradeAmount = TradeAmount / 100;
-                                            // 支付类型
-                                            // 01-内卡借记卡
-                                            // 02-内卡贷记卡
-                                            // 03-银联二维码
-                                            // 11-外卡借记卡
-                                            // 12-外卡贷记卡
-                                            // 30-微信
-                                            // 31-支付宝
-                                            // M3-扫码(银联二维码、微信、支付宝)
-                                            if (trade.BankCardType == "02")
+                                            else if (pos.BrandId == 30 || pos.BrandId == 31) //拉卡拉
                                             {
                                             {
-                                                BankCardType = 1;
+                                                TradeAmount = TradeAmount / 100;
+                                                if (trade.BankCardType == "01" || trade.BankCardType == "61")
+                                                {
+                                                    BankCardType = 1;
+                                                }
+                                                else
+                                                {
+                                                    BankCardType = 0;
+                                                }
                                             }
                                             }
-                                            else
+                                            int BrandId = pos.BrandId;
+                                            decimal SourceTradeAmount = TradeAmount;
+                                            decimal CheckMoney = brand.ActTradeAmount > 0 ? brand.ActTradeAmount : 1000;
+                                            //判断激活条件并激活
+                                            if (TradeAmount > 0)
                                             {
                                             {
-                                                BankCardType = 0;
+                                                ulong MerHelpFlag = 0;
+                                                int CapFlag = 0;
+                                                if (BankCardType == 0 && TradeAmount >= 1666.67M)
+                                                {
+                                                    CapFlag = 1;
+                                                }
+                                                string HelpProfitFlag = "";
+                                                bool checkHelpProfit = db.HelpProfitMerchantForUser.Any(m => m.MerchantId == pos.BindMerchantId);
+                                                if (checkHelpProfit)
+                                                {
+                                                    HelpProfitFlag = "HelpProfit";
+                                                }
+                                                int ActStatus = pos.ActivationState;
+                                                int Version = 0;
+                                                if (MerHelpFlag == 2) Version = 1;
+                                                if (MerHelpFlag == 3) Version = 2;
+                                                //盒易付和来客吧电签,稳定期自动转到稳定期A
+                                                if ((pos.BrandId == 12 || pos.BrandId == 13) && MerHelpFlag == 0 && Version == 0)
+                                                {
+                                                    Version = 1;
+                                                }
+                                                if (Utils.Instance.IsWifi(pos.BrandId))
+                                                {
+                                                    MerHelpFlag = 1;
+                                                    Version = 0;
+                                                }
+                                                decimal SettleFee = trade.SettleFee * 100;
+                                                PxcModels.TradeRecord add = db.TradeRecord.Add(new PxcModels.TradeRecord()
+                                                {
+                                                    ParentNav = user.ParentNav,
+                                                    CreateDate = trade.CreateDate,
+                                                    UpdateDate = trade.UpdateDate,
+                                                    RecordNo = trade.TradeSerialNo, //单号
+                                                    UserId = pos.UserId, //创客
+                                                    MerchantId = pos.BindMerchantId, //商户
+                                                    MerNo = trade.MerNo, //渠道商户编号
+                                                    MerHelpFlag = MerHelpFlag >= 2 ? 1 : MerHelpFlag, //1扶持周,0稳定期,2盈利期
+                                                    HelpMonthCount = 0, //扶持第几个月
+                                                    MerBuddyType = user.MerchantType, //商户创客类型
+                                                    SnNo = TradeSnNo, //渠道SN号
+                                                    TradeSerialNo = trade.ChannelSerial, //交易流水号
+                                                    TradeAmount = TradeAmount, //交易金额
+                                                    BankCardType = BankCardType, //银行卡类型
+                                                    QrPayFlag = QrPayFlag, //云闪付标识
+                                                    CapFlag = CapFlag, //借记卡是否封顶
+                                                    VipFlag = VipFlag, //会员标记
+                                                    PayType = PayType, //支付方式
+                                                    BrandId = BrandId, //品牌
+                                                    Remark = trade.TradeType == "2" && trade.ProductType == "12" ? "吱码SN:" + trade.TradeSnNo : trade.Remark, //备注
+                                                    TopUserId = TopUserId, //顶级创客
+                                                    MerUserId = pos.UserId, //商户直属创客M
+                                                    SeoTitle = HelpProfitFlag,
+                                                    Version = Version,
+                                                    ActStatus = ActStatus,
+                                                    CreateMan = trade.AgentNo,
+                                                    UpdateMan = trade.BankCardType,
+                                                    SeoKeyword = trade.SerEntryMode,
+                                                    SeoDescription = trade.TradeType,
+                                                    Sort = (int)SettleFee,
+                                                    TradeDate = pos.BindingTime,
+                                                }).Entity;
+                                                db.SaveChanges();
                                             }
                                             }
                                         }
                                         }
-                                        else if (pos.BrandId == 30 || pos.BrandId == 31) //拉卡拉
-                                        {
-                                            TradeAmount = TradeAmount / 100;
-                                            if (trade.BankCardType == "01" || trade.BankCardType == "61")
-                                            {
-                                                BankCardType = 1;
-                                            }
-                                            else
-                                            {
-                                                BankCardType = 0;
-                                            }
-                                        }
-                                        int BrandId = pos.BrandId;
-                                        decimal SourceTradeAmount = TradeAmount;
-                                        decimal CheckMoney = brand.ActTradeAmount > 0 ? brand.ActTradeAmount : 1000;
-                                        //判断激活条件并激活
-                                        if (TradeAmount > 0)
-                                        {
-                                            ulong MerHelpFlag = 0;
-                                            int CapFlag = 0;
-                                            if(BankCardType == 0 && TradeAmount >= 1666.67M)
-                                            {
-                                                CapFlag = 1;
-                                            }
-                                            string HelpProfitFlag = "";
-                                            bool checkHelpProfit = db.HelpProfitMerchantForUser.Any(m => m.MerchantId == pos.BindMerchantId);
-                                            if(checkHelpProfit)
-                                            {
-                                                HelpProfitFlag = "HelpProfit";
-                                            }
-                                            int ActStatus = pos.ActivationState;
-                                            int Version = 0;
-                                            if(MerHelpFlag == 2) Version = 1;
-                                            if(MerHelpFlag == 3) Version = 2;
-                                            //盒易付和来客吧电签,稳定期自动转到稳定期A
-                                            if((pos.BrandId == 12 || pos.BrandId == 13) && MerHelpFlag == 0 && Version == 0)
-                                            {
-                                                Version = 1;
-                                            }
-                                            if(Utils.Instance.IsWifi(pos.BrandId))
-                                            {
-                                                MerHelpFlag = 1;
-                                                Version = 0;
-                                            }
-                                            decimal SettleFee = trade.SettleFee * 100;
-                                            PxcModels.TradeRecord add = db.TradeRecord.Add(new PxcModels.TradeRecord()
-                                            {
-                                                ParentNav = user.ParentNav,
-                                                CreateDate = trade.CreateDate,
-                                                UpdateDate = trade.UpdateDate,
-                                                RecordNo = trade.TradeSerialNo, //单号
-                                                UserId = pos.UserId, //创客
-                                                MerchantId = pos.BindMerchantId, //商户
-                                                MerNo = trade.MerNo, //渠道商户编号
-                                                MerHelpFlag = MerHelpFlag >= 2 ? 1 : MerHelpFlag, //1扶持周,0稳定期,2盈利期
-                                                HelpMonthCount = 0, //扶持第几个月
-                                                MerBuddyType = user.MerchantType, //商户创客类型
-                                                SnNo = TradeSnNo, //渠道SN号
-                                                TradeSerialNo = trade.ChannelSerial, //交易流水号
-                                                TradeAmount = TradeAmount, //交易金额
-                                                BankCardType = BankCardType, //银行卡类型
-                                                QrPayFlag = QrPayFlag, //云闪付标识
-                                                CapFlag = CapFlag, //借记卡是否封顶
-                                                VipFlag = VipFlag, //会员标记
-                                                PayType = PayType, //支付方式
-                                                BrandId = BrandId, //品牌
-                                                Remark = trade.TradeType == "2" && trade.ProductType == "12" ? "吱码SN:" + trade.TradeSnNo : trade.Remark, //备注
-                                                TopUserId = TopUserId, //顶级创客
-                                                MerUserId = pos.UserId, //商户直属创客M
-                                                SeoTitle = HelpProfitFlag,
-                                                Version = Version,
-                                                ActStatus = ActStatus,
-                                                CreateMan = trade.AgentNo,
-                                                UpdateMan = trade.BankCardType,
-                                                SeoKeyword = trade.SerEntryMode,
-                                                SeoDescription = trade.TradeType,
-                                                Sort = (int)SettleFee,
-                                                TradeDate = pos.BindingTime,
-                                            }).Entity;
-                                            db.SaveChanges();
-                                        }
                                     }
                                     }
                                 }
                                 }
                             }
                             }
+                            // function.WritePage("/SycnSp/", "TradeRecordIdForHelp.txt", StartId.ToString());
+                            TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
+                            if (edit != null)
+                            {
+                                edit.Sort = 1;
+                            }
+                            spdb.SaveChanges();
                         }
                         }
-                        // function.WritePage("/SycnSp/", "TradeRecordIdForHelp.txt", StartId.ToString());
-                        TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
-                        if (edit != null)
-                        {
-                            edit.Sort = 1;
-                        }
-                        spdb.SaveChanges();   
+                        spdb.Dispose();
+                        db.Dispose();
                     }
                     }
-                    spdb.Dispose();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {

+ 29 - 26
AppStart/Helper/SycnSpServer/SycnSpTradeWifiService.cs

@@ -27,25 +27,28 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime start = DateTime.Now.AddDays(-60);
-                    DateTime end = DateTime.Now.AddMinutes(-1);
-                    int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/TradeRecordId.txt")));
-                    IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id >= StartId && m.ProductType == "23" && m.CreateDate >= start && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderBy(m => m.CreateDate).Take(20);
-                    foreach (TradeRecord trade in trades.ToList())
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        DoQueueTrade(db, trade);
-                        TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
-                        if (edit != null)
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime start = DateTime.Now.AddDays(-60);
+                        DateTime end = DateTime.Now.AddMinutes(-1);
+                        int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/TradeRecordId.txt")));
+                        IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id >= StartId && m.ProductType == "23" && m.CreateDate >= start && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderBy(m => m.CreateDate).Take(20);
+                        foreach (TradeRecord trade in trades.ToList())
                         {
                         {
-                            edit.Status = 2;
-                            spdb.SaveChanges();
+                            DoQueueTrade(db, trade);
+                            TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
+                            if (edit != null)
+                            {
+                                edit.Status = 2;
+                                spdb.SaveChanges();
+                            }
                         }
                         }
+                        spdb.Dispose();
+                        db.Dispose();
                     }
                     }
-                    spdb.Dispose();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
@@ -62,7 +65,7 @@ namespace MySystem
             {
             {
                 int BrandId = int.Parse(function.CheckInt(trade.ProductType));
                 int BrandId = int.Parse(function.CheckInt(trade.ProductType));
                 decimal TradeAmount = trade.TradeAmount;
                 decimal TradeAmount = trade.TradeAmount;
-                if(trade.SeoTitle != "v2") TradeAmount = TradeAmount / 100;
+                if (trade.SeoTitle != "v2") TradeAmount = TradeAmount / 100;
                 PxcModels.WifiTradeRecord add = db.WifiTradeRecord.Add(new PxcModels.WifiTradeRecord()
                 PxcModels.WifiTradeRecord add = db.WifiTradeRecord.Add(new PxcModels.WifiTradeRecord()
                 {
                 {
                     CreateDate = trade.CreateDate,
                     CreateDate = trade.CreateDate,
@@ -83,19 +86,19 @@ namespace MySystem
                 //开始统计
                 //开始统计
                 int Months = 0;
                 int Months = 0;
 
 
-                if(trade.SeoTitle == "v2")
+                if (trade.SeoTitle == "v2")
                 {
                 {
                     string duration = trade.Field2; //设备套餐时长
                     string duration = trade.Field2; //设备套餐时长
                     string unit = trade.Field3; //套餐单位 0:按天 1:按月
                     string unit = trade.Field3; //套餐单位 0:按天 1:按月
-                    if(unit == "1") Months = int.Parse(function.CheckInt(duration));
+                    if (unit == "1") Months = int.Parse(function.CheckInt(duration));
                     else Months = int.Parse(function.CheckInt(duration)) / 30;
                     else Months = int.Parse(function.CheckInt(duration)) / 30;
                 }
                 }
                 else
                 else
                 {
                 {
-                    if(BrandId == 23 && TradeAmount == 49) Months = 1;
-                    else if(BrandId == 23 && TradeAmount == 79) Months = 3;
-                    else if(BrandId == 23 && TradeAmount == 119) Months = 12;
-                    else if(BrandId == 23 && TradeAmount == 199) Months = 24;
+                    if (BrandId == 23 && TradeAmount == 49) Months = 1;
+                    else if (BrandId == 23 && TradeAmount == 79) Months = 3;
+                    else if (BrandId == 23 && TradeAmount == 119) Months = 12;
+                    else if (BrandId == 23 && TradeAmount == 199) Months = 24;
                     else Months = trade.QueryCount;
                     else Months = trade.QueryCount;
 
 
                     // if(BrandId == 24 && TradeAmount == 59) Months = 1;
                     // if(BrandId == 24 && TradeAmount == 59) Months = 1;
@@ -120,7 +123,7 @@ namespace MySystem
                 WifiTradeHelper.Instance.DoOne(db, add.Id, DateTime.Now.ToString("yyyy-MM"), trade.TradeSerialNo, true);
                 WifiTradeHelper.Instance.DoOne(db, add.Id, DateTime.Now.ToString("yyyy-MM"), trade.TradeSerialNo, true);
                 db.SaveChanges();
                 db.SaveChanges();
             }
             }
-            if(trade.SerEntryMode == "1")
+            if (trade.SerEntryMode == "1")
             {
             {
                 PosPushDataNewHelper.Deposit(new ActivateRecord()
                 PosPushDataNewHelper.Deposit(new ActivateRecord()
                 {
                 {
@@ -133,7 +136,7 @@ namespace MySystem
             }
             }
         }
         }
 
 
-        
+
 
 
         public void StatTrade(PxcModels.WebCMSEntities db, int UserId, int BrandId, string TradeMonth, decimal TradeAmount)
         public void StatTrade(PxcModels.WebCMSEntities db, int UserId, int BrandId, string TradeMonth, decimal TradeAmount)
         {
         {
@@ -283,7 +286,7 @@ namespace MySystem
                 string PosSn = jsonObj["pos_sn"].ToString();
                 string PosSn = jsonObj["pos_sn"].ToString();
                 decimal TradeAmount = decimal.Parse(jsonObj["amt"].ToString());
                 decimal TradeAmount = decimal.Parse(jsonObj["amt"].ToString());
                 PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PxcModels.PosMachinesTwo();
                 PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PxcModels.PosMachinesTwo();
-                if(pos.Status > -1 && pos.BuyUserId > 0 && pos.ActivationState == 1)
+                if (pos.Status > -1 && pos.BuyUserId > 0 && pos.ActivationState == 1)
                 {
                 {
                     PxcModels.PosMerchantInfo mer = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId) ?? new PxcModels.PosMerchantInfo();
                     PxcModels.PosMerchantInfo mer = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId) ?? new PxcModels.PosMerchantInfo();
                     PosPushDataNewHelper.Trade(new TradeRecord()
                     PosPushDataNewHelper.Trade(new TradeRecord()
@@ -297,7 +300,7 @@ namespace MySystem
                     });
                     });
                 }
                 }
             }
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
             {
                 Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "推送wifi每月交易到java异常");
                 Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "推送wifi每月交易到java异常");
             }
             }

+ 81 - 78
AppStart/Helper/SycnSpServer/SycnSpTradeZkbService.cs

@@ -27,85 +27,97 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> BrandIds = new List<string>();
-                    BrandIds.Add("17");
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime start = DateTime.Now.AddDays(-10);
-                    DateTime end = DateTime.Now.AddMinutes(-1);
-                    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())
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == trade.TradeSnNo);
-                        if (pos != null)
+                        List<string> BrandIds = new List<string>();
+                        BrandIds.Add("17");
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime start = DateTime.Now.AddDays(-10);
+                        DateTime end = DateTime.Now.AddMinutes(-1);
+                        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())
                         {
                         {
-                            PxcModels.KqProducts brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new PxcModels.KqProducts();
-                            if (pos.BindMerchantId > 0)
+                            PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == trade.TradeSnNo);
+                            if (pos != null)
                             {
                             {
-                                PxcModels.Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new PxcModels.Users();
-                                int TopUserId = 0;
-                                if (!string.IsNullOrEmpty(user.ParentNav))
+                                PxcModels.KqProducts brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new PxcModels.KqProducts();
+                                if (pos.BindMerchantId > 0)
                                 {
                                 {
-                                    TopUserId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
-                                }
-                                bool check = db.SpOrderNos.Any(m => m.OrderNo == trade.TradeSerialNo);
-                                if (!check)
-                                {
-                                    decimal TradeAmount = trade.TradeAmount / 100;
-                                    int BankCardType = 1;
-                                    int QrPayFlag = 0;
-                                    int VipFlag = 0;
-                                    int PayType = 0;
-                                    int BrandId = pos.BrandId;
-                                    int ActStatus = pos.ActivationState;
-                                    if (TradeAmount > 0)
+                                    PxcModels.Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new PxcModels.Users();
+                                    int TopUserId = 0;
+                                    if (!string.IsNullOrEmpty(user.ParentNav))
+                                    {
+                                        TopUserId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
+                                    }
+                                    bool check = db.SpOrderNos.Any(m => m.OrderNo == trade.TradeSerialNo);
+                                    if (!check)
                                     {
                                     {
-                                        PxcModels.TradeRecord add = db.TradeRecord.Add(new PxcModels.TradeRecord()
+                                        decimal TradeAmount = trade.TradeAmount / 100;
+                                        int BankCardType = 1;
+                                        int QrPayFlag = 0;
+                                        int VipFlag = 0;
+                                        int PayType = 0;
+                                        int BrandId = pos.BrandId;
+                                        int ActStatus = pos.ActivationState;
+                                        if (TradeAmount > 0)
                                         {
                                         {
-                                            ParentNav = user.ParentNav,
-                                            CreateDate = trade.CreateDate,
-                                            UpdateDate = trade.UpdateDate,
-                                            RecordNo = trade.TradeSerialNo, //单号
-                                            UserId = pos.UserId, //创客
-                                            MerchantId = pos.BindMerchantId, //商户
-                                            MerNo = trade.MerNo, //渠道商户编号
-                                            MerHelpFlag = 0,
-                                            HelpMonthCount = 0, //扶持第几个月
-                                            MerBuddyType = user.MerchantType, //商户创客类型
-                                            SnNo = trade.TradeSnNo, //渠道SN号
-                                            TradeSerialNo = trade.ChannelSerial, //交易流水号
-                                            TradeAmount = TradeAmount, //交易金额
-                                            BankCardType = BankCardType, //银行卡类型
-                                            QrPayFlag = QrPayFlag, //云闪付标识
-                                            VipFlag = VipFlag, //会员标记
-                                            PayType = PayType, //支付方式
-                                            BrandId = BrandId, //品牌
-                                            Remark = trade.Remark, //备注
-                                            TopUserId = TopUserId, //顶级创客
-                                            MerUserId = pos.UserId, //商户直属创客M
-                                            ActStatus = ActStatus,
-                                            CreateMan = trade.AgentNo,
-                                            UpdateMan = trade.BankCardType,
-                                            SeoKeyword = trade.SerEntryMode,
-                                            SeoDescription = trade.TradeType,
-                                            TradeDate = pos.BindingTime,
-                                        }).Entity;
+                                            PxcModels.TradeRecord add = db.TradeRecord.Add(new PxcModels.TradeRecord()
+                                            {
+                                                ParentNav = user.ParentNav,
+                                                CreateDate = trade.CreateDate,
+                                                UpdateDate = trade.UpdateDate,
+                                                RecordNo = trade.TradeSerialNo, //单号
+                                                UserId = pos.UserId, //创客
+                                                MerchantId = pos.BindMerchantId, //商户
+                                                MerNo = trade.MerNo, //渠道商户编号
+                                                MerHelpFlag = 0,
+                                                HelpMonthCount = 0, //扶持第几个月
+                                                MerBuddyType = user.MerchantType, //商户创客类型
+                                                SnNo = trade.TradeSnNo, //渠道SN号
+                                                TradeSerialNo = trade.ChannelSerial, //交易流水号
+                                                TradeAmount = TradeAmount, //交易金额
+                                                BankCardType = BankCardType, //银行卡类型
+                                                QrPayFlag = QrPayFlag, //云闪付标识
+                                                VipFlag = VipFlag, //会员标记
+                                                PayType = PayType, //支付方式
+                                                BrandId = BrandId, //品牌
+                                                Remark = trade.Remark, //备注
+                                                TopUserId = TopUserId, //顶级创客
+                                                MerUserId = pos.UserId, //商户直属创客M
+                                                ActStatus = ActStatus,
+                                                CreateMan = trade.AgentNo,
+                                                UpdateMan = trade.BankCardType,
+                                                SeoKeyword = trade.SerEntryMode,
+                                                SeoDescription = trade.TradeType,
+                                                TradeDate = pos.BindingTime,
+                                            }).Entity;
+                                            db.SaveChanges();
+                                        }
+                                        db.SpOrderNos.Add(new PxcModels.SpOrderNos()
+                                        {
+                                            OrderNo = trade.TradeSerialNo
+                                        });
                                         db.SaveChanges();
                                         db.SaveChanges();
                                     }
                                     }
-                                    db.SpOrderNos.Add(new PxcModels.SpOrderNos()
+                                    TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
+                                    if (edit != null)
                                     {
                                     {
-                                        OrderNo = trade.TradeSerialNo
-                                    });
-                                    db.SaveChanges();
+                                        edit.Status = 2;
+                                    }
+                                    spdb.SaveChanges();
                                 }
                                 }
-                                TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
-                                if (edit != null)
+                                else
                                 {
                                 {
-                                    edit.Status = 2;
+                                    TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
+                                    if (edit != null)
+                                    {
+                                        edit.Status = 0;
+                                    }
+                                    spdb.SaveChanges();
                                 }
                                 }
-                                spdb.SaveChanges();
                             }
                             }
                             else
                             else
                             {
                             {
@@ -117,18 +129,9 @@ namespace MySystem
                                 spdb.SaveChanges();
                                 spdb.SaveChanges();
                             }
                             }
                         }
                         }
-                        else
-                        {
-                            TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
-                            if (edit != null)
-                            {
-                                edit.Status = 0;
-                            }
-                            spdb.SaveChanges();
-                        }
+                        spdb.Dispose();
+                        db.Dispose();
                     }
                     }
-                    spdb.Dispose();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {

+ 25 - 22
AppStart/Helper/SycnSpServer/SycnSpUnBindService.cs

@@ -27,35 +27,38 @@ namespace MySystem
             {
             {
                 try
                 try
                 {
                 {
-                    List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
-                    WebCMSEntities spdb = new WebCMSEntities();
-                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime start = DateTime.Now.AddDays(-30);
-                    List<UnBindRecord> Binds = spdb.UnBindRecord.Where(m => m.UnBindTime >= start && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).ToList();
-                    foreach (UnBindRecord Bind in Binds)
+                    if (Utils.PushTimeCheck())
                     {
                     {
-                        var tran = db.Database.BeginTransaction();
-                        try
+                        List<string> SaveDataBindIds = Utils.Instance.SaveDataBindIds();
+                        WebCMSEntities spdb = new WebCMSEntities();
+                        PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                        DateTime start = DateTime.Now.AddDays(-30);
+                        List<UnBindRecord> Binds = spdb.UnBindRecord.Where(m => m.UnBindTime >= start && SaveDataBindIds.Contains(m.ProductType) && m.Status == 1).OrderByDescending(m => m.Id).ToList();
+                        foreach (UnBindRecord Bind in Binds)
                         {
                         {
-                            PosPushDataNewHelper.UnBind(Bind);                            
+                            var tran = db.Database.BeginTransaction();
+                            try
+                            {
+                                PosPushDataNewHelper.UnBind(Bind);
 
 
-                            UnBindRecord edit = spdb.UnBindRecord.FirstOrDefault(m => m.Id == Bind.Id);
-                            if (edit != null)
+                                UnBindRecord edit = spdb.UnBindRecord.FirstOrDefault(m => m.Id == Bind.Id);
+                                if (edit != null)
+                                {
+                                    edit.Status = 2;
+                                    spdb.SaveChanges();
+                                }
+                                tran.Commit();
+                            }
+                            catch (Exception ex)
                             {
                             {
-                                edit.Status = 2;
-                                spdb.SaveChanges();
+                                tran.Rollback();
+                                Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Bind.Id, "同步SP解绑数据到MAIN异常");
                             }
                             }
-                            tran.Commit();
-                        }
-                        catch (Exception ex)
-                        {
-                            tran.Rollback();
-                            Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n" + Bind.Id, "同步SP解绑数据到MAIN异常");
+                            tran.Dispose();
                         }
                         }
-                        tran.Dispose();
+                        spdb.Dispose();
+                        db.Dispose();
                     }
                     }
-                    spdb.Dispose();
-                    db.Dispose();
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {

+ 5 - 2
AppStart/WifiTradeHelper.cs

@@ -30,8 +30,11 @@ public class WifiTradeHelper
             {
             {
                 if(DateTime.Now.Day < 25 && DateTime.Now.Hour < 20)
                 if(DateTime.Now.Day < 25 && DateTime.Now.Hour < 20)
                 {
                 {
-                    string Month = DateTime.Now.ToString("yyyy-MM");
-                    DoSomething(Month);
+                    if(Utils.PushTimeCheck())
+                    {
+                        string Month = DateTime.Now.ToString("yyyy-MM");
+                        DoSomething(Month);
+                    }
                 }
                 }
                 Thread.Sleep(3600000);
                 Thread.Sleep(3600000);
             }
             }

+ 13 - 0
Util/Utils.cs

@@ -523,6 +523,19 @@ namespace MySystem
         }
         }
 
 
         #endregion
         #endregion
+
+        #region 推送数据时间判断
+
+        public static bool PushTimeCheck()
+        {
+            if(DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 02:15:00") || (DateTime.Now > DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 02:26:00") && DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 14:15:00")) || DateTime.Now > DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 14:26:00"))
+            {
+                return true;
+            }
+            return false;
+        }
+
+        #endregion
     
     
     }
     }
 }
 }