ajax()) { return response()->json($data); } return $this->htmlAlert($data); } public function htmlAlert($data) { echo ''; } public function findOneQrcode($request){ $time = time(); $token = $request->input('_token'); $old = $this::where([['session_id', '=', $token], ['expire_time', '>', intval($time)]])->orderBy('order_id', 'asc')->first(); if ($old) { return $old; } $has_order = $this::where([['expire_time', '<', intval($time)]])->orderBy('order_id', 'asc')->first(); if ($has_order) { $this::where('id', $has_order->id)->update(['session_id' => $token, 'expire_time' => $time + 1800, 'order_id' => $has_order->order_id + 1]); } else { return $this->msg(['error' => 1, 'msg' => '无可用二维码']); } return $has_order; } }