diff --git a/app/ExceptionHandler.php b/app/ExceptionHandler.php index 483b9d6bb..0ba7badc3 100644 --- a/app/ExceptionHandler.php +++ b/app/ExceptionHandler.php @@ -7,6 +7,7 @@ use Next\VarDumper\Dumper; use Next\VarDumper\DumperHandler; use support\exception\BusinessException; use support\exception\Handler; +use support\Log; use Throwable; use Webman\Http\Request; use Webman\Http\Response; @@ -22,6 +23,7 @@ class ExceptionHandler extends Handler return \response(self::convertToHtml($exception)); }elseif ($exception instanceof BusinessException) { if ($request->expectsJson()) { + Log::error('BusinessException:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]); return json(['code' => 0, 'msg' => $exception->getMessage(),'show'=>1]); } return response($exception->getMessage()); @@ -35,9 +37,12 @@ class ExceptionHandler extends Handler $error['file'] = $exception->getFile(); $error['line'] = $exception->getLine(); } + Log::error('Exception:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]); return response(json_encode($error, JSON_UNESCAPED_UNICODE)); } // 非json请求则返回一个页面 + Log::error('other:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]); + return new Response(200, [], 'msg:'.$exception->getMessage().'。line:'.$exception->getLine().'。file:'.$exception->getFile()); } } diff --git a/app/MyBusinessException.php b/app/MyBusinessException.php deleted file mode 100644 index bebfa4e05..000000000 --- a/app/MyBusinessException.php +++ /dev/null @@ -1,20 +0,0 @@ -expectsJson()) { - return json(['code' => $this->getCode() ?: 500, 'msg' => $this->getMessage(),'show'=>1]); - } - // 非json请求则返回一个页面 - return new Response(200, [], $this->getMessage()); - } -} \ No newline at end of file diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index d9bef6369..e707297b9 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -411,7 +411,7 @@ class BeforehandOrderLogic extends BaseLogic 'admin_id' => $admin_id, 'total_price' => $arr['total_price'], 'price' => $arr['price'], - 'vip_price' => $price==0?$arr['price']:$price, + 'vip_price' => $price, 'purchase' => $arr['purchase'], 'oid' => $res['id'], 'code' => $res['code'], @@ -870,10 +870,10 @@ class BeforehandOrderLogic extends BaseLogic if($order['uid']>0){ $user_ship = User::where('id', $order['uid'])->value('user_ship'); if($user_ship==0){ - throw new BusinessException('用户id不能为0'); + throw new BusinessException('用户角色id不能为0'); } }else{ - throw new BusinessException('用户id不能为0'); + throw new BusinessException('该订单没选择会员用户'); } $total_price = 0; $pay_price = 0; diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 3fd3e1bdf..29ee35a5d 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -346,31 +346,28 @@ class WarehouseProductLogic extends BaseLogic //减少 private static function decStock($res) { - $res = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id']) - ->where('product_id', $res['product_id']) - ->dec('nums', $res['nums']) - ->save(); - SqlChannelLog('WarehouseProductStorege', $res['id'], $res['nums'], -1, Request()->url()); + $res1 = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id']) + ->where('product_id', $res['product_id'])->find(); + $res1->save(['nums'=>bcsub($res1['nums'], $res['nums'],2)]); + SqlChannelLog('WarehouseProductStorege', $res1['id'], $res['nums'], -1, Request()->url()); - $res2 = StoreBranchProduct::where('id', $res['id']) - ->dec('stock', $res['nums']) - ->update(); + $res2 = StoreBranchProduct::where('id', $res['id'])->find(); + $res2->save(['stock'=>bcsub($res2['stock'], $res['nums'],2)]); SqlChannelLog('StoreBranchProduct', $res2['id'], $res['nums'], -1, Request()->url()); } //增加 private static function incStock($res, $params) { - $res = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id']) + $res1 = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id']) ->where('product_id', $res['product_id']) - ->inc('nums', $params['nums']) - ->save(); - SqlChannelLog('WarehouseProductStorege', $res['id'], $res['nums'], 1, Request()->url()); + ->find(); + $res1->save(['nums'=>bcadd($res1['nums'], $params['nums'],2)]); + + SqlChannelLog('WarehouseProductStorege', $res1['id'], $res['nums'], 1, Request()->url()); - - $res2 = StoreBranchProduct::where('id', $res['id']) - ->inc('stock', $params['nums']) - ->save(); + $res2 = StoreBranchProduct::where('id', $res['id'])->find(); + $res2->save(['stock'=>bcadd($res2['stock'], $params['nums'],2)]); SqlChannelLog('StoreBranchProduct', $res2['id'], $res['nums'], 1, Request()->url()); } } diff --git a/app/admin/validate/LoginValidate.php b/app/admin/validate/LoginValidate.php index 02dac88a3..5b39f4489 100644 --- a/app/admin/validate/LoginValidate.php +++ b/app/admin/validate/LoginValidate.php @@ -9,7 +9,6 @@ use app\common\enum\AdminTerminalEnum; use app\common\model\auth\Admin; use app\common\service\ConfigService; use app\common\validate\BaseValidate; -use app\MyBusinessException; use support\exception\BusinessException; use Webman\Config; diff --git a/app/api/lists/store/SystemStoreLists.php b/app/api/lists/store/SystemStoreLists.php index a45511f34..b48eaae63 100644 --- a/app/api/lists/store/SystemStoreLists.php +++ b/app/api/lists/store/SystemStoreLists.php @@ -9,8 +9,7 @@ use app\common\model\order\Cart; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\system_store\SystemStore; use app\common\lists\ListsSearchInterface; -use app\MyBusinessException; -use think\Exception; + /** diff --git a/app/common/model/store_branch_product/StoreBranchProduct.php b/app/common/model/store_branch_product/StoreBranchProduct.php index 494edb295..4f782f0f0 100644 --- a/app/common/model/store_branch_product/StoreBranchProduct.php +++ b/app/common/model/store_branch_product/StoreBranchProduct.php @@ -21,7 +21,34 @@ class StoreBranchProduct extends BaseModel use SoftDelete; protected $name = 'store_branch_product'; protected $deleteTime = 'delete_time'; - + public $ignoreLogFields = [ + 'top_cate_id', + 'two_cate_id', + 'cate_id', + 'store_name', + 'image', + 'price', + 'vip_price', + 'cost', + 'purchase', + 'total_price', + 'store_info', + 'keyword', + 'bar_code', + 'rose', + 'status', + 'product_type', + 'unit', + 'batch', + 'store_batch', + 'sort', + 'label_id', + 'is_lack', + 'manufacturer_information', + 'status', + 'create_time', + 'update_time', + ]; public function unitName() diff --git a/app/common/model/warehouse_product/WarehouseProduct.php b/app/common/model/warehouse_product/WarehouseProduct.php index fb086e088..451a42768 100644 --- a/app/common/model/warehouse_product/WarehouseProduct.php +++ b/app/common/model/warehouse_product/WarehouseProduct.php @@ -18,7 +18,34 @@ class WarehouseProduct extends BaseModel use SoftDelete; protected $name = 'warehouse_product'; protected $deleteTime = 'delete_time'; - + public $ignoreLogFields = [ + 'price', + 'total_price', + 'status', + 'pay_type', + 'is_pay', + 'vip_price', + 'cost', + 'purchase', + 'total_price', + 'mark', + 'after_nums', + 'before_nums', + 'batch', + 'enter_admin_id', + 'admin_id', + 'financial_pm', + 'expiration_date', + 'manufacture', + 'code', + 'oid', + 'unit', + 'store_id', + 'supplier_id', + 'warehouse_id', + 'create_time', + 'update_time', + ]; public static function onBeforeWrite($data) { try { diff --git a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php index 172b611f8..4dfe1a65f 100644 --- a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php +++ b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php @@ -18,7 +18,11 @@ class WarehouseProductStorege extends BaseModel use SoftDelete; protected $name = 'warehouse_product_storege'; protected $deleteTime = 'delete_time'; - + public $ignoreLogFields = [ + 'price', + 'total_price', + 'update_time', + ]; public static function onBeforeWrite($data) { try { diff --git a/app/store/logic/LoginLogic.php b/app/store/logic/LoginLogic.php index 453a991c1..adec25c4f 100644 --- a/app/store/logic/LoginLogic.php +++ b/app/store/logic/LoginLogic.php @@ -20,8 +20,6 @@ use app\common\model\system_store\SystemStoreStaff; use app\store\service\AdminTokenService; use app\common\model\auth\AdminRole; use app\common\service\FileService; -use app\MyBusinessException; -use think\facade\Db; use Webman\Config; /** diff --git a/app/store/logic/store_branch_product/StoreBranchProductLogic.php b/app/store/logic/store_branch_product/StoreBranchProductLogic.php index 7837ac1b5..9b1bce6c7 100644 --- a/app/store/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/store/logic/store_branch_product/StoreBranchProductLogic.php @@ -9,7 +9,6 @@ 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 app\MyBusinessException; use support\exception\BusinessException; use think\facade\Db;