model = $model; } /** * 检查用户是否有骑行时订单(包含锁车状态) * @param $user_id * @return mixed * User: Mead */ public function byUserIdCheckIsExistRideOrder($user_id) { return $this->model->where('user_id', $user_id)->whereIn('status', [Order::STATUS_RIDE_BIKE, Order::STATUS_CLOSE_BIKE, Order::STATUS_PAUSE_BIKE])->exists(); } /** * 检查用户是否有骑行时订单并获取no(不包含锁车状态) * @param $user_id * @return mixed * User: Mead */ public function byUserIdCheckIsExistRideOrderWithNo($user_id) { return $this->model->where('user_id', $user_id)->whereIn('status', [Order::STATUS_RIDE_BIKE, Order::STATUS_PAUSE_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', Order::STATUS_CLOSE_BIKE)->where('pay_status', Order::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', Order::STATUS_CLOSE_BIKE)->where('pay_status', Order::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(); } /** * 根据订单号获取骑行状态(骑行中,临时停车中) * @param $order_no * @return mixed * User: Mead */ public function byNoGetRideOrder($order_no) { return $this->model->where('no', $order_no)->whereIn('status', [Order::STATUS_RIDE_BIKE, Order::STATUS_PAUSE_BIKE])->first(); } /** * 检查用户是否恶意关锁 * @param $user_id * @return bool * User: Mead */ public function checkUserMoreCloseOrder($user_id) { $num = $this->model->where('user_id', $user_id)->whereDate('created_at', date('Y-m-d'))->where('status', Order::STATUS_CLOSE_ORDER)->count(); return ($num > 5); } /** * * @param $order_no * @param $bike_no * @param $user_id * @return mixed * User: Mead */ 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(); } /** * 通过车的中控id,获取订单 * @param $box_no * User: Mead */ public function byBikeNoGetRideOrder($bike_no) { return $this->model->where('bike_no', $bike_no)->whereIn('status', [Order::STATUS_RIDE_BIKE, Order::STATUS_PAUSE_BIKE])->orderBy('id', 'desc')->first(); } /** * 根据用户id 查询今日订单次数 * @param $user_id * * */ public function getTodayOrderNum($user_id) { return $this->model->where('created_at', '>', Carbon::today())->where('user_id', $user_id)->count(); } }