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(); } }