getModelFilter(); $query = $this->query(); if($this->withRelationships){ $query->with($this->withRelationships); } if ($filter) { $query->filter(request()->input(), $filter)->where('live_in', Oldmen::STATUS_LIVE); } return $query; } public function do($oldManId, $startAt, $endAt, $feeArr = null){ $oldMan = $this->getDetail($oldManId); if($oldMan){ //判断状态-是否是已经入住状态;已入住状态无法再入住; if($oldMan->live_in != Oldmen::STATUS_NORMAL){ return $this->setError('客人状态异常,请刷新后充试!'); } $flow = new ConstFlow(); $flow->oldman_id = $oldMan->id; $flow->const_type = ConstFlow::TYPE_IN; $flow->start_at = $startAt; $flow->end_at = $endAt; $flow->money = $this->totalFee($feeArr); $flow->extends = $feeArr; $flow->adminuser_id = OwlAdmin::user()->id; try{ DB::beginTransaction(); //缴费生成流水; $flow->save(); //更新客人信息状态; $oldMan->update([ 'live_in' => Oldmen::STATUS_LIVE, 'live_in_at' => $startAt, 'avliable_at' => $endAt, 'bonds' => $feeArr['bonds_fee'] ?? [] //记录保证金 ]); DB::commit(); }catch(Throwable $th){ DB::rollBack(); report($th); return $this->setError('系统错误,请刷新后重试'); } return true; }else{ return $this->setError('未找到客人信息!'); } } }