This commit is contained in:
Hankin 2025-08-13 14:00:53 +08:00
parent 1e6efdcd80
commit 7b84fb3b89

View File

@ -111,40 +111,40 @@ class WechatPayService
public function transferBatches(string $trade_no, string $trade_no2, string $openid, int $amount, string $remark): array
{
try {
$appid = config("wechat.official_account.default.app_id");
$data = [
"appid" => $appid,
"out_bill_no" => $trade_no,
"batch_name" => $remark,
"batch_remark" => $remark,
"total_amount" => $amount,
"total_num" => 1,
"transfer_detail_list" => [
"out_detail_no" => $trade_no2,
"transfer_amount" => $amount,
"transfer_remark" => $remark,
"openid" => $openid,
]
];
Log::info("转账到零钱数据", $data);
$instance = $this->newClient();
$resp = $instance->chain('v3/transfer/batches')->post([
"json" => $data
]);
$res = json_decode($resp->getBody(), true);
dd($res);
} catch (\Exception $e) {
// 进行异常捕获并进行错误判断处理
Log::info($e->getMessage());
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
$r = $e->getResponse();
$res = json_decode($r->getBody());
return ["code" => 1, "err_msg" => $r->getBody()];
}
// try {
$appid = config("wechat.official_account.default.app_id");
$data = [
"appid" => $appid,
"out_bill_no" => $trade_no,
"batch_name" => $remark,
"batch_remark" => $remark,
"total_amount" => $amount,
"total_num" => 1,
"transfer_detail_list" => [
"out_detail_no" => $trade_no2,
"transfer_amount" => $amount,
"transfer_remark" => $remark,
"openid" => $openid,
]
];
Log::info("转账到零钱数据", $data);
$instance = $this->newClient();
$resp = $instance->chain('v3/transfer/batches')->post([
"json" => $data
]);
$res = json_decode($resp->getBody(), true);
dd($res);
// } catch (\Exception $e) {
// // 进行异常捕获并进行错误判断处理
// Log::info($e->getMessage());
// if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
// $r = $e->getResponse();
// $res = json_decode($r->getBody());
// return ["code" => 1, "err_msg" => $r->getBody()];
// }
return ["code" => 1, "err_msg" => $e->getMessage()];
}
// return ["code" => 1, "err_msg" => $e->getMessage()];
// }
}