|
|
|
@ -54,9 +54,11 @@ class ParkingSpaceRepairService extends BaseService |
|
|
|
|
|
|
|
/** |
|
|
|
* @param array $data |
|
|
|
* @throws Exception |
|
|
|
* @param bool $is_import |
|
|
|
* @return string |
|
|
|
* @throws CustomException |
|
|
|
*/ |
|
|
|
public function createModel(array $data) |
|
|
|
public function createModel(array $data, bool $is_import = false): string |
|
|
|
{ |
|
|
|
try { |
|
|
|
DB::beginTransaction(); |
|
|
|
@ -66,6 +68,11 @@ class ParkingSpaceRepairService extends BaseService |
|
|
|
$space = ParkingSpace::query()->where('number', $parking_space_name)->first(); |
|
|
|
$str = $count > 1 ? ':' . $parking_space_name : ''; |
|
|
|
if (!$space) { |
|
|
|
if ($is_import) { |
|
|
|
DB::rollBack(); |
|
|
|
return __service($this->menuTitle . '.space_not_exists') |
|
|
|
. $str; |
|
|
|
} |
|
|
|
throw new CustomException( |
|
|
|
__service($this->menuTitle . '.space_not_exists') |
|
|
|
. $str |
|
|
|
@ -75,12 +82,16 @@ class ParkingSpaceRepairService extends BaseService |
|
|
|
$space = $space->toArray(); |
|
|
|
$space_id = $space['id']; |
|
|
|
if ($space['status'] == 2) { |
|
|
|
if ($is_import) { |
|
|
|
DB::rollBack(); |
|
|
|
return __service($this->menuTitle . '.space_exists') |
|
|
|
. $str; |
|
|
|
} |
|
|
|
throw new CustomException( |
|
|
|
__service($this->menuTitle . '.space_exists') |
|
|
|
. $str |
|
|
|
__service($this->menuTitle . '.space_exists') . $str |
|
|
|
); |
|
|
|
} |
|
|
|
$model = $this->createData( |
|
|
|
$this->createData( |
|
|
|
$space_id, |
|
|
|
$data['admin_user_id'], |
|
|
|
$data['start_at'], |
|
|
|
@ -89,7 +100,7 @@ class ParkingSpaceRepairService extends BaseService |
|
|
|
} |
|
|
|
|
|
|
|
DB::commit(); |
|
|
|
return $model; |
|
|
|
return ''; |
|
|
|
} catch (Exception $e) { |
|
|
|
DB::rollBack(); |
|
|
|
throw $e; |
|
|
|
|