From 7a742331def946189e0cc7fd210a8782cf4cefc3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 18 Oct 2024 11:36:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E8=AE=BE=E7=BD=AE=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=AE=A2=E5=8D=95=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 PurchaseProductOfferController 中的 setStoreroomInfo 方法,用于设置仓库商品信息 - 修改 BeforehandOrderCartInfoLogic 中的处理逻辑,增加对总价格的判断和计算 - 在更新订单信息时,增加对出库单中商品价格和总价格的同步更新 --- .../PurchaseProductOfferController.php | 3 +++ .../BeforehandOrderCartInfoLogic.php | 20 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php index a83f1c4eb..a26a5374a 100644 --- a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php +++ b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php @@ -83,6 +83,9 @@ class PurchaseProductOfferController extends BaseAdminController PurchaseProductOfferLogic::setBatchProcureInfo($params); return $this->success('设置成功', [], 1, 1); } + /** + * 设置仓库商品信息 + */ public function setStoreroomInfo() { $params = $this->request->post(); diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index be9419832..008adf9c1 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -8,6 +8,7 @@ use app\common\logic\BaseLogic; use app\common\model\beforehand_order\BeforehandOrder; use app\common\model\purchase_product_offer\PurchaseProductOffer; use app\common\model\warehouse_order\WarehouseOrder; +use app\common\model\warehouse_product\WarehouseProduct; use support\exception\BusinessException; use think\facade\Db; @@ -100,9 +101,14 @@ class BeforehandOrderCartInfoLogic extends BaseLogic if($params['admin_id']==23&&$params['purchases']!=$find['price'] ){ throw new BusinessException('当前账号没有权限编辑价格, 请联系管理员修改'); } + if($params['total_price']<=0){ + $total_price=bcmul($params['purchases'],$params['nums'],2); + }else{ + $total_price=$params['total_price']; + } $find->save([ 'price' => $params['purchases'], - 'total_price' => bcmul($params['purchases'],$params['nums'],2), + 'total_price' => $total_price, 'cart_num' => $params['nums'], ]); $bhoid = $params['bhoid']; @@ -110,7 +116,17 @@ class BeforehandOrderCartInfoLogic extends BaseLogic if($find['is_buyer']==1){ PurchaseProductOffer::where('order_id',$bhoid)->where('product_id',$find['product_id'])->update(['need_num'=>$params['nums']]); } - BeforehandOrder::where('id', $bhoid)->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]); + $order=BeforehandOrder::where('id', $bhoid)->find(); + $order->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]); + + if($order['outbound_id']>0){ + $wp= WarehouseProduct::where('oid',$order['outbound_id'])->where('product_id',$find['product_id'])->where('financial_pm',0)->find(); + if($wp){ + $wp->update(['price'=>$params['purchases'],'total_price'=>$total_price]); + $wp_total_price=WarehouseProduct::where('oid', $order['outbound_id'])->where('financial_pm',0)->sum('total_price'); + WarehouseOrder::where('id', $order['outbound_id'])->update(['total_price' => $wp_total_price]); + } + } Db::commit(); return true; } catch (\Throwable $e) {