Browse Source

测试分账

lcl 1 year ago
parent
commit
00c3218a38
2 changed files with 28 additions and 4 deletions
  1. 14 4
      AppStart/WeChatFunction.cs
  2. 14 0
      Controllers/HomeController.cs

+ 14 - 4
AppStart/WeChatFunction.cs

@@ -19,10 +19,18 @@ namespace MySystem
     public class WeChatFunction
     {
         private HttpContext _context;
+
+        string AppId = "wx5417e0770bb19c4e";
+        string MchId = "1611167423";
+        string serialNo = "534165421BE2814DEC08F8D00BDAB9944B13646C";
+
         public WeChatFunction(HttpContext context)
         {
             _context = context;
         }
+        public WeChatFunction()
+        {
+        }
 
         #region 领取会员卡
 
@@ -64,6 +72,9 @@ namespace MySystem
             par.Add("description", Description); //商品描述
             par.Add("out_trade_no", OrderNo); //商户订单号
             par.Add("notify_url", NotifyUrl); //服务商应用ID
+            Dictionary<string, object> settle_info = new Dictionary<string, object>();
+            settle_info.Add("profit_sharing", true); //是否指定分账
+            par.Add("settle_info", settle_info); //结算信息
             Dictionary<string, object> amountDic = new Dictionary<string, object>();
             amountDic.Add("total", amount); //总金额
             par.Add("amount", amountDic); //订单金额
@@ -194,7 +205,7 @@ namespace MySystem
 
         #region 服务商平台请求分账API
 
-        public string ProfitShare(string SubMchId, string AppId, string TradeNo, string OrderNo, ReceiverList Receivers)
+        public string ProfitShare(string SubMchId, string TradeNo, string OrderNo, List<ReceiverList> Receivers)
         {
             Dictionary<string, object> result = new Dictionary<string, object>();
             result.Add("sub_mchid", SubMchId); //子商户号
@@ -204,7 +215,7 @@ namespace MySystem
             result.Add("receivers", Receivers); //分账接收方列表
             result.Add("unfreeze_unsplit", true); //是否解冻剩余未分资金
             string req = Newtonsoft.Json.JsonConvert.SerializeObject(result);
-            string resp = function.PostWebRequest("https://api.mch.weixin.qq.com/v3/profitsharing/orders", req, "application/json");
+            string resp = postJson("https://api.mch.weixin.qq.com/v3/profitsharing/orders", req, prikey, MchId, serialNo);
             return resp;
         }
         #endregion
@@ -264,7 +275,7 @@ namespace MySystem
         {
             GcmBlockCipher gcmBlockCipher = new GcmBlockCipher(new AesEngine());
             AeadParameters aeadParameters = new AeadParameters(
-                new KeyParameter(Encoding.UTF8.GetBytes(AppConfig.WeChatParam.AesGemKey)),
+                new KeyParameter(Encoding.UTF8.GetBytes("VyULlqfAW2gBfCNfLdupcL7zlha7d93F")),
                 128,
                 Encoding.UTF8.GetBytes(nonce),
                 Encoding.UTF8.GetBytes(associatedData));
@@ -290,7 +301,6 @@ namespace MySystem
 
         #region 敏感信息加密
 
-        // string pubkey = "MIIBCgKCAQEAxK9K2ElQ0rUMwNFW4xMx7kmkpDlp7WGQ8VffXLpudJBIrRVFWJN7dlinCGu67ZATf+/GZvLSSzQPWejHEsI9vUp9ej0x5iZDHGc9/shNUjd03ORkKo/Ohj3Ju19RzX4mh+GoinKGiuKX8CdGPXPe7UObKWyETrDcxrit6VCJQjE604aNtVeAUE+41mOpCLGzTgAKt4psfHxsBRtqlveH4cH/51ip+cGkC/u36gfDMKaRluVfFO3ETxDkI94BwNtnthcA4WDKha+wjtB6HIJ5xxHV550+cfdkl4j8UKU6pB+C5JRNgvjAf6ljg/TF+cGF1d8C6IbYYodYKloqN2DzrwIDAQAB"; //公钥
         string pubkey = "MIID3DCCAsSgAwIBAgIUU0FlQhvigU3sCPjQC9q5lEsTZGwwDQYJKoZIhvcNAQELBQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsTFFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3QgQ0EwHhcNMjEwNjMwMDMwOTA5WhcNMjYwNjI5MDMwOTA5WjBuMRgwFgYDVQQDDA9UZW5wYXkuY29tIHNpZ24xEzARBgNVBAoMClRlbnBheS5jb20xHTAbBgNVBAsMFFRlbnBheS5jb20gQ0EgQ2VudGVyMQswCQYDVQQGDAJDTjERMA8GA1UEBwwIU2hlblpoZW4wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC64SI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5ZKGQ4A5VVhnmrkTGmyQCP37xhwKBgQCaLW+Fc4NqTt240x+Cn6IWV1E6UfzV+QmBtb4E/BznJBIGsHqjIbBeMOUC5X/DPq6mSwf9dEr0RVXNeQtq4aMrEyOrwG8yReCF7naaN/cZcfrjHvmzRN/PFda766Q7kS5ul3OsGS9ZvOYeWsdUf73+Ic1WN/u1Fy5X2P/3rYNhtQKBgAIioAq8psFdy/itpJryaWdmDM6fM6ctp5P6VBWOVp2JGkOzHboiXFToJJBtmi7Rdp8AN1aYBbtVX1o0+RmfEiHqXn84GpSNT6tGirHvARi5ab3jvn+bkUWjZYOGd96hus8GirA+wQb/V92Ms3jS5VUS1HBfHaTGT5G2Slrr8YZu"; //私钥
         public string RSAEncrypt(string text)

+ 14 - 0
Controllers/HomeController.cs

@@ -46,5 +46,19 @@ namespace MySystem.Controllers
             }
             return View();
         }
+
+        public string test()
+        {
+            List<ReceiverList> Receivers = new List<ReceiverList>();
+            Receivers.Add(new ReceiverList()
+            {
+                type = "MERCHANT_ID",  //分账接收方类型
+                account = "1611167423",  //分账接收方账号
+                amount = 1,  //分账金额
+                description = "服务费",  //分账描述
+            });
+            string result = new WeChatFunction().ProfitShare("1645266943", "4200001833202306012813500432", "2023060113423544310448679", Receivers);
+            return result;
+        }
     }
 }