From 465e8823198a76b34ceb817513711dbe40ae354e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 14 Oct 2024 12:49:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=A5=E5=BA=93=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=87=91=E9=A2=9D=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正入库订单的总金额、已完成金额和待完成金额的计算方式 - 使用数据库查询替代手动输入金额,提高数据准确性和逻辑性 - 优化代码可维护性,减少手动计算引入的潜在错误 --- .../BeforehandOrderCartInfoLogic.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index 52f4095ed..8ef7314e9 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -131,6 +131,9 @@ class BeforehandOrderCartInfoLogic extends BaseLogic throw new BusinessException('请勿重复入库'); } $offer_list = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'is_storage' => 0])->select(); + $total_price= PurchaseProductOffer::where(['order_id' => $params['bhoid']])->sum('total_price'); + $completed_amount= PurchaseProductOffer::where(['order_id' => $params['bhoid'],'pay_type'=>1])->sum('total_price'); + $outstanding_amount= PurchaseProductOffer::where(['order_id' => $params['bhoid'],'pay_type'=>2])->sum('total_price'); Db::startTrans(); try { $code = getNewOrderId('RK'); @@ -142,9 +145,9 @@ class BeforehandOrderCartInfoLogic extends BaseLogic 'batch' => 0, 'code' => $code, 'mark' => $params['remark'] ?? '', - 'total_price' => $params['total_price'], - 'completed_amount' => $params['completed_amount'] ?? 0, - 'outstanding_amount' => $params['outstanding_amount'] ?? 0, + 'total_price' => $total_price, + 'completed_amount' => $completed_amount, + 'outstanding_amount' => $outstanding_amount, ]; $res = WarehouseOrder::create($arr); foreach ($offer_list as $k => $v) {