user->wallet; // 扣减钱包余额 $wallet->decrement('total_balance', $order->balance_amount); $wallet->decrement('available_balance', $order->balance_amount); // 创建钱包交易记录 $this->createWalletPaymentRecord($order, $wallet); } private function createWalletPaymentRecord(Order $order, $wallet): void { WalletPaymentRecord::create([ 'order_id' => $order->id, 'wallet_id' => $wallet->id, 'payment_no' => 'B_'.$order->id, 'payment_method' => 'balance', 'total_amount' => $order->balance_amount, 'actual_amount' => 0, 'used_wallet_balance' => $order->balance_amount, 'used_recharge_balance' => 0, 'state' => 'success', ]); } }