From 3166a06a56325a8fbf3823fb1067c0e5494f7980 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 15 Nov 2024 16:53:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin):=20=E4=BF=AE=E5=A4=8D=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E4=BA=A7=E5=93=81=E9=80=80=E8=B4=A7=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=80=BB=E4=BB=B7=E8=AE=A1=E7=AE=97=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化了 WarehouseProductReturnLogic 中的总价计算逻辑 - 在更新商品数量后,同步更新订单总价和预订单支付价格 - 移除了冗余的异常捕获代码 --- .../WarehouseProductReturnLogic.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php b/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php index aeaf1440f..dbea9f7c3 100644 --- a/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php +++ b/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php @@ -6,6 +6,7 @@ namespace app\admin\logic\warehouse_product_return; use app\common\model\warehouse_product_return\WarehouseProductReturn; use app\common\logic\BaseLogic; use app\common\model\beforehand_order\BeforehandOrder; +use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; use app\common\model\warehouse_order\WarehouseOrder; use app\common\model\warehouse_product\WarehouseProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; @@ -64,8 +65,11 @@ class WarehouseProductReturnLogic extends BaseLogic $total_price=bcmul($nums,$find['price'],2); } $find->save(['nums'=>$nums,'total_price'=>$total_price]); + $total_price=WarehouseProduct::where('oid',$find['oid'])->sum('total_price'); if($nums>0){ - $total_price=WarehouseProduct::where('oid',$find['oid'])->sum('total_price'); + WarehouseOrder::where(['id'=>$find['oid']])->update(['total_price'=>$total_price]); + BeforehandOrder::update(['pay_price'=>$total_price],['id'=>$params['bhoid']]); + }elseif($nums==0){ WarehouseOrder::where(['id'=>$find['oid']])->update(['total_price'=>$total_price]); BeforehandOrder::update(['pay_price'=>$total_price],['id'=>$params['bhoid']]); } @@ -80,7 +84,6 @@ class WarehouseProductReturnLogic extends BaseLogic return true; } catch (\Throwable $e) { Db::rollback(); - d($e); throw new BusinessException($e->getMessage()); } }