Forráskód Böngészése

合并代码,删除冗余代码

DuGuYang 1 éve
szülő
commit
9604f54b93
26 módosított fájl, 2279 hozzáadás és 288 törlés
  1. 0 250
      Areas/Api/Controllers/PublicMethodController.cs
  2. 53 0
      Areas/Api/Controllers/v1/PublicMethodController.cs
  3. 1 1
      Program.cs
  4. 1 1
      Properties/launchSettings.json
  5. 13 3
      Startup.cs
  6. 112 0
      Util/HaoDa/Alipay/AliIotFunction.cs
  7. 102 0
      Util/HaoDa/Alipay/Base/AopDictionary.cs
  8. 191 0
      Util/HaoDa/Alipay/Base/AopModelParser.cs
  9. 90 0
      Util/HaoDa/Alipay/Base/RoyaltyDetail.cs
  10. 24 0
      Util/HaoDa/Alipay/Domain/IndirectAuthOrderFailedReason.cs
  11. 123 0
      Util/HaoDa/Alipay/Request/AlipayCommerceIotDeviceTradevoiceSendRequest.cs
  12. 123 0
      Util/HaoDa/Alipay/Request/AlipayMerchantIndirectAuthorderCreateRequest.cs
  13. 123 0
      Util/HaoDa/Alipay/Request/AlipayMerchantIndirectAuthorderQuerystatusRequest.cs
  14. 123 0
      Util/HaoDa/Alipay/Request/AlipayMerchantIndirectIotBindRequest.cs
  15. 139 0
      Util/HaoDa/Alipay/Request/AntMerchantExpandIndirectImageUploadRequest.cs
  16. 12 0
      Util/HaoDa/Alipay/Response/AlipayCommerceIotDeviceTradevoiceSendResponse.cs
  17. 23 0
      Util/HaoDa/Alipay/Response/AlipayMerchantIndirectAuthorderCreateResponse.cs
  18. 38 0
      Util/HaoDa/Alipay/Response/AlipayMerchantIndirectAuthorderQuerystatusResponse.cs
  19. 12 0
      Util/HaoDa/Alipay/Response/AlipayMerchantIndirectIotBindResponse.cs
  20. 17 0
      Util/HaoDa/Alipay/Response/AntMerchantExpandIndirectImageUploadResponse.cs
  21. 184 0
      Util/HaoDa/AlipayFunctionForHD.cs
  22. 126 0
      Util/HaoDa/HaoDaExtHelper.cs
  23. 155 0
      Util/HaoDa/HaoDaExtQueryHelper.cs
  24. 8 4
      Util/HaoDa/HaoDaHelper.cs
  25. 18 29
      Util/HaoDa/MerchantConfirmService.cs
  26. 468 0
      Util/HaoDa/WeChatFunctionForHD.cs

+ 0 - 250
Areas/Api/Controllers/PublicMethodController.cs

@@ -1,250 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Http;
-using System.DrawingCore.Imaging;
-using System.IO;
-using Library;
-using System.Collections;
-using LitJson;
-using System.Globalization;
-using System.Web;
-
-namespace MySystem.Areas.Api.Controllers
-{
-    [Area("Api")]
-    [Route("Api/[controller]/[action]")]
-    public class PublicMethodController : BaseController
-    {
-        public PublicMethodController(IHttpContextAccessor accessor) : base(accessor)
-        {
-        }
-        #region 图片验证码
-        public FileContentResult CheckCode()
-        {
-            string code = function.get_Random(4);
-            var bitmap = VerifyCodeHelper.GetSingleObj().CreateBitmapByImgVerifyCode(code, 120, 40);
-            MemoryStream stream = new MemoryStream();
-            bitmap.Save(stream, ImageFormat.Gif);
-            function.WriteCookie(_accessor.HttpContext, "checkcode", code);
-            return File(stream.ToArray(), "image/gif");
-        }
-        #endregion
-        
-        #region 图片验证码
-        public FileContentResult PictureCode(string Tag = "")
-        {
-            string code = function.get_Random(4);
-            var bitmap = VerifyCodeHelper.GetSingleObj().CreateBitmapByImgVerifyCode(code, 120, 40);
-            MemoryStream stream = new MemoryStream();
-            bitmap.Save(stream, ImageFormat.Gif);
-            RedisDbconn.Instance.Set(Tag, code);
-            RedisDbconn.Instance.SetExpire(Tag, 600);
-            return File(stream.ToArray(), "image/jpg");
-        }
-        #endregion
-
-
-
-        #region 编辑器上传图片
-
-        public object EditorUpload([FromForm] IFormCollection rf)
-        {
-            //文件保存目录路径
-            String savePath = "/up/v2/";
-
-            //文件保存目录URL
-            String saveUrl = "/up/v2/";
-
-            //定义允许上传的文件扩展名
-            Hashtable extTable = new Hashtable();
-            extTable.Add("image", "gif,jpg,jpeg,png,bmp");
-            extTable.Add("flash", "swf,flv");
-            extTable.Add("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb,mp4");
-            extTable.Add("file", "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2");
-
-            //最大文件大小
-            long maxSize = 1073741824000;
-
-            IFormFile imgFile = rf.Files["imgFile"];
-            if (imgFile == null)
-            {
-                showError("请选择文件。");
-            }
-
-            String dirPath = function.getPath(AppConfig.Oss.PathName + savePath);
-            if (!Directory.Exists(dirPath))
-            {
-                //showError("上传目录不存在。");
-                Directory.CreateDirectory(dirPath);
-            }
-
-            String fileName = imgFile.FileName;
-            String dirName = "";
-            if (String.IsNullOrEmpty(dirName))
-            {
-                if (fileName.ToLower().EndsWith(".mp4") || fileName.ToLower().EndsWith(".mp3"))
-                {
-                    dirName = "media";
-                }
-                else
-                {
-                    dirName = "image";
-                }
-            }
-            if (!extTable.ContainsKey(dirName))
-            {
-                showError("目录名不正确。");
-            }
-
-            String fileExt = Path.GetExtension(fileName).ToLower();
-
-            if (imgFile.Length > maxSize)
-            {
-                showError("上传文件大小超过限制。");
-            }
-
-            if (String.IsNullOrEmpty(fileExt) || Array.IndexOf(((String)extTable[dirName]).Split(','), fileExt.Substring(1).ToLower()) == -1)
-            {
-                showError("上传文件扩展名是不允许的扩展名。\n只允许" + ((String)extTable[dirName]) + "格式。");
-            }
-
-            //创建文件夹
-            dirPath += dirName + "/";
-            saveUrl += dirName + "/";
-            if (!Directory.Exists(dirPath))
-            {
-                Directory.CreateDirectory(dirPath);
-            }
-            String ymd = DateTime.Now.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo);
-            dirPath += ymd + "/";
-            saveUrl += ymd + "/";
-            if (!Directory.Exists(dirPath))
-            {
-                Directory.CreateDirectory(dirPath);
-            }
-            String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt;
-            String filePath = dirPath + newFileName;
-            using var fs = new FileStream(filePath, FileMode.Create);
-            imgFile.CopyTo(fs);
-            String fileUrl = saveUrl + newFileName;
-            if (dirName != "media")
-            {
-                if (!function.check_pic(filePath))
-                {
-                    System.IO.File.Delete(filePath);
-                    return null;
-                }
-                if (function.getImgRule(filePath)["width"] > 2000)
-                {
-                    String newFileName_sl = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + "_sl" + fileExt;
-                    function.imgcut(2000, filePath, dirPath + newFileName_sl);
-                    System.IO.File.Delete(filePath);
-                    fileUrl = saveUrl + newFileName_sl;
-                }
-            }
-
-            Hashtable hash = new Hashtable();
-            hash["error"] = 0;
-            hash["url"] = AppConfig.Oss.SourceHost + "/" + AppConfig.Oss.PathName + fileUrl;
-            OssHelper.Instance.ScanQueue(fileUrl, "");
-            return JsonMapper.ToJson(hash);
-        }
-
-        private object showError(string message)
-        {
-            Hashtable hash = new Hashtable();
-            hash["error"] = 1;
-            hash["message"] = message;
-            return JsonMapper.ToJson(hash);
-        }
-
-        public bool IsReusable
-        {
-            get
-            {
-                return false;
-            }
-        }
-
-
-
-        #endregion
-
-        #region 系统-上传文件
-
-        public JsonResult UploadFile([FromForm] IFormCollection rf)
-        {
-            IFormFile imgFile = rf.Files["file"];
-            string path = MySystemLib.SystemPublicFuction.GetFilePath(imgFile, AppConfig.Oss.PathName + "/uploadfile/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/");
-            OssHelper.Instance.ScanQueue(path, "");
-            Dictionary<string, string> obj = new Dictionary<string, string>();
-            obj.Add("FileName", path);
-            return Json(obj);
-        }
-
-        #endregion
-
-        #region 系统-上传图片
-        public JsonResult UploadPhoto([FromForm] IFormCollection rf)
-        {
-            IFormFile imgFile = rf.Files["Icon"];
-            string Icon = MySystemLib.SystemPublicFuction.GetPicPath(imgFile, AppConfig.Oss.PathName + "/upload/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/");
-            OssHelper.Instance.ScanQueue(Icon, "");
-            return Json(new AppResultJson() { Status = "1", Info = "", Data = Icon });
-        }
-
-        #endregion
-
-        #region 系统-上传图片
-        public JsonResult UploadPhotoByBase64(string value)
-        {
-            value = value.Replace("data:image/png;base64,", "");
-            string base64str = HttpUtility.UrlDecode(value).Replace(" ", "+");
-            string dummyData = base64str.Replace("%", "").Replace(",", "").Replace(" ", "+");
-            if (dummyData.Length % 4 > 0)
-            {
-                dummyData = dummyData.PadRight(dummyData.Length + 4 - dummyData.Length % 4, '=');
-            }
-            string Icon = function.base64StringToImage(dummyData, "/" + AppConfig.Oss.PathName + "/upload/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/", "MT" + function.MD5_16(Guid.NewGuid().ToString()) + ".png");
-            // OssHelper.Instance.ScanQueue(Icon, "");
-            return Json(new AppResultJson() { Status = "1", Info = "", Data = Icon });
-        }
-        #endregion
-
-        #region 系统-layui上传文件
-        public JsonResult LayUIUpload([FromForm] IFormCollection rf, string Path = "", string Resize = "")
-        {
-            IFormFile imgFile = rf.Files[0];
-            string Icon = MySystemLib.SystemPublicFuction.GetFilePath(imgFile, Path + "/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/",false);
-            string piccut = "";
-            if (!string.IsNullOrEmpty(Resize) && (imgFile.FileName.ToLower().EndsWith(".png") || imgFile.FileName.EndsWith(".jpg")))
-            {
-                JsonData data = JsonMapper.ToObject(Resize);
-                int width = int.Parse(data["width"].ToString());
-                int height = int.Parse(data["height"].ToString());
-                int quality = int.Parse(data["quality"].ToString());
-                piccut = Icon.Replace(".", "s.");
-                function.imgcut2(width, height, function.getPath(Icon), function.getPath(piccut));
-                System.IO.File.Delete(function.getPath(Icon));
-            }
-            else
-            { 
-                piccut = Icon;
-            }
-            return Json(new AppResultJson() { Status = "1", Info = "", Data = piccut });
-        }
-
-        #endregion
-
-        #region 图片转base64
-
-        public string ImgToBase64(string path)
-        {
-            path = HttpUtility.UrlDecode(path);
-            return function.imageToBase64String(function.getPath(path));
-        }
-
-        #endregion
-    }
-}

+ 53 - 0
Areas/Api/Controllers/v1/PublicMethodController.cs

@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using System.DrawingCore.Imaging;
+using System.IO;
+using Library;
+using System.Collections;
+using LitJson;
+using System.Globalization;
+using System.Web;
+
+// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
+
+namespace MySystem.Areas.Api.Controllers
+{
+    [Area("Api")]
+    [Route("Api/[controller]/[action]")]
+    public class PublicMethodController : BaseController
+    {
+        public PublicMethodController(IHttpContextAccessor accessor) : base(accessor)
+        {
+        }
+
+        #region 系统-上传图片
+        public JsonResult UploadPhotoByBase64(string value)
+        {
+            try
+            {
+                value = value.Replace("data:image/png;base64,", "");
+                string base64str = HttpUtility.UrlDecode(value).Replace(" ", "+");
+                string dummyData = base64str.Replace("%", "").Replace(",", "").Replace(" ", "+");
+                if (dummyData.Length % 4 > 0)
+                {
+                    dummyData = dummyData.PadRight(dummyData.Length + 4 - dummyData.Length % 4, '=');
+                }
+                string Icon = function.base64StringToImage(dummyData, "/static/upload/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/", "MT" + function.MD5_16(Guid.NewGuid().ToString()) + ".png");
+                return Json(new AppResultJson() { Status = "1", Info = "", Data = Icon });
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now + ":" + ex.ToString(), "系统上传图片异常");
+                return Json(new AppResultJson() { Status = "1", Info = "", Data = "" });
+            }
+        }
+        #endregion
+
+    }
+}

