transfer
This commit is contained in:
parent
f2e8429286
commit
ff37d8f17e
@ -20,13 +20,7 @@ class Controller extends BaseController
|
|||||||
$openid = "oPC_2vneOWpQbicNZQAUCxuwZ4mw";
|
$openid = "oPC_2vneOWpQbicNZQAUCxuwZ4mw";
|
||||||
$amount = 100;
|
$amount = 100;
|
||||||
$remark = "测试";
|
$remark = "测试";
|
||||||
$res = WechatPayService::officialUserTransfer($trade_no, $scene_id, $openid, $amount, $remark);
|
$res = WechatPayService::transferBatches($trade_no, $scene_id, $openid, $amount, $remark);
|
||||||
dd($res);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getWechatplatformcCert()
|
|
||||||
{
|
|
||||||
$res = WechatPayService::getPlatformCert();
|
|
||||||
dd($res);
|
dd($res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,30 +55,11 @@ class WechatPayService
|
|||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPlatformCert()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$instance = $this->newClient();
|
|
||||||
$resp = $instance->chain('v3/certificates')->get(
|
|
||||||
/** @see https://docs.guzzlephp.org/en/stable/request-options.html#debug */
|
|
||||||
// ['debug' => true] // 调试模式
|
|
||||||
);
|
|
||||||
return $resp->getBody();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
// 进行异常捕获并进行错误判断处理
|
|
||||||
Log::info($e->getMessage());
|
|
||||||
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
|
|
||||||
return $resp->getBody();
|
|
||||||
}
|
|
||||||
return $e->getTraceAsString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转账零钱
|
* 商家转账
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function officialUserTransfer(string $trade_no, string $scene_id, string $openid, int $amount, string $remark, array $transfer_scene_report_infos = []): array
|
public function mchTransfer(string $trade_no, string $scene_id, string $openid, int $amount, string $remark, array $transfer_scene_report_infos = []): array
|
||||||
{
|
{
|
||||||
// 发送请求
|
// 发送请求
|
||||||
if (empty(count($transfer_scene_report_infos))) {
|
if (empty(count($transfer_scene_report_infos))) {
|
||||||
@ -124,6 +105,50 @@ class WechatPayService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商家批量转账到零钱
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function transferBatches(string $trade_no, string $scene_id, string $openid, int $amount, string $remark): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$appid = config("wechat.official_account.default.app_id");
|
||||||
|
$data = [
|
||||||
|
"appid" => $appid,
|
||||||
|
"out_bill_no" => $trade_no,
|
||||||
|
"transfer_scene_id" => (string) $scene_id,
|
||||||
|
"batch_name" => $remark,
|
||||||
|
"batch_remark" => $remark,
|
||||||
|
"total_amount" => $amount,
|
||||||
|
"total_num" => 1,
|
||||||
|
"transfer_detail_list" => [
|
||||||
|
"out_detail_no" => $trade_no,
|
||||||
|
"transfer_amount" => $amount,
|
||||||
|
"transfer_remark" => $remark,
|
||||||
|
"openid" => $openid,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
Log::info("转账到零钱数据", $data);
|
||||||
|
$instance = $this->newClient();
|
||||||
|
$resp = $instance->chain('v3/transfer/batche')->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 void
|
* @return void
|
||||||
|
|||||||
@ -21,4 +21,3 @@ Route::prefix("transfer")->group(function () {
|
|||||||
|
|
||||||
Route::get("test", [Controller::class, "test"]);
|
Route::get("test", [Controller::class, "test"]);
|
||||||
|
|
||||||
Route::get("wechat/platform/cert", [Controller::class, "getWechatplatformcCert"]);
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user