Kirin il y a 3 ans
Parent
commit
8c73c15258

+ 6 - 9
app/admin/controller/finance/UserExtract.php

@@ -165,15 +165,12 @@ class UserExtract extends AuthController
             $open_id = WechatUser::where('uid', $extract['uid'])->find();
             if ($open_id['openid']) {
                 try {
-                    $ress = WechatService::paymentService()->batches('ex' . date('YmdHis') . $extract['id'], sys_config('site_name') . '-' . '用户提现到账',
-                        '提现申请通过,实际到账' . $real_get . '元', $real_get * 100, 1, [
-                            [
-                                'out_detail_no' => 'ex' . date('YmdHis') . $extract['id'] . '-1',
-                                'transfer_amount' => $real_get * 100,
-                                'transfer_remark' => '提现申请通过,实际到账' . $real_get . '元',
-                                'openid' => $open_id['openid'],
-                            ]
-                        ]);
+                    $ress = WechatService::paymentService()->batches(
+                        'ex' . date('YmdHis') . $extract['id'],
+                        $open_id,
+                        $real_get * 100,
+                        sys_config('site_name') . '-' . '用户提现到账'
+                    );
                     var_dump($ress);
                 } catch (\Exception $e) {
                     UserExtractModel::rollbackTrans();

+ 28 - 28
vendor/overtrue/wechat/src/Payment/API.php

@@ -74,7 +74,7 @@ class API extends AbstractAPI
     const API_QUERY_REFUND = '/pay/refundquery';
     const API_DOWNLOAD_BILL = '/pay/downloadbill';
     const API_REPORT = '/payitil/report';
-    const api_batches = '/v3/transfer/batches';
+    const api_batches = '/mmpaymkttransfers/promotion/transfers';
 
     const API_URL_SHORTEN = 'https://api.mch.weixin.qq.com/tools/shorturl';
     const API_AUTH_CODE_TO_OPENID = 'https://api.mch.weixin.qq.com/tools/authcodetoopenid';
@@ -95,7 +95,7 @@ class API extends AbstractAPI
     /**
      * API constructor.
      *
-     * @param \EasyWeChat\Payment\Merchant      $merchant
+     * @param \EasyWeChat\Payment\Merchant $merchant
      * @param \Doctrine\Common\Cache\Cache|null $cache
      */
     public function __construct(Merchant $merchant, Cache $cache = null)
@@ -212,8 +212,8 @@ class API extends AbstractAPI
      *
      * @param string $orderNo
      * @param string $refundNo
-     * @param float  $totalFee
-     * @param float  $refundFee
+     * @param float $totalFee
+     * @param float $refundFee
      * @param string $opUserId
      * @param string $type
      * @param string $refundAccount
@@ -230,7 +230,8 @@ class API extends AbstractAPI
         $type = self::OUT_TRADE_NO,
         $refundAccount = 'REFUND_SOURCE_UNSETTLED_FUNDS',
         $refundReason = ''
-        ) {
+    )
+    {
         $params = [
             $type => $orderNo,
             'out_refund_no' => $refundNo,
@@ -250,8 +251,8 @@ class API extends AbstractAPI
      *
      * @param string $orderNo
      * @param string $refundNo
-     * @param float  $totalFee
-     * @param float  $refundFee
+     * @param float $totalFee
+     * @param float $refundFee
      * @param string $opUserId
      * @param string $refundAccount
      * @param string $refundReason
@@ -266,7 +267,8 @@ class API extends AbstractAPI
         $opUserId = null,
         $refundAccount = 'REFUND_SOURCE_UNSETTLED_FUNDS',
         $refundReason = ''
-        ) {
+    )
+    {
         return $this->refund($orderNo, $refundNo, $totalFee, $refundFee, $opUserId, self::TRANSACTION_ID, $refundAccount, $refundReason);
     }
 
@@ -357,10 +359,10 @@ class API extends AbstractAPI
      * Report API status to WeChat.
      *
      * @param string $api
-     * @param int    $timeConsuming
+     * @param int $timeConsuming
      * @param string $resultCode
      * @param string $returnCode
-     * @param array  $other         ex: err_code,err_code_des,out_trade_no,user_ip...
+     * @param array $other ex: err_code,err_code_des,out_trade_no,user_ip...
      *
      * @return \EasyWeChat\Support\Collection
      */
@@ -431,10 +433,10 @@ class API extends AbstractAPI
      * Make a API request.
      *
      * @param string $api
-     * @param array  $params
+     * @param array $params
      * @param string $method
-     * @param array  $options
-     * @param bool   $returnResponse
+     * @param array $options
+     * @param bool $returnResponse
      *
      * @return \EasyWeChat\Support\Collection|\Psr\Http\Message\ResponseInterface
      */
@@ -475,7 +477,7 @@ class API extends AbstractAPI
      * Request with SSL.
      *
      * @param string $api
-     * @param array  $params
+     * @param array $params
      * @param string $method
      *
      * @return \EasyWeChat\Support\Collection
@@ -503,7 +505,7 @@ class API extends AbstractAPI
             $response = $response->getBody();
         }
 
-        return new Collection((array) XML::parse($response));
+        return new Collection((array)XML::parse($response));
     }
 
     /**
@@ -515,7 +517,7 @@ class API extends AbstractAPI
      */
     protected function wrapApi($resource)
     {
-        return self::API_HOST.($this->sandboxEnabled ? '/sandboxnew' : '').$resource;
+        return self::API_HOST . ($this->sandboxEnabled ? '/sandboxnew' : '') . $resource;
     }
 
     /**
@@ -530,7 +532,7 @@ class API extends AbstractAPI
         }
 
         // Try to get sandbox_signkey from cache
-        $cacheKey = 'sandbox_signkey.'.$this->merchant->merchant_id.$this->merchant->sub_merchant_id;
+        $cacheKey = 'sandbox_signkey.' . $this->merchant->merchant_id . $this->merchant->sub_merchant_id;
 
         /** @var \Doctrine\Common\Cache\Cache $cache */
         $cache = $this->getCache();
@@ -565,19 +567,17 @@ class API extends AbstractAPI
 
     public function batches(
         $out_batch_no,
-        $batch_name,
-        $batch_remark,
-        $total_amount,
+        $open_id,
         $total_num,
-        $transfer_detail_list
-    ) {
+        $mark
+    )
+    {
         $params = [
-            'out_batch_no' => $out_batch_no,
-            'batch_name' => $batch_name,
-            'batch_remark' => $batch_remark,
-            'total_amount' => $total_amount,
-            'total_num' => $total_num,
-            'transfer_detail_list' => $transfer_detail_list,
+            'partnet_trade_no' => $out_batch_no,
+            'open_id' => $open_id,
+            'check_name' => 'NO_CHECK',
+            'amount' => $total_num,
+            'desc' => $mark
         ];
 
         return $this->safeRequest($this->wrapApi(self::api_batches), $params);