+ 1 - 1
Program.cs

@@ -22,7 +22,7 @@ namespace MySystem
                 .ConfigureWebHostDefaults(webBuilder =>
                 {
                     webBuilder
-                    .UseUrls("http://*:5501")
+                    .UseUrls("http://*:5601")
                     .UseKestrel()
                     .UseContentRoot(Directory.GetCurrentDirectory())
                     .UseIISIntegration()

+ 1 - 1
Properties/launchSettings.json

@@ -21,7 +21,7 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       },
-      "applicationUrl": "http://127.0.0.1:5501"
+      "applicationUrl": "http://127.0.0.1:5601"
     }
   }
 }

+ 13 - 3
Startup.cs

@@ -109,6 +109,11 @@ namespace MySystem
 
             app.UseStaticFiles();
             app.UseStaticFiles(new StaticFileOptions
+            {
+                FileProvider = new PhysicalFileProvider(AppContext.BaseDirectory + "/static"),
+                RequestPath = "/static"
+            });
+            app.UseStaticFiles(new StaticFileOptions
             {
                 ContentTypeProvider = new FileExtensionContentTypeProvider(new Dictionary<string, string>
                 {
@@ -130,9 +135,14 @@ namespace MySystem
             });
 
             initMainServer();
-            // MerchantConfirmService.Instance.Start(); //提交商户进件
-            // CheckWeChatSignService.Instance.Start(); //查询商户审核状态
-            TestOpenDivideAccountsService.Instance.Start(); //测试
+            MerchantConfirmService.Instance.Start(); //提交商户进件
+            CheckWeChatSignService.Instance.Start(); //查询商户审核状态
+            ProfitShareService.Instance.Start(); //分账
+            // TestOpenDivideAccountsService.Instance.Start(); //测试
+            HaoDaExtHelper.Instance.StartWeChat();
+            HaoDaExtHelper.Instance.StartAlipay();
+            HaoDaExtQueryHelper.Instance.StartWeChat();
+            HaoDaExtQueryHelper.Instance.StartAlipay();
         }
 
         //初始化数据结构

+ 112 - 0
Util/HaoDa/Alipay/AliIotFunction.cs

@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using Aop.Api;
+using Library;
+using Microsoft.AspNetCore.Http;
+using Aop.Api.Request;
+using Aop.Api.Response;
+using Aop.Api.Util;
+using MySystem.Models;
+using System.Linq;
+
+namespace MySystem
+{
+    public class AliIotFunction
+    {
+        public readonly static AliIotFunction Instance = new AliIotFunction();
+        private AliIotFunction()
+        { }
+
+        // public string Pid = "2088720140260314";
+        private string AppId = "2021004109682585";
+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GAdJ+v6GAzt56JETLvUQ6XLnAkguwDyyOINCQKZdMiYgX3qwluWdtiBujKXPxbuya4pW8TjfFJyhZLBh38K8JJ4jReb1QowN0im289OGnxBCj9bQKh2ZPJH9hH4sk0bvpvpZidjcGx2+lGZr3ckNifASFpwcJTnCkpRzqkhXhuKJUCgYEAmh3iiB7VlXboMaTVygrO4JSZZf4G47aG1h05JM/zbHnZR4j1nZqAuqejNYP0Mo8RD+29100LLTd38E5UY9TZRKGhv9r5PVuSiEVKFJFWzFPxzued4xnGkNmJlZDm6s8EH3AcpxOsCqu1POGtM8umyR/pENP74j4rGNFH5eP+PYcCgYA84Die07zXP31rfOWWabjDMaq4bPMH9drzhjXdMYaFH3T6F1Ba52Iqsk5K526RdPM6eeR1dFPPotNhZMJPmg1PALNSjVBmKnklF+/y6c4eFOiUgTS/wyNpSlr/eKECsWPch9UlAkkIos5lq02pVAv4kK9WumSyXDe5Gu6a5pUC1A==";
+        private string PublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvf75JGQL9IDg8xu2C6qWrIO3H4roSwpvwUeh6y2kQ8iH0gqQXlyLj13ku8pzY1H9JTSeARCsHSD/VJFxMoPOBO+/xGDV3CSdxhOE5Fu5E30ZZMA5XmnMKyN8q+MEh7refGuCmldedTmzr9mNw4HDjS1uqJoqYRl3eUEaC/Syl620iiaSh7Q9/rsT/qNcnP5hO9P3DWionNt78elmjLt0sBdBkQ10o2XwC5RuzBfP8DCBEdL/DPOOE4vtmLP1IdDI7qtjBhX8PdL+/IRxe/4OGvYSPnHW7JNlN970h2UN5i0Yu0AkidJvlS59nX9C1WJ4U37HiMnkMNXLB/Ubi5BkgQIDAQAB";
+        public string AlipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiXVtTk6opnYllnH/X40k/jSw/82WZ+lGbYQLYH/nVONFJ7Gr9C/dlKpJFIbS+vNDn+YLtM923KmEVSgf8zU0WrTkRjWvKEiyLswWZVqSZW5Jfon1e2SfjNrAVi6XBZa7urAItKQsdD2vFFuyG/ohlXBL103xC1wnjvECD/iholoruEFOLyfobJKTY/6iyrKeOElem1V7OWl6gdjG2oozj3nbVZhtkQvPJECYlolH96eK2mieTkFK82aZ5Tdzx1LPk/3hxRAmzz/9X7xfXdOly88hKBmW8LC9RhTlOWbrXJhhFz13A4brnbnOiY/X7b2OkAYifammc2uh0AIJlCmBTQIDAQAB";
+        //"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB";
+
+
+        #region 间连iot设备和间连商户绑定
+        public string IotBind(string Smid, string DeviceId)
+        {            
+            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
+            AlipayMerchantIndirectIotBindRequest  request = new AlipayMerchantIndirectIotBindRequest() ;
+            request.BizContent="{" +
+            "  \"smid\":\"" + Smid + "\"," +
+            "  \"mode\":\"ALIYUN\"," +
+            "  \"device_id\":\"" + DeviceId + "\"" +
+            // "  \"supplier_id\":\"2022043454334\"" +
+            "}";
+            function.WriteLog(request.BizContent, "间连iot设备和间连商户绑定");
+
+            string result = "";
+            try
+            {
+                AlipayMerchantIndirectIotBindResponse response=client.Execute(request);
+                result = response.Body;
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(ex.ToString(), "间连iot设备和间连商户绑定异常");
+                result = "";
+            }
+            return result;
+        }
+
+        #endregion
+
+        #region 到账播报
+        public string IotTradeVoice(string BizTid, string Smid, string Amount, string TradeType = "ALIPAY_TRADE")
+        {
+            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
+            AlipayCommerceIotDeviceTradevoiceSendRequest  request= new AlipayCommerceIotDeviceTradevoiceSendRequest() ;
+            request.BizContent="{" +
+            "  \"biz_tid\":\"" + BizTid + "\"," +
+            "  \"smid\":\"" + Smid + "\"," +
+            "  \"trade_type\":\"" + TradeType + "\"," +
+            // "  \"trade_id\":\"5404dd23186a-4e62967a3bf0458cd3f4\"," +
+            "  \"amount\":\"" + Amount + "\"" +
+            // "  \"msg_id\":\"202108020001101043\"" +
+            "}";
+            function.WriteLog(request.BizContent, "到账播报");
+
+            string result = "";
+            try
+            {
+                AlipayCommerceIotDeviceTradevoiceSendResponse response=client.Execute(request);
+                result = response.Body;
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(ex.ToString(), "到账播报异常");
+                result = "";
+            }
+            return result;
+        }
+
+        #endregion
+
+        #region 图片上传
+
+        public string UploadPic(string path)
+        {
+            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
+            string fileName = path.Substring(path.LastIndexOf("/") + 1);
+            string imageBase64 = function.imageToBase64String(function.getPath(path));
+            // imageBase64 = imageBase64.Substring(imageBase64.IndexOf(";base64,") + 8);
+            AntMerchantExpandIndirectImageUploadRequest request = new AntMerchantExpandIndirectImageUploadRequest();
+            FileItem imageContent = new FileItem(fileName,Convert.FromBase64String(imageBase64));
+            request.ImageContent = imageContent;
+            request.ImageType = "jpg";
+            AntMerchantExpandIndirectImageUploadResponse response = client.Execute(request);
+            return fileName;
+        }
+
+        #endregion
+
+
+
+
+
+
+    }
+}

+ 102 - 0
Util/HaoDa/Alipay/Base/AopDictionary.cs

@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Collections;
+using Aop.Api.Parser;
+using Newtonsoft.Json;
+
+namespace Aop.Api
+{
+    /// <summary>
+    /// 符合AOP习惯的纯字符串字典结构。
+    /// </summary>
+    public class AopDictionary : Dictionary<string, string>
+    {
+        private const string DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+        public AopDictionary() { }
+
+        public AopDictionary(IDictionary<string, string> dictionary)
+            : base(dictionary)
+        { }
+
+        public void AddAll(Dictionary<string, string> textParams)
+        {
+            foreach (var param in textParams)
+            {
+                this.Add(param.Key, param.Value);
+            }
+        }
+
+        /// <summary>
+        /// 添加一个新的键值对。空键或者空值的键值对将会被忽略。
+        /// </summary>
+        /// <param name="key">键名称</param>
+        /// <param name="value">键对应的值,目前支持:string, int, long, double, bool, DateTime类型</param>
+        public void Add(string key, object value)
+        {
+            string strValue;
+
+            if (value == null)
+            {
+                strValue = null;
+            }
+            else if (value is string)
+            {
+                strValue = (string)value;
+            }
+            else if (value is Nullable<DateTime>)
+            {
+                Nullable<DateTime> dateTime = value as Nullable<DateTime>;
+                strValue = dateTime.Value.ToString(DATE_TIME_FORMAT);
+            }
+            else if (value is Nullable<int>)
+            {
+                strValue = (value as Nullable<int>).Value.ToString();
+            }
+            else if (value is Nullable<long>)
+            {
+                strValue = (value as Nullable<long>).Value.ToString();
+            }
+            else if (value is Nullable<double>)
+            {
+                strValue = (value as Nullable<double>).Value.ToString();
+            }
+            else if (value is Nullable<bool>)
+            {
+                strValue = (value as Nullable<bool>).Value.ToString().ToLower();
+            }
+            else if (value is ICollection)
+            {
+                Aop.Api2.Parser.AopModelParser parser = new Aop.Api2.Parser.AopModelParser();
+                object jo = parser.serializeArrayValue(value as ICollection);
+
+                JsonSerializerSettings jsetting = new JsonSerializerSettings();
+                jsetting.NullValueHandling = NullValueHandling.Ignore;
+                strValue = JsonConvert.SerializeObject(jo, Formatting.None, jsetting);
+            }
+            else if (value is AopObject)
+            {
+                AopModelParser parser = new AopModelParser();
+                object jo = parser.serializeAopObject(value as AopObject);
+
+                JsonSerializerSettings jsetting = new JsonSerializerSettings();
+                jsetting.NullValueHandling = NullValueHandling.Ignore;
+                strValue = JsonConvert.SerializeObject(jo, Formatting.None, jsetting);
+            }
+            else
+            {
+                strValue = value.ToString();
+            }
+
+            this.Add(key, strValue);
+        }
+
+        public new void Add(string key, string value)
+        {
+            if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
+            {
+                base.Add(key, value);
+            }
+        }
+    }
+}

+ 191 - 0
Util/HaoDa/Alipay/Base/AopModelParser.cs

@@ -0,0 +1,191 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Aop.Api;
+using System.Reflection;
+using System.Collections;
+using System.Xml.Serialization;
+using Newtonsoft.Json;
+
+namespace Aop.Api2.Parser
+{
+    public class AopModelParser
+    {
+
+        /// <summary>
+        /// Json序列化AopObject对象
+        /// </summary>
+        /// <param name="res"></param>
+        /// <returns></returns>
+        public IDictionary<object, object> serializeAopObject(AopObject res)
+        {
+            PropertyInfo[] pis = res.GetType().GetProperties();
+            IDictionary<object, object> jo = new Dictionary<object, object>();
+            foreach (PropertyInfo pi in pis)
+            {
+                if (!pi.CanRead)
+                {
+                    continue;
+                }
+
+                String elementName = getElementName(pi);
+                Object value = getPiValue(res, pi);
+                if (!String.IsNullOrEmpty(elementName))
+                {
+                    Object serialized = serializeValue(value);
+                    if (serialized != null)
+                    {
+                        jo[elementName] = serialized;
+                    }
+                }
+            }
+
+            return jo;
+        }
+
+        /// <summary>
+        /// 序列化某个对象
+        /// </summary>
+        /// <param name="value"></param>
+        /// <returns></returns>
+        private Object serializeValue(Object value)
+        {
+            if (value == null)
+            {
+                return null;
+            }
+
+            Object result = null;
+            if (value is IDictionary)
+            {
+                result = serializeDicValue((IDictionary)value);
+            }
+            else if (value is ICollection)
+            {
+                result = serializeArrayValue((ICollection)value);
+            }
+            else
+            {
+                result = serializeElementValue(value);
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 序列化一个元素
+        /// </summary>
+        /// <param name="value"></param>
+        /// <returns></returns>
+        private Object serializeElementValue(Object value)
+        {
+            if (value == null)
+            {
+                return null;
+            }
+
+            Object result = null;
+            if (value is AopObject)
+            {
+                result = serializeAopObject((AopObject)value);
+            }
+            else
+            {
+                result = value;
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 序列化一个字典
+        /// </summary>
+        /// <param name="dic"></param>
+        /// <returns></returns>
+        private Object serializeDicValue(IDictionary dic)
+        {
+            if (dic == null)
+            {
+                return null;
+            }
+
+            IDictionary<object, object> jo = new Dictionary<object, object>();
+            foreach (String key in dic.Keys)
+            {
+                Object dicValue = dic[key];
+                Object serializedValue = serializeValue(dicValue);
+                jo[key] = serializedValue;
+            }
+            return jo;
+        }
+
+        /// <summary>
+        /// 序列化一个数组
+        /// </summary>
+        /// <param name="collection"></param>
+        /// <returns></returns>
+        public Object serializeArrayValue(ICollection collection)
+        {
+            if (collection == null)
+            {
+                return null;
+            }
+
+            List<object> ja = new List<object>();
+            foreach (var item in collection)
+            {
+                ja.Add(serializeValue(item));
+            }
+            return ja;
+        }
+
+        /// <summary>
+        /// 获取对象的属性值
+        /// </summary>
+        /// <param name="res"></param>
+        /// <param name="pi"></param>
+        /// <returns></returns>
+        private Object getPiValue(Object res, PropertyInfo pi)
+        {
+            if (!pi.CanRead)
+            {
+                return null;
+            }
+
+            Object value = pi.GetValue(res, null);
+            return value;
+        }
+
+        /// <summary>
+        /// 获取Xml属性名
+        /// </summary>
+        /// <param name="pi"></param>
+        /// <returns></returns>
+        private String getElementName(PropertyInfo pi)
+        {
+            if (pi == null)
+            {
+                return null;
+            }
+
+            // 获取XmlElement属性
+            XmlElementAttribute[] xeas = pi.GetCustomAttributes(typeof(XmlElementAttribute), true) as XmlElementAttribute[];
+            String elementName = null;
+            if (xeas != null && xeas.Length > 0)
+            {
+                elementName = xeas[0].ElementName;
+            }
+
+            // 如果获取XmlElement属性为空,则去获取XmlArray属性
+            if (String.IsNullOrEmpty(elementName))
+            {
+                XmlArrayAttribute[] xaas = pi.GetCustomAttributes(typeof(XmlArrayAttribute), true) as XmlArrayAttribute[];
+                if (xaas != null && xaas.Length > 0)
+                {
+                    elementName = xaas[0].ElementName;
+                }
+            }
+            return elementName;
+        }
+
+    }
+}

+ 90 - 0
Util/HaoDa/Alipay/Base/RoyaltyDetail.cs

@@ -0,0 +1,90 @@
+using System;
+using System.Xml.Serialization;
+
+namespace Aop.Api.Domain
+{
+    /// <summary>
+    /// RoyaltyDetail Data Structure.
+    /// </summary>
+    [Serializable]
+    public class RoyaltyDetail : AopObject
+    {
+        /// <summary>
+        /// 分账金额
+        /// </summary>
+        [XmlElement("amount")]
+        public string Amount { get; set; }
+
+        /// <summary>
+        /// 支付宝分账明细单号,每笔分账业务执行的明细单号
+        /// </summary>
+        [XmlElement("detail_id")]
+        public string DetailId { get; set; }
+
+        /// <summary>
+        /// 分账失败错误码,只在分账失败时返回
+        /// </summary>
+        [XmlElement("error_code")]
+        public string ErrorCode { get; set; }
+
+        /// <summary>
+        /// 分账错误描述信息
+        /// </summary>
+        [XmlElement("error_desc")]
+        public string ErrorDesc { get; set; }
+
+        /// <summary>
+        /// 分账执行时间
+        /// </summary>
+        [XmlElement("execute_dt")]
+        public string ExecuteDt { get; set; }
+
+        /// <summary>
+        /// 分账操作类型。有以下几种类型: replenish(补差)、replenish_refund(退补差)、transfer(分账)、transfer_refund(退分账)
+        /// </summary>
+        [XmlElement("operation_type")]
+        public string OperationType { get; set; }
+
+        /// <summary>
+        /// 分账状态,SUCCESS成功,FAIL失败,PROCESSING处理中
+        /// </summary>
+        [XmlElement("state")]
+        public string State { get; set; }
+
+        /// <summary>
+        /// 分账转入账号,只有在operation_type为replenish_refund(退补差),transfer(分账)才返回该字段或trans_in_open_id。trans_in_open_id为分账转入方的openId,当trans_in_open_id不为空的时候,请优先使用trans_in_open_id。
+        /// </summary>
+        [XmlElement("trans_in")]
+        public string TransIn { get; set; }
+
+        /// <summary>
+        /// 分账转入方的OpenId,OpenId为用户在该应用下支付宝的唯一用户标识。
+        /// </summary>
+        [XmlElement("trans_in_open_id")]
+        public string TransInOpenId { get; set; }
+
+        /// <summary>
+        /// 分账转入账号类型,userId表示是支付宝账号对应的支付宝唯一用户号,loginName表示是支付宝登录号,secondMerchantID表示是二级商户id。 只有在operation_type为replenish_refund(退补差),transfer(分账)才返回该字段
+        /// </summary>
+        [XmlElement("trans_in_type")]
+        public string TransInType { get; set; }
+
+        /// <summary>
+        /// 分账转出账号,只有在operation_type为replenish(补差),transfer_refund(退分账)类型才返回该字段或trans_out_open_id字段。trans_out_open_id字段为分账转出方的openId,当trans_out_open_id 字段不为空时,请优先使用trans_out_open_id。
+        /// </summary>
+        [XmlElement("trans_out")]
+        public string TransOut { get; set; }
+
+        /// <summary>
+        /// 分账转出方的OpenId,OpenId为用户在该应用下支付宝内的唯一用户标识。
+        /// </summary>
+        [XmlElement("trans_out_open_id")]
+        public string TransOutOpenId { get; set; }
+
+        /// <summary>
+        /// 分账转出账号类型,userId表示是支付宝账号对应的支付宝唯一用户号,loginName表示是支付宝登录号,secondMerchantID表示是二级商户id。 只有在operation_type为replenish(补差),transfer_refund(退分账)类型才返回该字段
+        /// </summary>
+        [XmlElement("trans_out_type")]
+        public string TransOutType { get; set; }
+    }
+}

+ 24 - 0
Util/HaoDa/Alipay/Domain/IndirectAuthOrderFailedReason.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Xml.Serialization;
+
+namespace Aop.Api.Domain
+{
+    /// <summary>
+    /// IndirectAuthOrderFailedReason Data Structure.
+    /// </summary>
+    [Serializable]
+    public class IndirectAuthOrderFailedReason : AopObject
+    {
+        /// <summary>
+        /// 审核失败字段
+        /// </summary>
+        [XmlElement("fail_param")]
+        public string FailParam { get; set; }
+
+        /// <summary>
+        /// 描述申请单审核失败原因
+        /// </summary>
+        [XmlElement("fail_reason")]
+        public string FailReason { get; set; }
+    }
+}

+ 123 - 0
Util/HaoDa/Alipay/Request/AlipayCommerceIotDeviceTradevoiceSendRequest.cs

@@ -0,0 +1,123 @@
+using System;
+using Aop.Api.Domain;
+using System.Collections.Generic;
+using Aop.Api.Response;
+
+namespace Aop.Api.Request
+{
+    /// <summary>
+    /// AOP API: alipay.commerce.iot.device.tradevoice.send
+    /// </summary>
+    public class AlipayCommerceIotDeviceTradevoiceSendRequest : IAopRequest<AlipayCommerceIotDeviceTradevoiceSendResponse>
+    {
+        /// <summary>
+        /// 到账播报
+        /// </summary>
+        public string BizContent { get; set; }
+
+        #region IAopRequest Members
+        private bool  needEncrypt=false;
+        private string apiVersion = "1.0";
+	    private string terminalType;
+	    private string terminalInfo;
+        private string prodCode;
+	    private string notifyUrl;
+        private string returnUrl;
+	    private AopObject bizModel;
+        private Dictionary<string, string> udfParams; //add user-defined text parameters
+
+		public void SetNeedEncrypt(bool needEncrypt){
+             this.needEncrypt=needEncrypt;
+        }
+
+        public bool GetNeedEncrypt(){
+
+            return this.needEncrypt;
+        }
+
+		public void SetNotifyUrl(string notifyUrl){
+            this.notifyUrl = notifyUrl;
+        }
+
+        public string GetNotifyUrl(){
+            return this.notifyUrl;
+        }
+
+        public void SetReturnUrl(string returnUrl){
+            this.returnUrl = returnUrl;
+        }
+
+        public string GetReturnUrl(){
+            return this.returnUrl;
+        }
+
+        public void SetTerminalType(String terminalType){
+			this.terminalType=terminalType;
+		}
+
+    	public string GetTerminalType(){
+    		return this.terminalType;
+    	}
+
+    	public void SetTerminalInfo(String terminalInfo){
+    		this.terminalInfo=terminalInfo;
+    	}
+
+    	public string GetTerminalInfo(){
+    		return this.terminalInfo;
+    	}
+
+        public void SetProdCode(String prodCode){
+            this.prodCode=prodCode;
+        }
+
+        public string GetProdCode(){
+            return this.prodCode;
+        }
+
+        public string GetApiName()
+        {
+            return "alipay.commerce.iot.device.tradevoice.send";
+        }
+
+        public void SetApiVersion(string apiVersion){
+            this.apiVersion=apiVersion;
+        }
+
+        public string GetApiVersion(){
+            return this.apiVersion;
+        }
+
+        public void PutOtherTextParam(string key, string value) 
+        {
+            if(this.udfParams == null) 
+            {
+                this.udfParams = new Dictionary<string, string>();
+            }
+            this.udfParams.Add(key, value);
+        }
+
+        public IDictionary<string, string> GetParameters()
+        {
+            AopDictionary parameters = new AopDictionary();
+            parameters.Add("biz_content", this.BizContent);
+            if(udfParams != null) 
+            {
+                parameters.AddAll(this.udfParams);
+            }
+            return parameters;
+        }
+
+		public AopObject GetBizModel()
+        {
+            return this.bizModel;
+        }
+
+        public void SetBizModel(AopObject bizModel)
+        {
+            this.bizModel = bizModel;
+        }
+
+        #endregion
+    }
+}

+ 123 - 0
Util/HaoDa/Alipay/Request/AlipayMerchantIndirectAuthorderCreateRequest.cs

@@ -0,0 +1,123 @@
+using System;
+using Aop.Api.Domain;
+using System.Collections.Generic;
+using Aop.Api.Response;
+
+namespace Aop.Api.Request
+{
+    /// <summary>
+    /// AOP API: alipay.merchant.indirect.authorder.create
+    /// </summary>
+    public class AlipayMerchantIndirectAuthorderCreateRequest : IAopRequest<AlipayMerchantIndirectAuthorderCreateResponse>
+    {
+        /// <summary>
+        /// 间连商户意愿确认申请单提交
+        /// </summary>
+        public string BizContent { get; set; }
+
+        #region IAopRequest Members
+        private bool  needEncrypt=false;
+        private string apiVersion = "1.0";
+	    private string terminalType;
+	    private string terminalInfo;
+        private string prodCode;
+	    private string notifyUrl;
+        private string returnUrl;
+	    private AopObject bizModel;
+        private Dictionary<string, string> udfParams; //add user-defined text parameters
+
+		public void SetNeedEncrypt(bool needEncrypt){
+             this.needEncrypt=needEncrypt;
+        }
+
+        public bool GetNeedEncrypt(){
+
+            return this.needEncrypt;
+        }
+
+		public void SetNotifyUrl(string notifyUrl){
+            this.notifyUrl = notifyUrl;
+        }
+
+        public string GetNotifyUrl(){
+            return this.notifyUrl;
+        }
+
+        public void SetReturnUrl(string returnUrl){
+            this.returnUrl = returnUrl;
+        }
+
+        public string GetReturnUrl(){
+            return this.returnUrl;
+        }
+
+        public void SetTerminalType(String terminalType){
+			this.terminalType=terminalType;
+		}
+
+    	public string GetTerminalType(){
+    		return this.terminalType;
+    	}
+
+    	public void SetTerminalInfo(String terminalInfo){
+    		this.terminalInfo=terminalInfo;
+    	}
+
+    	public string GetTerminalInfo(){
+    		return this.terminalInfo;
+    	}
+
+        public void SetProdCode(String prodCode){
+            this.prodCode=prodCode;
+        }
+
+        public string GetProdCode(){
+            return this.prodCode;
+        }
+
+        public string GetApiName()
+        {
+            return "alipay.merchant.indirect.authorder.create";
+        }
+
+        public void SetApiVersion(string apiVersion){
+            this.apiVersion=apiVersion;
+        }
+
+        public string GetApiVersion(){
+            return this.apiVersion;
+        }
+
+        public void PutOtherTextParam(string key, string value) 
+        {
+            if(this.udfParams == null) 
+            {
+                this.udfParams = new Dictionary<string, string>();
+            }
+            this.udfParams.Add(key, value);
+        }
+
+        public IDictionary<string, string> GetParameters()
+        {
+            AopDictionary parameters = new AopDictionary();
+            parameters.Add("biz_content", this.BizContent);
+            if(udfParams != null) 
+            {
+                parameters.AddAll(this.udfParams);
+            }
+            return parameters;
+        }
+
+		public AopObject GetBizModel()
+        {
+            return this.bizModel;
+        }
+
+        public void SetBizModel(AopObject bizModel)
+        {
+            this.bizModel = bizModel;
+        }
+
+        #endregion
+    }
+}

+ 123 - 0
Util/HaoDa/Alipay/Request/AlipayMerchantIndirectAuthorderQuerystatusRequest.cs

@@ -0,0 +1,123 @@
+using System;
+using Aop.Api.Domain;
+using System.Collections.Generic;
+using Aop.Api.Response;
+
+namespace Aop.Api.Request
+{
+    /// <summary>
+    /// AOP API: alipay.merchant.indirect.authorder.querystatus
+    /// </summary>
+    public class AlipayMerchantIndirectAuthorderQuerystatusRequest : IAopRequest<AlipayMerchantIndirectAuthorderQuerystatusResponse>
+    {
+        /// <summary>
+        /// 查询意愿申请单审核结果
+        /// </summary>
+        public string BizContent { get; set; }
+
+        #region IAopRequest Members
+        private bool  needEncrypt=false;
+        private string apiVersion = "1.0";
+	    private string terminalType;
+	    private string terminalInfo;
+        private string prodCode;
+	    private string notifyUrl;
+        private string returnUrl;
+	    private AopObject bizModel;
+        private Dictionary<string, string> udfParams; //add user-defined text parameters
+
+		public void SetNeedEncrypt(bool needEncrypt){
+             this.needEncrypt=needEncrypt;
+        }
+
+        public bool GetNeedEncrypt(){
+
+            return this.needEncrypt;
+        }
+
+		public void SetNotifyUrl(string notifyUrl){
+            this.notifyUrl = notifyUrl;
+        }
+
+        public string GetNotifyUrl(){
+            return this.notifyUrl;
+        }
+
+        public void SetReturnUrl(string returnUrl){
+            this.returnUrl = returnUrl;
+        }
+
+        public string GetReturnUrl(){
+            return this.returnUrl;
+        }
+
+        public void SetTerminalType(String terminalType){
+			this.terminalType=terminalType;
+		}
+
+    	public string GetTerminalType(){
+    		return this.terminalType;
+    	}
+
+    	public void SetTerminalInfo(String terminalInfo){
+    		this.terminalInfo=terminalInfo;
+    	}
+
+    	public string GetTerminalInfo(){
+    		return this.terminalInfo;
+    	}
+
+        public void SetProdCode(String prodCode){
+            this.prodCode=prodCode;
+        }
+
+        public string GetProdCode(){
+            return this.prodCode;
+        }
+
+        public string GetApiName()
+        {
+            return "alipay.merchant.indirect.authorder.querystatus";
+        }
+
+        public void SetApiVersion(string apiVersion){
+            this.apiVersion=apiVersion;
+        }
+
+        public string GetApiVersion(){
+            return this.apiVersion;
+        }
+
+        public void PutOtherTextParam(string key, string value) 
+        {
+            if(this.udfParams == null) 
+            {
+                this.udfParams = new Dictionary<string, string>();
+            }
+            this.udfParams.Add(key, value);
+        }
+
+        public IDictionary<string, string> GetParameters()
+        {
+            AopDictionary parameters = new AopDictionary();
+            parameters.Add("biz_content", this.BizContent);
+            if(udfParams != null) 
+            {
+                parameters.AddAll(this.udfParams);
+            }
+            return parameters;
+        }
+
+		public AopObject GetBizModel()
+        {
+            return this.bizModel;
+        }
+
+        public void SetBizModel(AopObject bizModel)
+        {
+            this.bizModel = bizModel;
+        }
+
+        #endregion
+    }
+}

+ 123 - 0
Util/HaoDa/Alipay/Request/AlipayMerchantIndirectIotBindRequest.cs

@@ -0,0 +1,123 @@
+using System;
+using Aop.Api.Domain;
+using System.Collections.Generic;
+using Aop.Api.Response;
+
+namespace Aop.Api.Request
+{
+    /// <summary>
+    /// AOP API: alipay.merchant.indirect.iot.bind
+    /// </summary>
+    public class AlipayMerchantIndirectIotBindRequest : IAopRequest<AlipayMerchantIndirectIotBindResponse>
+    {
+        /// <summary>
+        /// 间连iot设备和间连商户绑定
+        /// </summary>
+        public string BizContent { get; set; }
+
+        #region IAopRequest Members
+        private bool  needEncrypt=false;
+        private string apiVersion = "1.0";
+	    private string terminalType;
+	    private string terminalInfo;
+        private string prodCode;
+	    private string notifyUrl;
+        private string returnUrl;
+	    private AopObject bizModel;
+        private Dictionary<string, string> udfParams; //add user-defined text parameters
+
+		public void SetNeedEncrypt(bool needEncrypt){
+             this.needEncrypt=needEncrypt;
+        }
+
+        public bool GetNeedEncrypt(){
+
+            return this.needEncrypt;
+        }
+
+		public void SetNotifyUrl(string notifyUrl){
+            this.notifyUrl = notifyUrl;
+        }
+
+        public string GetNotifyUrl(){
+            return this.notifyUrl;
+        }
+
+        public void SetReturnUrl(string returnUrl){
+            this.returnUrl = returnUrl;
+        }
+
+        public string GetReturnUrl(){
+            return this.returnUrl;
+        }
+
+        public void SetTerminalType(String terminalType){
+			this.terminalType=terminalType;
+		}
+
+    	public string GetTerminalType(){
+    		return this.terminalType;
+    	}
+
+    	public void SetTerminalInfo(String terminalInfo){
+    		this.terminalInfo=terminalInfo;
+    	}
+
+    	public string GetTerminalInfo(){
+    		return this.terminalInfo;
+    	}
+
+        public void SetProdCode(String prodCode){
+            this.prodCode=prodCode;
+        }
+
+        public string GetProdCode(){
+            return this.prodCode;
+        }
+
+        public string GetApiName()
+        {
+            return "alipay.merchant.indirect.iot.bind";
+        }
+
+        public void SetApiVersion(string apiVersion){
+            this.apiVersion=apiVersion;
+        }
+
+        public string GetApiVersion(){
+            return this.apiVersion;
+        }
+
+        public void PutOtherTextParam(string key, string value) 
+        {
+            if(this.udfParams == null) 
+            {
+                this.udfParams = new Dictionary<string, string>();
+            }
+            this.udfParams.Add(key, value);
+        }
+
+        public IDictionary<string, string> GetParameters()
+        {
+            AopDictionary parameters = new AopDictionary();
+            parameters.Add("biz_content", this.BizContent);
+            if(udfParams != null) 
+            {
+                parameters.AddAll(this.udfParams);
+            }
+            return parameters;
+        }
+
+		public AopObject GetBizModel()
+        {
+            return this.bizModel;
+        }
+
+        public void SetBizModel(AopObject bizModel)
+        {
+            this.bizModel = bizModel;
+        }
+
+        #endregion
+    }
+}

+ 139 - 0
Util/HaoDa/Alipay/Request/AntMerchantExpandIndirectImageUploadRequest.cs

@@ -0,0 +1,139 @@
+using System;
+using System.Collections.Generic;
+using Aop.Api.Response;
+using Aop.Api.Util;
+
+namespace Aop.Api.Request
+{
+    /// <summary>
+    /// AOP API: ant.merchant.expand.indirect.image.upload
+    /// </summary>
+    public class AntMerchantExpandIndirectImageUploadRequest : IAopUploadRequest<AntMerchantExpandIndirectImageUploadResponse>
+    {
+        /// <summary>
+        /// 图片二进制字节流,最大为10M
+        /// </summary>
+        public FileItem ImageContent { get; set; }
+
+        /// <summary>
+        /// 图片格式,支持格式:bmp、jpg、jpeg、png、gif.
+        /// </summary>
+        public string ImageType { get; set; }
+
+        #region IAopRequest Members
+		private bool needEncrypt=false;
+		private string apiVersion = "1.0";
+		private string terminalType;
+		private string terminalInfo;
+        private string prodCode;
+		private string notifyUrl;
+        private string returnUrl;
+		private AopObject bizModel;
+        private Dictionary<string, string> udfParams; //add user-defined text parameters
+
+    	 public void SetNeedEncrypt(bool needEncrypt){
+             this.needEncrypt=needEncrypt;
+        }
+
+        public bool GetNeedEncrypt(){
+
+            return this.needEncrypt;
+        }
+
+		public void SetNotifyUrl(string notifyUrl){
+            this.notifyUrl = notifyUrl;
+        }
+
+        public string GetNotifyUrl(){
+            return this.notifyUrl;
+        }
+
+        public void SetReturnUrl(string returnUrl){
+            this.returnUrl = returnUrl;
+        }
+
+        public string GetReturnUrl(){
+            return this.returnUrl;
+        }
+
+		public void SetTerminalType(String terminalType){
+			this.terminalType=terminalType;
+		}
+
+    	public string GetTerminalType(){
+    		return this.terminalType;
+    	}
+
+    	public void SetTerminalInfo(String terminalInfo){
+    		this.terminalInfo=terminalInfo;
+    	}
+
+    	public string GetTerminalInfo(){
+    		return this.terminalInfo;
+    	}
+
+        public void SetProdCode(String prodCode){
+            this.prodCode=prodCode;
+        }
+
+        public string GetProdCode(){
+            return this.prodCode;
+        }
+
+		public void SetApiVersion(string apiVersion){
+            this.apiVersion=apiVersion;
+        }
+
+        public string GetApiVersion(){
+            return this.apiVersion;
+        }
+
+        public string GetApiName()
+        {
+            return "ant.merchant.expand.indirect.image.upload";
+        }
+
+        public void PutOtherTextParam(string key, string value) 
+        {
+            if(this.udfParams == null) 
+            {
+                this.udfParams = new Dictionary<string, string>();
+            }
+            this.udfParams.Add(key, value);
+        }
+
+        public IDictionary<string, string> GetParameters()
+        {
+            AopDictionary parameters = new AopDictionary();
+            parameters.Add("image_type", this.ImageType);
+            if(udfParams != null) 
+            {
+                parameters.AddAll(this.udfParams);
+            }
+            return parameters;
+        }
+		
+		public AopObject GetBizModel()
+        {
+            return this.bizModel;
+        }
+
+        public void SetBizModel(AopObject bizModel)
+        {
+            this.bizModel = bizModel;
+        }
+
+        #endregion
+
+        #region IAopUploadRequest Members
+
+        public IDictionary<string, FileItem> GetFileParameters()
+        {
+            IDictionary<string, FileItem> parameters = new Dictionary<string, FileItem>();
+            parameters.Add("image_content", this.ImageContent);
+            return parameters;
+        }
+
+        #endregion
+    }
+}

+ 12 - 0
Util/HaoDa/Alipay/Response/AlipayCommerceIotDeviceTradevoiceSendResponse.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Xml.Serialization;
+
+namespace Aop.Api.Response
+{
+    /// <summary>
+    /// AlipayCommerceIotDeviceTradevoiceSendResponse.
+    /// </summary>
+    public class AlipayCommerceIotDeviceTradevoiceSendResponse : AopResponse
+    {
+    }
+}

+ 23 - 0
Util/HaoDa/Alipay/Response/AlipayMerchantIndirectAuthorderCreateResponse.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Xml.Serialization;
+
+namespace Aop.Api.Response
+{
+    /// <summary>
+    /// AlipayMerchantIndirectAuthorderCreateResponse.
+    /// </summary>
+    public class AlipayMerchantIndirectAuthorderCreateResponse : AopResponse
+    {
+        /// <summary>
+        /// 申请单号
+        /// </summary>
+        [XmlElement("order_no")]
+        public string OrderNo { get; set; }
+
+        /// <summary>
+        /// 意愿申请单状态,枚举值:审核中(AUDITING)、待联系人确认(CONTACT_CONFIRM),待法人确认(LEGAL_CONFIRM)、审核通过(AUDIT_PASS)、审核失败(AUDIT_REJECT)、已冻结(AUDIT_FREEZE)、已撤回(CANCELED)、联系人处理中(CONTACT_PROCESSING)
+        /// </summary>
+        [XmlElement("order_status")]
+        public string OrderStatus { get; set; }
+    }
+}

+ 38 - 0
Util/HaoDa/Alipay/Response/AlipayMerchantIndirectAuthorderQuerystatusResponse.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Xml.Serialization;
+using System.Collections.Generic;
+using Aop.Api.Domain;
+
+namespace Aop.Api.Response
+{
+    /// <summary>
+    /// AlipayMerchantIndirectAuthorderQuerystatusResponse.
+    /// </summary>
+    public class AlipayMerchantIndirectAuthorderQuerystatusResponse : AopResponse
+    {
+        /// <summary>
+        /// 商家认证申请单号
+        /// </summary>
+        [XmlElement("order_no")]
+        public string OrderNo { get; set; }
+
+        /// <summary>
+        /// 商家认证申请单状态,枚举值:审核中(AUDITING)、待联系人确认(CONTACT_CONFIRM),待法人确认(LEGAL_CONFIRM)、审核通过(AUDIT_PASS)、审核失败(AUDIT_REJECT)、已冻结(AUDIT_FREEZE)、已撤回(CANCELED)、联系人处理中(CONTACT_PROCESSING)
+        /// </summary>
+        [XmlElement("order_status")]
+        public string OrderStatus { get; set; }
+
+        /// <summary>
+        /// 商家认证小程序二维码图片链接,申请单状态处于审核通过、待联系人确认、待法人确认、已冻结、审核失败时返回,商户使用支付宝APP扫码后完成后续确认、修改信息等动作。 此字段是平台生成并返回的二维码码值,通过浏览器访问即可获得一个二维码的图片。服务商在推广过程中,可引导商家使用支付宝APP扫描此二维码,进入认证申请单页面,完成认证申请的后续确认操作。
+        /// </summary>
+        [XmlElement("qr_code")]
+        public string QrCode { get; set; }
+
+        /// <summary>
+        /// 申请单审核失败时的原因描述列表
+        /// </summary>
+        [XmlArray("verify_list")]
+        [XmlArrayItem("indirect_auth_order_failed_reason")]
+        public List<IndirectAuthOrderFailedReason> VerifyList { get; set; }
+    }
+}

+ 12 - 0
Util/HaoDa/Alipay/Response/AlipayMerchantIndirectIotBindResponse.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Xml.Serialization;
+
+namespace Aop.Api.Response
+{
+    /// <summary>
+    /// AlipayMerchantIndirectIotBindResponse.
+    /// </summary>
+    public class AlipayMerchantIndirectIotBindResponse : AopResponse
+    {
+    }
+}

+ 17 - 0
Util/HaoDa/Alipay/Response/AntMerchantExpandIndirectImageUploadResponse.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Xml.Serialization;
+
+namespace Aop.Api.Response
+{
+    /// <summary>
+    /// AntMerchantExpandIndirectImageUploadResponse.
+    /// </summary>
+    public class AntMerchantExpandIndirectImageUploadResponse : AopResponse
+    {
+        /// <summary>
+        /// 图片在文件存储平台的标识
+        /// </summary>
+        [XmlElement("image_id")]
+        public string ImageId { get; set; }
+    }
+}

+ 184 - 0
Util/HaoDa/AlipayFunctionForHD.cs

@@ -0,0 +1,184 @@
+using System;
+using System.Collections.Generic;
+using Aop.Api;
+using Library;
+using Microsoft.AspNetCore.Http;
+using Aop.Api.Request;
+using Aop.Api.Response;
+using Aop.Api.Util;
+using MySystem.Models;
+using System.Linq;
+using MySystem.Models.Main;
+
+namespace MySystem
+{
+    public class AlipayFunctionForHD
+    {
+        public readonly static AlipayFunctionForHD Instance = new AlipayFunctionForHD();
+        private AlipayFunctionForHD()
+        { }
+
+        // public string Pid = "2088720140260314";
+        private string AppId = "2021004109682585";
+        private string PrivateKey = "MIIEpAIBAAKCAQEAvf75JGQL9IDg8xu2C6qWrIO3H4roSwpvwUeh6y2kQ8iH0gqQXlyLj13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4jReb1QowN0im289OGnxBCj9bQKh2ZPJH9hH4sk0bvpvpZidjcGx2+lGZr3ckNifASFpwcJTnCkpRzqkhXhuKJUCgYEAmh3iiB7VlXboMaTVygrO4JSZZf4G47aG1h05JM/zbHnZR4j1nZqAuqejNYP0Mo8RD+29100LLTd38E5UY9TZRKGhv9r5PVuSiEVKFJFWzFPxzued4xnGkNmJlZDm6s8EH3AcpxOsCqu1POGtM8umyR/pENP74j4rGNFH5eP+PYcCgYA84Die07zXP31rfOWWabjDMaq4bPMH9drzhjXdMYaFH3T6F1Ba52Iqsk5K526RdPM6eeR1dFPPotNhZMJPmg1PALNSjVBmKnklF+/y6c4eFOiUgTS/wyNpSlr/eKECsWPch9UlAkkIos5lq02pVAv4kK9WumSyXDe5Gu6a5pUC1A==";
+        private string PublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvf75JGQL9IDg8xu2C6qWrIO3H4roSwpvwUeh6y2kQ8iH0gqQXlyLj13ku8pzY1H9JTSeARCsHSD/VJFxMoPOBO+/xGDV3CSdxhOE5Fu5E30ZZMA5XmnMKyN8q+MEh7refGuCmldedTmzr9mNw4HDjS1uqJoqYRl3eUEaC/Syl620iiaSh7Q9/rsT/qNcnP5hO9P3DWionNt78elmjLt0sBdBkQ10o2XwC5RuzBfP8DCBEdL/DPOOE4vtmLP1IdDI7qtjBhX8PdL+/IRxe/4OGvYSPnHW7JNlN970h2UN5i0Yu0AkidJvlS59nX9C1WJ4U37HiMnkMNXLB/Ubi5BkgQIDAQAB";
+        public string AlipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiXVtTk6opnYllnH/X40k/jSw/82WZ+lGbYQLYH/nVONFJ7Gr9C/dlKpJFIbS+vNDn+YLtM923KmEVSgf8zU0WrTkRjWvKEiyLswWZVqSZW5Jfon1e2SfjNrAVi6XBZa7urAItKQsdD2vFFuyG/ohlXBL103xC1wnjvECD/iholoruEFOLyfobJKTY/6iyrKeOElem1V7OWl6gdjG2oozj3nbVZhtkQvPJECYlolH96eK2mieTkFK82aZ5Tdzx1LPk/3hxRAmzz/9X7xfXdOly88hKBmW8LC9RhTlOWbrXJhhFz13A4brnbnOiY/X7b2OkAYifammc2uh0AIJlCmBTQIDAQAB";
+        //"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB";
+
+
+        #region 商家认证申请单提交
+        public string AuthOrderCreate(MerchantAddInfo info, string MerToken)
+        {            
+            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
+            AlipayMerchantIndirectAuthorderCreateRequest request = new AlipayMerchantIndirectAuthorderCreateRequest() ;
+            string out_biz_no = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
+            string identity_type = info.SubjectType;
+            if(identity_type == "SUBJECT_TYPE_ENTERPRISE") identity_type = "ENTERPRISE";
+            if(identity_type == "SUBJECT_TYPE_INDIVIDUAL") identity_type = "IND_BIZ";
+            if(identity_type == "SUBJECT_TYPE_SMALL") identity_type = "MSE";
+            string PeriodEnd = info.PeriodEnd.Value.ToString("yyyy-MM-dd");
+            if(PeriodEnd.Substring(0, 4) == "2050")
+            {
+                PeriodEnd = "forever";
+            }
+            string CardPeriodEnd = info.CardPeriodEnd.Value.ToString("yyyy-MM-dd");
+            if(CardPeriodEnd.Substring(0, 4) == "2050")
+            {
+                CardPeriodEnd = "forever";
+            }
+            string BizContent = "{" +
+            "  \"out_biz_no\":\"" + out_biz_no + "\"," +
+            "  \"contact_person_info\":{" +
+            "    \"contact_name\":\"" + info.CertLegalPerson + "\"," +
+            "    \"contact_phone_no\":\"" + info.MobilePhone + "\"," +
+            "    \"contact_card_no\":\"" + info.IdCardNumber + "\"," +
+            "    \"contact_cert_type\":\"RESIDENT\"" +
+            "  }," +
+            "  \"auth_identity_info\":{" +
+            "    \"identity_type\":\"" + identity_type + "\"," +
+            "    \"is_financial_org\":false," +
+            "    \"certificate_type\":\"BUSINESS_CERT\"," +
+            "    \"certificate_info\":{" +
+            "      \"cert_type\":\"UNIT_SOCIAL_CREDIT\"," +
+            "      \"cert_no\":\"" + info.LicenseNumber + "\"," +
+            "      \"cert_image\":\"" + UploadPic(info.LicenseCopy) + "\"," +
+            "      \"merchant_name\":\"" + info.CertMerchantName + "\"," +
+            "      \"legal_person_name\":\"" + info.CertLegalPerson + "\"," +
+            "      \"register_address\":\"" + info.BizAddressCode.Replace(",", "") + info.BizStoreAddress + "\"," +
+            "      \"effect_time\":\"" + info.PeriodBegin.Value.ToString("yyyy-MM-dd") + "\"," +
+            "      \"expire_time\":\"" + PeriodEnd + "\"" +
+            "    },";
+            if(info.SubjectType == "SUBJECT_TYPE_SMALL")
+            {
+                string bizAddressCode = info.BizAddressCode;
+                string province_code = "", city_code = "", district_code = "";
+                string province = "", city = "", district = "";
+                WebCMSEntities db = new WebCMSEntities();
+                OpenBankCityTable cityItem = db.OpenBankCityTable.FirstOrDefault(m => m.CityName.EndsWith(bizAddressCode));
+                if(cityItem != null)
+                {
+                    district_code = cityItem.Code;
+                    city_code = district_code.Substring(0, 4) + "00";
+                    province_code = district_code.Substring(0, 2) + "0000";
+                    string[] CityNames = cityItem.CityName.Split(',');
+                    district = CityNames[CityNames.Length - 3];
+                    city = CityNames[CityNames.Length - 2];
+                    province = CityNames[CityNames.Length - 1];
+                }
+                BizContent += "    \"support_credentials\":{" +
+                "      \"merchant_type\":\"STORE\"," +
+                "      \"store_name\":\"" + info.BizStoreName + "\"," +
+                "      \"province_code\":\"" + province_code + "\"," +
+                "      \"province\":\"" + province + "\"," +
+                "      \"city_code\":\"" + city_code + "\"," +
+                "      \"city\":\"" + city + "\"," +
+                "      \"district_code\":\"" + district_code + "\"," +
+                "      \"district\":\"" + district + "\"," +
+                "      \"store_address\":\"" + info.BizStoreAddress + "\"," +
+                "      \"store_door_img\":\"" + UploadPic(info.StoreEntrancePic.Split(',')[0]) + "\"," +
+                "      \"store_inner_img\":\"" + UploadPic(info.IndoorPic.Split(',')[0]) + "\"" +
+                "    }";
+            }
+            BizContent += "  }," +
+            "  \"legal_person_info\":{" +
+            "    \"legal_type\":\"LEGAL_PERSON\"," +
+            "    \"card_type\":\"RESIDENT\"," +
+            "    \"person_name\":\"" + info.CertLegalPerson + "\"," +
+            "    \"card_no\":\"" + info.IdCardNumber + "\"," +
+            "    \"effect_time\":\"" + info.CardPeriodBegin.Value.ToString("yyyy-MM-dd") + "\"," +
+            "    \"expire_time\":\"" + CardPeriodEnd + "\"," +
+            "    \"card_front_img\":\"" + UploadPic(info.IdCardCopy) + "\"," +
+            "    \"card_back_img\":\"" + UploadPic(info.IdCardNational) + "\"," +
+            "    \"is_benefit_person\":true" +
+            "  }" +
+            "}";
+            request.BizContent = BizContent;
+            function.WriteLog(BizContent, "商家认证申请单提交异常");
+
+            string result = "";
+            try
+            {
+                AlipayMerchantIndirectAuthorderCreateResponse response = client.Execute(request, null, MerToken);
+                result = response.Body;
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(ex.ToString(), "商家认证申请单提交异常");
+                result = "";
+            }
+            return result;
+        }
+
+        #endregion
+
+        #region 查询商家认证申请单状态
+        public string AuthOrderQuery(string OrderNo)
+        {
+            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
+            AlipayMerchantIndirectAuthorderQuerystatusRequest request = new AlipayMerchantIndirectAuthorderQuerystatusRequest();
+            request.BizContent = "{" +
+            "  \"order_no\":\"" + OrderNo + "\"" +
+            "}";
+            function.WriteLog(request.BizContent, "查询商家认证申请单状态");
+
+            string result = "";
+            try
+            {
+                AlipayMerchantIndirectAuthorderQuerystatusResponse response = client.Execute(request);
+                result = response.Body;
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(ex.ToString(), "查询商家认证申请单状态异常");
+                result = "";
+            }
+            return result;
+        }
+
+        #endregion
+
+        #region 图片上传
+
+        public string UploadPic(string path)
+        {
+            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
+            string fileName = path.Substring(path.LastIndexOf("/") + 1);
+            string imageBase64 = function.imageToBase64String(function.getPath(path));
+            // imageBase64 = imageBase64.Substring(imageBase64.IndexOf(";base64,") + 8);
+            AntMerchantExpandIndirectImageUploadRequest request = new AntMerchantExpandIndirectImageUploadRequest();
+            FileItem imageContent = new FileItem(fileName,Convert.FromBase64String(imageBase64));
+            request.ImageContent = imageContent;
+            request.ImageType = "jpg";
+            AntMerchantExpandIndirectImageUploadResponse response = client.Execute(request);
+            return fileName;
+        }
+
+        #endregion
+
+
+
+
+
+
+    }
+}

+ 126 - 0
Util/HaoDa/HaoDaExtHelper.cs

@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Linq;
+using Microsoft.Extensions.Hosting;
+using MySystem;
+using MySystem.Models;
+using LitJson;
+using Library;
+using MySystem.Models.Main;
+
+public class HaoDaExtHelper
+{
+    public readonly static HaoDaExtHelper Instance = new HaoDaExtHelper();
+    private HaoDaExtHelper()
+    {
+    }
+    
+    public void StartWeChat()
+    {
+        Thread th = new Thread(StartWeChatDo);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    private void StartWeChatDo()
+    {
+        while (true)
+        {
+            string content = RedisDbconn.Instance.RPop<string>("WeChatForHaoDaQueue");
+            if (!string.IsNullOrEmpty(content))
+            {
+                WeChatAddInfo(int.Parse(content));
+            }
+            else
+            {
+                Thread.Sleep(10000);
+            }
+        }
+    }
+
+    public void WeChatAddInfo(int Id)
+    {
+        try
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            MerchantAddInfo info = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
+            string result = WeChatFunctionForHD.Instance.MerchantApply(info);
+            if (result.Contains("\"applyment_id\":"))
+            {
+                JsonData json = JsonMapper.ToObject(result);
+                string applyment_id = json["applyment_id"].ToString();
+                RedisDbconn.Instance.AddList("WeChatResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"ApplymentId\":\"" + applyment_id + "\"}");
+            }
+            else if (result.Contains("\"message\":"))
+            {
+                MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
+                JsonData jsonObj = JsonMapper.ToObject(result);
+                info.Status = -1;
+                merchant.Status = -1;
+                info.WeChatRemark = jsonObj["message"].ToString();
+                db.SaveChanges();
+            }
+            db.Dispose();
+        }
+        catch(Exception ex)
+        {
+            function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "微信开户意愿申请异常");
+        }
+    }
+
+
+
+    public void StartAlipay()
+    {
+        Thread th = new Thread(StartAlipayDo);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    private void StartAlipayDo()
+    {
+        while (true)
+        {
+            string content = RedisDbconn.Instance.RPop<string>("AlipayForHaoDaQueue");
+            if (!string.IsNullOrEmpty(content))
+            {
+                AlipayAddInfo(int.Parse(content));
+            }
+            else
+            {
+                Thread.Sleep(10000);
+            }
+        }
+    }
+
+    public void AlipayAddInfo(int Id)
+    {
+        try
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            MerchantAddInfo info = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
+            string result = AlipayFunctionForHD.Instance.AuthOrderCreate(info, info.AlipayAuthToken);
+            JsonData jsonObj = JsonMapper.ToObject(result);
+            if (jsonObj["alipay_merchant_indirect_authorder_create_response"]["code"].ToString() == "10000")
+            {
+                string order_no = jsonObj["alipay_merchant_indirect_authorder_create_response"]["order_no"].ToString();
+                RedisDbconn.Instance.AddList("AlipayResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"order_no\":\"" + order_no + "\"}");
+            }
+            else
+            {
+                MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
+                info.QueryCount = -1;
+                merchant.QueryCount = -1;
+                info.AlipayRemark = jsonObj["alipay_merchant_indirect_authorder_create_response"]["msg"].ToString();
+                db.SaveChanges();
+            }
+            db.Dispose();
+        }
+        catch(Exception ex)
+        {
+            function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "支付宝开户意愿申请异常");
+        }
+    }
+}

+ 155 - 0
Util/HaoDa/HaoDaExtQueryHelper.cs

@@ -0,0 +1,155 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Linq;
+using Microsoft.Extensions.Hosting;
+using MySystem;
+using MySystem.Models;
+using LitJson;
+using Library;
+using MySystem.Models.Main;
+
+public class HaoDaExtQueryHelper
+{
+    public readonly static HaoDaExtQueryHelper Instance = new HaoDaExtQueryHelper();
+    private HaoDaExtQueryHelper()
+    {
+    }
+    
+    public void StartWeChat()
+    {
+        Thread th = new Thread(StartWeChatDo);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    private void StartWeChatDo()
+    {
+        while (true)
+        {
+            string content = RedisDbconn.Instance.RPop<string>("WeChatResultForHaoDaQueue");
+            if (!string.IsNullOrEmpty(content))
+            {
+                JsonData json = JsonMapper.ToObject(content);
+                WeChatAddInfo(int.Parse(json["MerchantId"].ToString()), json["ApplymentId"].ToString());
+            }
+            else
+            {
+                Thread.Sleep(10000);
+            }
+        }
+    }
+
+    public void WeChatAddInfo(int Id, string ApplymentId)
+    {
+        try
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            MerchantAddInfo info = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
+            string result = WeChatFunctionForHD.Instance.QueryMerchant(ApplymentId);
+            JsonData jsonObj = JsonMapper.ToObject(result);
+            if (jsonObj["applyment_state"].ToString() == "APPLYMENT_STATE_FINISHED")
+            {
+                MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
+                info.Status = 1;
+                merchant.Status = 1;
+                info.WeChatRemark = "";
+                info.WeChatSignUrl = jsonObj["sign_url"].ToString();
+                db.SaveChanges();
+            }
+            else if (jsonObj["applyment_state"].ToString() == "APPLYMENT_STATE_REJECTED")
+            {
+                MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
+                info.Status = -1;
+                merchant.Status = -1;
+                info.WeChatRemark = jsonObj["reject_reason"].ToString();
+                db.SaveChanges();
+            }
+            else
+            {
+                RedisDbconn.Instance.AddList("WeChatResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"ApplymentId\":\"" + ApplymentId + "\"}");
+            }
+            db.Dispose();
+        }
+        catch(Exception ex)
+        {
+            function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "微信开户意愿申请异常");
+        }
+    }
+
+
+
+    public void StartAlipay()
+    {
+        Thread th = new Thread(StartAlipayDo);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    private void StartAlipayDo()
+    {
+        while (true)
+        {
+            string content = RedisDbconn.Instance.RPop<string>("AlipayResultForHaoDaQueue");
+            if (!string.IsNullOrEmpty(content))
+            {
+                JsonData json = JsonMapper.ToObject(content);
+                AlipayAddInfo(int.Parse(json["MerchantId"].ToString()), json["order_no"].ToString());
+            }
+            else
+            {
+                Thread.Sleep(10000);
+            }
+        }
+    }
+
+    public void AlipayAddInfo(int Id, string OrderNo)
+    {
+        try
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            MerchantAddInfo info = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
+            string result = AlipayFunctionForHD.Instance.AuthOrderQuery(OrderNo);
+            JsonData jsonObj = JsonMapper.ToObject(result);
+            if (jsonObj["alipay_merchant_indirect_authorder_querystatus_response"]["code"].ToString() == "10000")
+            {
+                string order_status = jsonObj["alipay_merchant_indirect_authorder_querystatus_response"]["order_status"].ToString();
+                if (order_status == "CONTACT_CONFIRM")
+                {
+                    MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
+                    info.QueryCount = 1;
+                    merchant.QueryCount = 1;
+                    info.AlipayRemark = "";
+                    info.AlipaySignUrl = jsonObj["alipay_merchant_indirect_authorder_querystatus_response"]["qr_code"].ToString();
+                    db.SaveChanges();
+                }
+                else if (order_status == "AUDIT_PASS" || order_status == "AUDIT_REJECT" || order_status == "AUDIT_FREEZE")
+                {
+                    MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
+                    info.QueryCount = -1;
+                    merchant.QueryCount = -1;
+                    info.AlipayRemark = jsonObj["alipay_merchant_indirect_authorder_querystatus_response"]["msg"].ToString();
+                    db.SaveChanges();
+                }
+                else
+                {
+                    RedisDbconn.Instance.AddList("AlipayResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"order_no\":\"" + OrderNo + "\"}");
+                }
+            }
+            else
+            {
+                MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
+                info.QueryCount = -1;
+                merchant.QueryCount = -1;
+                info.AlipayRemark = jsonObj["alipay_merchant_indirect_authorder_querystatus_response"]["msg"].ToString();
+                db.SaveChanges();
+            }
+            db.Dispose();
+        }
+        catch(Exception ex)
+        {
+            function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "支付宝开户意愿申请异常");
+        }
+    }
+}

+ 8 - 4
Util/HaoDa/HaoDaHelper.cs

@@ -355,14 +355,14 @@ namespace MySystem
         {
             function.WriteLog(DateTime.Now.ToString(), "好哒订单分账申请");
             Dictionary<string, object> reqdic = new Dictionary<string, object>();
-            List<Dictionary<string, object>> list = new List<Dictionary<string, object>> ();
+            List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
             Dictionary<string, object> lists = new Dictionary<string, object>();
             reqdic.Add("applyNo", "FZ202307050006");
             reqdic.Add("mchtNo", "1475762");
             reqdic.Add("orderNo", "G2230818C01935875690");
-            lists.Add("acctNo","030510106621391");
-            lists.Add("acctType","0");
-            lists.Add("amount","1");
+            lists.Add("acctNo", "030510106621391");
+            lists.Add("acctType", "0");
+            lists.Add("amount", "1");
             list.Add(lists);
             reqdic.Add("detail", list);
             string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
@@ -794,6 +794,10 @@ namespace MySystem
         {
             Dictionary<string, string> file = new Dictionary<string, string>();
             file.Add("fileName", value.Substring(value.LastIndexOf("/")).Trim('/'));
+            if (!string.IsNullOrEmpty(value.Split(',')[0]))
+            {
+                return "";
+            }
             FileItem item = new FileItem(function.getPath(value.Split(',')[0]));
             Dictionary<string, FileItem> files = new Dictionary<string, FileItem>();
             files.Add("file", item);

+ 18 - 29
Util/HaoDa/MerchantConfirmService.cs

@@ -24,38 +24,27 @@ namespace MySystem
 
         public void StartListen()
         {
-            // while (true)
-            // {
-            //     string content = RedisDbconn.Instance.RPop<string>("MerchantConfirmQueue");
-            //     if (!string.IsNullOrEmpty(content))
-            //     {
-            //         try
-            //         {
-            //             JsonData jsonObj = JsonMapper.ToObject(content);
-            //             int MerchantId = int.Parse(jsonObj["MerchantId"].ToString());
-            //             StartDo(MerchantId);
-            //         }
-            //         catch (Exception ex)
-            //         {
-            //             function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "好哒商户进件异常");
-            //         }
-            //     }
-            //     else
-            //     {
-            //         Thread.Sleep(2000);
-            //     }
-            // }
-
-            // StartDo(1);//开通分账和添加分账接收方
             while (true)
             {
-                StartDo(571);
-                // StartDo(580);
-                // StartDo(581);//小微
-                Thread.Sleep(20000);
+                string content = RedisDbconn.Instance.RPop<string>("MerchantConfirmQueue");
+                if (!string.IsNullOrEmpty(content))
+                {
+                    try
+                    {
+                        JsonData jsonObj = JsonMapper.ToObject(content);
+                        int MerchantId = int.Parse(jsonObj["MerchantId"].ToString());
+                        StartDo(MerchantId);
+                    }
+                    catch (Exception ex)
+                    {
+                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "好哒商户进件异常");
+                    }
+                }
+                else
+                {
+                    Thread.Sleep(2000);
+                }
             }
-
-            // StartDo(581);//小微
         }
 
         public void StartDo(int MerchantId)

+ 468 - 0
Util/HaoDa/WeChatFunctionForHD.cs

@@ -0,0 +1,468 @@
+using System;
+using System.Collections.Generic;
+using Library;
+using LitJson;
+using System.Linq;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography;
+using System.Text;
+using System.IO;
+using System.Net;
+using System.Web;
+using MySystem.Models;
+using Org.BouncyCastle.Crypto.Modes;
+using Org.BouncyCastle.Crypto.Parameters;
+using Org.BouncyCastle.Crypto.Engines;
+using MySystem.Models.Main;
+
+namespace MySystem
+{
+    public class WeChatFunctionForHD
+    {
+        public readonly static WeChatFunctionForHD Instance = new WeChatFunctionForHD();
+        private WeChatFunctionForHD()
+        { }
+
+        public string MchId = "178590308";
+        public string ApiKey = "XTH7TLTSJH4SOZC3NVFQJ726B5VRNVO6"; //AesGcmDecrypt解密使用
+        public string serialNo = "5293C873581457469F1BE1839EA127B08ADE2D7B";
+        public string getSerialNo = "7C6E6AD5DA1F7EB4A1071F2333C2FED0D8CC3A46";  //平台证书序列号Wechatpay-Serial
+        // string pubkey = "MIIEJzCCAw+gAwIBAgIUUpPIc1gUV0afG+GDnqEnsIreLXswDQYJKoZIhvcNAQELBQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsTFFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3QgQ0EwHhcNMjMwODE3MTA0NzAyWhcNMjgw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TrdiHVBNuc+ic8aqmiSPmlenOlYtRIP+VIygWJzUAqkGRYZDfZN1f0TvwwpTPHTWN/vjFofkSubXGyaTaoGEiwe61in9WdHO7dEIcIr3EN3v3hbSZVtIU4MmCWHri4BeNqDkxZeOvLf8bVEY5Hn/vwKBgCq3bDMLSX3OgF7dUfdbnlVIM4izSICICAXc9caBxhO5OTEF1Ji5nXb3rKA2UDSQiGWUklUnrEynqz0y0eu0onE0VYyACyio0z4j70L21gwh5K01Y8r/03nzzaRH5PMWLGZ26+rWSEkiLnJzhN1hcl1bVTPB20ODagI3z9nsHx6xAoGBANoqZ97soR2+lCWxwaa4wrNb4DNLgI1ky91o3LpIFH/lX3grCpNBee9E6kW2XoSe7PUh8/WzQMxtyYEYvt9z+QPWcUjCjs9sexck/o+RTTVBM6JtOwKbUQzsQ0bUUSFAIw1ofGruQMHt/2v4ODFGCNI5FSy4ZruWGmN2d2t3uMP8"; //私钥
+
+
+        #region 间连商户开户意愿确认(提交申请单)
+
+        public string MerchantApply(MerchantAddInfo info)
+        {
+            Dictionary<string, object> result = new Dictionary<string, object>();
+            string business_code = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
+            result.Add("business_code", business_code); //业务申请编号
+
+            WebCMSEntities dbpxc = new WebCMSEntities();
+            //超级管理员信息
+            Dictionary<string, object> contact_info = new Dictionary<string, object>();
+            contact_info.Add("contact_type", "LEGAL"); //联系人类型
+            contact_info.Add("name", RSAEncrypt(info.CertLegalPerson)); //联系人姓名
+            contact_info.Add("id_card_number", RSAEncrypt(info.IdCardNumber)); //超级管理员身份证件号码
+            contact_info.Add("contact_id_doc_type", "IDENTIFICATION_TYPE_IDCARD"); //联系人证件类型            
+            contact_info.Add("mobile", RSAEncrypt(info.MobilePhone)); //联系手机
+            result.Add("contact_info", contact_info);
+
+            //主体资料
+            Dictionary<string, object> subject_info = new Dictionary<string, object>();
+            string SubjectType = info.SubjectType;
+            if(SubjectType == "SUBJECT_TYPE_SMALL") SubjectType = "SUBJECT_TYPE_MICRO";
+            subject_info.Add("subject_type", SubjectType); //主体类型
+
+            Dictionary<string, object> business_licence_info = new Dictionary<string, object>();
+            business_licence_info.Add("licence_number", info.LicenseNumber); //注册号/统一社会信用代码
+            business_licence_info.Add("licence_copy", GetMediaId("/" + info.LicenseCopy)); //营业执照照片
+            business_licence_info.Add("merchant_name", info.CertMerchantName); //商户名称
+            business_licence_info.Add("legal_person", info.CertLegalPerson); //个体户经营者/法人姓名
+            business_licence_info.Add("company_address", info.BizStoreAddress); //注册地址
+            string PeriodEnd = info.PeriodEnd.Value.ToString("yyyy-MM-dd");
+            if(PeriodEnd.Substring(0, 4) == "2050")
+            {
+                PeriodEnd = "forever";
+            }
+            business_licence_info.Add("licence_valid_date", "[\"" + info.PeriodBegin.Value.ToString("yyyy-MM-dd") + "\",\"" + PeriodEnd + "\"]"); //营业执照有效日期
+            
+            subject_info.Add("business_licence_info", business_licence_info); //营业执照
+            result.Add("subject_info", subject_info);
+
+            Dictionary<string, object> identification_info = new Dictionary<string, object>();
+            identification_info.Add("id_holder_type", "LEGAL"); //证件持有人类型
+            identification_info.Add("identification_type", "IDENTIFICATION_TYPE_IDCARD"); //证件类型
+            identification_info.Add("identification_name", RSAEncrypt(info.CertLegalPerson)); //身份证姓名
+            identification_info.Add("identification_number", RSAEncrypt(info.IdCardNumber)); //身份证号码
+            string CardPeriodEnd = info.CardPeriodEnd.Value.ToString("yyyy-MM-dd");
+            if(CardPeriodEnd.Substring(0, 4) == "2050")
+            {
+                CardPeriodEnd = "forever";
+            }
+            identification_info.Add("identification_valid_date", "[\"" + info.CardPeriodBegin.Value.ToString("yyyy-MM-dd") + "\",\"" + CardPeriodEnd + "\"]"); //身份证有效期
+            identification_info.Add("identification_front_copy", GetMediaId("/" + info.IdCardCopy)); //身份证件正面照片
+            identification_info.Add("identification_back_copy", GetMediaId("/" + info.IdCardNational)); //身份证件反面照片
+            bool owner = true;
+            if(info.SubjectType == "SUBJECT_TYPE_ENTERPRISE")
+            {
+                identification_info.Add("identification_address", RSAEncrypt(info.IdCardAddress)); //身份证居住地址
+                identification_info.Add("owner", owner);
+            }
+            result.Add("identification_info", identification_info); //经营者/法人身份证件
+
+
+            //最终受益人信息列表(UBO)----仅企业需要填写
+            if(info.SubjectType == "SUBJECT_TYPE_ENTERPRISE" && !owner)
+            {
+                List<Dictionary<string, object>> ubo_info_list = new List<Dictionary<string, object>>();
+                Dictionary<string, object> ubo_info_list_item = new Dictionary<string, object>();
+                ubo_info_list_item.Add("ubo_id_doc_type", "IDENTIFICATION_TYPE_IDCARD"); //证件类型
+                ubo_info_list_item.Add("ubo_id_doc_copy", GetMediaId("/" + info.IdCardCopy)); //身份证件正面照片
+                ubo_info_list_item.Add("ubo_id_doc_copy_back", GetMediaId("/" + info.IdCardNational)); //身份证件反面照片
+                ubo_info_list_item.Add("ubo_id_doc_name", RSAEncrypt(info.CertLegalPerson)); //身份证姓名
+                ubo_info_list_item.Add("ubo_id_doc_number", RSAEncrypt(info.IdCardNumber)); //身份证号码
+                ubo_info_list_item.Add("ubo_id_doc_address", RSAEncrypt(info.IdCardAddress)); //身份证居住地址
+                ubo_info_list_item.Add("ubo_period_begin", info.CardPeriodBegin.Value.ToString("yyyy-MM-dd")); //身份证有效期
+                if(CardPeriodEnd == "forever")
+                {
+                    CardPeriodEnd = "长期";
+                }
+                ubo_info_list_item.Add("ubo_period_end", CardPeriodEnd); //身份证有效期
+                ubo_info_list.Add(ubo_info_list_item);
+                result.Add("ubo_info_list", ubo_info_list);
+            }
+            dbpxc.Dispose();
+
+            string req = Newtonsoft.Json.JsonConvert.SerializeObject(result);
+            // 如何查看证书序列号?
+            // 登陆商户平台【API安全】->【API证书】->【查看证书】,可查看商户API证书序列号。
+            // 商户API证书和微信支付平台证书均可以使用第三方的证书解析工具,查看证书内容。或者使用openssl命令行工具查看证书序列号。
+            // $ openssl x509 -in 1900009191_20180326_cert.pem -noout -serial
+            // serial=1DDE55AD98ED71D6EDD4A4A16996DE7B47773A8C
+            function.WriteLog(req, "间连商户开户意愿确认");
+            string resp = postJson("https://api.mch.weixin.qq.com/v3/apply4subject/applyment", req);
+            function.WriteLog(resp + "\n\n", "间连商户开户意愿确认");
+            return resp;
+        }
+
+        #endregion
+
+        #region 间连商户开户意愿确认(提交申请单)查询申请单状态
+
+        public string QueryMerchant(string BusinessCode)
+        {
+            string result = "";
+            try
+            {
+                result = postJson("https://api.mch.weixin.qq.com/v3/apply4subject/applyment?applyment_id=" + BusinessCode, "", "GET");
+                //"{\"applyment_state\":\"APPLYMENT_STATE_REJECTED\",\"reject_param\":\"licence_valid_date|cert_valid_date\",\"reject_reason\":\"有效期开始日期填写有误,请填写与营业执照上一致的开始日期,如影印件上无开始日期请填写成立日期/注册日期;有效期结束日期填写有误,请填写与营业执照上一致的日期,如影印件上无结束日期请填写“长期”\"}"
+                
+                //{\"applyment_id\":2000002247709762,\"applyment_state\":\"APPLYMENT_STATE_FINISHED\",\"applyment_state_msg\":\"商户入驻申请已完成\",\"audit_detail\":[],\"business_code\":\"0123456789\",\"sign_url\":\"https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQFv7zwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUXE1czkzb3JlUjIxZHpXbTF5Y2YAAgRjbe9hAwQAjScA\",\"sub_mchid\":\"1619775262\"}
+                
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "间连商户开户意愿确认(提交申请单)查询申请单状态异常");
+            }
+            return result;
+        }
+        #endregion
+        
+
+
+        #region 获取平台证书
+
+        public string GetPlatCert()
+        { 
+            string merchantId = MchId;   //商户号
+            string result = postJson("https://api.mch.weixin.qq.com/v3/certificates", "", "GET");
+            return result;
+        }
+
+        #endregion
+
+        #region 敏感信息加密
+
+        public string RSAEncrypt(string text)
+        {
+            byte[] publicKey = Convert.FromBase64String(pubkey);
+            // var rsa = RSA.Create();
+            // rsa.ImportRSAPublicKey(publicKey, out _);
+            // var buff = rsa.Encrypt(Encoding.UTF8.GetBytes(text), RSAEncryptionPadding.OaepSHA1);
+            // return Convert.ToBase64String(buff);
+            using (var x509 = new X509Certificate2(publicKey))
+            {
+                using (var rsa = x509.GetRSAPublicKey())
+                {
+                    var buff = rsa.Encrypt(Encoding.UTF8.GetBytes(text), RSAEncryptionPadding.OaepSHA1);
+                    return Convert.ToBase64String(buff);
+                }
+            }
+        }
+        // public string RSADecrypt(string text)
+        // {
+        //     byte[] key = Encoding.UTF8.GetBytes(AppConfig.WeChatParam.AesGemKey);
+        //     byte[] nonce = Encoding.UTF8.GetBytes("1234567890ab");
+        //     byte[] ciphertext = Convert.FromBase64String(text);
+
+        //     AesGcm aes = new AesGcm(key);
+        //     byte[] plaintext = new byte[ciphertext.Length];
+        //     aes.Decrypt(nonce, ciphertext, plaintext, null);
+        //     return Encoding.UTF8.GetString(plaintext);
+        // }
+        public string AesGcmDecrypt(string associatedData, string nonce, string ciphertext)
+        {
+            // GcmBlockCipher gcmBlockCipher = new GcmBlockCipher(new AesEngine());
+            // AeadParameters aeadParameters = new AeadParameters(
+            //     new KeyParameter(Encoding.UTF8.GetBytes(AppConfig.WeChatParam.AesGemKey)), 
+            //     128, 
+            //     Encoding.UTF8.GetBytes(nonce), 
+            //     Encoding.UTF8.GetBytes(associatedData));
+            // gcmBlockCipher.Init(false, aeadParameters);
+    
+            // byte[] data = Convert.FromBase64String(ciphertext);
+            // byte[] plaintext = new byte[gcmBlockCipher.GetOutputSize(data.Length)];
+            // int length = gcmBlockCipher.ProcessBytes(data, 0, data.Length, plaintext, 0);
+            // gcmBlockCipher.DoFinal(plaintext, length);
+            // return Encoding.UTF8.GetString(plaintext);
+
+            byte[] key = Encoding.UTF8.GetBytes(ApiKey); // 256-bit key
+            byte[] nonceByte = Encoding.UTF8.GetBytes(nonce); // 96-bit nonce
+            byte[] cipherByte = Convert.FromBase64String(ciphertext);
+            byte[] associatedByte = Encoding.UTF8.GetBytes(associatedData);
+
+            GcmBlockCipher cipher = new GcmBlockCipher(new AesEngine());
+            AeadParameters parameters = new AeadParameters(new KeyParameter(key), 128, nonceByte, associatedByte);
+            cipher.Init(false, parameters);
+
+            byte[] plaintext = new byte[cipher.GetOutputSize(cipherByte.Length)];
+            int len = cipher.ProcessBytes(cipherByte, 0, cipherByte.Length, plaintext, 0);
+            cipher.DoFinal(plaintext, len);
+            return Encoding.UTF8.GetString(plaintext);
+        }
+        public string postJson(string url, string postData, string method = "POST")
+        {
+            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
+            request.Method = method;
+            request.ContentType = "application/json;charset=UTF-8";
+            request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3100.0 Safari/537.36";
+            request.Accept = "application/json";
+
+            string Authorization = GetAuthorization(url, method, postData, prikey, MchId, serialNo);
+            request.Headers.Add("Authorization", Authorization);
+            request.Headers.Add("Wechatpay-Serial", getSerialNo);
+            if (!string.IsNullOrEmpty(postData))
+            {
+                byte[] paramJsonBytes;
+                paramJsonBytes = System.Text.Encoding.UTF8.GetBytes(postData);
+                request.ContentLength = paramJsonBytes.Length;
+                Stream writer;
+                try
+                {
+                    writer = request.GetRequestStream();
+                }
+                catch (Exception ex)
+                {
+                    writer = null;
+                    function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "http请求异常");
+                }
+                writer.Write(paramJsonBytes, 0, paramJsonBytes.Length);
+                writer.Close();
+            }
+
+            HttpWebResponse response;
+            try
+            {
+                response = (HttpWebResponse)request.GetResponse();
+            }
+            catch (WebException ex)
+            {
+                response = ex.Response as HttpWebResponse;
+            }
+            Stream resStream = response.GetResponseStream();
+            StreamReader reader = new StreamReader(resStream);
+            string text = reader.ReadToEnd();
+            return text;
+            //{\"code\":\"PARAM_ERROR\",\"message\":\"请确认待处理的消息是否为加密后的密文\"}
+            //{\"applyment_id\":2000002247709762}
+        }
+
+        #endregion
+
+        #region 图片上传
+
+        public string GetMediaId(string imgPath)
+        {
+            if (string.IsNullOrEmpty(imgPath))
+            {
+                return "";
+            }
+            if (imgPath.Contains(","))
+            {
+                imgPath = imgPath.Split(',')[0];
+            }
+            string key = "wechatpic:" + function.MD5_16(imgPath);
+            string media_id = RedisDbconn.Instance.Get<string>(key);
+            if (!string.IsNullOrEmpty(media_id))
+            {
+                return media_id;
+            }
+            string filePath = function.getPath(imgPath);
+            var filename = Path.GetFileName(filePath);
+            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
+            Byte[] imgBytesIn = new Byte[fs.Length];
+            fs.Read(imgBytesIn, 0, imgBytesIn.Length);
+            fs.Close();
+
+            byte[] hash = SHA256Managed.Create().ComputeHash(imgBytesIn);
+
+            StringBuilder builder = new StringBuilder();
+            for (int i = 0; i < hash.Length; i++)
+            {
+                builder.Append(hash[i].ToString("x2"));
+            }
+            var sha256 = builder.ToString();
+            string metaStr = "{\"filename\":\""+ filename + "\",\"sha256\":\"" + sha256 + "\"}";
+            media_id = UploadImgApi(metaStr, imgBytesIn, filename);
+            RedisDbconn.Instance.Set(key, media_id);
+            return media_id;
+        }
+
+        public string UploadImgApi(string metaStr, Byte[] imgBytesIn,string filename)
+        {
+            string url = "https://api.mch.weixin.qq.com/v3/merchant/media/upload";
+            
+            string merchantId = MchId;   //商户号
+            string privateKey = prikey;
+            #region 定义请求体中的内容 并转成二进制
+
+            string boundary = "lc199aecd61b4653ef";
+            string Enter = "\r\n";
+            string campaignIDStr1
+                = "--" + boundary
+                + Enter
+                + "Content-Disposition: form-data; name=\"meta\";"
+                + Enter
+                + "Content-Type:application/json;"
+                + Enter
+                + Enter
+                + metaStr
+                + Enter
+                + "--" + boundary
+                + Enter
+                + "Content-Disposition:form-data;name=\"file\";filename=\""+ filename + "\";"
+                + Enter
+                + "Content-Type:image/jpeg"
+                + Enter
+                + Enter;
+            byte[] byteData2
+                = imgBytesIn;
+            string campaignIDStr3 
+                = Enter
+                + "--" + boundary 
+                + Enter;
+            var byteData1 = System.Text.Encoding.UTF8.GetBytes(campaignIDStr1);
+
+            var byteData3 = System.Text.Encoding.UTF8.GetBytes(campaignIDStr3);
+            #endregion
+
+            string transactionsResponse = UploadImg_postJson(url, byteData1, byteData2, byteData3, metaStr, privateKey, merchantId, serialNo, boundary, "POST");
+            var result=JsonMapper.ToObject(transactionsResponse);
+            return result["media_id"].ToString();
+        }
+        public string UploadImg_postJson(string url, byte[] b1, byte[] b2, byte[] b3, string metaStr, string privateKey, string merchantId, string serialNo, string boundary, string method = "POST")
+        {
+            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
+            request.Method = method;
+            //request.ContentType = "application/json;charset=UTF-8";
+            request.ContentType = "multipart/form-data;boundary=" + boundary;
+            request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3100.0 Safari/537.36";
+            request.Accept = "application/json";
+            string Authorization = GetAuthorization(url, method, metaStr, privateKey, merchantId, serialNo);
+            request.Headers.Add("Authorization", Authorization);
+
+            Stream writer;
+            try
+            {
+                writer = request.GetRequestStream();
+            }
+            catch (Exception)
+            {
+                writer = null;
+            }
+            writer.Write(b1, 0, b1.Length);
+            writer.Write(b2, 0, b2.Length);
+            writer.Write(b3, 0, b3.Length);
+            writer.Close();
+
+            HttpWebResponse response;
+            try
+            {
+                response = (HttpWebResponse)request.GetResponse();
+            }
+            catch (WebException ex)
+            {
+                response = ex.Response as HttpWebResponse;
+            }
+            Stream resStream = response.GetResponseStream();
+            StreamReader reader = new StreamReader(resStream);
+            string text = reader.ReadToEnd();
+            return text;
+        }
+        protected string GetAuthorization(string url, string method, string jsonParame, string privateKey, string merchantId, string serialNo)
+        {
+            var uri = new Uri(url);
+            string urlPath = uri.PathAndQuery;
+            string nonce = Guid.NewGuid().ToString();
+            var timestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
+            //数据签名     HTTP请求方法\n接口地址的url\n请求时间戳\n请求随机串\n请求报文主体\n
+            method = string.IsNullOrEmpty(method) ? "" : method;
+            string message = string.Format("{0}\n{1}\n{2}\n{3}\n{4}\n", method, urlPath, timestamp, nonce, jsonParame);
+            string signTxt = Sign(message, privateKey);
+
+            //Authorization和格式
+            string authorzationTxt = string.Format("WECHATPAY2-SHA256-RSA2048 mchid=\"{0}\",nonce_str=\"{1}\",timestamp=\"{2}\",serial_no=\"{3}\",signature=\"{4}\"",
+                merchantId,
+                nonce,
+                timestamp,
+                serialNo,
+                signTxt
+                );
+            return authorzationTxt;
+        }
+
+        protected string Sign(string message, string privateKey)
+        {
+            byte[] keyData = Convert.FromBase64String(privateKey);
+            byte[] data = System.Text.Encoding.UTF8.GetBytes(message);
+            var rsa = RSA.Create();
+            rsa.ImportPkcs8PrivateKey(keyData, out _);
+            return Convert.ToBase64String(rsa.SignData(data, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1));
+
+            // using (CngKey cngKey = CngKey.Import(keyData, CngKeyBlobFormat.Pkcs8PrivateBlob))
+            // using (RSACng rsa = new RSACng(cngKey))
+            // {
+            //     return Convert.ToBase64String(rsa.SignData(data, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1));
+            // }
+        }
+
+        #endregion
+
+        #region 获取文件sha256
+
+        public string GetSha256(FileStream stream)
+        { 
+            using (SHA256 mySHA256 = SHA256.Create())
+            {
+                byte[] hashValue = mySHA256.ComputeHash(stream);
+                return Encoding.UTF8.GetString(hashValue);
+            }
+        }
+
+        #endregion
+
+        #region 判断长期
+
+        public string CheckForever(DateTime? time)
+        {
+            if (time == null)
+            {
+                return "";
+            }
+            if (time.Value.Year >= 2050)
+            {
+                return "长期";
+            }
+            return time.Value.ToString("yyyy-MM-dd");
+        }
+
+        #endregion
+
+
+    }
+}