WhatDidYouDoWithAILoading
Back to the forum
书店库存桌面

书店库存提醒老差两本

Google Sheets 和 Apps Script 同步库存后,周末结账常发现同一本书卖了两次。

我给独立书店做了个库存提醒,用 Google Sheets 加 Apps Script 跑同步。平时看着还行,一到周末结账就容易发现线上下单和线下盘点差两本,而且经常是同一本书被卖了两次。

问题主要出在同步不是实时的:线上下单先扣一次,店员手动盘点又改一次,晚上脚本再跑一遍,三边都在写表。老板只愿意花半天维护,所以我没法把流程改得太复杂。

我现在加了一个很土的锁:同步前先检查最近 10 分钟有没有人工改动,如果有就延后。但这只能减少冲突,不能彻底解决,尤其是周末人多的时候,还是会漏单或者重复扣减。

最意外的是,真正麻烦的不是技术,而是收银和盘点的习惯没统一。接下来我想先把“谁来改表”固定下来,不然再多提醒也只是把差两本变成差三本。

10 replies

郑亦然#1 · 2026-10-17

你现在是按分钟同步,还是有人点按钮才同步?

蓝舟#2 · 2026-10-17

现在是定时同步,每 15 分钟一次,人工改表后就更容易撞车。

陈木雨#3 · 2026-10-17

我们店也这样,最怕周末高峰和手工盘点同时发生。

顾一#4 · 2026-10-18

最好加一个版本号,不然只靠时间窗很容易误判。

李楠楠#5 · 2026-10-18

半天维护的话,感觉你越做越像在补流程漏洞。

蓝舟#6 · 2026-10-18

是,所以我现在更像在止血,不是在重构。

周启#7 · 2026-10-18

If two sales channels can decrement the same stock, you need a reservation step before final commit. Otherwise the “same book sold twice” bug just moves from Sheets to whatever sync runs last.

孙迅曦#8 · 2026-10-18

We had a similar issue with comic books, and the fix was ugly: one sheet became read-only, the other got a 10-minute reservation hold. Not elegant, but the double-sell stopped.

苏琳#9 · 2026-10-18

Is the two-book mismatch mostly from weekend rush orders, or from manual edits after closing time? That changes whether you should prioritize locking or audit logs.

蓝舟#10 · 2026-10-18

Mostly weekend rush plus one staff member editing counts after close. I added a 5-minute hold this week, but I haven’t figured out how to show expired holds cleanly without confusing the cashier.