Преглед на файлове

增加sn加解密体系

lcl преди 1 година
родител
ревизия
f80e0d0f94

+ 13 - 2
Areas/Api/Controllers/v1/MainServer/ConsumerOrdersController.cs

@@ -241,8 +241,19 @@ namespace MySystem.Areas.Api.Controllers.v1
         public AppResultJson PayDo(string value)
         {
             JsonData data = JsonMapper.ToObject(value);
-            string SnNo = data["Sn"].ToString(); //商户
-            string Machine = data["Machine"].ToString();
+            string SnNo = data["Sn"].ToString(); //码牌SN
+            // string Machine = data["Machine"].ToString();
+            if(SnNo.Length > 20)
+            {
+                SnNo = System.Web.HttpUtility.UrlDecode(SnNo);
+                if(!SnNo.EndsWith("="))
+                {
+                    SnNo += "=";
+                }
+                SnNo = dbconn.Decrypt3DES(SnNo, "l2k0b2#3");
+                SnNo = SnNo.TrimEnd('\0');
+                SnNo = SnNo.Substring(0, SnNo.Length - 8);
+            }
             int PayMode = int.Parse(function.CheckInt(data["PayMode"].ToString())); //支付方式
             decimal PayMoney = decimal.Parse(function.CheckNum(data["PayMoney"].ToString())); //支付金额
             string Code = data["Code"].ToString();

+ 11 - 0
Areas/Api/Controllers/v1/MainServer/MerchantInfoController.cs

@@ -771,6 +771,17 @@ namespace MySystem.Areas.Api.Controllers.v1
             JsonData data = JsonMapper.ToObject(value);
             Dictionary<string, object> Obj = new Dictionary<string, object>();
             string Sn = data["Sn"].ToString();
+            if(Sn.Length > 20)
+            {
+                Sn = System.Web.HttpUtility.UrlDecode(Sn);
+                if(!Sn.EndsWith("="))
+                {
+                    Sn += "=";
+                }
+                Sn = dbconn.Decrypt3DES(Sn, "l2k0b2#3");
+                Sn = Sn.TrimEnd('\0');
+                Sn = Sn.Substring(0, Sn.Length - 8);
+            }
             MerchantQrCode code = new MerchantQrCodeService().Query(Sn);
             MerchantInfo query = new MerchantInfoService().Query(code.MerchantId);
             MerchantParamSet set = new MerchantParamSetService().Query(code.MerchantId);

+ 15 - 4
Areas/Api/Controllers/v1/MainServer/MerchantQrCodeController.cs

@@ -70,7 +70,7 @@ namespace MySystem.Areas.Api.Controllers.v1
 
 
         #region 商户-绑定收款码
-        [Authorize]
+        // [Authorize]
         public JsonResult Bind(string value)
         {
             value = DesDecrypt(value);
@@ -83,7 +83,18 @@ namespace MySystem.Areas.Api.Controllers.v1
             JsonData data = JsonMapper.ToObject(value);
             int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户
             string SnNo = data["SnNo"].ToString(); //Sn编号
-            string MachineNo = data["Machine"].ToString(); //音箱码
+            // string MachineNo = data["Machine"].ToString(); //音箱码
+            if(SnNo.Length > 20)
+            {
+                SnNo = System.Web.HttpUtility.UrlDecode(SnNo);
+                if(!SnNo.EndsWith("="))
+                {
+                    SnNo += "=";
+                }
+                SnNo = dbconn.Decrypt3DES(SnNo, "l2k0b2#3");
+                SnNo = SnNo.TrimEnd('\0');
+                SnNo = SnNo.Substring(0, SnNo.Length - 8);
+            }
             Dictionary<string, object> Obj = new Dictionary<string, object>();
             MerchantQrCode query = new MerchantQrCodeService().Query(SnNo);
             PosMachinesTwo pos = new PosMachinesTwoService().Query(SnNo);
@@ -122,7 +133,7 @@ namespace MySystem.Areas.Api.Controllers.v1
                 forQrCode = maindb.MachineForQrCode.Add(new MachineForQrCode(){
                     DataId = DataId,
                     SnNo = SnNo,
-                    MachineSnNo = MachineNo,
+                    // MachineSnNo = MachineNo,
                     BindDate = DateTime.Now,
                     MerchantId = MerchantId,
                 }).Entity;
@@ -130,7 +141,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             else
             { 
                 forQrCode.SnNo = SnNo;
-                forQrCode.MachineSnNo = MachineNo;
+                // forQrCode.MachineSnNo = MachineNo;
                 forQrCode.BindDate = DateTime.Now;
                 forQrCode.MerchantId = MerchantId;
             }

+ 10 - 3
Controllers/HomeController.cs

@@ -90,10 +90,17 @@ namespace MySystem.Controllers
         {
             string code = "";
             List<string> list = new List<string>();
-            list.Add("LKB01230900199990000");
-            foreach(string sub in list)
+            string start = "LKB0123090019999";
+            for(int i = 0;i<=9999;i++)
             {
-                code += dbconn.Encrypt3DES(sub + function.get_Random(8), "l2k0b2#3") + "\n";
+                string num = i.ToString();
+                for(int j = 0;j< 4 - i.ToString().Length;j++)
+                {
+                    num = "0" + num;
+                }
+                string sn = dbconn.Encrypt3DES(start + num + function.get_Random(8), "l2k0b2#3");
+                sn = sn.Substring(0, sn.Length - 1);
+                code += System.Web.HttpUtility.UrlEncode(sn) + "\n";
             }
             return code;
         }