编辑数量时记录

This commit is contained in:
2026-02-24 16:15:49 +08:00
parent cf7d8a9f5b
commit 144fa72075
2 changed files with 21 additions and 1 deletions
+20
View File
@@ -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);
}
/**
* 变动物品库存数量