优化(斗鱼预售台账): 支持失败单复核并智能推进批量状态
查兑换记录可将抢购失败单重新判定为抢购成功或保持失败;同状态批量改状态默认推进到下一阶段。
This commit is contained in:
@@ -1477,6 +1477,8 @@ def set_status(
|
||||
for name, field in STATUS_TIMESTAMP_FIELDS.items():
|
||||
if current_index < STAGE_INDEX[name] <= target_index:
|
||||
setattr(order, field, now)
|
||||
if target == STATUS_DONE and order.done_at is None:
|
||||
order.done_at = now
|
||||
order.status = target
|
||||
order.updated_by = current.id
|
||||
order.version = int(order.version or 0) + 1
|
||||
@@ -1752,7 +1754,7 @@ def query_activity(
|
||||
if matched:
|
||||
verdict = VERDICT_SUCCESS
|
||||
message = f"兑换记录命中「{order.gift_name}」{matched} 条"
|
||||
elif order.status != STATUS_SCRIPTED:
|
||||
elif order.status not in (STATUS_SCRIPTED, STATUS_FAILED):
|
||||
verdict = VERDICT_UNKNOWN
|
||||
message = "订单当前状态不再由兑换记录自动判定"
|
||||
elif order.scripted_at is None:
|
||||
@@ -1826,15 +1828,19 @@ def query_activity(
|
||||
},
|
||||
)
|
||||
|
||||
# 只有查兑换记录时才做业务判定;余额查询保持只读,不动状态。
|
||||
# 查兑换记录会把待判定状态和抢购失败单重新分类;余额查询保持只读。
|
||||
if include_records:
|
||||
if order.status == STATUS_SCRIPTED and verdict == VERDICT_SUCCESS:
|
||||
if (
|
||||
order.status in (STATUS_SCRIPTED, STATUS_FAILED)
|
||||
and verdict == VERDICT_SUCCESS
|
||||
):
|
||||
set_status(
|
||||
db,
|
||||
current,
|
||||
order,
|
||||
status=STATUS_DONE,
|
||||
reason=message,
|
||||
rollback=order.status == STATUS_FAILED,
|
||||
expected_version=None,
|
||||
commit=False,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user