model = $model; } /** * 检查用户是否有租车的订单 * @param $user_id * @return mixed * User: Mead */ public function byUserIdCheckIsExistRideOrder($user_id) { return $this->model->where('user_id', $user_id)->whereIn('status', [RentOrder::STATUS_RENT_BIKE, RentOrder::STATUS_CLOSE_RENT_BIKE])->exists(); } /** * * @param $order_no * @param $bike_no * @param $user_id * @return mixed * User: Fx */ public function checkUserIsRetryOpenLock($order_no, $bike_no, $user_id) { return $this->model->where('no', $order_no)->where('user_id', $user_id)->where('bike_no', $bike_no)->select(['start_use_bike_time', 'bike_id', 'end_use_bike_time'])->first(); } /** * 检查用户是否有租车的订单并获取no * @param $user_id * @return mixed * User: Mead */ public function byUserIdCheckIsExistRentOrderWithNo($user_id) { return $this->model->where('user_id', $user_id)->where('status', RentOrder::STATUS_RENT_BIKE)->value('no'); } /** * 检查用户是否有为支付的订单 * @param $user_id * @return mixed * User: Mead */ public function byUserIdCheckIsExistNoPayOrder($user_id) { return $this->model->where('user_id', $user_id)->where('status', RentOrder::STATUS_CLOSE_RENT_BIKE)->where('pay_status', RentOrder::PAY_STATUS_NO)->exists(); } /** * 检查用户是否有为支付的订单并获取no * @param $user_id * @return mixed * User: Mead */ public function byUserIdCheckIsExistNoPayOrderWithNo($user_id) { return $this->model->where('user_id', $user_id)->where('status', RentOrder::STATUS_CLOSE_RENT_BIKE)->where('pay_status', RentOrder::PAY_STATUS_NO)->value('no'); } /** * 根据订单号获取model * @param $order_no * @return mixed * User: Mead */ public function byNo($order_no) { return $this->model->where('no', $order_no)->first(); } /** * 根据用户id和订单号获取订单 * @param $order_no * @param $user_id * @return mixed * User: Mead */ public function byNoAndUserId($order_no, $user_id) { return $this->model->where('no', $order_no)->where('user_id', $user_id)->first(); } /** * 根据订单获取租车的订单 * User: Mead */ public function byNoGetRideOrder($no) { return $this->model->where('no', $no)->where('status', RentOrder::STATUS_RENT_BIKE)->first(); } /** * 检查用户是否恶意 * @param $user_id * User: Mead */ public function checkUserMoreCloseOrder($user_id) { $num = $this->model->where('user_id', $user_id)->where('created_at', now())->where('status', RentOrder::STATUS_CLOSE_ORDER)->count(); return $num > 5; } }