附函数代码:
//微信单次分账支付, $receive 分账接收方列表
public function wechat_profitsharing_buid($params, $wechat,$receive){
global $_W;
load()->func("communication");
$wOpt = array( );
$package = array( );
// $platform_amount = ($params['fee'] - array_sum(array_column($receive, 'amount')));//平台分成 = 订单总金额 - 分给接收方的分成
// $platform = array('type'=>'MERCHANT_ID','account'=>$wechat["mch_id"],'amount'=>$platform_amount,'description'=>'分给平台');//平台
$package["mch_id"] = trim($wechat["mch_id"]);//商户号
$package["appid"] = trim($wechat["appid"]);//公众账号ID
$package["nonce_str"] = random(32);//32位随机字符串
$package["transaction_id"] = $params['transaction_id'];//微信支付订单号
$package["out_order_no"] = trim($params["tid"]);//商户分账单号
$package['receivers']=json_encode(array($receive));//接收会员列表,包含字段:type、account、amount、description
ksort($package, SORT_STRING);
$string1 = "";
foreach( $package as $key => $v )
{
if( empty($v) )
{
continue;
}
$string1 .= (string) $key . "=" . $v . "&";
}
$string1 .= "key=" . $wechat["apikey"];
$package['sign_type'] = 'HMAC-SHA256';//签名类型,目前只支持HMAC-SHA256
$package["sign"] = strtoupper(hash_hmac('sha256',trim($string1),$wechat["apikey"]));//sha256签名,
flog($package,'common.wechat_profitsharing_buid.log','ewei_shop.model','package封装请求的参数');
$dat = array2xml($package);
$response = ihttp_request("https://api.mch.weixin.qq.com/secapi/pay/profitsharing", $dat);
flog($response,'common.wechat_profitsharing_buid.log','ewei_shop.model','RESPONSE的值');
return $response;
}
<xml><appid>wx7888493b589bb548</appid><mch_id>1378820302</mch_id><nonce_str>C4411Q4Dx6a1aXd8xHzdd4eDq460DeZh</nonce_str><out_order_no>SK20200118173743113186</out_order_no><receivers>[{"type":"PERSONAL_OPENID","account":"oVUjTvyQlLm_NHf17ZWbQBulZP8I","amount":1,"description":"TEST:4"}]</receivers><transaction_id>4200000508202001184570067415</transaction_id><sign_type>HMAC-SHA256</sign_type><sign>0562D988C411521FE4D18A109340EC6302E4BD6224CEDC17151D946F0C7836F5</sign></xml>
楼主 解决了吗?