Эх сурвалжийг харах

调整通道查询结果逻辑,所有机具查询变更通道成功,才设置主分类的状态为成功

lcl 1 жил өмнө
parent
commit
ec63a455fc

+ 44 - 29
AppStart/PosChannelHelper.cs

@@ -47,39 +47,54 @@ public class PosChannelHelper
 
     public void DoSomething(WebCMSEntities db)
     {
-        List<PosChannelSetRecord> list = db.PosChannelSetRecord.Where(m => m.Status == 0).ToList();
-        foreach(PosChannelSetRecord sub in list)
+        List<PosChannelSet> mains = db.PosChannelSet.Where(m => m.Status == 0).ToList();
+        foreach(PosChannelSet main in mains)
         {
-            string jsonString = QueryTermAcqInfo(sub.PosSn);
-            JsonData jsonData = JsonMapper.ToObject(jsonString);
-            if(jsonData["resultCode"].ToString() == "1")
+            int PassCount = 0;
+            List<PosChannelSetRecord> list = db.PosChannelSetRecord.Where(m => m.RecordId == main.Id).ToList();
+            foreach(PosChannelSetRecord sub in list)
             {
-                // string acqInstId = jsonData["data"]["acqInstId"].ToString();
-                // if(sub.ChannelNo == acqInstId)
-                // {
-                    PosChannelSetRecord edit = db.PosChannelSetRecord.FirstOrDefault(m => m.Id == sub.Id);
-                    if(edit != null)
-                    {
-                        edit.Status = 1;
-                        db.SaveChanges();
-                        PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == edit.PosId) ?? new PosMachinesTwo();
-                        Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
-                        string ChannelName = "";
-                        if(sub.ChannelNo == "48130000") ChannelName = "环讯";
-                        if(sub.ChannelNo == "48310000") ChannelName = "易生";
-                        if(sub.ChannelNo == "48330000") ChannelName = "海科";
-                        if(sub.ChannelNo == "48470000") ChannelName = "中付";
-                        RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                string jsonString = QueryTermAcqInfo(sub.PosSn);
+                JsonData jsonData = JsonMapper.ToObject(jsonString);
+                if(jsonData["resultCode"].ToString() == "1")
+                {
+                    // string acqInstId = jsonData["data"]["acqInstId"].ToString();
+                    // if(sub.ChannelNo == acqInstId)
+                    // {
+                        PosChannelSetRecord edit = db.PosChannelSetRecord.FirstOrDefault(m => m.Id == sub.Id);
+                        if(edit != null)
                         {
-                            UserId = pos.BuyUserId, //创客
-                            Title = "机具通道变更通知", //标题
-                            Content = "<div class='f16' style='padding:12px 16px;'>尊敬的" + user.RealName + "盟主您好:<br/><br/><div class='f14' style='text-indent:2em;'>您名下的机具" + pos.PosSn + ",通道已更改为" + ChannelName + ",请知悉!</ div> </ div>", //内容
-                            CreateDate = DateTime.Now,
-                        }));
-                    }
-                // }
+                            edit.Status = 1;
+                            db.SaveChanges();
+                            PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == edit.PosId) ?? new PosMachinesTwo();
+                            Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
+                            string ChannelName = "";
+                            if(sub.ChannelNo == "48130000") ChannelName = "环讯";
+                            if(sub.ChannelNo == "48310000") ChannelName = "易生";
+                            if(sub.ChannelNo == "48330000") ChannelName = "海科";
+                            if(sub.ChannelNo == "48470000") ChannelName = "中付";
+                            RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                            {
+                                UserId = pos.BuyUserId, //创客
+                                Title = "机具通道变更通知", //标题
+                                Content = "<div class='f16' style='padding:12px 16px;'>尊敬的" + user.RealName + "盟主您好:<br/><br/><div class='f14' style='text-indent:2em;'>您名下的机具" + pos.PosSn + ",通道已更改为" + ChannelName + ",请知悉!</ div> </ div>", //内容
+                                CreateDate = DateTime.Now,
+                            }));
+                            PassCount += 1;
+                        }
+                    // }
+                }
             }
