fix(backend): 出库单确认/取消时同步清空 stock_locked
- stockout.confirm 完成出库时置 stock_locked=0(与 stock_deducted 同步) - order.cancel 回调:单据已推送(3)、或推送未成功但已锁定库存(stock_locked=1),且尚未扣减时释放锁定并置 0
This commit is contained in:
parent
92be712dbc
commit
5329aa8003
@ -578,7 +578,7 @@ async function confirmOutbound(ctx, { principalId, warehouseId, data }) {
|
||||
}
|
||||
// 确认摘要(含运单号/物流公司)与状态、库存同事务写入
|
||||
summaryResult = await applyOutboundConfirmSummary(ctx, order, payload, packages, lines, { transaction, express: expressResult.first });
|
||||
await order.update({ status: 4, stock_deducted: 1 }, { transaction });
|
||||
await order.update({ status: 4, stock_deducted: 1, stock_locked: 0 }, { transaction });
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
@ -950,8 +950,8 @@ async function cancelOrder(ctx, { principalId, warehouseId, data }) {
|
||||
return { ok: true, message: 'ok', data: { bill_id: order.id, bill_no: order.bill_no, bill_type: billType, status: 9, already_cancelled: true } };
|
||||
}
|
||||
|
||||
// 出库单已推送(3)且未扣减库存:取消时释放锁定库存
|
||||
if (billType === 2 && order.status === 3 && !order.stock_deducted) {
|
||||
// 出库单已推送(3)、或推送未成功但已锁定库存(stock_locked=1)且未扣减库存:取消时释放锁定库存
|
||||
if (billType === 2 && (order.status === 3 || Number(order.stock_locked) === 1) && !order.stock_deducted) {
|
||||
const items = await ctx.model.StockItem.findAll({
|
||||
where: { bill_type: 2, bill_id: order.id, product_id: { [ctx.app.Sequelize.Op.ne]: null } },
|
||||
attributes: [ 'product_id', 'code', 'name', 'quantity', 'inventory_type' ],
|
||||
@ -977,7 +977,7 @@ async function cancelOrder(ctx, { principalId, warehouseId, data }) {
|
||||
transaction,
|
||||
});
|
||||
}
|
||||
await order.update({ status: 9 }, { transaction });
|
||||
await order.update({ status: 9, stock_locked: 0 }, { transaction });
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user