|
@@ -8,7 +8,6 @@ using System.Security.Cryptography;
|
|
|
using System.Text;
|
|
|
using System.IO;
|
|
|
using System.Net;
|
|
|
-using MySystem.PxcModels;
|
|
|
using Org.BouncyCastle.Crypto.Modes;
|
|
|
using Org.BouncyCastle.Crypto.Parameters;
|
|
|
using Org.BouncyCastle.Crypto.Engines;
|
|
@@ -17,10 +16,13 @@ namespace MySystem
|
|
|
{
|
|
|
public class WeChatFunction
|
|
|
{
|
|
|
- public WeChatFunction()
|
|
|
- {
|
|
|
- }
|
|
|
+ public readonly static WeChatFunction Instance = new WeChatFunction();
|
|
|
+ private WeChatFunction()
|
|
|
+ { }
|
|
|
|
|
|
+ public string AppId = "wx5417e0770bb19c4e";
|
|
|
+ public string MchId = "1611167423";
|
|
|
+ public string serialNo = "534165421BE2814DEC08F8D00BDAB9944B13646C";
|
|
|
|
|
|
#region 服务商平台商户进件提交申请单API
|
|
|
|
|
@@ -218,9 +220,7 @@ namespace MySystem
|
|
|
Dictionary<string, object> return_result = new Dictionary<string, object>();
|
|
|
try
|
|
|
{
|
|
|
- string merchantId = "1611167423"; //商户号
|
|
|
- string serialNo = "534165421BE2814DEC08F8D00BDAB9944B13646C"; //证书编号
|
|
|
- string result = postJson("https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/business_code/" + BusinessCode, "", prikey, merchantId, serialNo, "GET");
|
|
|
+ string result = postJson("https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/business_code/" + BusinessCode, "", prikey, MchId, serialNo, "GET");
|
|
|
function.WriteLog(result, "服务商平台查询申请单状态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);
|
|
@@ -257,7 +257,7 @@ namespace MySystem
|
|
|
|
|
|
#region 服务商平台申请退款API
|
|
|
|
|
|
- public Dictionary<string, string> Refund(string AppId, string MchId, string SubMchId, decimal RefundMoney, decimal TotalMoney, string OrderNo, string RefundNo)
|
|
|
+ public Dictionary<string, string> Refund(string SubMchId, decimal RefundMoney, decimal TotalMoney, string OrderNo, string RefundNo)
|
|
|
{
|
|
|
Dictionary<string, string> return_result = new Dictionary<string, string>();
|
|
|
int refund = (int)(RefundMoney * 100);
|
|
@@ -276,10 +276,8 @@ namespace MySystem
|
|
|
string req = Newtonsoft.Json.JsonConvert.SerializeObject(par);
|
|
|
function.WriteLog(req, "服务商平台申请退款API");
|
|
|
try
|
|
|
- {
|
|
|
- string merchantId = MchId; //商户号
|
|
|
- string serialNo = "534165421BE2814DEC08F8D00BDAB9944B13646C"; //证书编号
|
|
|
- string result = postJson("https://api.mch.weixin.qq.com/v3/refund/domestic/refunds", req, prikey, merchantId, serialNo);
|
|
|
+ {
|
|
|
+ string result = postJson("https://api.mch.weixin.qq.com/v3/refund/domestic/refunds", req, prikey, MchId, serialNo);
|
|
|
function.WriteLog(result, "服务商平台申请退款API");
|
|
|
JsonData jsonObj = JsonMapper.ToObject(result);
|
|
|
return_result.Add("refund_id", jsonObj["refund_id"].ToString()); //微信支付退款单号
|
|
@@ -300,6 +298,45 @@ namespace MySystem
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
+ #region 服务商平台请求分账API
|
|
|
+
|
|
|
+ public string ProfitShare(string SubMchId, string TradeNo, string OrderNo, List<ReceiverList> Receivers) //有活动分0.62%,没活动不分账
|
|
|
+ {
|
|
|
+ Dictionary<string, object> result = new Dictionary<string, object>();
|
|
|
+ result.Add("sub_mchid", SubMchId); //子商户号
|
|
|
+ result.Add("appid", AppId); //应用ID
|
|
|
+ result.Add("transaction_id", TradeNo); //微信订单号
|
|
|
+ result.Add("out_order_no", OrderNo); //商户分账单号
|
|
|
+ result.Add("receivers", Receivers); //分账接收方列表
|
|
|
+ result.Add("unfreeze_unsplit", true); //是否解冻剩余未分资金
|
|
|
+ string req = Newtonsoft.Json.JsonConvert.SerializeObject(result);
|
|
|
+ string resp = postJson("https://api.mch.weixin.qq.com/v3/profitsharing/orders", req, prikey, MchId, serialNo);
|
|
|
+ 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"}
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 服务商平台添加分账接收方API
|
|
|
+
|
|
|
+ public string AddReceive(string SubMchId, string TypeName, string Account, string Name, string Relation)
|
|
|
+ {
|
|
|
+ Dictionary<string, object> result = new Dictionary<string, object>();
|
|
|
+ result.Add("sub_mchid", SubMchId); //子商户号
|
|
|
+ result.Add("appid", AppId); //应用ID
|
|
|
+ result.Add("type", TypeName); //分账接收方类型 MERCHANT_ID:商户ID PERSONAL_OPENID:个人openid(由父商户APPID转换得到) PERSONAL_SUB_OPENID:个人sub_openid(由子商户APPID转换得到)
|
|
|
+ result.Add("account", Account); //分账接收方账号
|
|
|
+ if(!string.IsNullOrEmpty(Name))
|
|
|
+ {
|
|
|
+ result.Add("name", RSAEncrypt(Name)); //分账个人接收方姓名
|
|
|
+ }
|
|
|
+ result.Add("relation_type", Relation); //与分账方的关系类型 STORE:门店 STAFF:员工 STORE_OWNER:店主 PARTNER:合作伙伴 HEADQUARTER:总部 BRAND:品牌方 DISTRIBUTOR:分销商 USER:用户 SUPPLIER: 供应商 CUSTOM:自定义
|
|
|
+ string req = Newtonsoft.Json.JsonConvert.SerializeObject(result);
|
|
|
+ string resp = postJson("https://api.mch.weixin.qq.com/v3/profitsharing/receivers/add", req, prikey, MchId, serialNo);
|
|
|
+ return resp;
|
|
|
+ //{"account":"1611167423","name":"x+8m5jM4x2jSZLDOpN46Js9JyeNgUXkFSmGjCBN45QcSYUNPN86TOheRF64WlwDeO45E/walWPeZSksNN/LfJiB2fZRVun1CJuJ7zxePma8L7iDbKS92i+d38rvOmNTjLhKX64O8oJR4HMtFw1HryxJlUFgM5/ickJ79WGrX3GaVArWisgEzwOyxGBfGSL3ofJhi5TdTnrxHMzqYWv43DRvI9Ja5eMgFbgrGcn+JiJVKQcYj1L8tZ6xQeQCXkY6ubyDiV9wQps2nQA1Oh+UdFcS13Ex4FUSYLCczGFAl4EV8TBJQleZeC1p4ZJquJjje0uMjI2xB6S41yUBoN86gkA==","relation_type":"PARTNER","sub_mchid":"1645266943","type":"MERCHANT_ID"}
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
|
|
|
|
|
|
|