-        }  
+            if(PassCount >= list.Count)
+            {
+                PosChannelSet edit = db.PosChannelSet.FirstOrDefault(m => m.Id == main.Id);
+                if(edit != null)
+                {
+                    edit.Status = 1;
+                    db.SaveChanges();
+                }
+            }
+        }
     }
 
 

+ 19 - 0
PxcModels/PosChannelSet.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.PxcModels
+{
+    public partial class PosChannelSet
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public int SnCount { get; set; }
+        public int BrandId { get; set; }
+        public string ChannelNo { get; set; }
+        public int UserId { get; set; }
+    }
+}

+ 1 - 0
PxcModels/PosChannelSetRecord.cs

@@ -15,5 +15,6 @@ namespace MySystem.PxcModels
         public string MerNo { get; set; }
         public string PosSn { get; set; }
         public int BrandId { get; set; }
+        public int RecordId { get; set; }
     }
 }

+ 54 - 4
PxcModels/WebCMSEntities.cs

@@ -141,6 +141,7 @@ namespace MySystem.PxcModels
         public virtual DbSet<Orders> Orders { get; set; }
         public virtual DbSet<PageInfo> PageInfo { get; set; }
         public virtual DbSet<PageUpdateInfo> PageUpdateInfo { get; set; }
+        public virtual DbSet<PosChannelSet> PosChannelSet { get; set; }
         public virtual DbSet<PosChannelSetRecord> PosChannelSetRecord { get; set; }
         public virtual DbSet<PosCouponForUser> PosCouponForUser { get; set; }
         public virtual DbSet<PosCouponOrders> PosCouponOrders { get; set; }
@@ -9814,12 +9815,61 @@ namespace MySystem.PxcModels
                 entity.Property(e => e.Version).HasColumnType("int(11)");
             });
 
+            modelBuilder.Entity<PosChannelSet>(entity =>
+            {
+                entity.HasComment("机具通道修改记录");
+
+                entity.Property(e => e.Id).HasColumnType("int(11)");
+
+                entity.Property(e => e.BrandId)
+                    .HasColumnType("int(11)")
+                    .HasComment("品牌");
+
+                entity.Property(e => e.ChannelNo)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("通道编号")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.CreateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("创建时间");
+
+                entity.Property(e => e.SnCount)
+                    .HasColumnType("int(11)")
+                    .HasComment("机具数");
+
+                entity.Property(e => e.Sort)
+                    .HasColumnType("int(11)")
+                    .HasComment("排序序号");
+
+                entity.Property(e => e.Status)
+                    .HasColumnType("int(11)")
+                    .HasComment("状态");
+
+                entity.Property(e => e.UpdateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("修改时间");
+
+                entity.Property(e => e.UserId)
+                    .HasColumnType("int(11)")
+                    .HasComment("创客Id");
+
+                entity.Property(e => e.Version)
+                    .HasColumnType("int(11)")
+                    .HasComment("版本号");
+            });
+
             modelBuilder.Entity<PosChannelSetRecord>(entity =>
             {
                 entity.HasComment("机具通道修改记录");
 
                 entity.Property(e => e.Id).HasColumnType("int(11)");
 
+                entity.Property(e => e.BrandId)
+                    .HasColumnType("int(11)")
+                    .HasComment("品牌");
+
                 entity.Property(e => e.ChannelNo)
                     .HasColumnType("varchar(50)")
                     .HasComment("通道编号")
@@ -9850,6 +9900,10 @@ namespace MySystem.PxcModels
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.RecordId)
+                    .HasColumnType("int(11)")
+                    .HasComment("记录Id");
+
                 entity.Property(e => e.Status)
                     .HasColumnType("int(11)")
                     .HasComment("状态");
@@ -9857,10 +9911,6 @@ namespace MySystem.PxcModels
                 entity.Property(e => e.UpdateDate)
                     .HasColumnType("datetime")
                     .HasComment("修改时间");
-
-                entity.Property(e => e.BrandId)
-                    .HasColumnType("int(11)")
-                    .HasComment("品牌");
             });
 
             modelBuilder.Entity<PosCouponForUser>(entity =>