فهرست منبع

添加电渠虚拟券

lcl 2 سال پیش
والد
کامیت
bc7fe7e7ed

+ 78 - 0
AppStart/TestHelper.cs

@@ -30,6 +30,11 @@ namespace MySystem
             Thread thread3 = new Thread(ImportPost3Do);
             thread3.IsBackground = true;
             thread3.Start();
+
+            
+            Thread thread3 = new Thread(ImportVirtualCard);
+            thread3.IsBackground = true;
+            thread3.Start();            
         }
 
         public void ImportPostDo()
@@ -135,5 +140,78 @@ namespace MySystem
                 function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "生成兑换券异常");
             }
         }
+
+        //生成虚拟广电卡SN
+        public void ImportVirtualCard()
+        {
+            while (true)
+            {
+                string data = RedisDbconn.Instance.RPop<string>("VirtualCardQueue");
+                if (!string.IsNullOrEmpty(data))
+                {
+                    int count = int.Parse(function.CheckInt(data));
+                    if (count > 0)
+                    {
+                        MakerVirtualCard(count);
+                    }
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+        public void MakerVirtualCard(int count = 0)
+        {
+            try
+            {
+                string BatchNo = DateTime.Now.ToString("yyyyMMddHHmmss");
+                WebCMSEntities db = new WebCMSEntities();
+                string StartCode = "CS00000000000001";
+                if(db.PosMachinesTwo.Any(m => m.BrandId == 14 && m.PosSn.StartsWith("CS")))
+                {
+                    StartCode = db.PosMachinesTwo.Where(m => m.BrandId == 14 && m.PosSn.StartsWith("CS")).OrderByDescending(m => m.Id).FirstOrDefault().PosSn;
+                }
+                string title = "CS";
+                int start = int.Parse(function.CheckInt(StartCode.Substring(2).TrimStart('0'))) + 1;
+                if (start > 0)
+                {
+                    int end = start + count - 1;
+                    for (int i = start; i <= end; i++)
+                    {
+                        string Code = i.ToString();
+                        for (int j = 0; j < 14 - i.ToString().Length; j++)
+                        {
+                            Code = "0" + Code;
+                        }
+                        Code = title + Code;
+                        bool check = db.PosMachinesTwo.Any(m => m.PosSn == Code);
+                        if (!check)
+                        {
+                            PosMachinesTwo pos = db.PosMachinesTwo.Add(new PosMachinesTwo()
+                            {
+                                CreateDate = DateTime.Now,
+                                PosSn = Code, //SN编号
+                                BrandId = 14, //产品类型
+                                StoreId = 8664, //所在仓库
+                                DeviceType = "dianqu", //设备类型
+                                BatchNo = BatchNo,
+                                DeviceName = "电渠",
+                                DeviceKind = "电渠虚拟",
+                                SourceStoreId = 8664, //源仓库
+                                CardType = 2,
+                                OutBatchNo = "线上",
+                            }).Entity;
+                            db.SaveChanges();
+                        }
+                    }
+                }
+                db.Dispose();
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "生成电渠广电虚拟卡异常");
+            }
+        }
     }
 }

+ 8 - 1
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -1557,7 +1557,14 @@ namespace MySystem.Areas.Admin.Controllers
             if (checkTime.AddHours(1) < DateTime.Now)
             {
                 RedisDbconn.Instance.Set("MakerCouponsQueueCheckTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
-                RedisDbconn.Instance.AddList("MakerCouponsQueue:" + Kind, Number);
+                if(Kind == 4)
+                {
+                    RedisDbconn.Instance.AddList("VirtualCardQueue", Number);
+                }
+                else
+                {
+                    RedisDbconn.Instance.AddList("MakerCouponsQueue:" + Kind, Number);
+                }
                 return "生成程序已执行";
             }
             return "请稍后再试";

+ 1 - 0
Areas/Admin/Views/MainServer/SysTools/MakeCoupons.cshtml

@@ -33,6 +33,7 @@
                                         <select id="Kind" name="Kind" lay-search="">
                                             <option value="1">电签券</option>
                                             <option value="2">大机券</option>
+                                            <option value="4">电渠虚拟SN</option>
                                         </select>
                                     </div>
                                 </div>