refactor(weibo): 移除兑换待确认状态
This commit is contained in:
@@ -33,7 +33,6 @@ from .weibo_service import query_weibo_mall, refresh_weibo_account
|
||||
STATUS_INCOMPLETE = "incomplete"
|
||||
STATUS_TO_RECHARGE = "to_recharge"
|
||||
STATUS_RECHARGED = "recharged"
|
||||
STATUS_EXCHANGE_PENDING = "exchange_pending"
|
||||
STATUS_DONE = "done"
|
||||
STATUS_WEIDOU_ERROR = "weidou_error"
|
||||
STATUS_FAILED = "failed"
|
||||
@@ -43,7 +42,6 @@ ORDER_STATUSES = (
|
||||
STATUS_INCOMPLETE,
|
||||
STATUS_TO_RECHARGE,
|
||||
STATUS_RECHARGED,
|
||||
STATUS_EXCHANGE_PENDING,
|
||||
STATUS_DONE,
|
||||
STATUS_WEIDOU_ERROR,
|
||||
STATUS_FAILED,
|
||||
@@ -54,7 +52,6 @@ ORDER_STATUS_LABELS = {
|
||||
STATUS_INCOMPLETE: "待补资料",
|
||||
STATUS_TO_RECHARGE: "待充值",
|
||||
STATUS_RECHARGED: "已充值",
|
||||
STATUS_EXCHANGE_PENDING: "兑换待确认",
|
||||
STATUS_DONE: "兑换成功",
|
||||
STATUS_WEIDOU_ERROR: "微豆异常",
|
||||
STATUS_FAILED: "兑换失败",
|
||||
@@ -65,15 +62,13 @@ STATUS_FLOW = (
|
||||
STATUS_INCOMPLETE,
|
||||
STATUS_TO_RECHARGE,
|
||||
STATUS_RECHARGED,
|
||||
STATUS_EXCHANGE_PENDING,
|
||||
STATUS_DONE,
|
||||
)
|
||||
STAGE_INDEX = {status: index for index, status in enumerate(STATUS_FLOW)}
|
||||
NEXT_STATUS = {
|
||||
STATUS_INCOMPLETE: STATUS_TO_RECHARGE,
|
||||
STATUS_TO_RECHARGE: STATUS_RECHARGED,
|
||||
STATUS_RECHARGED: STATUS_EXCHANGE_PENDING,
|
||||
STATUS_EXCHANGE_PENDING: STATUS_DONE,
|
||||
STATUS_RECHARGED: STATUS_DONE,
|
||||
}
|
||||
|
||||
BALANCE_GROUP_STATUSES = (
|
||||
@@ -672,9 +667,9 @@ def set_status(
|
||||
_assert_mutable(order)
|
||||
if target not in ORDER_STATUSES:
|
||||
raise CollabError("非法状态", code="status_invalid")
|
||||
if target in (STATUS_RECHARGED, STATUS_WEIDOU_ERROR) and not allow_check:
|
||||
if target == STATUS_WEIDOU_ERROR and not allow_check:
|
||||
raise CollabError(
|
||||
"「已充值 / 微豆异常」必须通过余额核账写入",
|
||||
"「微豆异常」必须通过余额核账写入",
|
||||
code="balance_check_required",
|
||||
)
|
||||
old = order.status
|
||||
@@ -725,12 +720,6 @@ def set_status(
|
||||
if rollback:
|
||||
order.exchange_started_at = None
|
||||
order.done_at = None
|
||||
elif target == STATUS_EXCHANGE_PENDING and not order.recharged_at:
|
||||
raise CollabError("请先完成余额核账", code="recharge_check_required")
|
||||
elif target == STATUS_EXCHANGE_PENDING:
|
||||
if order.exchange_started_at is None:
|
||||
order.exchange_started_at = now
|
||||
order.done_at = None
|
||||
elif target == STATUS_DONE:
|
||||
if order.exchange_started_at is None:
|
||||
order.exchange_started_at = now
|
||||
@@ -1227,7 +1216,7 @@ def check_exchange_records(
|
||||
order.exchange_record_snapshot = _json_safe(record)
|
||||
order.exchange_verdict = VERDICT_SUCCESS
|
||||
order.exchange_message = "兑换记录唯一命中"
|
||||
if order.status == STATUS_EXCHANGE_PENDING:
|
||||
if order.status == STATUS_RECHARGED:
|
||||
set_status(
|
||||
db,
|
||||
current,
|
||||
|
||||
Reference in New Issue
Block a user