Kaynağa Gözat

微信接口打日志

lcl 1 yıl önce
ebeveyn
işleme
de64639efe
2 değiştirilmiş dosya ile 16 ekleme ve 12 silme
  1. 12 8
      AppStart/WeChatFunction.cs
  2. 4 4
      Startup.cs

+ 12 - 8
AppStart/WeChatFunction.cs

@@ -204,10 +204,9 @@ namespace MySystem
             // 商户API证书和微信支付平台证书均可以使用第三方的证书解析工具,查看证书内容。或者使用openssl命令行工具查看证书序列号。
             // $ openssl x509 -in 1900009191_20180326_cert.pem -noout -serial
             // serial=1DDE55AD98ED71D6EDD4A4A16996DE7B47773A8C
-            string merchantId = "1611167423";   //商户号
-            string serialNo = "534165421BE2814DEC08F8D00BDAB9944B13646C";  //证书编号
-            string resp = postJson("https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/", req, prikey, merchantId, serialNo);
-            function.WriteLog(resp, "商户进件日志");
+            function.WriteLog(req, "服务商平台商户进件提交申请单API");
+            string resp = postJson("https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/", req, prikey, MchId, serialNo);
+            function.WriteLog(resp + "\n\n", "服务商平台商户进件提交申请单API");
             return resp;
         }
 
@@ -220,8 +219,9 @@ namespace MySystem
             Dictionary<string, object> return_result = new Dictionary<string, object>();
             try
             {
+                function.WriteLog(BusinessCode, "服务商平台商户进件提交申请单API");
                 string result = postJson("https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/business_code/" + BusinessCode, "", prikey, MchId, serialNo, "GET");
-                function.WriteLog(result, "服务商平台查询申请单状态API");
+                function.WriteLog(result + "\n\n", "服务商平台查询申请单状态API");
                 //{\"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\"}
                 JsonData jsonObj = JsonMapper.ToObject(result);
                 return_result.Add("applyment_id", jsonObj["applyment_id"].ToString()); //微信支付申请单号
@@ -274,11 +274,11 @@ namespace MySystem
             par.Add("amount", amountDic); //金额信息
 
             string req = Newtonsoft.Json.JsonConvert.SerializeObject(par);
-            function.WriteLog(req, "服务商平台申请退款API");
             try
-            {           
+            {
+                function.WriteLog(req, "服务商平台申请退款API");
                 string result = postJson("https://api.mch.weixin.qq.com/v3/refund/domestic/refunds", req, prikey, MchId, serialNo);
-                function.WriteLog(result, "服务商平台申请退款API");
+                function.WriteLog(result + "\n\n", "服务商平台申请退款API");
                 JsonData jsonObj = JsonMapper.ToObject(result);
                 return_result.Add("refund_id", jsonObj["refund_id"].ToString()); //微信支付退款单号
                 return_result.Add("channel", jsonObj["channel"].ToString()); //退款渠道
@@ -310,7 +310,9 @@ namespace MySystem
             result.Add("receivers", Receivers); //分账接收方列表
             result.Add("unfreeze_unsplit", true); //是否解冻剩余未分资金
             string req = Newtonsoft.Json.JsonConvert.SerializeObject(result);
+            function.WriteLog(req, "服务商平台请求分账API");
             string resp = postJson("https://api.mch.weixin.qq.com/v3/profitsharing/orders", req, prikey, MchId, serialNo);
+            function.WriteLog(resp + "\n\n", "服务商平台请求分账API");
             return resp;
             //{"order_id":"30000104462023060249559178531","out_order_no":"2023060210583730173782834","receivers":[{"account":"1611167423","amount":3,"create_time":"2023-06-02T11:34:10+08:00","description":"服务费","detail_id":"36000104462023060269999025889","finish_time":"1970-01-01T08:00:00+08:00","result":"PENDING","type":"MERCHANT_ID"},{"account":"1645266943","amount":7,"create_time":"2023-06-02T11:34:10+08:00","description":"解冻给分账方","detail_id":"36000104462023060269999025890","finish_time":"1970-01-01T08:00:00+08:00","result":"PENDING","type":"MERCHANT_ID"}],"state":"PROCESSING","sub_mchid":"1645266943","transaction_id":"4200001833202306025522158377"}
         }
@@ -331,7 +333,9 @@ namespace MySystem
             }
             result.Add("relation_type", Relation); //与分账方的关系类型 STORE:门店 STAFF:员工 STORE_OWNER:店主 PARTNER:合作伙伴 HEADQUARTER:总部 BRAND:品牌方 DISTRIBUTOR:分销商 USER:用户 SUPPLIER: 供应商 CUSTOM:自定义
             string req = Newtonsoft.Json.JsonConvert.SerializeObject(result);
+            function.WriteLog(req, "服务商平台添加分账接收方API");
             string resp = postJson("https://api.mch.weixin.qq.com/v3/profitsharing/receivers/add", req, prikey, MchId, serialNo);
+            function.WriteLog(resp + "\n\n", "服务商平台添加分账接收方API");
             return resp;
             //{"account":"1611167423","name":"x+8m5jM4x2jSZLDOpN46Js9JyeNgUXkFSmGjCBN45QcSYUNPN86TOheRF64WlwDeO45E/walWPeZSksNN/LfJiB2fZRVun1CJuJ7zxePma8L7iDbKS92i+d38rvOmNTjLhKX64O8oJR4HMtFw1HryxJlUFgM5/ickJ79WGrX3GaVArWisgEzwOyxGBfGSL3ofJhi5TdTnrxHMzqYWv43DRvI9Ja5eMgFbgrGcn+JiJVKQcYj1L8tZ6xQeQCXkY6ubyDiV9wQps2nQA1Oh+UdFcS13Ex4FUSYLCczGFAl4EV8TBJQleZeC1p4ZJquJjje0uMjI2xB6S41yUBoN86gkA==","relation_type":"PARTNER","sub_mchid":"1645266943","type":"MERCHANT_ID"}
         }

+ 4 - 4
Startup.cs

@@ -171,10 +171,10 @@ namespace MySystem
             });
 
             //必须打开的
-            // MerchantConfirmService.Instance.Start();
-            // CheckWeChatSignService.Instance.Start();
-            // WeChatPayBackService.Instance.Start();
-            // ProfitHelper.Instance.StartListenTrade();
+            MerchantConfirmService.Instance.Start();
+            CheckWeChatSignService.Instance.Start();
+            WeChatPayBackService.Instance.Start();
+            ProfitHelper.Instance.StartListenTrade();
             //必须打开的
         }
     }