From dd681470d8d423b83e008393326a40548a91aba0 Mon Sep 17 00:00:00 2001 From: sjeam <359824901@qq.com> Date: Tue, 8 Apr 2025 11:39:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=8B=A8=E8=AE=A2=E5=8D=95=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=92=8C=E6=8F=92=E5=85=A5arr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InventoryTransferOrderLogic.php | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php b/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php index b796c5fc9..3f69c394c 100644 --- a/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php +++ b/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php @@ -233,6 +233,7 @@ class InventoryTransferOrderLogic extends BaseLogic ->toArray(); return $data->toArray(); } + /** * 插入调拨订单 */ @@ -240,18 +241,44 @@ class InventoryTransferOrderLogic extends BaseLogic { Db::startTrans(); try { - $find = InventoryTransfer::where('product_id', $params['product_id'])->where('oid', $params['id'])->find()->toArray(); - if ($find) { - unset($find['id']); - $find['nums'] = $params['nums']; - $find['create_time'] = time(); + $product_arr = $params['product_arr']; + $insert = []; + foreach ($product_arr as $v) { + $find = InventoryTransfer::where('product_id', $v['id'])->where('oid', $params['oid'])->find()->toArray(); + if ($find) { + unset($find['id']); + $find['nums'] = $v['nums']; + $find['create_time'] = time(); + $insert[] = $find; + } } - InventoryTransfer::insert($find); + InventoryTransfer::insertAll($insert); Db::commit(); return true; - } catch (\Throwable $e) { + } catch (\Exception $e) { Db::rollback(); - throw new BusinessException($e->getMessage()); + return false; } } + // /** + // * 插入调拨订单 + // */ + // public static function insert($params) + // { + // Db::startTrans(); + // try { + // $find = InventoryTransfer::where('product_id', $params['product_id'])->where('oid', $params['id'])->find()->toArray(); + // if ($find) { + // unset($find['id']); + // $find['nums'] = $params['nums']; + // $find['create_time'] = time(); + // } + // InventoryTransfer::insert($find); + // Db::commit(); + // return true; + // } catch (\Throwable $e) { + // Db::rollback(); + // throw new BusinessException($e->getMessage()); + // } + // } }