Procházet zdrojové kódy

添加间连商户开户意愿确认(提交申请单),商家认证申请单提交

lcl před 1 rokem
rodič
revize
d7918f8643

binární
AppStart/.DS_Store


binární
AppStart/Alipay/.DS_Store


+ 5 - 2
AppStart/Alipay/AlipayFunction.cs

@@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Http;
 using Aop.Api.Request;
 using Aop.Api.Response;
 using Aop.Api.Util;
+using MySystem.Models;
+using System.Linq;
 
 namespace MySystem
 {
@@ -145,10 +147,10 @@ namespace MySystem
         //     }
         //     return result;
         // }
-        public string CommonSign(string BatchNo, string MccCode, string BusinessLicenseNo = "", string BusinessLicensePicPath = "", string SpecialLicensePicPath = "", string ShopScenePicPath = "", string ShopSignBoardPicPath = "")
+        public string  CommonSign(string BatchNo, string MccCode, string BusinessLicenseNo = "", string BusinessLicensePicPath = "", string SpecialLicensePicPath = "", string ShopScenePicPath = "", string ShopSignBoardPicPath = "")
         { 
             IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
-            AlipayOpenAgentFacetofaceSignRequest request= new AlipayOpenAgentFacetofaceSignRequest() ;
+            AlipayOpenAgentFacetofaceSignRequest request = new AlipayOpenAgentFacetofaceSignRequest() ;
             request.BatchNo = BatchNo;
             request.MccCode = MccCode;
             if (!string.IsNullOrEmpty(BusinessLicenseNo))
@@ -485,5 +487,6 @@ namespace MySystem
         #endregion
 
 
+
     }
 }

+ 156 - 0
AppStart/Alipay/AlipayFunctionForHD.cs

@@ -0,0 +1,156 @@
+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 AlipayFunctionForHD
+    {
+        public readonly static AlipayFunctionForHD Instance = new AlipayFunctionForHD();
+        private AlipayFunctionForHD()
+        { }
+
+        public string Pid = "2088720140260314";
+        private string AppId = "2021004100667901";
+        private string PrivateKey = "MIIEowIBAAKCAQEAhw2C7AypN/cSBNZU1LU2th58fzvLlhlfg7jZz3xNJQwpICtSF6hXXB2qChecEZv7ZGyiuuamTn/c+ZAKJAl3EZ8fMEgTrdK9M8+3DX6FIzWywCuPktsnxLIkTj4Lt/LjPI3P3yZLESuWzHIQ+TGnwEgm/Fx5ESWribFOddLRnNpINk36y+gtaVoXpQ742Wt6Yg1l4FZrzCAOHjLfVeTyAzmXXm8TGdzep83fyCqSBp+rdpb1CGQukHYpCapyk52hM4wqsAVdndAqO5qoRi5BfuyiVs2BR6Oe+8iF4rD5FJ/Wk6QguemWX8C/4jTnuNs1YsFuCTHqYwr8k8J6ekEdgwIDAQABAoIBAEob/PsBW56NYwLqhnSO2G4JvrGnI2nDlKlYt5VnFYI98RdpDkxTIVU4JgYRvJ/hI4uRHZ9IUHyFJ8J+60GpPACce+Xnt3zMRuz2j/HEutR+dA+GF+wzfNgwFUImRBH2JAIno6lFfy316HNaKLxGJlKahWI4cGsba81MUczQGhxi04XD9eVZNdeoRpt9eXTEuojjZIQB4JImHXI6jYxjhowP86D/hQ1lz78mC9mflSF0MC5gHtjdR0MScIKsewbJlRWpOw/UNuLXUoEjcXA4YXM1CPW4uSKpPm8j3S0eNT6vE8+DGViLrH5u5YxiLOlFMdkTsdyoq9teQDQl8eCW6skCgYEAxc8hbktBDnMLyEi+6JCzMDTQ5S16fhR8fjahXP5D+2gZZcNSu4X/Z5/WEWSHwH8YOGCXeXEujXe8bEy1dJ8B8c3KDDg2xU9NsxA9N1B4BHkva/3PzhzQGjST1OIYwLZAwMDJlQxtmUNT5Ab55i8AAEO5ewi4Rq+Y3PKNeQ0a7gcCgYEArsg+nFa+8ekZsiFkl/IAe5EsJhl/NPrPhXPHsjp2y1CK3Zg2Y1hOYjBLnIi6ID6l+6uYwVKoe/UOphnIBuw9WkfdojrLAmDCge3eiXTrYTj5XnKMZZon3xDHnuEB5dTMZG2hW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8CdL395qwoX5RnEx9yRUotkwN0ZF6qMUojFKu/J/X2DpxBWBc6jIa+cnFwPUykefXcXj/AQsgiIbFzNXBH9NSz+hngXP6xDs8D1u9h+fJB+TYD+WFXKwOcGwcx23uHLHUDi1UIEZOhT2Eui+aMCYVygUWH7JynTtbFQZyZcSsD2Dxj5OJNJlK110jarFgvqY98WxqtaRtB9Y8whwRRlGfa5GP2r/Vt3xbGeAflRl5khFgRLZgeFIfxJpEj1TZV2tCtpFS0uhXJGEQbMnzFynx8UaOx/0hBCyik1MQuu3flym6nx7XxPSQIDAQAB";
+        //"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 + "\"," +
+            "    \"expire_time\":\"" + CardPeriodEnd + "\"," +
+            "    \"card_front_img\":\"" + UploadPic(info.IdCardCopy) + "\"," +
+            "    \"card_back_img\":\"" + UploadPic(info.IdCardNational) + "\"," +
+            "    \"is_benefit_person\":true" +
+            "  }" +
+            "}";
+            request.BizContent = 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 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
+
+
+
+
+
+
+    }
+}

