From 454b9b2e9d1b1a51424d5a254a9556735786774d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 10 Oct 2024 09:23:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=87=87=E8=B4=AD=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=92=8C=E9=80=80=E8=B4=A7=E8=AE=A2=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改了入库逻辑,以区分采购订单和退货订单: - 采购订单在入库时增加库存 - 退货订单在确认时更新为确认时间 - 为所有订单类型添加了订单类型字段 --- .../beforehand_order/BeforehandOrderLogic.php | 1 + .../SystemStoreStorageLogic.php | 22 +++++++++++-------- .../WarehouseProductLogic.php | 1 + 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 7f792b6e3..6c95c4652 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -158,6 +158,7 @@ class BeforehandOrderLogic extends BaseLogic 'store_id' => $store_id, 'financial_pm' => 0, 'batch' => 1, + 'order_type' => $order['order_type'], 'nums' => $arr['cart_num'], 'status' => 1, 'admin_id' => $admin_id, diff --git a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php index f1c0d8847..4e221db77 100644 --- a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php +++ b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php @@ -64,18 +64,22 @@ class SystemStoreStorageLogic extends BaseLogic Db::startTrans(); try { $find=SystemStoreStorage::where(['id' => $params['id']])->find(); - if($find){ - $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']]); + if($find['order_type']==1){ + $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']]); + }else{ + $storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty(); + $storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct); + $storeBranchProduct->stock = $find['nums']; + $storeBranchProduct->save(); + } }else{ - $storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty(); - $storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct); - $storeBranchProduct->stock = $find['nums']; - $storeBranchProduct->save(); + $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())]); } + } Db::commit(); return true; diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 69b21bbb1..a567b737d 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -154,6 +154,7 @@ class WarehouseProductLogic extends BaseLogic SystemStoreStorage::create([ 'store_id' => $params['store_id'], 'admin_id' => $params['admin_id'], + 'order_type' => $params['order_type'], 'staff_id' => 0, 'type' => 1, 'product_id' => $params['product_id'],