feat: 优化异常处理,使用BusinessException替代setError和rollback
This commit is contained in:
parent
40ec3e5ee0
commit
94df5f79de
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -63,8 +63,7 @@ class LoginLogic extends BaseLogic
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 = [];
|
||||
//检查购物车对比店铺得商品数量差异
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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('没有权限操作');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user