diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index a652d465..3518ad79 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -255,6 +255,7 @@ class WarehouseProductLogic extends BaseLogic $datas['expiration_date'] = strtotime($params['expiration_date']); } $res->save($datas); + self::updateWarehouseOrder($res['oid']); } Db::commit(); return $res; @@ -281,6 +282,7 @@ class WarehouseProductLogic extends BaseLogic $productNum = -$res['nums']; self::updateWarehouseProduct($res, $storageNum, $productNum); $res->delete(); + self::updateWarehouseOrder($res['oid']); $types = $res['financial_pm'] == 1 ? ProductSourceLinkInfo::TypeIn : ProductSourceLinkInfo::TypeOut; ProductSourceLinkInfoLogic::deleteByLinkId($res['id'], $types); Db::commit(); @@ -347,6 +349,7 @@ class WarehouseProductLogic extends BaseLogic } $warehouseProduct->save($datas); + self::updateWarehouseOrder($warehouseProduct['oid']); } Db::commit(); } catch (\Throwable $th) { @@ -478,14 +481,26 @@ class WarehouseProductLogic extends BaseLogic WarehouseProduct::where('id',$warehouseProduct['id'])->update($update); SqlChannelLog('WarehouseProduct', $warehouseProduct['id'], $productNum, $productNum > 0 ? 1 : -1, Request()->url()); - $find = WarehouseProduct::where('oid', $warehouseProduct['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); + self::updateStoreStorage2($warehouseProduct, $productNum); + } + + /** + * 更新订单数量和总价 + * @param $oid + * @return void + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + */ + public static function updateWarehouseOrder($oid) + { + $find = WarehouseProduct::where('oid', $oid)->field('sum(nums) as nums,sum(total_price) as total_price')->find(); if ($find) { - WarehouseOrder::where('id', $warehouseProduct['oid'])->update([ + WarehouseOrder::where('id', $oid)->update([ 'nums' => $find['nums'], 'total_price' => $find['total_price'] ]); } - self::updateStoreStorage2($warehouseProduct, $productNum); } /**