From a5ccb95cf2ec86a8a36fca476de97da19f221c41 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 1 Aug 2024 16:46:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E9=80=BB=E8=BE=91=E5=92=8C=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E5=8F=91=E9=80=81=E9=98=9F=E5=88=97=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=B4=A2=E5=8A=A1PM=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../warehouse_product/WarehouseProductLogic.php | 17 +++++++++++++---- app/queue/redis/StoreStorageSend.php | 1 - 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 76693e53..66540148 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -51,7 +51,7 @@ class WarehouseProductLogic extends BaseLogic $data['expiration_date']=strtotime($params['expiration_date']); } $res=WarehouseProduct::create($data); - self::enter($res['id']); + self::enter($res['id'],$params['financial_pm']); Db::commit(); return true; } catch (\Exception $e) { @@ -107,18 +107,27 @@ class WarehouseProductLogic extends BaseLogic * @author admin * @date 2024/07/31 16:55 */ - public static function enter($id) + public static function enter($id,$financial_pm=0) { Db::startTrans(); try { $find=WarehouseProduct::where('id',$id)->find(); $find->status=1; $find->save(); - StoreProduct::where('id',$find['product_id'])->inc('stock',$find['nums'])->update(); $storege=WarehouseProductStorege::where('warehouse_id',$find['warehouse_id'])->where('product_id',$find['product_id'])->find(); + if($financial_pm==0){ + StoreProduct::where('id',$find['product_id'])->dec('stock',$find['nums'])->update(); + }else{ + StoreProduct::where('id',$find['product_id'])->inc('stock',$find['nums'])->update(); + } if($storege){ - $storege->nums=$storege->nums+$find['nums']; + if($financial_pm==0){ + $storege->nums=bcsub($storege->nums,$find['nums']); + }else{ + $storege->nums=bcadd($storege->nums,$find['nums']); + } $storege->save(); + }else{ WarehouseProductStorege::create([ 'warehouse_id' => $find['warehouse_id'], diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index 73cdf015..bd90165b 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -191,7 +191,6 @@ class StoreStorageSend implements Consumer } else { SystemStoreStorage::create($storage); WarehouseProductLogic::add($data); - StoreProduct::where('id', $product_arr['id'])->dec('stock', $product_arr['stock'])->update(); } }