Browse Source

fix:业务异常

super-yimizi 1 month ago
parent
commit
5677eb081d

+ 12 - 12
application/common/Service/InspectionService.php

@@ -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());
         }
     }
 

+ 11 - 3
application/common/Service/Lottery/LotteryChanceService.php

@@ -34,8 +34,7 @@ class LotteryChanceService
 
 
     /**
-     * 订单完成后检查并分发抽奖机会
-     * 
+     * 订单完成后检查并分发抽奖机会     * 
      * @param array $orderInfo 订单信息 ['id', 'total_amount', 'goods' => [['goods_id']]]
      * @param int $userId 用户ID
      * @return array 获得的抽奖机会信息
@@ -208,6 +207,12 @@ class LotteryChanceService
         return $result;
     }
 
+
+
+
+
+
+
     // ============ 私有处理方法 ============
 
     /**
@@ -480,6 +485,7 @@ class LotteryChanceService
         return $record ? true : false;
     }
 
+
     // ============ 条件验证方法 ============
 
     /**
@@ -584,6 +590,7 @@ class LotteryChanceService
         return $totalAmount >= $condition->condition_value;
     }
 
+
     // ============ 条件管理方法 ============
 
     /**
@@ -598,7 +605,7 @@ class LotteryChanceService
                               ->where('status', 1)
                               ->order('id', 'asc')
                               ->select();
-        }
+    }
 
     /**
      * 检查条件是否可重复获得奖励
@@ -899,6 +906,7 @@ class LotteryChanceService
         return $userChance->save();
     }
 
+    
     // ============ 统计和查询方法 ============
 
     /**

+ 11 - 3
application/common/Service/lottery/LotteryChanceService.php

@@ -34,8 +34,7 @@ class LotteryChanceService
 
 
     /**
-     * 订单完成后检查并分发抽奖机会
-     * 
+     * 订单完成后检查并分发抽奖机会     * 
      * @param array $orderInfo 订单信息 ['id', 'total_amount', 'goods' => [['goods_id']]]
      * @param int $userId 用户ID
      * @return array 获得的抽奖机会信息
@@ -208,6 +207,12 @@ class LotteryChanceService
         return $result;
     }
 
+
+
+
+
+
+
     // ============ 私有处理方法 ============
 
     /**
@@ -480,6 +485,7 @@ class LotteryChanceService
         return $record ? true : false;
     }
 
+
     // ============ 条件验证方法 ============
 
     /**
@@ -584,6 +590,7 @@ class LotteryChanceService
         return $totalAmount >= $condition->condition_value;
     }
 
+
     // ============ 条件管理方法 ============
 
     /**
@@ -598,7 +605,7 @@ class LotteryChanceService
                               ->where('status', 1)
                               ->order('id', 'asc')
                               ->select();
-        }
+    }
 
     /**
      * 检查条件是否可重复获得奖励
@@ -899,6 +906,7 @@ class LotteryChanceService
         return $userChance->save();
     }
 
+    
     // ============ 统计和查询方法 ============
 
     /**