transfer
This commit is contained in:
parent
4639ed83f2
commit
8631be3cc3
@ -683,7 +683,7 @@ class EarningController extends Controller
|
|||||||
Log::info("转账回调");
|
Log::info("转账回调");
|
||||||
$url = config("app.url") . "/util/api/wechatpay/saas/mch/transfer/callback";
|
$url = config("app.url") . "/util/api/wechatpay/saas/mch/transfer/callback";
|
||||||
$token = $request->bearerToken();
|
$token = $request->bearerToken();
|
||||||
$header = [
|
$headers = [
|
||||||
'Authorization' => "Bearer " . $token,
|
'Authorization' => "Bearer " . $token,
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'wechatpay-timestamp' => $_SERVER['HTTP_WECHATPAY_TIMESTAMP'] ?? '',
|
'wechatpay-timestamp' => $_SERVER['HTTP_WECHATPAY_TIMESTAMP'] ?? '',
|
||||||
@ -692,12 +692,14 @@ class EarningController extends Controller
|
|||||||
'wechatpay-serial' => $_SERVER['HTTP_WECHATPAY_SERIAL'] ?? '',
|
'wechatpay-serial' => $_SERVER['HTTP_WECHATPAY_SERIAL'] ?? '',
|
||||||
];
|
];
|
||||||
|
|
||||||
$data = $request->all();
|
$body = file_get_contents('php://input');
|
||||||
|
Log::info("请求头", ["headers" => $headers]);
|
||||||
|
Log::info("请求体", ["body" => $body]);
|
||||||
$options = [
|
$options = [
|
||||||
RequestOptions::TIMEOUT => 3,
|
RequestOptions::TIMEOUT => 3,
|
||||||
RequestOptions::HTTP_ERRORS => false,
|
RequestOptions::HTTP_ERRORS => false,
|
||||||
RequestOptions::HEADERS => $header,
|
RequestOptions::HEADERS => $headers,
|
||||||
RequestOptions::QUERY => $data,
|
RequestOptions::QUERY => $body,
|
||||||
];
|
];
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
$response = $client->post($url, $options);
|
$response = $client->post($url, $options);
|
||||||
@ -714,11 +716,17 @@ class EarningController extends Controller
|
|||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$withdraw = MEarningwithdraws::where("trade_no", $res["data"]["out_bill_no"])->first();
|
$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 = MEarningAccount::where("m_id", $withdraw->m_id)->where("m_user_id", $withdraw->m_user_id)->first(); //修改账号状态
|
||||||
|
if ($res["data"]["state"] == "SUCCESS") {
|
||||||
$earning_account->decrement('frozen_withdraw', $withdraw->value);
|
$earning_account->decrement('frozen_withdraw', $withdraw->value);
|
||||||
$earning_account->increment('withdrawl', $withdraw->value);
|
$earning_account->increment('withdrawl', $withdraw->value);
|
||||||
$withdraw->update(['status' => 'finished']);
|
$withdraw->update(['status' => 'finished']);
|
||||||
//成功通知
|
//成功通知
|
||||||
$this->sendWithdrawNotice($earning_account, $withdraw);
|
$this->sendWithdrawNotice($earning_account, $withdraw);
|
||||||
|
} else { // 转账失败
|
||||||
|
$earning_account->decrement('frozen_withdraw', $withdraw->value);
|
||||||
|
$earning_account->increment("balance", $withdraw->value);
|
||||||
|
$withdraw->update(['status' => 'canceled']);
|
||||||
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user