|
|
@@ -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(), "生成电渠广电虚拟卡异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|