diff --git a/app/admin/logic/ConfigLogic.php b/app/admin/logic/ConfigLogic.php index a2b705d0c..44cd45dc8 100644 --- a/app/admin/logic/ConfigLogic.php +++ b/app/admin/logic/ConfigLogic.php @@ -18,6 +18,7 @@ use app\common\logic\BaseLogic; use app\common\model\Config; use app\common\model\dict\DictData; use app\common\service\{FileService, ConfigService}; +use support\exception\BusinessException; use think\facade\Db; /** @@ -46,10 +47,9 @@ class ConfigLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -73,10 +73,9 @@ class ConfigLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/app_update/AppUpdateLogic.php b/app/admin/logic/app_update/AppUpdateLogic.php index c32200227..c4e2921f0 100644 --- a/app/admin/logic/app_update/AppUpdateLogic.php +++ b/app/admin/logic/app_update/AppUpdateLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\app_update; use app\common\model\app_update\AppUpdate; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -40,10 +41,9 @@ class AppUpdateLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -71,10 +71,9 @@ class AppUpdateLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/auth/AdminLogic.php b/app/admin/logic/auth/AdminLogic.php index 0f92fa397..bff5eb111 100644 --- a/app/admin/logic/auth/AdminLogic.php +++ b/app/admin/logic/auth/AdminLogic.php @@ -24,6 +24,7 @@ use app\common\model\auth\AdminRole; use app\common\model\auth\AdminSession; use app\common\cache\AdminTokenCache; use app\common\service\FileService; +use support\exception\BusinessException; use Webman\Config; use think\facade\Db; @@ -70,10 +71,9 @@ class AdminLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -138,10 +138,9 @@ class AdminLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -177,10 +176,9 @@ class AdminLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/delivery_service/DeliveryServiceLogic.php b/app/admin/logic/delivery_service/DeliveryServiceLogic.php index c9a1eba72..99f671683 100644 --- a/app/admin/logic/delivery_service/DeliveryServiceLogic.php +++ b/app/admin/logic/delivery_service/DeliveryServiceLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\delivery_service; use app\common\model\delivery_service\DeliveryService; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -37,10 +38,9 @@ class DeliveryServiceLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -65,10 +65,9 @@ class DeliveryServiceLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/dept/DeptLogic.php b/app/admin/logic/dept/DeptLogic.php index d39e42b2b..e7e37737c 100644 --- a/app/admin/logic/dept/DeptLogic.php +++ b/app/admin/logic/dept/DeptLogic.php @@ -17,7 +17,7 @@ namespace app\admin\logic\dept; use app\common\enum\YesNoEnum; use app\common\logic\BaseLogic; use app\common\model\dept\Dept; - +use support\exception\BusinessException; /** * 部门管理逻辑 @@ -147,9 +147,8 @@ class DeptLogic extends BaseLogic 'sort' => $params['sort'] ?? 0 ]); return true; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + } catch (\Throwable $e) { + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/dept/JobsLogic.php b/app/admin/logic/dept/JobsLogic.php index f23c0551f..ec137b68e 100644 --- a/app/admin/logic/dept/JobsLogic.php +++ b/app/admin/logic/dept/JobsLogic.php @@ -17,7 +17,7 @@ namespace app\admin\logic\dept; use app\common\enum\YesNoEnum; use app\common\logic\BaseLogic; use app\common\model\dept\Jobs; - +use support\exception\BusinessException; /** * 岗位管理逻辑 @@ -65,9 +65,8 @@ class JobsLogic extends BaseLogic 'remark' => $params['remark'] ?? '', ]); return true; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + } catch (\Throwable $e) { + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/financial_transfers/FinancialTransfersLogic.php b/app/admin/logic/financial_transfers/FinancialTransfersLogic.php index d9b0577b3..f8dd223b2 100644 --- a/app/admin/logic/financial_transfers/FinancialTransfersLogic.php +++ b/app/admin/logic/financial_transfers/FinancialTransfersLogic.php @@ -6,6 +6,7 @@ namespace app\admin\logic\financial_transfers; use app\common\model\financial_transfers\FinancialTransfers; use app\common\logic\BaseLogic; use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow; +use support\exception\BusinessException; use think\facade\Db; @@ -43,10 +44,9 @@ class FinancialTransfersLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -76,10 +76,9 @@ class FinancialTransfersLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -123,10 +122,9 @@ class FinancialTransfersLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -138,7 +136,7 @@ class FinancialTransfersLogic extends BaseLogic $date = date('Y-m-d', $time); //获取一个月前的日期 $receivable = StoreCashFinanceFlow::whereMonth('create_time', $date)->where('status', 0)->sum('receivable'); if($receivable==0){ - self::setError('暂无法确认,还有未收取的现金'); + throw new BusinessException('暂无法确认,还有未收取的现金'); } Db::startTrans(); try { @@ -149,10 +147,9 @@ class FinancialTransfersLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } } diff --git a/app/admin/logic/inventory_transfer/InventoryTransferLogic.php b/app/admin/logic/inventory_transfer/InventoryTransferLogic.php index 445a69b3d..bae2f627b 100644 --- a/app/admin/logic/inventory_transfer/InventoryTransferLogic.php +++ b/app/admin/logic/inventory_transfer/InventoryTransferLogic.php @@ -7,6 +7,7 @@ use app\common\model\inventory_transfer\InventoryTransfer; use app\common\logic\BaseLogic; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; +use support\exception\BusinessException; use think\facade\Db; @@ -35,8 +36,7 @@ class InventoryTransferLogic extends BaseLogic if($params['one_type']==1){ $stock = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->value('stock'); if ($stock < $params['nums']) { - self::setError('调拨数量不能大于当前门店库存'); - return false; + throw new BusinessException('调拨数量不能大于当前门店库存'); } if($params['two_type']==1){ $stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock'); @@ -51,8 +51,7 @@ class InventoryTransferLogic extends BaseLogic }elseif($params['one_type']==2){ $stock = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->value('nums'); if ($stock < $params['nums']) { - self::setError('调拨数量不能大于当前仓库库存'); - return false; + throw new BusinessException('调拨数量不能大于当前仓库库存'); } if($params['two_type']==1){ $stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock'); @@ -65,8 +64,7 @@ class InventoryTransferLogic extends BaseLogic $two_before_nums = $stock_two; $two_after_nums = bcadd($stock_two, $params['nums']); }else{ - self::setError('调拨类型错误'); - return false; + throw new BusinessException('调拨类型错误'); } Db::startTrans(); @@ -97,8 +95,7 @@ class InventoryTransferLogic extends BaseLogic return true; } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -127,8 +124,7 @@ class InventoryTransferLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/purchase_order/PurchaseOrderLogic.php b/app/admin/logic/purchase_order/PurchaseOrderLogic.php index 7f7ddfdbb..2ce0f4072 100644 --- a/app/admin/logic/purchase_order/PurchaseOrderLogic.php +++ b/app/admin/logic/purchase_order/PurchaseOrderLogic.php @@ -11,6 +11,7 @@ use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; use app\common\model\system_store\SystemStore; +use support\exception\BusinessException; use think\facade\Db; @@ -181,8 +182,7 @@ class PurchaseOrderLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -231,8 +231,7 @@ class PurchaseOrderLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/purchase_order_info/PurchaseOrderInfoLogic.php b/app/admin/logic/purchase_order_info/PurchaseOrderInfoLogic.php index 44d5483a4..25089631f 100644 --- a/app/admin/logic/purchase_order_info/PurchaseOrderInfoLogic.php +++ b/app/admin/logic/purchase_order_info/PurchaseOrderInfoLogic.php @@ -6,6 +6,7 @@ use app\common\logic\BaseLogic; use app\common\model\purchase_order_info\PurchaseOrderInfo; use app\common\model\purchase_product_offer\PurchaseProductOffer; use app\common\model\store_product\StoreProduct; +use support\exception\BusinessException; use think\facade\Db; class PurchaseOrderInfoLogic extends BaseLogic @@ -37,8 +38,7 @@ class PurchaseOrderInfoLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } } diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index d9b5fc996..32fd6aac4 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -6,6 +6,7 @@ namespace app\admin\logic\purchase_product_offer; use app\common\model\purchase_product_offer\PurchaseProductOffer; use app\common\logic\BaseLogic; use app\common\model\delivery_service\DeliveryService; +use support\exception\BusinessException; use think\facade\Db; @@ -53,8 +54,7 @@ class PurchaseProductOfferLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -94,8 +94,7 @@ class PurchaseProductOfferLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -106,8 +105,7 @@ class PurchaseProductOfferLogic extends BaseLogic { if($params['is_buyer']==1){ if($params['buyer_id']==''){ - self::setError('采购人不能为空'); - return false; + throw new BusinessException('采购人不能为空'); } $data['buyer_id']=$params['buyer_id']; $data['buyer_nums']=$params['buyer_nums']; @@ -120,8 +118,7 @@ class PurchaseProductOfferLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } /** diff --git a/app/admin/logic/setting/CategoryLogic.php b/app/admin/logic/setting/CategoryLogic.php index 2afd91ffc..875d3d5df 100644 --- a/app/admin/logic/setting/CategoryLogic.php +++ b/app/admin/logic/setting/CategoryLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\setting; use app\common\model\setting\Category; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -43,8 +44,7 @@ class CategoryLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -75,8 +75,7 @@ class CategoryLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index f76a43d5f..cf365b69b 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -36,8 +36,7 @@ class StoreBranchProductLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/store_cash_finance_flow/StoreCashFinanceFlowLogic.php b/app/admin/logic/store_cash_finance_flow/StoreCashFinanceFlowLogic.php index a8a1b4c24..e7787183a 100644 --- a/app/admin/logic/store_cash_finance_flow/StoreCashFinanceFlowLogic.php +++ b/app/admin/logic/store_cash_finance_flow/StoreCashFinanceFlowLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\store_cash_finance_flow; use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -36,8 +37,7 @@ class StoreCashFinanceFlowLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -64,8 +64,7 @@ class StoreCashFinanceFlowLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/store_category/StoreCategoryLogic.php b/app/admin/logic/store_category/StoreCategoryLogic.php index ba0b1c08b..5fd79536b 100644 --- a/app/admin/logic/store_category/StoreCategoryLogic.php +++ b/app/admin/logic/store_category/StoreCategoryLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\store_category; use app\common\model\store_category\StoreCategory; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -40,8 +41,7 @@ class StoreCategoryLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -69,8 +69,7 @@ class StoreCategoryLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/store_extract/StoreExtractLogic.php b/app/admin/logic/store_extract/StoreExtractLogic.php index f11d97ccd..70b5a4622 100644 --- a/app/admin/logic/store_extract/StoreExtractLogic.php +++ b/app/admin/logic/store_extract/StoreExtractLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\store_extract; use app\common\model\store_extract\StoreExtract; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -36,8 +37,7 @@ class StoreExtractLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -61,8 +61,7 @@ class StoreExtractLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/store_finance_flow/StoreFinanceFlowLogic.php b/app/admin/logic/store_finance_flow/StoreFinanceFlowLogic.php index d4dec2553..c39bd660e 100644 --- a/app/admin/logic/store_finance_flow/StoreFinanceFlowLogic.php +++ b/app/admin/logic/store_finance_flow/StoreFinanceFlowLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\store_finance_flow; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -36,8 +37,7 @@ class StoreFinanceFlowLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -61,8 +61,7 @@ class StoreFinanceFlowLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/store_order/StoreOrderLogic.php b/app/admin/logic/store_order/StoreOrderLogic.php index a46665fe7..e4dae7376 100644 --- a/app/admin/logic/store_order/StoreOrderLogic.php +++ b/app/admin/logic/store_order/StoreOrderLogic.php @@ -16,6 +16,7 @@ use app\common\model\store_product\StoreProduct; use app\common\model\user\User; use app\common\model\warehouse_order\WarehouseOrder; use app\common\model\warehouse_product\WarehouseProduct; +use support\exception\BusinessException; use think\facade\Db; @@ -73,8 +74,7 @@ class StoreOrderLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/store_product_attr_value/StoreProductAttrValueLogic.php b/app/admin/logic/store_product_attr_value/StoreProductAttrValueLogic.php index 32f3370dd..d6ba4c20d 100644 --- a/app/admin/logic/store_product_attr_value/StoreProductAttrValueLogic.php +++ b/app/admin/logic/store_product_attr_value/StoreProductAttrValueLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\store_product_attr_value; use app\common\model\store_product_attr_value\StoreProductAttrValue; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -36,8 +37,7 @@ class StoreProductAttrValueLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -61,8 +61,7 @@ class StoreProductAttrValueLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/store_product_unit/StoreProductUnitLogic.php b/app/admin/logic/store_product_unit/StoreProductUnitLogic.php index 9ea649ec1..caa9bb9d8 100644 --- a/app/admin/logic/store_product_unit/StoreProductUnitLogic.php +++ b/app/admin/logic/store_product_unit/StoreProductUnitLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\store_product_unit; use app\common\model\store_product_unit\StoreProductUnit; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -40,8 +41,7 @@ class StoreProductUnitLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -69,8 +69,7 @@ class StoreProductUnitLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/supplier/SupplierLogic.php b/app/admin/logic/supplier/SupplierLogic.php index ba686ab0b..907b352e2 100644 --- a/app/admin/logic/supplier/SupplierLogic.php +++ b/app/admin/logic/supplier/SupplierLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\supplier; use app\common\model\supplier\Supplier; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -41,8 +42,7 @@ class SupplierLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -71,8 +71,7 @@ class SupplierLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/system_store/SystemStoreLogic.php b/app/admin/logic/system_store/SystemStoreLogic.php index 4e68384b3..fbf3302e1 100644 --- a/app/admin/logic/system_store/SystemStoreLogic.php +++ b/app/admin/logic/system_store/SystemStoreLogic.php @@ -6,6 +6,7 @@ namespace app\admin\logic\system_store; use app\common\model\system_store\SystemStore; use app\common\logic\BaseLogic; use app\common\model\system_store\SystemStoreStaff; +use support\exception\BusinessException; use think\facade\Db; use Webman\Config; @@ -70,8 +71,8 @@ class SystemStoreLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } @@ -137,8 +138,8 @@ class SystemStoreLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } diff --git a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php index 03fac3aea..21eea8686 100644 --- a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php +++ b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php @@ -10,6 +10,7 @@ use app\common\logic\BaseLogic; use app\common\model\store_product\StoreProduct; use app\common\model\warehouse_product\WarehouseProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; +use support\exception\BusinessException; use think\facade\Db; @@ -44,10 +45,9 @@ class SystemStoreStorageLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -74,8 +74,8 @@ class SystemStoreStorageLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } diff --git a/app/admin/logic/user/UserFeedbackLogic.php b/app/admin/logic/user/UserFeedbackLogic.php index 4f291ebdc..aa612ccf3 100644 --- a/app/admin/logic/user/UserFeedbackLogic.php +++ b/app/admin/logic/user/UserFeedbackLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\user; use app\common\logic\BaseLogic; use app\common\model\user\UserFeedback; +use support\exception\BusinessException; use think\facade\Db; @@ -40,8 +41,7 @@ class UserFeedbackLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -69,8 +69,7 @@ class UserFeedbackLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/user_bill/UserBillLogic.php b/app/admin/logic/user_bill/UserBillLogic.php index f586146df..fd68aff01 100644 --- a/app/admin/logic/user_bill/UserBillLogic.php +++ b/app/admin/logic/user_bill/UserBillLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\user_bill; use app\common\model\user_bill\UserBill; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -36,8 +37,7 @@ class UserBillLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -61,8 +61,7 @@ class UserBillLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/admin/logic/user_label/UserLabelLogic.php b/app/admin/logic/user_label/UserLabelLogic.php index d8a766b7c..af080ae80 100644 --- a/app/admin/logic/user_label/UserLabelLogic.php +++ b/app/admin/logic/user_label/UserLabelLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\user_label; use app\common\model\user_label\UserLabel; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -36,8 +37,7 @@ class UserLabelLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -61,8 +61,8 @@ class UserLabelLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } diff --git a/app/admin/logic/user_recharge/UserRechargeLogic.php b/app/admin/logic/user_recharge/UserRechargeLogic.php index 27fb78dc4..c60c1e8c3 100644 --- a/app/admin/logic/user_recharge/UserRechargeLogic.php +++ b/app/admin/logic/user_recharge/UserRechargeLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\user_recharge; use app\common\model\user_recharge\UserRecharge; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -36,8 +37,8 @@ class UserRechargeLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } @@ -61,8 +62,8 @@ class UserRechargeLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } diff --git a/app/admin/logic/user_ship/UserShipLogic.php b/app/admin/logic/user_ship/UserShipLogic.php index 6075c5cb8..40cd0650c 100644 --- a/app/admin/logic/user_ship/UserShipLogic.php +++ b/app/admin/logic/user_ship/UserShipLogic.php @@ -41,8 +41,8 @@ class UserShipLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } @@ -68,8 +68,8 @@ class UserShipLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } diff --git a/app/admin/logic/warehouse/WarehouseLogic.php b/app/admin/logic/warehouse/WarehouseLogic.php index 13568bdbe..88e24f4fc 100644 --- a/app/admin/logic/warehouse/WarehouseLogic.php +++ b/app/admin/logic/warehouse/WarehouseLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\warehouse; use app\common\model\warehouse\Warehouse; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -42,8 +43,8 @@ class WarehouseLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } @@ -73,8 +74,8 @@ class WarehouseLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } diff --git a/app/admin/logic/warehouse_order/WarehouseOrderLogic.php b/app/admin/logic/warehouse_order/WarehouseOrderLogic.php index 441d57aab..8c9d262c3 100644 --- a/app/admin/logic/warehouse_order/WarehouseOrderLogic.php +++ b/app/admin/logic/warehouse_order/WarehouseOrderLogic.php @@ -88,8 +88,7 @@ class WarehouseOrderLogic extends BaseLogic { $find = WarehouseOrder::where('id', $params['id'])->find(); if (!$find) { - self::setError('订单不存在'); - return false; + throw new BusinessException('订单不存在'); } Db::startTrans(); try { diff --git a/app/api/logic/LoginLogic.php b/app/api/logic/LoginLogic.php index e5dcd48df..bb5f57f66 100644 --- a/app/api/logic/LoginLogic.php +++ b/app/api/logic/LoginLogic.php @@ -63,8 +63,7 @@ class LoginLogic extends BaseLogic return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index 53e5d26fd..b3f84aaf8 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -21,6 +21,7 @@ use Exception; use support\Cache; use think\facade\Db; use app\common\model\system_store\SystemStore; +use support\exception\BusinessException; class StoreOrderLogic extends BaseLogic { @@ -46,7 +47,7 @@ class StoreOrderLogic extends BaseLogic $where = ['is_pay' => 0]; $cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray(); if (empty($cart_select)) { - self::setError('购物车为空'); + throw new BusinessException('购物车为空'); return false; } try { @@ -164,8 +165,7 @@ class StoreOrderLogic extends BaseLogic } } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } return ['order' => $order, 'cart_list' => $cart_select]; } @@ -222,8 +222,8 @@ class StoreOrderLogic extends BaseLogic return $order; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); + } } @@ -413,8 +413,7 @@ class StoreOrderLogic extends BaseLogic $cart_select = Cart::whereIn('id', $params['cart_id']) ->where($where)->field('id,product_id,cart_num,store_id')->select()->toArray(); if (empty($cart_select)) { - self::setError('购物车为空'); - return false; + throw new BusinessException('购物车为空'); } $newArr = []; //检查购物车对比店铺得商品数量差异 diff --git a/app/common/service/generator/stub/php/logic.stub b/app/common/service/generator/stub/php/logic.stub index e7ad55245..901e5232d 100644 --- a/app/common/service/generator/stub/php/logic.stub +++ b/app/common/service/generator/stub/php/logic.stub @@ -5,6 +5,7 @@ {USE} use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -34,10 +35,9 @@ class {UPPER_CAMEL_NAME}Logic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -59,10 +59,9 @@ class {UPPER_CAMEL_NAME}Logic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/store/logic/auth/AdminLogic.php b/app/store/logic/auth/AdminLogic.php index fd63d0ef4..9f8af98bc 100644 --- a/app/store/logic/auth/AdminLogic.php +++ b/app/store/logic/auth/AdminLogic.php @@ -25,6 +25,7 @@ use app\common\model\auth\AdminSession; use app\common\cache\AdminTokenCache; use app\common\model\system_store\SystemStoreStaff; use app\common\service\FileService; +use support\exception\BusinessException; use Webman\Config; use think\facade\Db; @@ -73,8 +74,7 @@ class AdminLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -141,8 +141,7 @@ class AdminLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -180,8 +179,7 @@ class AdminLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/store/logic/store_branch_product/StoreBranchProductLogic.php b/app/store/logic/store_branch_product/StoreBranchProductLogic.php index d37e60cad..7837ac1b5 100644 --- a/app/store/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/store/logic/store_branch_product/StoreBranchProductLogic.php @@ -65,8 +65,7 @@ class StoreBranchProductLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -95,8 +94,7 @@ class StoreBranchProductLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -151,7 +149,7 @@ class StoreBranchProductLogic extends BaseLogic public static function checkAuth($product) { if (request()->adminInfo['store_id'] != $product['store_id']) { - throw new \Exception('没有权限操作'); + throw new BusinessException('没有权限操作'); } } diff --git a/app/store/logic/store_order/StoreOrderLogic.php b/app/store/logic/store_order/StoreOrderLogic.php index 80df42e05..13b7948a0 100644 --- a/app/store/logic/store_order/StoreOrderLogic.php +++ b/app/store/logic/store_order/StoreOrderLogic.php @@ -7,6 +7,7 @@ use app\common\model\order\Cart; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -38,8 +39,7 @@ class StoreOrderLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -63,8 +63,7 @@ class StoreOrderLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/store/logic/store_product/StoreProductLogic.php b/app/store/logic/store_product/StoreProductLogic.php index 7af0b7980..594a72821 100644 --- a/app/store/logic/store_product/StoreProductLogic.php +++ b/app/store/logic/store_product/StoreProductLogic.php @@ -7,6 +7,7 @@ use app\common\model\store_product\StoreProduct; use app\common\logic\BaseLogic; use app\common\model\store_category\StoreCategory; use app\common\model\store_product_attr_value\StoreProductAttrValue; +use support\exception\BusinessException; use think\facade\Db; @@ -34,8 +35,7 @@ class StoreProductLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -58,8 +58,7 @@ class StoreProductLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } diff --git a/app/store/logic/store_product_attr_value/StoreProductAttrValueLogic.php b/app/store/logic/store_product_attr_value/StoreProductAttrValueLogic.php index 2520412a2..0572ba6ce 100644 --- a/app/store/logic/store_product_attr_value/StoreProductAttrValueLogic.php +++ b/app/store/logic/store_product_attr_value/StoreProductAttrValueLogic.php @@ -5,6 +5,7 @@ namespace app\store\logic\store_product_attr_value; use app\common\model\store_product_attr_value\StoreProductAttrValue; use app\common\logic\BaseLogic; +use support\exception\BusinessException; use think\facade\Db; @@ -36,8 +37,7 @@ class StoreProductAttrValueLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } } @@ -61,8 +61,7 @@ class StoreProductAttrValueLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + throw new BusinessException($e->getMessage()); } }