|
@@ -60,7 +60,7 @@ namespace MySystem
|
|
|
|
|
|
#region 服务商平台JSAPI下单
|
|
|
|
|
|
- public Dictionary<string, string> Pay(string AppId, string MchId, string SubMchId, decimal PayMoney, string OrderNo, string Description, string OpenId, string Key, string NotifyUrl)
|
|
|
+ public Dictionary<string, string> Pay(string SubMchId, decimal PayMoney, string OrderNo, string Description, string OpenId, string Key, string NotifyUrl, bool IsAct = false)
|
|
|
{
|
|
|
Dictionary<string, string> return_result = new Dictionary<string, string>();
|
|
|
int amount = (int)(PayMoney * 100);
|
|
@@ -73,7 +73,7 @@ namespace MySystem
|
|
|
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); //是否指定分账
|
|
|
+ settle_info.Add("profit_sharing", IsAct); //是否指定分账
|
|
|
par.Add("settle_info", settle_info); //结算信息
|
|
|
Dictionary<string, object> amountDic = new Dictionary<string, object>();
|
|
|
amountDic.Add("total", amount); //总金额
|
|
@@ -86,11 +86,9 @@ namespace MySystem
|
|
|
function.WriteLog(req, "服务商平台JSAPI下单请求参数");
|
|
|
try
|
|
|
{
|
|
|
- string merchantId = MchId; //商户号
|
|
|
- string serialNo = "62B64854B768D344249FDB9E6EF4A1232C000E84"; //证书编号
|
|
|
function.WriteLog(serialNo, "服务商平台JSAPI下单请求参数");
|
|
|
function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(par), "服务商平台JSAPI下单请求参数");
|
|
|
- string result = postJson("https://api.mch.weixin.qq.com/v3/pay/partner/transactions/jsapi", req, prikey, merchantId, serialNo);
|
|
|
+ string result = postJson("https://api.mch.weixin.qq.com/v3/pay/partner/transactions/jsapi", req, prikey, MchId, serialNo);
|
|
|
function.WriteLog(result, "服务商平台JSAPI下单请求参数");
|
|
|
JsonData jsonObj = JsonMapper.ToObject(result);
|
|
|
string timeStamp = function.ConvertDateTimeInt(DateTime.Now).ToString();
|
|
@@ -205,7 +203,7 @@ namespace MySystem
|
|
|
|
|
|
#region 服务商平台请求分账API
|
|
|
|
|
|
- public string ProfitShare(string SubMchId, string TradeNo, string OrderNo, List<ReceiverList> Receivers)
|
|
|
+ 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); //子商户号
|
|
@@ -217,6 +215,28 @@ namespace MySystem
|
|
|
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
|
|
|
|
|
@@ -224,8 +244,9 @@ namespace MySystem
|
|
|
|
|
|
public string QueryProfitShare(string SubMchId, string TradeNo, string OrderNo)
|
|
|
{
|
|
|
- string resp = function.GetWebRequest("https://api.mch.weixin.qq.com/v3/profitsharing/orders/" + OrderNo + "?sub_mchid=" + SubMchId + "&transaction_id=" + TradeNo);
|
|
|
+ string resp = postJson("https://api.mch.weixin.qq.com/v3/profitsharing/orders/" + OrderNo + "?sub_mchid=" + SubMchId + "&transaction_id=" + TradeNo, "", prikey, MchId, serialNo, "GET");
|
|
|
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":"2023-06-02T11:34:41+08:00","result":"SUCCESS","type":"MERCHANT_ID"},{"account":"1645266943","amount":7,"create_time":"2023-06-02T11:34:10+08:00","description":"解冻给分账方","detail_id":"36000104462023060269999025890","finish_time":"2023-06-02T11:34:41+08:00","result":"SUCCESS","type":"MERCHANT_ID"}],"state":"FINISHED","sub_mchid":"1645266943","transaction_id":"4200001833202306025522158377"}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
@@ -239,7 +260,7 @@ namespace MySystem
|
|
|
result.Add("out_order_no", OrderNo); //商户分账单号
|
|
|
result.Add("description", Description); //分账描述
|
|
|
string req = Newtonsoft.Json.JsonConvert.SerializeObject(result);
|
|
|
- string resp = function.PostWebRequest("https://api.mch.weixin.qq.com/v3/profitsharing/orders/unfreeze", req, "application/json");
|
|
|
+ string resp = postJson("https://api.mch.weixin.qq.com/v3/profitsharing/orders/unfreeze", req, prikey, MchId, serialNo);
|
|
|
return resp;
|
|
|
}
|
|
|
#endregion
|