This commit is contained in:
Hankin 2026-04-23 18:23:13 +08:00
parent 9bde14c832
commit 81d3db72fe
2 changed files with 51 additions and 1 deletions

View File

@ -614,12 +614,14 @@ class EarningController extends Controller
} else {
Log::info("转账请求");
$url = config("app.url") . "/util/api/wechatpay/saas/mch/transfer";
$notify_url = config("app.url") . "/api/s/h5/mch/transfer/callback";
Log::info("转账请求链接:" . $url);
$data = [
"trade_no" => $withdraw->trade_no,
"openid" => $openid,
"amount" => (int) ($withdraw->real_value * 100),
"remark" => "用户提现",
"notify_url" => $notify_url,
];
$token = $request->bearerToken();
$header = [
@ -658,7 +660,52 @@ class EarningController extends Controller
// $this->sendWithdrawNotice($earning_account, $withdraw);
}
DB::commit();
return $this->success('ok', ['status' => 1]);
return $this->success('ok', ['status' => 1, "package_info" => "", "app_id" => "", "mch_id" => ""]);
} catch (Exception $e) {
DB::rollBack();
$this->getError($e);
return $this->failure('服务器休息,请稍后再试');
}
}
public function withdrawApplyCallback(Request $request)
{
try {
Log::info("转账回调");
$url = config("app.url") . "/util/api/wechatpay/saas/mch/transfer/callback";
$token = $request->bearerToken();
$header = [
'Authorization' => "Bearer " . $token,
'Content-Type' => 'application/json'
];
$data = $request->all();
$options = [
RequestOptions::TIMEOUT => 3,
RequestOptions::HTTP_ERRORS => false,
RequestOptions::HEADERS => $header,
RequestOptions::QUERY => $data,
];
$client = new Client();
$response = $client->post($url, $options);
$content = $response->getBody();
$res = json_decode($content, true);
if ($res && isset($res['code'])) {
if ($res['code']) {
throw new Exception($res['message']);
}
} else {
throw new Exception("回调失败");
}
DB::beginTransaction();
$withdraw = MEarningwithdraws::where("trade_no", $res["data"]["out_bill_no"])->first();
$earning_account = MEarningAccount::where("m_id", $withdraw->m_id)->where("m_user_id", $withdraw->m_user_id)->first(); //修改账号状态
$earning_account->decrement('frozen_withdraw', $withdraw->value);
$earning_account->increment('withdrawl', $withdraw->value);
$withdraw->update(['status' => 'finished']);
//成功通知
$this->sendWithdrawNotice($earning_account, $withdraw);
DB::commit();
} catch (Exception $e) {
DB::rollBack();
$this->getError($e);

View File

@ -473,6 +473,9 @@ Route::middleware('merchant_user')->group(function () {
//中转页面
Route::get('general/qrcode/transfer', 'GeneralQrcodeController@transfer')->name('s_h5.general.qrcode.transfer');
// 转账回调
Route::any("communities/UserWithdrawal/callback", [EarningController::class, "withdrawApplyCallback"]);
/**
* 商户渠道