feat(weibo): 优化协作单详情并增加已上脚本状态
This commit is contained in:
@@ -33,6 +33,7 @@ from .weibo_service import query_weibo_mall, refresh_weibo_account
|
||||
STATUS_INCOMPLETE = "incomplete"
|
||||
STATUS_TO_RECHARGE = "to_recharge"
|
||||
STATUS_RECHARGED = "recharged"
|
||||
STATUS_SCRIPTED = "scripted"
|
||||
STATUS_DONE = "done"
|
||||
STATUS_WEIDOU_ERROR = "weidou_error"
|
||||
STATUS_FAILED = "failed"
|
||||
@@ -42,6 +43,7 @@ ORDER_STATUSES = (
|
||||
STATUS_INCOMPLETE,
|
||||
STATUS_TO_RECHARGE,
|
||||
STATUS_RECHARGED,
|
||||
STATUS_SCRIPTED,
|
||||
STATUS_DONE,
|
||||
STATUS_WEIDOU_ERROR,
|
||||
STATUS_FAILED,
|
||||
@@ -52,6 +54,7 @@ ORDER_STATUS_LABELS = {
|
||||
STATUS_INCOMPLETE: "待补资料",
|
||||
STATUS_TO_RECHARGE: "待充值",
|
||||
STATUS_RECHARGED: "已充值",
|
||||
STATUS_SCRIPTED: "已上脚本",
|
||||
STATUS_DONE: "兑换成功",
|
||||
STATUS_WEIDOU_ERROR: "微豆异常",
|
||||
STATUS_FAILED: "兑换失败",
|
||||
@@ -62,13 +65,15 @@ STATUS_FLOW = (
|
||||
STATUS_INCOMPLETE,
|
||||
STATUS_TO_RECHARGE,
|
||||
STATUS_RECHARGED,
|
||||
STATUS_SCRIPTED,
|
||||
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_DONE,
|
||||
STATUS_RECHARGED: STATUS_SCRIPTED,
|
||||
STATUS_SCRIPTED: STATUS_DONE,
|
||||
}
|
||||
|
||||
BALANCE_GROUP_STATUSES = (
|
||||
@@ -712,15 +717,25 @@ def set_status(
|
||||
now = _now()
|
||||
if target == STATUS_TO_RECHARGE:
|
||||
order.recharged_at = None
|
||||
order.scripted_at = None
|
||||
order.exchange_started_at = None
|
||||
order.done_at = None
|
||||
elif target in (STATUS_RECHARGED, STATUS_WEIDOU_ERROR):
|
||||
if order.recharged_at is None:
|
||||
order.recharged_at = now
|
||||
if rollback:
|
||||
order.scripted_at = None
|
||||
order.exchange_started_at = None
|
||||
order.done_at = None
|
||||
elif target == STATUS_SCRIPTED:
|
||||
if order.recharged_at is None:
|
||||
raise CollabError("请先完成余额核账", code="recharge_check_required")
|
||||
if order.scripted_at is None:
|
||||
order.scripted_at = now
|
||||
order.done_at = None
|
||||
elif target == STATUS_DONE:
|
||||
if order.scripted_at is None:
|
||||
order.scripted_at = now
|
||||
if order.exchange_started_at is None:
|
||||
order.exchange_started_at = now
|
||||
order.done_at = now
|
||||
@@ -1216,7 +1231,7 @@ def check_exchange_records(
|
||||
order.exchange_record_snapshot = _json_safe(record)
|
||||
order.exchange_verdict = VERDICT_SUCCESS
|
||||
order.exchange_message = "兑换记录唯一命中"
|
||||
if order.status == STATUS_RECHARGED:
|
||||
if order.status in (STATUS_RECHARGED, STATUS_SCRIPTED):
|
||||
set_status(
|
||||
db,
|
||||
current,
|
||||
@@ -1518,6 +1533,7 @@ def serialize_order(
|
||||
"exchange_verdict": order.exchange_verdict or "",
|
||||
"exchange_message": order.exchange_message or "",
|
||||
"recharged_at": order.recharged_at,
|
||||
"scripted_at": order.scripted_at,
|
||||
"done_at": order.done_at,
|
||||
"void_reason": order.void_reason or "",
|
||||
"is_archived": order.archived_at is not None,
|
||||
|
||||
Reference in New Issue
Block a user