修复线下提号后商品仍显示在「已上架」的问题
创建提号时将 listing/account 置为 rented 并记录状态事件,与正常订单锁定一致;完成提号对齐 completed/offline;取消提号恢复上架。补充 migration 修复历史数据。
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
|
||||
-- 进行中的线下提号:listing 应从「已上架」移出,与正常订单锁定一致(status=rented)
|
||||
UPDATE rental_listings l
|
||||
JOIN admin_pickups p ON p.listing_id = l.id AND p.status = 'picking_up'
|
||||
SET l.status = 'rented',
|
||||
l.in_transaction = 1
|
||||
WHERE l.status = 'published';
|
||||
|
||||
UPDATE game_accounts a
|
||||
JOIN admin_pickups p ON p.account_id = a.id AND p.status = 'picking_up'
|
||||
SET a.status = 'rented'
|
||||
WHERE a.status IN ('published', 'draft', '');
|
||||
|
||||
-- 已完成的线下提号:listing 应为 completed,账号下线(兜底历史数据)
|
||||
UPDATE rental_listings l
|
||||
JOIN admin_pickups p ON p.listing_id = l.id AND p.status = 'completed'
|
||||
SET l.status = 'completed',
|
||||
l.in_transaction = 0,
|
||||
l.published_at = NULL
|
||||
WHERE l.status IN ('published', 'rented');
|
||||
|
||||
UPDATE game_accounts a
|
||||
JOIN admin_pickups p ON p.account_id = a.id AND p.status = 'completed'
|
||||
SET a.status = 'offline'
|
||||
WHERE a.status NOT IN ('offline', 'sealed', 'abnormal');
|
||||
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
|
||||
-- 回滚仅恢复「进行中提号」的锁定(completed 终态不回滚,避免误恢复可租)
|
||||
UPDATE rental_listings l
|
||||
JOIN admin_pickups p ON p.listing_id = l.id AND p.status = 'picking_up'
|
||||
SET l.status = 'published',
|
||||
l.in_transaction = 1
|
||||
WHERE l.status = 'rented';
|
||||
|
||||
UPDATE game_accounts a
|
||||
JOIN admin_pickups p ON p.account_id = a.id AND p.status = 'picking_up'
|
||||
SET a.status = 'published'
|
||||
WHERE a.status = 'rented';
|
||||
|
||||
-- +goose StatementEnd
|
||||
Reference in New Issue
Block a user