where('id', $uid)->first(); Db::table('wa_users')->where('id', $uid)->increment($mold_filed, $money); $total_money = bcadd($userData->$mold_filed, $money, 2); Db::table('wa_stream')->insert([ 'user_id' => $uid, 'money' => $money, 'total_money' => $total_money, 'type' => $type, 'mold' => $mold, 'source_id' => $source_id, 'add_time' => time(), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'), ]); } catch (\Throwable $exception) { throw new \Exception($exception->getMessage()); } } /** 扣除金额 * @param $uid * @param $money * @param $type * @param $mold * @param $mold_filed * @param $source_id * @return void * @throws \Exception */ static public function delStream($uid, $money, $type, $mold, $mold_filed, $source_id = 0) { try { $userData = Db::table('wa_users')->where('id', $uid)->first(); Db::table('wa_users')->where('id', $uid)->decrement($mold_filed, $money); $total_money = bcsub($userData->$mold_filed, $money, 2); if($type == 25 || $type == 21 || $type == 27 || $type == 28){ }else{ if ($total_money < 0) { throw new \Exception('您余额不足!'); } } Db::table('wa_stream')->insert([ 'user_id' => $uid, 'money' => '-' . $money, 'consume_money' => $money, 'total_money' => $total_money, 'income' => 2, 'type' => $type, 'mold' => $mold, 'source_id' => $source_id, 'add_time' => time(), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'), ]); } catch (\Throwable $exception) { throw new \Exception($exception->getMessage()); } } }