orderRepository = $orderRepository; $this->rentOrderRepository = $rentOrderRepository; } public function transform(User $user) { if (Carbon::today()->format('Y-m-d') == Carbon::parse($user->deposit_expire_time)->format('Y-m-d')) { $deposit_expire_time = '免押金资格' . Carbon::parse($user->deposit_expire_time)->diffForHumans(Carbon::now()) . '到期'; } else { $deposit_expire_time = '免押金资格有效期至' . Carbon::parse($user->deposit_expire_time)->format('Y-m-d'); } return [ 'is_card_certified' => $user->is_card_certified, 'is_deposit' => $user->is_deposit, 'deposit_type_name' => User::$depositTypeMaps[$user->deposit_type], 'deposit_type' => $user->deposit_type, 'deposit_expire_time' => $deposit_expire_time, // , 'is_match_ride_age' => $user->is_match_ride_age, 'is_bind_mobile' => $user->is_bind_mobile, 'status' => $user->status, 'is_register' => $user->is_register, 'is_ride_order' => $this->rideOrder($user), 'is_pay_order' => $this->noPayOrder($user), 'is_rent_order' => $this->rentOrder($user), 'is_pay_rent_order' => $this->rentPayOrder($user), 'is_punishment' => $this->checkPunishment($user->id) ]; } /** * 检查用户是否有罚单 * @param $user_id * @return mixed * Author: Mead */ protected function checkPunishment($user_id) { return PunishmentOrder::where('user_id', $user_id)->where('pay_status', PunishmentOrder::PAY_STATUS_NO)->exists(); } protected function rentOrder($user) { $no = $this->rentOrderRepository->byUserIdCheckIsExistRentOrderWithNo($user->id); if (is_null($no)) return false; return $no; } public function rentPayOrder($user) { $no = $this->rentOrderRepository->byUserIdCheckIsExistNoPayOrderWithNo($user->id); if (is_null($no)) return false; return $no; } protected function rideOrder($user) { $no = $this->orderRepository->byUserIdCheckIsExistRideOrderWithNo($user->id); if (is_null($no)) return false; return $no; } protected function noPayOrder($user) { $no = $this->orderRepository->byUserIdCheckIsExistNoPayOrderWithNo($user->id); if (is_null($no)) return false; return $no; } }