|
@@ -5,7 +5,7 @@ namespace app\common\Service;
|
|
|
use app\common\model\inspection\InspectionApplication;
|
|
|
use think\Db;
|
|
|
use think\Exception;
|
|
|
-
|
|
|
+use app\common\exception\BusinessException;
|
|
|
/**
|
|
|
* 验货员申请服务类
|
|
|
*/
|
|
@@ -49,7 +49,7 @@ class InspectionService
|
|
|
} catch (Exception $e) {
|
|
|
// 回滚事务
|
|
|
Db::rollback();
|
|
|
- throw new Exception('申请提交失败:' . $e->getMessage());
|
|
|
+ throw new BusinessException('申请提交失败:' . $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -73,7 +73,7 @@ class InspectionService
|
|
|
->find();
|
|
|
|
|
|
if (!$application) {
|
|
|
- throw new Exception('申请记录不存在或无权访问');
|
|
|
+ throw new BusinessException('申请记录不存在或无权访问');
|
|
|
}
|
|
|
|
|
|
return $application;
|
|
@@ -106,16 +106,16 @@ class InspectionService
|
|
|
->find();
|
|
|
|
|
|
if (!$application) {
|
|
|
- throw new Exception('申请记录不存在或无权访问');
|
|
|
+ throw new BusinessException('申请记录不存在或无权访问');
|
|
|
}
|
|
|
|
|
|
if (!$application->canEdit()) {
|
|
|
- throw new Exception('该申请状态下不允许修改');
|
|
|
+ throw new BusinessException('该申请状态下不允许修改');
|
|
|
}
|
|
|
|
|
|
// 检查手机号是否已被其他用户使用
|
|
|
if (InspectionApplication::isPhoneApplied($data['phone'], $applicationId)) {
|
|
|
- throw new Exception('该手机号已被其他用户申请');
|
|
|
+ throw new BusinessException('该手机号已被其他用户申请');
|
|
|
}
|
|
|
|
|
|
// 启动事务
|
|
@@ -131,7 +131,7 @@ class InspectionService
|
|
|
} catch (Exception $e) {
|
|
|
// 回滚事务
|
|
|
Db::rollback();
|
|
|
- throw new Exception('修改失败:' . $e->getMessage());
|
|
|
+ throw new BusinessException('修改失败:' . $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -202,11 +202,11 @@ class InspectionService
|
|
|
$application = InspectionApplication::get($applicationId);
|
|
|
|
|
|
if (!$application) {
|
|
|
- throw new Exception('申请记录不存在');
|
|
|
+ throw new BusinessException('申请记录不存在');
|
|
|
}
|
|
|
|
|
|
if ($application->audit_status != InspectionApplication::AUDIT_STATUS_PENDING) {
|
|
|
- throw new Exception('该申请已被审核,无法重复操作');
|
|
|
+ throw new BusinessException('该申请已被审核,无法重复操作');
|
|
|
}
|
|
|
|
|
|
// 验证审核状态
|
|
@@ -216,12 +216,12 @@ class InspectionService
|
|
|
];
|
|
|
|
|
|
if (!in_array($auditStatus, $validStatuses)) {
|
|
|
- throw new Exception('无效的审核状态');
|
|
|
+ throw new BusinessException('无效的审核状态');
|
|
|
}
|
|
|
|
|
|
// 如果是驳回,必须填写驳回原因
|
|
|
if ($auditStatus == InspectionApplication::AUDIT_STATUS_REJECTED && empty($rejectReason)) {
|
|
|
- throw new Exception('驳回申请必须填写驳回原因');
|
|
|
+ throw new BusinessException('驳回申请必须填写驳回原因');
|
|
|
}
|
|
|
|
|
|
// 启动事务
|
|
@@ -239,7 +239,7 @@ class InspectionService
|
|
|
} catch (Exception $e) {
|
|
|
// 回滚事务
|
|
|
Db::rollback();
|
|
|
- throw new Exception('审核失败:' . $e->getMessage());
|
|
|
+ throw new BusinessException('审核失败:' . $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|