request->param(); $data = []; if (isset($getData['search']) && !empty($getData['search'])) { $data[] = ['checkout_id', 'like', "%{$getData['search']}%"]; } $list = $model->getList($data); return $this->renderSuccess(['list'=>$list]); } /** * 获取所有结账 * @return mixed * @throws \think\exception\DbException */ public function all(): Json { $list = CheckoutModel::getAll(); return $this->renderSuccess(compact('list','user')); } /** * 结账 * @return array|mixed * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function checkout() { $model = new CheckoutModel; $data = $this->postForm(); // 新增记录 if ($model->checkout($data, $this->store['user'])) { return $this->renderSuccess('结账成功'); } return $this->renderError($model->getError() ?: '结账失败'); } /** * 删除商户 * @return Json * @throws \think\exception\DbException */ public function delete(): Json { $arr = $this->postData(); foreach ((array)$arr as $val){ $model = CheckoutModel::detail($val); $model->setDelete(); } return $this->renderSuccess('删除成功'); } }