소스 검색

feat: 更新微信转账逻辑以使用新的转账接口和参数

在WalletWithdrawRecordService中,修改了processPayment方法,更新了微信转账请求的接口路径为'v3/fund-app/mch-transfer/transfer-bills',并调整了请求参数以支持新的转账场景和详细信息。这一更改旨在提升转账功能的灵活性和稳定性,确保提现操作的顺利进行。
刘学玺 2 달 전
부모
커밋
a54780ed3a
1개의 변경된 파일21개의 추가작업 그리고 19개의 파일을 삭제
  1. 21 19
      app/Services/Admin/WalletWithdrawRecordService.php

+ 21 - 19
app/Services/Admin/WalletWithdrawRecordService.php

@@ -245,7 +245,7 @@ class WalletWithdrawRecordService
 
                 // 使用 EasyWeChat 支付实例
                 $config = config('wechat.pay.default');
-                $app = \EasyWeChat\Pay\Application::fromConfig($config);
+                $app = new \EasyWeChat\Pay\Application($config);
 
                 // 生成商户订单号
                 $outTradeNo = 'W' . date('YmdHis') . str_pad($record->id, 6, '0', STR_PAD_LEFT);
@@ -264,21 +264,23 @@ class WalletWithdrawRecordService
                 ]);
 
                 try {
-                    // 使用商户转账到零钱接口
-                    $response = $app->getClient()->postJson('v3/transfer/batches', [
+                    // 使用商家转账接口
+                    $response = $app->getClient()->postJson('v3/fund-app/mch-transfer/transfer-bills', [
                         'appid' => $config['app_id'],
-                        'out_batch_no' => $outTradeNo,
-                        'batch_name' => '提现到零钱',
-                        'batch_remark' => '用户提现',
-                        'total_amount' => (int)bcmul($record->amount, '100'),
-                        'total_num' => 1,
-                        'transfer_detail_list' => [
+                        'out_bill_no' => $outTradeNo,
+                        'transfer_scene_id' => '1001', // 现金营销场景
+                        'openid' => $record->withdraw_account,
+                        // 'user_name' => $record->withdraw_account_name,
+                        'transfer_amount' => (int)bcmul($record->amount, '100'),
+                        'transfer_remark' => '提现到零钱',
+                        'transfer_scene_report_infos' => [
                             [
-                                'out_detail_no' => $outTradeNo,
-                                'transfer_amount' => (int)bcmul($record->amount, '100'),
-                                'transfer_remark' => '提现到零钱',
-                                'openid' => $record->withdraw_account,
-                                'user_name' => $record->withdraw_account_name
+                                'info_type' => '活动名称',
+                                'info_content' => '用户提现'
+                            ],
+                            [
+                                'info_type' => '奖励说明',
+                                'info_content' => '余额提现'
                             ]
                         ]
                     ]);
@@ -290,17 +292,17 @@ class WalletWithdrawRecordService
                         'result' => $result
                     ]);
 
-                    // 检查批次处理状态
-                    if (isset($result['batch_id'])) {
+                    // 检查转账状态
+                    if (isset($result['bill_id'])) {
                         Log::info('微信转账成功', [
                             'withdraw_id' => $record->id,
-                            'batch_id' => $result['batch_id'],
-                            'out_batch_no' => $outTradeNo
+                            'bill_id' => $result['bill_id'],
+                            'out_bill_no' => $outTradeNo
                         ]);
 
                         return [
                             'success' => true,
-                            'trade_no' => $result['batch_id'],
+                            'trade_no' => $result['bill_id'],
                             'message' => '微信转账成功'
                         ];
                     }