transfer
This commit is contained in:
parent
9bde14c832
commit
81d3db72fe
@ -614,12 +614,14 @@ class EarningController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
Log::info("转账请求");
|
Log::info("转账请求");
|
||||||
$url = config("app.url") . "/util/api/wechatpay/saas/mch/transfer";
|
$url = config("app.url") . "/util/api/wechatpay/saas/mch/transfer";
|
||||||
|
$notify_url = config("app.url") . "/api/s/h5/mch/transfer/callback";
|
||||||
Log::info("转账请求链接:" . $url);
|
Log::info("转账请求链接:" . $url);
|
||||||
$data = [
|
$data = [
|
||||||
"trade_no" => $withdraw->trade_no,
|
"trade_no" => $withdraw->trade_no,
|
||||||
"openid" => $openid,
|
"openid" => $openid,
|
||||||
"amount" => (int) ($withdraw->real_value * 100),
|
"amount" => (int) ($withdraw->real_value * 100),
|
||||||
"remark" => "用户提现",
|
"remark" => "用户提现",
|
||||||
|
"notify_url" => $notify_url,
|
||||||
];
|
];
|
||||||
$token = $request->bearerToken();
|
$token = $request->bearerToken();
|
||||||
$header = [
|
$header = [
|
||||||
@ -658,7 +660,52 @@ class EarningController extends Controller
|
|||||||
// $this->sendWithdrawNotice($earning_account, $withdraw);
|
// $this->sendWithdrawNotice($earning_account, $withdraw);
|
||||||
}
|
}
|
||||||
DB::commit();
|
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) {
|
} catch (Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
$this->getError($e);
|
$this->getError($e);
|
||||||
|
|||||||
@ -473,6 +473,9 @@ Route::middleware('merchant_user')->group(function () {
|
|||||||
//中转页面
|
//中转页面
|
||||||
Route::get('general/qrcode/transfer', 'GeneralQrcodeController@transfer')->name('s_h5.general.qrcode.transfer');
|
Route::get('general/qrcode/transfer', 'GeneralQrcodeController@transfer')->name('s_h5.general.qrcode.transfer');
|
||||||
|
|
||||||
|
// 转账回调
|
||||||
|
Route::any("communities/UserWithdrawal/callback", [EarningController::class, "withdrawApplyCallback"]);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商户渠道
|
* 商户渠道
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user