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

增加金控自备机恢复功能,并重置达标月份

lcl 1 жил өмнө
parent
commit
2ce43059bf

+ 2 - 2
AppStart/Helper/DepositReturnStatService.cs

@@ -88,7 +88,7 @@ namespace MySystem
             {
                 try
                 {
-                    string content = RedisDbconn.Instance.Get<string>("DepositReturnStatQueue");
+                    string content = RedisDbconn.Instance.RPop<string>("DepositReturnStatQueue");
                     if(!string.IsNullOrEmpty(content))
                     {
                         int MerchantId = int.Parse(function.CheckInt(content));
@@ -114,7 +114,7 @@ namespace MySystem
 
 
 
-        private void DoSomething(WebCMSEntities db, PosMerchantInfo merchant)
+        public void DoSomething(WebCMSEntities db, PosMerchantInfo merchant)
         {
             function.WriteLog("商户ID:" + merchant.Id, "每月统计押金达标情况");
             // string start = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");

+ 0 - 1
AppStart/Helper/SycnSpServer/SycnSpBindService.cs

@@ -192,7 +192,6 @@ namespace MySystem
                                 pos.BindingState = 1;
                                 pos.BindingTime = Bind.CreateTime;
                                 pos.Status = 0;
-                                pos.CardType = 2;
 
                                 string KindName = Bind.Remark; //商品类型名称
                                 string Name = Bind.Field3; //商品名称

+ 122 - 0
Controllers/HomeController.cs

@@ -301,5 +301,127 @@ namespace MySystem.Controllers
             return "ok";
         }
 
+    
+    
+    
+    
+        //金控自备机,补商户信息
+        public string jkmerinfo(string sn)
+        {
+            SpModels.WebCMSEntities spdb = new SpModels.WebCMSEntities();
+            PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+            var Bind = spdb.BindRecord.FirstOrDefault(m => m.MerSnNo == sn && m.Field1 == "解绑");
+            if (Bind != null)
+            {
+                PxcModels.MachineForSnNo posFor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == Bind.MerSnNo) ?? new PxcModels.MachineForSnNo();
+                PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == posFor.SnId);
+                if (pos != null)
+                {
+                    pos.BindingState = 1;
+                    pos.BindingTime = Bind.CreateTime;
+                    pos.Status = 0;
+
+                    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();
+
+                    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]);
+                    }
+                    int BrandId = pos.BrandId;
+                    
+                    PxcModels.TradeRecord trade = db.TradeRecord.FirstOrDefault(m => m.SnNo == sn) ?? new PxcModels.TradeRecord();
+                    PxcModels.PosMerchantInfo add = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == Bind.MerNo);
+                    if (add == null)
+                    {
+                        if(trade.MerchantId > 0)
+                        {
+                            add = db.PosMerchantInfo.Add(new PxcModels.PosMerchantInfo()
+                            {
+                                CreateDate = Bind.CreateTime,
+                                KqMerNo = Bind.MerNo,
+                                MerchantNo = Bind.MerNo.Length > 16 ? Bind.MerNo.Substring(0, 16) : Bind.MerNo,
+                                Id = trade.MerchantId,
+                            }).Entity;
+                            db.SaveChanges();
+                        }
+                        else
+                        {
+                            add = db.PosMerchantInfo.Add(new PxcModels.PosMerchantInfo()
+                            {
+                                CreateDate = Bind.CreateTime,
+                                KqMerNo = Bind.MerNo,
+                                MerchantNo = Bind.MerNo.Length > 16 ? Bind.MerNo.Substring(0, 16) : Bind.MerNo,
+                            }).Entity;
+                            db.SaveChanges();
+                        }
+                    }
+                    add.UpdateDate = Bind.UpdateTime;
+                    add.TopUserId = TopUserId;
+                    add.BrandId = BrandId;
+                    add.SnStoreId = pos.StoreId;
+                    add.SnType = pos.PosSnType;
+                    add.UserId = pos.UserId;
+                    add.MerStatus = 1;
+                    add.KqSnNo = Bind.MerSnNo;
+                    add.MerIdcardNo = function.CheckNull(Bind.SeoKeyword).ToUpper();
+                    add.MerRealName = Bind.MerName;
+                    add.MerchantMobile = Bind.MerNewSnNo;
+                    add.MerchantName = Bind.MerName;
+                    pos.BindMerchantId = add.Id;
+                    pos.LastMerchantId = add.Id;
+                    db.SaveChanges();
+                    RedisDbconn.Instance.AddList("DepositReturnStatQueue", add.Id.ToString());
+                    PxcModels.Users buser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new PxcModels.Users();
+                    if(buser.BusinessFlag == 1)
+                    {
+                        bool checkMer = db.BusinessPartnerMerchant.Any(m => m.MerchantId == add.Id);
+                        if(!checkMer)
+                        {
+                            PxcModels.BusinessPartnerPos bpos = db.BusinessPartnerPos.FirstOrDefault(m => m.PosId == pos.Id) ?? new PxcModels.BusinessPartnerPos();
+                            db.BusinessPartnerMerchant.Add(new PxcModels.BusinessPartnerMerchant()
+                            {
+                                CreateDate = DateTime.Now,
+                                MerNo = Bind.MerNo,
+                                MerchantId = add.Id,
+                                PartnerId = bpos.PartnerId,
+                                UserId = pos.BuyUserId,
+                            });
+                            db.SaveChanges();
+                        }
+                    }
+                }
+            }
+            spdb.Dispose();
+            db.Dispose();
+            return "ok";
+        }
+
+        public string sycnTrade(int Id)
+        {
+            PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+            PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == Id);
+            if(merchant != null)
+            {
+                DepositReturnStatService.Instance.DoSomething(db, merchant);
+            }
+            return "ok";
+        }
+    
+    
     }
 }