Kaynağa Gözat

推送好哒商户信息

lcl 7 ay önce
ebeveyn
işleme
8ca7f966d9
3 değiştirilmiş dosya ile 97 ekleme ve 0 silme
  1. 37 0
      Util/EncryptHelper.cs
  2. 16 0
      Util/HaoDa/CheckWeChatSignService.cs
  3. 44 0
      Util/PushHelper.cs

+ 37 - 0
Util/EncryptHelper.cs

@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using Library;
+using System.Text;
+
+namespace MySystem
+{
+    public class EncryptHelper
+    {
+
+        public static string Encrypt1(SortedList<string, string> obj, string key)
+        {
+            string signstr = function.BuildQueryString(obj) + key;
+            string sign = function.MD532(signstr).ToUpper();
+            obj.Add("sign", sign);
+            return AesEncrypt(Newtonsoft.Json.JsonConvert.SerializeObject(obj), key);
+        }
+
+        public static string AesEncrypt(string str, string key)
+        {
+            if (string.IsNullOrEmpty(str)) return null;
+            Byte[] toEncryptArray = Encoding.UTF8.GetBytes(str);
+
+            System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged
+            {
+                Key = Encoding.UTF8.GetBytes(key),
+                Mode = System.Security.Cryptography.CipherMode.ECB,
+                Padding = System.Security.Cryptography.PaddingMode.PKCS7
+            };
+            System.Security.Cryptography.ICryptoTransform cTransform = rm.CreateEncryptor();
+            Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
+            return Convert.ToBase64String(resultArray, 0, resultArray.Length);
+        }
+
+        
+    }
+}

+ 16 - 0
Util/HaoDa/CheckWeChatSignService.cs

@@ -181,6 +181,22 @@ namespace MySystem
                             db1.SaveChanges();
                         }
                         db1.Dispose();
+
+                        if (merchantadd.BrandId == 1)
+                        {
+                            SortedList<string, string> obj = new SortedList<string, string>();
+                            obj.Add("bind_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
+                            obj.Add("merch_no", merchantadd.MchtNo);
+                            obj.Add("name", merchantadd.CertMerchantName);
+                            string IdCardNumber = merchantadd.IdCardNumber;
+                            if(!string.IsNullOrEmpty(IdCardNumber))
+                            {
+                                IdCardNumber = IdCardNumber.Substring(0, 6) + "**********" + IdCardNumber.Substring(IdCardNumber.Length - 4);
+                            }
+                            obj.Add("supplement_info", IdCardNumber);
+                            obj.Add("mobile", merchantadd.MobilePhone);
+                            PushHelper.Instance.Do(obj);
+                        }
                     }
                 }
                 //审核被拒绝

+ 44 - 0
Util/PushHelper.cs

@@ -0,0 +1,44 @@
+using System;
+using System.Linq;
+using System.Data;
+using System.Threading;
+using Library;
+using LitJson;
+using MySystem.Models.Push;
+using System.Collections.Generic;
+
+namespace MySystem
+{   
+    public class PushHelper
+    {
+        public readonly static PushHelper Instance = new PushHelper();
+        private PushHelper()
+        {
+        }
+
+        string NoticeUrl = "http://cybsp.888cyb.com/v1/cybsp/bindChangeNotify/hd";
+        string AesSecret = "kvS4TIRh7Yulg4nr";
+
+        //要执行的方法
+        public void Do(SortedList<string, string> obj)
+        {
+            string PushData = "";
+            string PushDataEncrypt = "";
+            PushData = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
+            LogHelper.Instance.WriteLog("原始数据:" + PushData, "好哒推送数据日志");
+            string content = EncryptHelper.Encrypt1(obj, AesSecret);
+            LogHelper.Instance.WriteLog("加密数据:" + content, "好哒推送数据日志");
+            obj = new SortedList<string, string>();
+            obj.Add("type", "好哒商户绑定信息");
+            obj.Add("notice_id", Guid.NewGuid().ToString());
+            obj.Add("timestamp", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8));
+            obj.Add("content", content);
+            string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
+            PushDataEncrypt = requestJson;
+            LogHelper.Instance.WriteLog("请求参数:" + PushDataEncrypt, "好哒推送数据日志");
+            LogHelper.Instance.WriteLog("请求地址:" + NoticeUrl, "好哒推送数据日志");
+            string result = function.PostWebRequest(NoticeUrl, requestJson, "application/json");
+            LogHelper.Instance.WriteLog("返回报文:" + result + "\n\n", "好哒推送数据日志");
+        }        
+    }
+}