From 8e072374891d0732cefd923bb8a6eb898f80daac Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 8 Jan 2025 14:42:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor(admin):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E5=95=86=E5=93=81=E9=80=80=E8=B4=A7=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了采购信息的相关代码 - 将 supplier_id 和 price 设置为 0 - 删除了 total_price 的计算逻辑 --- .../WarehouseProductReturnLogic.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php b/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php index 19314681b..88c8a096d 100644 --- a/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php +++ b/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php @@ -76,15 +76,15 @@ class WarehouseProductReturnLogic extends BaseLogic throw new BusinessException('该商品库存:'.$params['nums'].'小于仓库库存'.$proudct['nums']); } } - $offer = PurchaseProductOffer::where('order_id', $params['bhoid'])->where('product_id', $find['product_id'])->find(); - if (!$offer) { - throw new BusinessException('该商品没有采购信息'); - } + // $offer = PurchaseProductOffer::where('order_id', $params['bhoid'])->where('product_id', $find['product_id'])->find(); + // if (!$offer) { + // throw new BusinessException('该商品没有采购信息'); + // } $datas = [ 'source_id' => $params['id'], 'bhoid' => $params['bhoid'] ?? 0, 'warehouse_id' => $find['warehouse_id'], - 'supplier_id' => $offer['supplier_id'], + 'supplier_id' => 0, 'store_id' => $find['store_id'], 'product_id' => $find['product_id'], 'unit' => $find['unit'], @@ -93,8 +93,10 @@ class WarehouseProductReturnLogic extends BaseLogic 'nums' => $params['nums'], 'return_type' => $params['return_type'], 'mark' => $params['mark'], - 'price' => $offer['price'], - 'total_price' => bcmul($params['nums'], $offer['price'], 2), + // 'price' => $offer['price'], + // 'total_price' => bcmul($params['nums'], $offer['price'], 2), + 'price' => 0, + 'total_price' => 0, ]; } From 0ca77643f1614839f183c44dce4f83d207308fe3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 8 Jan 2025 15:13:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(admin):=20=E4=BC=98=E5=8C=96=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 StoreBranchProduct 库存更新方式,先更新 stock 属性再保存 - 这种方式可以减少数据库查询次数,提高性能 --- .../logic/system_store_storage/SystemStoreStorageLogic.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php index 2309fcf9d..9ddcf05ff 100644 --- a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php +++ b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php @@ -69,7 +69,8 @@ class SystemStoreStorageLogic extends BaseLogic $find->save(['status'=>1,'staff_id'=>$params['staff_id']??0,'admin_id'=>$params['admin_id']??0,'mark'=>'入库时间:'.date('Y-m-d H:i:s',time())]); $branch_product=StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->find(); if($branch_product){ - $branch_product->save(['stock'=>$branch_product['stock']+$find['nums']]); + $branch_product->stock=$branch_product['stock']+$find['nums']; + $branch_product->save(); SqlChannelLog('StoreBranchProduct', $branch_product['id'], $find['nums'], 1,Request()->url(),$admin_id); }else{ $storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty();