ming #1

Merged
liufumingren merged 558 commits from ming into main 2026-11-18 16:13:25 +08:00
2 changed files with 7 additions and 1 deletions
Showing only changes of commit b9fe9e774c - Show all commits

View File

@ -3995,13 +3995,15 @@ class RecheckOrderService extends OrderBaseService {
);
// 步骤3:检查是否存在 wms_picking 记录(仅统计 pending 且未删除的记录)
// 使用 FOR UPDATE 行锁,防止并发事务读取到相同的 picking 记录导致重复扣减库存
const pickingRows = await ctx.model.query(
`SELECT id, storage_id, quantity, space_id
FROM wms_picking
WHERE order_id = :orderId
AND warehouse_id = :warehouseId
AND status = 'pending'
AND deleted_at IS NULL`,
AND deleted_at IS NULL
FOR UPDATE`,
{
replacements: { orderId, warehouseId },
type: ctx.model.QueryTypes.SELECT,

View File

@ -335,6 +335,7 @@ class PickCompensationService extends MainService {
try {
// Step 1: 重新查询 wms_picking,确保只处理仍然 status='pending' 的记录
// 使用 FOR UPDATE 行锁,防止并发事务读取到相同的 picking 记录导致重复释放锁定库存
const confirmedRows = await ctx.model.query(`
SELECT
p.id,
@ -348,6 +349,7 @@ class PickCompensationService extends MainService {
AND p.storage_id IS NOT NULL
AND p.storage_id > 0
AND p.deleted_at IS NULL -- 排除软删除记录
FOR UPDATE
`, {
replacements: { pickingIds, warehouseId },
type: ctx.model.QueryTypes.SELECT,
@ -474,6 +476,7 @@ class PickCompensationService extends MainService {
try {
// Step 1: 重新查询 wms_picking,确保只处理仍然 status='pending' 的记录
// 使用 FOR UPDATE 行锁,防止并发事务读取到相同的 picking 记录导致重复扣减库存
const confirmedRows = await ctx.model.query(`
SELECT
p.id,
@ -487,6 +490,7 @@ class PickCompensationService extends MainService {
AND p.storage_id IS NOT NULL
AND p.storage_id > 0
AND p.deleted_at IS NULL -- 排除软删除记录
FOR UPDATE
`, {
replacements: { pickingIds, warehouseId },
type: ctx.model.QueryTypes.SELECT,