isEmpty() || $user['user_money'] < $order['order_amount']) { throw new \Exception('余额不足'); } //扣除余额 User::update([ 'user_money' => ['dec', $order['order_amount']] ], ['id' => $order['user_id']]); if($from){ switch ($from) { case 'order': $changeType = AccountLogEnum::ORDER_DEC_MONEY; break; case 'orderGap': $changeType = AccountLogEnum::ORDER_GAP_DEC_MONEY; break; case 'orderAppend': $changeType = AccountLogEnum::ORDER_APPEND_DEC_MONEY; break; } } //余额流水 AccountLogLogic::add($order['user_id'], AccountLogEnum::MONEY,$changeType,AccountLogEnum::DEC, $order['order_amount'], $order['sn']); return [ 'pay_way' => PayEnum::BALANCE_PAY ]; } catch (\Exception $e) { $this->setError($e->getMessage()); return false; } } }