+ 123 - 0
AppStart/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
+    }
+}

+ 139 - 0
AppStart/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
+    }
+}

+ 23 - 0
AppStart/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; }
+    }
+}

+ 17 - 0
AppStart/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; }
+    }
+}

+ 0 - 1
AppStart/WeChatFunction.cs

@@ -408,7 +408,6 @@ namespace MySystem
 
 
 
-
         #region 敏感信息加密
         string pubkey = "MIID3DCCAsSgAwIBAgIUYdmfchi0h3iONdbE4+05jgl50/YwDQYJKoZIhvcNAQELBQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsTFFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYD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ibNP5qzklYMBwmSsA5aODFpCkDcLpNDqBUrZldN2Oh26gw/ErPJLTU5drZsf06eOvbqooEG3imlgChcrHtcMHNK6mQtIqRRjZIbUQFaVXCag4mnkDWDnpRmidp7HwKBgQCtAZhik5vdzGT+UQmY679ILlT4fD7kKhUZ3PQVlmgITPJH9DWhyCM3HtRFpN2jTa4js4jrqSxlwQbcCffIRlMaqRhl+eEOYqSI/JheO+RhLerFVHeTFZAF7qnM4SHjvwAEswgoeQ6Xt8m//9bPeLCqjBcNU6wgHBDrbF/ddYba0QKBgH4lLjA5U0P4YBXuQpt0raazOy52+NLdJfMlkHV6ZC3IeOo+n9aDVjq9R5YaZKfexLcZEYvVI08cLcQJ5sK1nbh2/DmN0xf3cRMzU/TkXNmpSCNxy/0V9fPFKZVn9QHvdTS32Kvd9rLc6LXXjetuCDuVJ5DAPeRfbNHks9CmT973AoGBAK400faHTcodLHR/MXEmfI6BZlsTh2Cbm5q+k8Of095xKB/sfTWPprMQW+/U5OEQrKDbt+FI+psJFixmSNFuZdt4JU9P5/bp4SGIQpCfsp1p7GP/irc1yikrHXeGes9HPeUn7yGmvz4QC+sFO32haYr1SaAzZvMhf3RQVuAiFOnw"; //私钥

+ 445 - 0
AppStart/WeChatFunctionForHD.cs

