From 144fa72075901e702ba5d7bef3df2d35a982c8a1 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 24 Feb 2026 16:15:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=95=B0=E9=87=8F=E6=97=B6?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/InvItemController.php | 2 +- app/common/service/InvItemService.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/admin/controller/InvItemController.php b/app/admin/controller/InvItemController.php index b3eac43..f2aba20 100644 --- a/app/admin/controller/InvItemController.php +++ b/app/admin/controller/InvItemController.php @@ -76,7 +76,7 @@ class InvItemController extends BaseController } // 获取应用访问地址 - $appUrl = config('app.app_url', 'http://127.0.0.1:25616'); + $appUrl = 'https://'.$request->host(); $qrCodeService = new \app\common\service\QrCodeService(); $content = $qrCodeService->generateItemQrCode($id, $appUrl); diff --git a/app/common/service/InvItemService.php b/app/common/service/InvItemService.php index 3dad1cd..ac675be 100644 --- a/app/common/service/InvItemService.php +++ b/app/common/service/InvItemService.php @@ -141,6 +141,26 @@ class InvItemService ], $res['stock_qty']); } + public function beforeServiceUpdate($data, Request $request) + { + $uid = $request->user->uid; + $name = $uid ? User::where('id', $uid)->value('name') : ''; + $item = InvItem::where('id', $data['id'])->first(); + $change_qty = $data['change_qty'] - $item['stock_qty']; + // 记录库存变化日志 + $this->recordStockLog([ + 'item_id' => $data['id'], + 'item_name_snap' => $data['item_name'], + 'change_qty' => $change_qty, + 'before_qty' => $item['stock_qty'], + 'after_qty' => $data['stock_qty'], + 'biz_type' => 1, + 'biz_no' => '', + 'operator_id' => $uid, + 'operator_name' => $name, + 'remark' => '管理员修改数量', + ], $change_qty); + } /** * 变动物品库存数量