|
|
@@ -33,6 +33,8 @@ class Wechat
|
|
|
'queryOrder' => 'https://api.mch.weixin.qq.com/pay/orderquery',
|
|
|
// 企业付款到零钱
|
|
|
'transfers' => 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers',
|
|
|
+ // 查询企业付款订单
|
|
|
+ 'queryTransfer' => 'https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo',
|
|
|
// 生成二维码
|
|
|
'makeQrcode' => 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s',
|
|
|
// 换取二维码
|
|
|
@@ -684,7 +686,6 @@ class Wechat
|
|
|
return ['code' => 'error', 'message' => '参数错误'];
|
|
|
}
|
|
|
$unified = array(
|
|
|
-// 'mch_appid' => 'ww80960cfd3748a47f',
|
|
|
'mch_appid' => $appId,
|
|
|
'mchid' => trim($mchId),
|
|
|
'device_info' => uniqid(),
|
|
|
@@ -701,17 +702,15 @@ class Wechat
|
|
|
if($unified['check_name'] == 'FORCE_CHECK'){
|
|
|
$unified['re_user_name'] = isset($order['real_name']) ? trim($order['real_name']) : '';
|
|
|
}
|
|
|
-var_dump($unified);
|
|
|
+
|
|
|
PRedis::set('orders:'.$scene.':'.$openid.':unified', $unified, 600);
|
|
|
$unified['sign'] = Wechat::getPaySign($unified);
|
|
|
- var_dump($unified);
|
|
|
PRedis::set('orders:'.$scene.':'.$openid.':unifiedSign', $unified, 600);
|
|
|
$url = !empty(self::$apiUrl['transfers']) ? trim(self::$apiUrl['transfers']) : 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers';
|
|
|
$data = Wechat::arrayToXml($unified);
|
|
|
- var_dump($data);
|
|
|
PRedis::set('orders:'.$scene.':'.$openid.':unifiedXml', ['data'=> $unified,'result'=> $data], 600);
|
|
|
$responseXml = Wechat::curlPost($url, $data, [], self::$certPaths);
|
|
|
- var_dump($responseXml);
|
|
|
+
|
|
|
//禁止引用外部xml实体
|
|
|
libxml_disable_entity_loader(true);
|
|
|
$result = simplexml_load_string($responseXml, 'SimpleXMLElement', LIBXML_NOCDATA);
|
|
|
@@ -731,6 +730,50 @@ var_dump($unified);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 查询企业付款订单
|
|
|
+ * @param $trane_order_no 订单号
|
|
|
+ * @return string[]
|
|
|
+ */
|
|
|
+ public static function queryTransferOrder($trane_order_no){
|
|
|
+ $appId = Wechat::getConfigs('appid');
|
|
|
+ $mchId = Wechat::getConfigs('mch_id');
|
|
|
+ if (empty($trane_order_no)) {
|
|
|
+ return ['code' => 'error', 'message' => '参数错误'];
|
|
|
+ }
|
|
|
+ $unified = array(
|
|
|
+ 'mch_appid' => $appId,
|
|
|
+ 'mchid' => trim($mchId),
|
|
|
+ 'nonce_str' => Wechat::createNonceStr(),
|
|
|
+ 'partner_trade_no' => $trane_order_no,
|
|
|
+ );
|
|
|
+
|
|
|
+ PRedis::set('orders:transfer:'.$trane_order_no.':unified', $unified, 600);
|
|
|
+ $unified['sign'] = Wechat::getPaySign($unified);
|
|
|
+ PRedis::set('orders:transfer:'.$trane_order_no.':unifiedSign', $unified, 600);
|
|
|
+ $url = !empty(self::$apiUrl['queryTransfer']) ? trim(self::$apiUrl['queryTransfer']) : 'https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo';
|
|
|
+ $data = Wechat::arrayToXml($unified);
|
|
|
+ PRedis::set('orders:transfer:'.$trane_order_no.':unifiedXml', ['data'=> $unified,'result'=> $data], 600);
|
|
|
+ $responseXml = Wechat::curlPost($url, $data, [], self::$certPaths);
|
|
|
+
|
|
|
+ //禁止引用外部xml实体
|
|
|
+ libxml_disable_entity_loader(true);
|
|
|
+ $result = simplexml_load_string($responseXml, 'SimpleXMLElement', LIBXML_NOCDATA);
|
|
|
+ $result = (array)$result;
|
|
|
+ PRedis::set('orders:transfer:'.$trane_order_no.':unifiedResult', ['data'=> $result,'result'=> $data], 600);
|
|
|
+ if ($result === false) {
|
|
|
+ return ['code' => 'exception', 'message' => 'parase xml error'];
|
|
|
+ }
|
|
|
+ if (isset($result['return_code']) && $result['return_code'] != 'SUCCESS') {
|
|
|
+ return ['code' => 'error', 'message' => Wechat::getError($result['return_msg']),'type'=>'return_code'];
|
|
|
+ }
|
|
|
+ if (isset($result['result_code']) && $result['result_code'] != 'SUCCESS') {
|
|
|
+ return ['code' => 'error', 'message' => $result['err_code_des'],'error_code'=> $result['err_code'],'type'=>'result_code'];
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取错误码内容
|
|
|
* @param $code
|
|
|
* @return mixed|string
|