@@ -0,0 +1,445 @@
+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;
+
+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+GDnqEnsIreLXswDQYJKoZIhvcNAQELBQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsTFFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3QgQ0EwHhcNMjMwODE3MTA0NzAyWhcNMjgwODE1MTA0NzAyWjCBgDESMBAGA1UEAwwJMTc4NTkwMzA4MRswGQYDVQQKDBLlvq7kv6HllYbmiLfns7vnu58xLTArBgNVBAsMJOWbm+W3neecgea2puinguexs+enkeaKgOaciemZkOWFrOWPuDELMAkGA1UEBgwCQ04xETAPBgNVBAcMCFNoZW5aaGVuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy6sn15bA09Umbch+Zd1rr23y7WRJ3UPc/LpPCLL7okjZRH4w3F3/pCDtZ659fyjz99WcDrP+rXkcFk31ysuXEbnyK3qUQJJ2aua1Qe9kzuAV4aF9PYedzIh6gZHaRmg36FEfgMPXBu/CIzV9Ap4YrIBWmPW2J8IM1L6Klmrt5G3XWA3A9Nu4R/ANgbe0/wskgC0Ytf0bY+B+5RVw3+93u+6Z3SNQBKpKlxY5su5sYvSqWC5AlFRh1lblemfzQsD3PGU+us5dr62y3rcWVOft9cgb8nK8nMf8sOXWmY8nbRRwU/8+9caZbLW18qGAvI7Egd02b6oVnwzo17tTE3jbowIDAQABo4G5MIG2MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgP4MIGbBgNVHR8EgZMwgZAwgY2ggYqggYeGgYRodHRwOi8vZXZjYS5pdHJ1cy5jb20uY24vcHVibGljL2l0cnVzY3JsP0NBPTFCRDQyMjBFNTBEQkMwNEIwNkFEMzk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eWNs3yNWq6AjxJSwgPLoXnOdhv0kTAZRMUb3EAnRRxSyPJreTbAN+LbLInf0uQqSUBAW32B6CX1oGHG5xUzy6zsYn3QkKTvxT6RNxzl8LDmZhk80+vE8bWlI9ZL+wKBgQDRIyFJFXfHPQx0/12bqkc8mLSNWGqO1OdxMoUYld7UHXgbNusM2w4f/3TsvZHSWEwAtP4BfeeuEfmXPMK8O8kvrEmbW/tsb3SZ5d1TTtmxb4LVFgMk05BY4G/XaLX4BwcqLPMkzJ1r3vHl86u3cqCLy0Pzb7TULgEaKKjwvPg2eQKBgQCxR7QOQ4IYF0NPoqN0M7P8TrdiHVBNuc+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)); //身份证件反面照片
+            if(info.SubjectType == "SUBJECT_TYPE_ENTERPRISE")
+            {
+                identification_info.Add("identification_address", RSAEncrypt(info.IdCardAddress)); //身份证居住地址
+                identification_info.Add("owner", true);
+            }
+            result.Add("identification_info", identification_info); //经营者/法人身份证件
+
+
+            //最终受益人信息列表(UBO)----仅企业需要填写
+            if(info.SubjectType == "SUBJECT_TYPE_ENTERPRISE")
+            {
+                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 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
+
+
+    }
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 54 - 45
Controllers/HomeController.cs


+ 19 - 19
Startup.cs

@@ -170,25 +170,25 @@ namespace MySystem
             });
 
             //必须打开的
-            if(Library.ConfigurationManager.EnvironmentFlag == 2)
-            {
-                MerchantConfirmService.Instance.Start(); //特约商户进件队列
-                CheckAlipaySignService.Instance.Start(); //特约商户签约队列(支付宝)
-                CheckWeChatSignService.Instance.Start(); //特约商户签约队列(微信)
-                AlipayPayBackService.Instance.Start(); //支付宝支付回调队列
-                AlipayPayBackService.Instance.StartProfitShare(); //监听已支付订单,超过1分钟的订单执行分账
-                WeChatPayBackService.Instance.Start(); //微信支付回调队列
-                WeChatPayBackService.Instance.StartProfitShare(); //监听已支付订单,超过1分钟的订单执行分账
-                ProfitHelper.Instance.StartActive(); //发放达标奖励队列
-                ProfitHelper.Instance.StartListenTrade(); //支付宝返现队列
-                ProfitHelper.Instance.StartListenWxTrade(); //微信返现队列
-                ProfitShareService.Instance.Start(); //分账状态监控队列,分账完成则提交返现(微信)
-                AlipayShareService.Instance.Start(); //分账状态监控队列,分账完成则提交返现(支付宝)
-            }
-            else
-            {
-                ProfitHelper.Instance.StartListenProfit();
-            }
+            // if(Library.ConfigurationManager.EnvironmentFlag == 2)
+            // {
+            //     MerchantConfirmService.Instance.Start(); //特约商户进件队列
+            //     CheckAlipaySignService.Instance.Start(); //特约商户签约队列(支付宝)
+            //     CheckWeChatSignService.Instance.Start(); //特约商户签约队列(微信)
+            //     AlipayPayBackService.Instance.Start(); //支付宝支付回调队列
+            //     AlipayPayBackService.Instance.StartProfitShare(); //监听已支付订单,超过1分钟的订单执行分账
+            //     WeChatPayBackService.Instance.Start(); //微信支付回调队列
+            //     WeChatPayBackService.Instance.StartProfitShare(); //监听已支付订单,超过1分钟的订单执行分账
+            //     ProfitHelper.Instance.StartActive(); //发放达标奖励队列
+            //     ProfitHelper.Instance.StartListenTrade(); //支付宝返现队列
+            //     ProfitHelper.Instance.StartListenWxTrade(); //微信返现队列
+            //     ProfitShareService.Instance.Start(); //分账状态监控队列,分账完成则提交返现(微信)
+            //     AlipayShareService.Instance.Start(); //分账状态监控队列,分账完成则提交返现(支付宝)
+            // }
+            // else
+            // {
+            //     ProfitHelper.Instance.StartListenProfit();
+            // }
             //必须打开的
 
             

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů