feat: 打款新增2个状态,回调
This commit is contained in:
parent
5804bf6daf
commit
115b19f565
|
@ -17,6 +17,8 @@ use App\dao\UserRewardDao;
|
|||
use hg\apidoc\annotation as Apidoc;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use support\Log;
|
||||
|
||||
/**
|
||||
* @Apidoc\Title("提现订单")
|
||||
*/
|
||||
|
@ -105,47 +107,37 @@ class WithdrawController
|
|||
//提现金额
|
||||
$rate = ExchangeRate::where('type', 'BDT')->get();
|
||||
$money = $money_no / 100 * $rate[0]['points'];
|
||||
var_dump($money);
|
||||
|
||||
$withdraw = Withdraw::create([
|
||||
'user_id' => $user_id,
|
||||
'amount' => $money,
|
||||
'status' => 1,
|
||||
'createtime2' => date('Y-m-d H:i:s'),
|
||||
'username' => $user->username,
|
||||
'status_text' => '申请中',
|
||||
]);
|
||||
//大于1000等待管理员审核
|
||||
if ($money >= 1000) {
|
||||
Withdraw::create([
|
||||
'user_id' => $user_id,
|
||||
'amount' => $money,
|
||||
'status' => 1,
|
||||
'createtime2' => date('Y-m-d H:i:s'),
|
||||
'username' => $user->username,
|
||||
'status_text' => '申请中',
|
||||
]);
|
||||
return ApiResponseApp::success(null, '等待管理员审核');
|
||||
}
|
||||
//用户积分减少$money
|
||||
UserRewardDao::base($user_id, 1, - ($money_no + 300), '提现');
|
||||
$userbank = Userbank::where('id', $bank_id)->first();
|
||||
//存入数据库
|
||||
$withdraw = Withdraw::create([
|
||||
'user_id' => $user_id,
|
||||
'amount' => $money,
|
||||
'status' => 1,
|
||||
'createtime2' => date('Y-m-d H:i:s'),
|
||||
'username' => $user->username,
|
||||
'status_text' => '申请中',
|
||||
]);
|
||||
|
||||
//获取刚刚存入数据库的id(订单号)
|
||||
$orderId = $withdraw->id;
|
||||
$res = PaymentNew::pushMoney($money, $userbank->bank_username, $userbank->account, $userbank->bank_name,$orderId);
|
||||
// //逻辑错误需要修改
|
||||
if ($res['Success']) {
|
||||
$withdraw->update([
|
||||
'status' => 2, //
|
||||
'status_text' => '已到账',
|
||||
'status' => 4, //
|
||||
'status_text' => '等待银行打款',
|
||||
'order_number' => $res['TrackingNumber'] ?? null,
|
||||
]);
|
||||
return ApiResponseApp::success(null, '转账成功');
|
||||
} else {
|
||||
return ApiResponseApp::error(null, '转账失败');
|
||||
}
|
||||
return ApiResponseApp::success(null, '转账成功');
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,14 +149,15 @@ class WithdrawController
|
|||
public function callback(Request $request)
|
||||
{
|
||||
$callbackData = $request->all();
|
||||
|
||||
// 记录回调数据以便调试
|
||||
Log::info('Payment Callback Received:', $callbackData);
|
||||
$orderId = $callbackData['TrackingNumber'] ?? null;
|
||||
$failedMessage = $callbackData['FailedMessage'] ?? null;
|
||||
$withdraw = Withdraw::where('order_number', $orderId)->first();
|
||||
//$failedMessage为null就是成功
|
||||
if ($failedMessage != null) {
|
||||
$withdraw->update([
|
||||
'status' => 3,
|
||||
'status' => 5,
|
||||
'status_text' => '支付失败: ' . $failedMessage,
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue