Przeglądaj źródła

修复:try catch导致用户端域名未授权时提示商城未找到

萤火科技 2 lat temu
rodzic
commit
c58cb22c09

+ 6 - 0
app/admin/controller/Store.php

@@ -73,6 +73,9 @@ class Store extends Controller
      * 移入回收站
      * @param int $storeId
      * @return Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function recovery(int $storeId): Json
     {
@@ -88,6 +91,9 @@ class Store extends Controller
      * 移出回收站
      * @param int $storeId
      * @return Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function move(int $storeId): Json
     {

+ 3 - 0
app/api/controller/Controller.php

@@ -63,6 +63,9 @@ class Controller extends BaseController
      * 验证当前商城状态
      * @return void
      * @throws BaseException
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
      */
     private function checkStore(): void
     {

+ 4 - 1
app/api/model/Store.php

@@ -46,7 +46,10 @@ class Store extends StoreModel
 
     /**
      * 获取当前商城的基本信息
-     * @return static|array|null
+     * @return Store|array|null
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public static function getInfo()
     {

+ 3 - 0
app/api/service/Store.php

@@ -74,6 +74,9 @@ class Store extends BaseService
     /**
      * 店铺基本信息(名称、简介、logo)
      * @return StoreModel|array|null
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     private function storeInfo()
     {

+ 7 - 8
app/common/model/Store.php

@@ -41,17 +41,16 @@ class Store extends BaseModel
      * 详情信息
      * @param int $storeId
      * @return static|array|null
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public static function detail(int $storeId)
     {
-        try {
-            return self::withoutGlobalScope()
-                ->with(['logoImage'])
-                ->where('store_id', '=', $storeId)
-                ->find();
-        } catch (\Exception $e) {
-            return null;
-        }
+        return self::withoutGlobalScope()
+            ->with(['logoImage'])
+            ->where('store_id', '=', $storeId)
+            ->find();
     }
 
     /**

+ 7 - 1
app/common/service/order/Printer.php

@@ -35,6 +35,9 @@ class Printer extends BaseService
      * @param int $printerId 打印机ID
      * @return bool|mixed
      * @throws BaseException
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function printEvent($order, int $printerId)
     {
@@ -90,8 +93,11 @@ class Printer extends BaseService
 
     /**
      * 构建订单打印的内容
-     * @param mixed $order
+     * @param $order
      * @return string
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     private function getPrintContent($order): string
     {

+ 6 - 0
app/store/controller/Store.php

@@ -25,6 +25,9 @@ class Store extends Controller
     /**
      * 获取当前登录的商城信息
      * @return Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function info(): Json
     {
@@ -36,6 +39,9 @@ class Store extends Controller
     /**
      * 更新商城信息
      * @return Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function update(): Json
     {

+ 3 - 0
app/store/model/Order.php

@@ -228,6 +228,9 @@ class Order extends OrderModel
      * @param array $data
      * @return bool
      * @throws BaseException
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function printer(array $data): bool
     {