Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1530b7e74 | ||
|
|
95bfa0dcb7 | ||
|
|
751a45782f | ||
|
|
c6e6e66f2d | ||
|
|
55afbaa903 | ||
|
|
abab55a810 |
@@ -588,3 +588,101 @@ GET bindInfo?actAlias=20260120QYOOB
|
|||||||
bindAct、换绑等待、错误/消息;
|
bindAct、换绑等待、错误/消息;
|
||||||
- 以后先看这张表,再看平台任务状态,不再把“绑定任务 role_ready”和
|
- 以后先看这张表,再看平台任务状态,不再把“绑定任务 role_ready”和
|
||||||
“平台任务 qr_pending”混为一谈。
|
“平台任务 qr_pending”混为一谈。
|
||||||
|
|
||||||
|
### 9.11 2026-11-24 人工确认被误用:账号旧角色 ≠ 客户角色(订单 2632801603123492)
|
||||||
|
|
||||||
|
生产只读:
|
||||||
|
|
||||||
|
```text
|
||||||
|
平台任务 7882:
|
||||||
|
binding_status=bound, execution_status=bound
|
||||||
|
account_id=24087, bind_task_id=575407
|
||||||
|
账号 24087:
|
||||||
|
game_name=小乖悄, role_bind_status=bound
|
||||||
|
绑定任务 575407:
|
||||||
|
status=success, role_ready
|
||||||
|
role_name=等清晰, current_role_name=小乖悄
|
||||||
|
act_alias=cjm, action_act_aliases=[20260120QYOOB]
|
||||||
|
手工事件 58716:
|
||||||
|
binding_manually_confirmed
|
||||||
|
roleName=等清晰, account_role=小乖悄
|
||||||
|
note=等清晰, operator=45
|
||||||
|
```
|
||||||
|
|
||||||
|
后续确认:
|
||||||
|
|
||||||
|
```text
|
||||||
|
08:44/08:46 confirm_bind.precheck:
|
||||||
|
QYOOB 小乖悄 bindAct=1
|
||||||
|
cjm 等清晰 bindAct=0
|
||||||
|
confirm_bind.error:
|
||||||
|
error=-200001
|
||||||
|
msg=该账号未到可换绑时间,请使用其他账号
|
||||||
|
```
|
||||||
|
|
||||||
|
判断:
|
||||||
|
|
||||||
|
1. 客户扫到的是 cjm 的「等清晰」;
|
||||||
|
2. 账号 24087 官方当前角色仍是「小乖悄」,QYOOB 没有「等清晰」pending;
|
||||||
|
3. 账号的 `canChangeTime` 已过(2026-11-24 00:00 北京时间),所以不是账号侧冷却;
|
||||||
|
4. actBind 仍返回 `-200001`,说明更可能是**客户角色侧**未到换绑时间/绑定在其他账号;
|
||||||
|
5. 本地 `account_events` 没有「等清晰」的 bind_ok,所以本地角色锁无法提前发现,只有官方 actBind 是权威;
|
||||||
|
6. 人工确认在 08:38 直接把订单标成 bound,但账号角色仍是「小乖悄」,这是**错误的强制确认**。
|
||||||
|
|
||||||
|
根因:
|
||||||
|
|
||||||
|
- 人工确认接口只要求“填写确认角色”,没有要求账号当前角色等于确认角色;
|
||||||
|
- 运营填了「等清晰」,就绕过了 actBind 和角色校验;
|
||||||
|
- 结果订单 bound,但账号并没有换绑到客户角色,兑换会在错误角色上执行。
|
||||||
|
|
||||||
|
修复:
|
||||||
|
|
||||||
|
- 人工确认必须同时满足:
|
||||||
|
- 账号 `role_bind_status=bound`;
|
||||||
|
- 账号 `game_name` 与确认角色完全一致;
|
||||||
|
- 备注至少 2 个字;
|
||||||
|
- 不一致直接 409,提示“账号当前角色是 X,确认角色是 Y,不能人工确认;换绑请先 actBind 或使用正确账号”;
|
||||||
|
- 前端确认角色与账号当前角色不一致时禁用“确认绑定”,并显示错误提示;
|
||||||
|
- 该订单 7882 应释放/转人工,重新分配能绑定「等清晰」的账号,或等角色冷却结束,不能继续按 bound 走兑换。
|
||||||
|
|
||||||
|
教训:
|
||||||
|
|
||||||
|
人工确认只能作为“账号已经绑定到该角色、只是缺本次扫码证据”的兜底,
|
||||||
|
不能作为“换绑失败后强行标记成功”的按钮。
|
||||||
|
|
||||||
|
### 9.12 普通代确认 vs 人工强制确认
|
||||||
|
|
||||||
|
两种人工动作必须分开,不能都要求填角色/备注:
|
||||||
|
|
||||||
|
| 动作 | 使用场景 | 是否填信息 | 行为 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| 代客户确认 | 客户已登记资料、已扫码,只是没点确认 | 否 | 刷新绑定证据后走正常 `actBind`;成功才 bound |
|
||||||
|
| 人工强制确认 | 账号已确认绑定该角色,但没有本次扫码证据 | 是(角色+依据) | 直接标 bound;必须记录操作人/角色/备注 |
|
||||||
|
|
||||||
|
普通代确认:
|
||||||
|
|
||||||
|
- `POST /tasks/{id}/bind/operator-confirm`;
|
||||||
|
- 内部 `refresh_binding` → 要求平台任务 `role_ready` → 创建正常 `confirm_bind`;
|
||||||
|
- 不直接改 bound,不写 `binding_manually_confirmed`;
|
||||||
|
- 同账号同角色可复用的情况会直接 bound(已有复用逻辑);
|
||||||
|
- 角色锁/actBind 冷却仍然生效。
|
||||||
|
|
||||||
|
人工强制确认:
|
||||||
|
|
||||||
|
- `POST /tasks/{id}/bind/manual-confirm`;
|
||||||
|
- 必须账号 `role_bind_status=bound` 且 `game_name == 确认角色`;
|
||||||
|
- 必须填写角色 + 至少 2 字依据;
|
||||||
|
- 不一致 409;
|
||||||
|
- 前端红色按钮,不一致时禁用。
|
||||||
|
|
||||||
|
订单 2632801853205627(任务 7936)这类:
|
||||||
|
|
||||||
|
```text
|
||||||
|
本次扫码角色 = 账号当前角色
|
||||||
|
本次可确认 = 不可确认(same_role_stale)
|
||||||
|
本次扫码与账号当前角色相同,可复用
|
||||||
|
```
|
||||||
|
|
||||||
|
属于**普通代确认**,运营一键“代客户确认”即可;不需要填写角色/备注,也不应该走强制确认。
|
||||||
|
|
||||||
|
订单 2632801603123492(任务 7882)这类账号当前角色与客户角色不一致的,普通代确认会被 actBind/角色锁挡住;强制确认也必须拒绝,只能换号或等冷却。
|
||||||
|
|||||||
@@ -304,3 +304,36 @@ capability_key = elite:<commodity_id>
|
|||||||
2. 做租约 CK 保护优先级(P1);
|
2. 做租约 CK 保护优先级(P1);
|
||||||
3. 做首次登录普查(P2,已有 `account_onboarding`);
|
3. 做首次登录普查(P2,已有 `account_onboarding`);
|
||||||
4. 最后才把质量分/冗余接入选号(P3)。
|
4. 最后才把质量分/冗余接入选号(P3)。
|
||||||
|
|
||||||
|
## 11. 后续 TODO(2026-11-24 部署后)
|
||||||
|
|
||||||
|
当前生产:`c883f83`,Alembic `20261124_0128`,账号供给画像作业已开启。
|
||||||
|
|
||||||
|
| 优先级 | 事项 | 状态/说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| P0 | 等 31k 画像铺满(约 7 批、70 分钟) | 第一批 5000 条已成功,游标 5188 |
|
||||||
|
| P0 | 分析全量角色/质量分/冗余/租约 CK 分布 | 形成基线后再改行为 |
|
||||||
|
| P1 | 租约 CK 保护优先级 | 接入现有 `ck_health` protection groups,不新建重复机制 |
|
||||||
|
| P1 | 登录任务“触发方式/执行人”验收 | 自动化/人工/首次登录/重登/检测 |
|
||||||
|
| P2 | 首次登录作业 20 个样本 | 默认关闭;成功后再打开、放量 |
|
||||||
|
| P2 | 观察重登邮箱回退 | `ck_relogin` 已启用;18,355 失效积压,先看回退与失败率 |
|
||||||
|
| P3 | 选号接入质量分/冗余预留 | 观察 3 天后;unique/rare 不用于普通单 |
|
||||||
|
| P4 | 告警 | 租约 CK 24h 到期、unique/rare 不足、供给 buffer、普查停滞 |
|
||||||
|
| 运维 | 7887/7889 预确认投影缺口 | 旧单;7871/7868 人工处理 |
|
||||||
|
|
||||||
|
### 执行顺序
|
||||||
|
|
||||||
|
1. 等画像铺满,导出角色/冗余/质量分基线;
|
||||||
|
2. 验收登录任务来源列;
|
||||||
|
3. 首次登录 20 个样本;
|
||||||
|
4. 观察 `ck_relogin` 回退 1–2 天,再评估 batch/concurrency;
|
||||||
|
5. 做 P1 租约 CK 保护;
|
||||||
|
6. 观察 3 天后再做 P3 选号接入;
|
||||||
|
7. P4 告警与每周复盘。
|
||||||
|
|
||||||
|
### 不做
|
||||||
|
|
||||||
|
- 不在画像未铺满前改选号;
|
||||||
|
- 不用总分替代硬约束;
|
||||||
|
- 不把租约账号算进供给池;
|
||||||
|
- 不一次性全量跑首次登录。
|
||||||
|
|||||||
@@ -3089,6 +3089,109 @@ class TestBindingAndCompletion(_Base):
|
|||||||
== 1
|
== 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_operator_confirm_uses_scanned_role_without_form(self):
|
||||||
|
task = self._allocated()
|
||||||
|
account = self.session.get(Account, task.account_id)
|
||||||
|
account.game_name = "旧角色"
|
||||||
|
account.role_bind_status = "bound"
|
||||||
|
qr_task = DouyuTask(
|
||||||
|
batch_id="operator-confirm-qr",
|
||||||
|
account_id=task.account_id,
|
||||||
|
account_assigned_to=self.admin_id,
|
||||||
|
task_type="get_bind_qr",
|
||||||
|
handbook_scope="elite",
|
||||||
|
status="success",
|
||||||
|
platform_task_id=task.id,
|
||||||
|
result={
|
||||||
|
"act_alias": "cjm",
|
||||||
|
"role_name": "新角色",
|
||||||
|
"current_role_name": "旧角色",
|
||||||
|
"baseline_role_name": "旧角色",
|
||||||
|
"action_act_aliases": ["20260120QYOOB"],
|
||||||
|
"bind_ready_for_confirm": True,
|
||||||
|
"bind_confirmed": False,
|
||||||
|
"bind_phase": "role_ready",
|
||||||
|
"bind_decision": {
|
||||||
|
"alias": "cjm",
|
||||||
|
"role_name": "新角色",
|
||||||
|
"reason": "role_changed",
|
||||||
|
"confirmable": True,
|
||||||
|
"actionable_alias": False,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created_by=self.admin_id,
|
||||||
|
)
|
||||||
|
self.session.add(qr_task)
|
||||||
|
self.session.flush()
|
||||||
|
task.bind_task_id = qr_task.id
|
||||||
|
task.binding_status = "qr_pending"
|
||||||
|
task.execution_status = "waiting_bind"
|
||||||
|
self.session.commit()
|
||||||
|
|
||||||
|
detail = service.operator_confirm_binding_sync(
|
||||||
|
self.session,
|
||||||
|
task_id=task.id,
|
||||||
|
current=self.admin,
|
||||||
|
)
|
||||||
|
|
||||||
|
confirm_task = (
|
||||||
|
self.session.query(DouyuTask)
|
||||||
|
.filter_by(task_type="confirm_bind", platform_task_id=task.id)
|
||||||
|
.one()
|
||||||
|
)
|
||||||
|
assert confirm_task.result["expected_role_name"] == "新角色"
|
||||||
|
assert detail["task"]["bindingStatus"] in {"role_ready", "confirming"}
|
||||||
|
assert (
|
||||||
|
self.session.query(PlatformFulfillmentEvent)
|
||||||
|
.filter_by(task_id=task.id, event_type="binding_manually_confirmed")
|
||||||
|
.count()
|
||||||
|
== 0
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_manual_confirm_rejects_role_not_currently_bound(self):
|
||||||
|
task = self._allocated()
|
||||||
|
account = self.session.get(Account, task.account_id)
|
||||||
|
account.game_name = "小乖悄"
|
||||||
|
account.role_bind_status = "bound"
|
||||||
|
qr_task = DouyuTask(
|
||||||
|
batch_id="manual-mismatch-qr",
|
||||||
|
account_id=task.account_id,
|
||||||
|
account_assigned_to=self.admin_id,
|
||||||
|
task_type="get_bind_qr",
|
||||||
|
handbook_scope="elite",
|
||||||
|
status="success",
|
||||||
|
platform_task_id=task.id,
|
||||||
|
result={"bind_phase": "waiting_scan", "role_name": "等清晰"},
|
||||||
|
created_by=self.admin_id,
|
||||||
|
)
|
||||||
|
self.session.add(qr_task)
|
||||||
|
self.session.flush()
|
||||||
|
task.bind_task_id = qr_task.id
|
||||||
|
task.binding_status = "qr_pending"
|
||||||
|
task.execution_status = "waiting_bind"
|
||||||
|
self.session.commit()
|
||||||
|
|
||||||
|
with pytest.raises(HTTPException) as exc_info:
|
||||||
|
service.manual_confirm_binding_sync(
|
||||||
|
self.session,
|
||||||
|
task_id=task.id,
|
||||||
|
current=self.admin,
|
||||||
|
role_name="等清晰",
|
||||||
|
note="客户说角色是等清晰",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.session.refresh(task)
|
||||||
|
assert exc_info.value.status_code == 409
|
||||||
|
assert "不一致" in str(exc_info.value.detail)
|
||||||
|
assert task.binding_status == "qr_pending"
|
||||||
|
assert task.execution_status == "waiting_bind"
|
||||||
|
assert (
|
||||||
|
self.session.query(PlatformFulfillmentEvent)
|
||||||
|
.filter_by(task_id=task.id, event_type="binding_manually_confirmed")
|
||||||
|
.count()
|
||||||
|
== 0
|
||||||
|
)
|
||||||
|
|
||||||
def test_cjm_only_new_role_enters_role_ready_for_customer_confirm(self):
|
def test_cjm_only_new_role_enters_role_ready_for_customer_confirm(self):
|
||||||
task = self._allocated()
|
task = self._allocated()
|
||||||
qr_task = DouyuTask(
|
qr_task = DouyuTask(
|
||||||
|
|||||||
@@ -465,6 +465,29 @@ async def confirm_binding(
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/tasks/{task_id}/bind/operator-confirm")
|
||||||
|
def operator_confirm_binding(
|
||||||
|
task_id: int,
|
||||||
|
db: Session = Depends(get_db),
|
||||||
|
current: User = Depends(require_permission("platform_fulfillment:use")),
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
"""普通人工代确认:客户已扫码但没点确认,运营代为提交正常 actBind。"""
|
||||||
|
result = service.operator_confirm_binding_sync(
|
||||||
|
db,
|
||||||
|
task_id=task_id,
|
||||||
|
current=current,
|
||||||
|
)
|
||||||
|
record_audit(
|
||||||
|
db,
|
||||||
|
current,
|
||||||
|
action="platform_fulfillment:binding:operator_confirm",
|
||||||
|
target=f"platform_fulfillment_task:{task_id}",
|
||||||
|
detail={"bindingStatus": result.get("task", {}).get("bindingStatus")},
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
@router.post("/tasks/{task_id}/bind/manual-confirm")
|
@router.post("/tasks/{task_id}/bind/manual-confirm")
|
||||||
def manual_confirm_binding(
|
def manual_confirm_binding(
|
||||||
task_id: int,
|
task_id: int,
|
||||||
|
|||||||
@@ -598,6 +598,35 @@ def _mark_reused_pair(
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def operator_confirm_binding_sync(
|
||||||
|
db: Session,
|
||||||
|
*,
|
||||||
|
task_id: int,
|
||||||
|
current: User,
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
"""普通人工代确认:客户已扫码但没点确认,运营代为提交正常 actBind。
|
||||||
|
|
||||||
|
不填写角色/备注,不直接标 bound;复用客户确认的同一套确认任务。
|
||||||
|
当前没有可确认的扫码角色时,要求客户扫码或走“强制确认”。
|
||||||
|
"""
|
||||||
|
task = _load_task_for_update(db, task_id)
|
||||||
|
if _frozen(task):
|
||||||
|
return get_task_detail(db, task.id)
|
||||||
|
refresh_binding(db, task_id=task.id)
|
||||||
|
task = _load_task(db, task.id)
|
||||||
|
if task.binding_status == "bound":
|
||||||
|
return get_task_detail(db, task.id)
|
||||||
|
if task.binding_status != "role_ready":
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=409,
|
||||||
|
detail=(
|
||||||
|
"当前没有可代确认的扫码角色。请让客户先扫码;"
|
||||||
|
"只有账号已绑定到该角色、但缺少本次扫码证据时,才使用强制确认。"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
return confirm_binding_sync(db, task_id=task.id, current=current)
|
||||||
|
|
||||||
|
|
||||||
def manual_confirm_binding_sync(
|
def manual_confirm_binding_sync(
|
||||||
db: Session,
|
db: Session,
|
||||||
*,
|
*,
|
||||||
@@ -629,7 +658,24 @@ def manual_confirm_binding_sync(
|
|||||||
status_code=409,
|
status_code=409,
|
||||||
detail="账号没有可确认的角色,请先查询角色或填写确认角色",
|
detail="账号没有可确认的角色,请先查询角色或填写确认角色",
|
||||||
)
|
)
|
||||||
|
account_role = str(account.game_name or "").strip()
|
||||||
|
if str(account.role_bind_status or "") != "bound" or not account_role:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=409,
|
||||||
|
detail="账号当前没有已生效角色,不能人工确认;请先刷新/查询角色",
|
||||||
|
)
|
||||||
|
if account_role != confirmed_role:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=409,
|
||||||
|
detail=(
|
||||||
|
f"账号当前角色是「{account_role}」,确认角色是「{confirmed_role}」,"
|
||||||
|
"不一致,不能人工确认。人工确认只能用于账号已经绑定到该角色的场景;"
|
||||||
|
"换绑请先完成 actBind 或使用正确账号。"
|
||||||
|
),
|
||||||
|
)
|
||||||
note = str(note or "").strip()[:500]
|
note = str(note or "").strip()[:500]
|
||||||
|
if len(note) < 2:
|
||||||
|
raise HTTPException(status_code=409, detail="请填写人工确认依据/备注")
|
||||||
previous_binding = str(task.binding_status or "")
|
previous_binding = str(task.binding_status or "")
|
||||||
previous_execution = str(task.execution_status or "")
|
previous_execution = str(task.execution_status or "")
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from .binding import ( # noqa: F401
|
|||||||
confirm_binding,
|
confirm_binding,
|
||||||
confirm_binding_sync,
|
confirm_binding_sync,
|
||||||
manual_confirm_binding_sync,
|
manual_confirm_binding_sync,
|
||||||
|
operator_confirm_binding_sync,
|
||||||
reconcile_binding_observations,
|
reconcile_binding_observations,
|
||||||
reconcile_binding_state_outbox,
|
reconcile_binding_state_outbox,
|
||||||
refresh_binding,
|
refresh_binding,
|
||||||
@@ -156,6 +157,7 @@ __all__ = [
|
|||||||
"manual_confirm_binding_sync",
|
"manual_confirm_binding_sync",
|
||||||
"mapping_impact",
|
"mapping_impact",
|
||||||
"mark_manual_required",
|
"mark_manual_required",
|
||||||
|
"operator_confirm_binding_sync",
|
||||||
"prepare_manual_allocation",
|
"prepare_manual_allocation",
|
||||||
"prepare_platform_task_for_collab_takeover",
|
"prepare_platform_task_for_collab_takeover",
|
||||||
"reconcile_binding_observations",
|
"reconcile_binding_observations",
|
||||||
|
|||||||
@@ -137,6 +137,10 @@ export const platformFulfillmentApi = {
|
|||||||
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
||||||
`/platform-fulfillment/tasks/${taskId}/bind/confirm`,
|
`/platform-fulfillment/tasks/${taskId}/bind/confirm`,
|
||||||
),
|
),
|
||||||
|
operatorConfirmBinding: (taskId: number) =>
|
||||||
|
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
||||||
|
`/platform-fulfillment/tasks/${taskId}/bind/operator-confirm`,
|
||||||
|
),
|
||||||
manualConfirmBinding: (taskId: number, roleName: string, note: string) =>
|
manualConfirmBinding: (taskId: number, roleName: string, note: string) =>
|
||||||
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
||||||
`/platform-fulfillment/tasks/${taskId}/bind/manual-confirm`,
|
`/platform-fulfillment/tasks/${taskId}/bind/manual-confirm`,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import type { Dayjs } from 'dayjs';
|
import type { Dayjs } from 'dayjs';
|
||||||
import { Alert, Button, Card, Col, DatePicker, Descriptions, Drawer, Empty, Input, InputNumber, Modal, QRCode, Row, Segmented, Select, Space, Switch, Table, Tabs, Tag, Timeline, Typography } from 'antd';
|
import { Alert, Button, Card, Col, DatePicker, Descriptions, Drawer, Empty, Input, InputNumber, Modal, QRCode, Row, Segmented, Select, Space, Switch, Table, Tag, Timeline, Typography } from 'antd';
|
||||||
import { CheckCircleOutlined, CopyOutlined, CreditCardOutlined, DownloadOutlined, GiftOutlined, LinkOutlined, QrcodeOutlined, ReloadOutlined, SettingOutlined, ShoppingOutlined, SyncOutlined, UndoOutlined, UserSwitchOutlined } from '@ant-design/icons';
|
import { CheckCircleOutlined, CopyOutlined, CreditCardOutlined, DownloadOutlined, GiftOutlined, LinkOutlined, QrcodeOutlined, ReloadOutlined, SettingOutlined, ShoppingOutlined, SyncOutlined, UndoOutlined, UserSwitchOutlined } from '@ant-design/icons';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import { douyuApi, platformFulfillmentApi } from '../api/modules';
|
import { douyuApi, platformFulfillmentApi } from '../api/modules';
|
||||||
@@ -95,14 +95,6 @@ const SALE_MODE_LABELS: Record<string, string> = {
|
|||||||
unknown: '未分类',
|
unknown: '未分类',
|
||||||
};
|
};
|
||||||
|
|
||||||
const AVAILABILITY_LABELS: Record<string, string> = {
|
|
||||||
waiting_release: '待开放',
|
|
||||||
available: '可兑换',
|
|
||||||
sold_out: '已售罄',
|
|
||||||
ended: '已结束',
|
|
||||||
unknown: '未知',
|
|
||||||
};
|
|
||||||
|
|
||||||
const MANUAL_REASON_LABELS: Record<string, string> = {
|
const MANUAL_REASON_LABELS: Record<string, string> = {
|
||||||
points_short: '积分不足',
|
points_short: '积分不足',
|
||||||
elite_not_opened: '宝典未开通',
|
elite_not_opened: '宝典未开通',
|
||||||
@@ -466,6 +458,13 @@ export default function PlatformFulfillmentPage() {
|
|||||||
const [manualBindRole, setManualBindRole] = useState('');
|
const [manualBindRole, setManualBindRole] = useState('');
|
||||||
const [manualBindNote, setManualBindNote] = useState('');
|
const [manualBindNote, setManualBindNote] = useState('');
|
||||||
const [manualBinding, setManualBinding] = useState(false);
|
const [manualBinding, setManualBinding] = useState(false);
|
||||||
|
const manualBindCurrentRole =
|
||||||
|
manualBindTarget?.bindingEvidence?.accountCurrentRole || '';
|
||||||
|
const manualBindMismatch = Boolean(
|
||||||
|
manualBindCurrentRole &&
|
||||||
|
manualBindRole.trim() &&
|
||||||
|
manualBindRole.trim() !== manualBindCurrentRole,
|
||||||
|
);
|
||||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||||
const [selectedId, setSelectedId] = useState<number | null>(null);
|
const [selectedId, setSelectedId] = useState<number | null>(null);
|
||||||
const [detail, setDetail] = useState<PlatformFulfillmentDetail | null>(null);
|
const [detail, setDetail] = useState<PlatformFulfillmentDetail | null>(null);
|
||||||
@@ -475,6 +474,9 @@ export default function PlatformFulfillmentPage() {
|
|||||||
const [bindingQrImage, setBindingQrImage] = useState('');
|
const [bindingQrImage, setBindingQrImage] = useState('');
|
||||||
const [bindingQrLoading, setBindingQrLoading] = useState(false);
|
const [bindingQrLoading, setBindingQrLoading] = useState(false);
|
||||||
const [mappingOpen, setMappingOpen] = useState(false);
|
const [mappingOpen, setMappingOpen] = useState(false);
|
||||||
|
const [mappingEditorOpen, setMappingEditorOpen] = useState(false);
|
||||||
|
const [mappingSaving, setMappingSaving] = useState(false);
|
||||||
|
const [mappingKeyword, setMappingKeyword] = useState('');
|
||||||
const [mappingSku, setMappingSku] = useState('');
|
const [mappingSku, setMappingSku] = useState('');
|
||||||
const [mappingEditingId, setMappingEditingId] = useState<number | null>(null);
|
const [mappingEditingId, setMappingEditingId] = useState<number | null>(null);
|
||||||
const [mappingCampaignKey, setMappingCampaignKey] = useState('douyu-current');
|
const [mappingCampaignKey, setMappingCampaignKey] = useState('douyu-current');
|
||||||
@@ -860,6 +862,10 @@ export default function PlatformFulfillmentPage() {
|
|||||||
message.warning('请填写客户确认的游戏角色');
|
message.warning('请填写客户确认的游戏角色');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (manualBindCurrentRole && role !== manualBindCurrentRole) {
|
||||||
|
message.error(`账号当前角色是「${manualBindCurrentRole}」,不能人工确认「${role}」`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (note.length < 2) {
|
if (note.length < 2) {
|
||||||
message.warning('请填写人工确认依据/备注');
|
message.warning('请填写人工确认依据/备注');
|
||||||
return;
|
return;
|
||||||
@@ -885,6 +891,18 @@ export default function PlatformFulfillmentPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const submitOperatorConfirm = async (task: PlatformFulfillmentTask) => {
|
||||||
|
try {
|
||||||
|
const result = await platformFulfillmentApi.operatorConfirmBinding(task.id);
|
||||||
|
setDetail(result);
|
||||||
|
setSelectedId(result.task.id);
|
||||||
|
await loadTasks();
|
||||||
|
message.success('已代客户提交确认,等待绑定结果');
|
||||||
|
} catch (error) {
|
||||||
|
message.error(getErrorMessage(error));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const runDouyuAccountAction = async (taskType: string) => {
|
const runDouyuAccountAction = async (taskType: string) => {
|
||||||
if (!selected?.account) {
|
if (!selected?.account) {
|
||||||
message.warning('当前履约任务还没有分配斗鱼账号');
|
message.warning('当前履约任务还没有分配斗鱼账号');
|
||||||
@@ -997,7 +1015,7 @@ export default function PlatformFulfillmentPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadMappingRows = async (
|
const loadMappingRows = async (
|
||||||
keyword = mappingSku.trim(),
|
keyword = mappingKeyword.trim(),
|
||||||
mode = mappingFilterMode,
|
mode = mappingFilterMode,
|
||||||
includeArchived = mappingIncludeArchived,
|
includeArchived = mappingIncludeArchived,
|
||||||
) => {
|
) => {
|
||||||
@@ -1012,12 +1030,15 @@ export default function PlatformFulfillmentPage() {
|
|||||||
const openMapping = async (task?: PlatformFulfillmentTask) => {
|
const openMapping = async (task?: PlatformFulfillmentTask) => {
|
||||||
resetMappingForm(task);
|
resetMappingForm(task);
|
||||||
setMappingOpen(true);
|
setMappingOpen(true);
|
||||||
|
if (task) setMappingEditorOpen(true);
|
||||||
setMappingGoodsLoading(true);
|
setMappingGoodsLoading(true);
|
||||||
try {
|
try {
|
||||||
|
const keyword = task?.internalSkuKey || '';
|
||||||
|
setMappingKeyword(keyword);
|
||||||
const [goodsRows, mappingRows] = await Promise.all([
|
const [goodsRows, mappingRows] = await Promise.all([
|
||||||
douyuApi.listLiveGoods(),
|
douyuApi.listLiveGoods(),
|
||||||
platformFulfillmentApi.listMappings({
|
platformFulfillmentApi.listMappings({
|
||||||
keyword: task?.internalSkuKey || '',
|
keyword,
|
||||||
sale_mode: mappingFilterMode || undefined,
|
sale_mode: mappingFilterMode || undefined,
|
||||||
include_archived: mappingIncludeArchived,
|
include_archived: mappingIncludeArchived,
|
||||||
}),
|
}),
|
||||||
@@ -1034,7 +1055,13 @@ export default function PlatformFulfillmentPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openMappingCreate = () => {
|
||||||
|
resetMappingForm();
|
||||||
|
setMappingEditorOpen(true);
|
||||||
|
};
|
||||||
|
|
||||||
const editMapping = (row: PlatformFulfillmentMapping) => {
|
const editMapping = (row: PlatformFulfillmentMapping) => {
|
||||||
|
setMappingEditorOpen(true);
|
||||||
setMappingEditingId(row.id);
|
setMappingEditingId(row.id);
|
||||||
setMappingSku(row.internalSkuKey);
|
setMappingSku(row.internalSkuKey);
|
||||||
setMappingCampaignKey(row.campaignKey || 'douyu-current');
|
setMappingCampaignKey(row.campaignKey || 'douyu-current');
|
||||||
@@ -1118,6 +1145,7 @@ export default function PlatformFulfillmentPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveMapping = async () => {
|
const saveMapping = async () => {
|
||||||
|
if (mappingSaving) return;
|
||||||
if (!mappingSku.trim() || !mappingCampaignKey.trim() || !mappingGoodsId || !mappingSaleMode) {
|
if (!mappingSku.trim() || !mappingCampaignKey.trim() || !mappingGoodsId || !mappingSaleMode) {
|
||||||
message.warning('请填写内部 SKU、活动批次、销售模式并选择斗鱼商品');
|
message.warning('请填写内部 SKU、活动批次、销售模式并选择斗鱼商品');
|
||||||
return;
|
return;
|
||||||
@@ -1140,17 +1168,21 @@ export default function PlatformFulfillmentPage() {
|
|||||||
available_until: mappingAvailableUntil?.toISOString() || null,
|
available_until: mappingAvailableUntil?.toISOString() || null,
|
||||||
enabled: mappingEnabled,
|
enabled: mappingEnabled,
|
||||||
};
|
};
|
||||||
|
setMappingSaving(true);
|
||||||
if (mappingEditingId) {
|
if (mappingEditingId) {
|
||||||
await platformFulfillmentApi.updateMapping(mappingEditingId, payload);
|
await platformFulfillmentApi.updateMapping(mappingEditingId, payload);
|
||||||
} else {
|
} else {
|
||||||
await platformFulfillmentApi.createMapping(payload);
|
await platformFulfillmentApi.createMapping(payload);
|
||||||
}
|
}
|
||||||
message.success('商品映射已保存');
|
message.success('商品映射已保存');
|
||||||
|
setMappingEditorOpen(false);
|
||||||
resetMappingForm();
|
resetMappingForm();
|
||||||
await loadMappingRows();
|
await loadMappingRows();
|
||||||
await loadTasks();
|
await loadTasks();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error(getErrorMessage(error));
|
message.error(getErrorMessage(error));
|
||||||
|
} finally {
|
||||||
|
setMappingSaving(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1268,7 +1300,6 @@ export default function PlatformFulfillmentPage() {
|
|||||||
<Tag color={task.saleMode === 'presale' ? 'gold' : task.saleMode === 'direct' ? 'green' : 'default'}>
|
<Tag color={task.saleMode === 'presale' ? 'gold' : task.saleMode === 'direct' ? 'green' : 'default'}>
|
||||||
{SALE_MODE_LABELS[task.saleMode] || task.saleMode}
|
{SALE_MODE_LABELS[task.saleMode] || task.saleMode}
|
||||||
</Tag>
|
</Tag>
|
||||||
<Tag>{AVAILABILITY_LABELS[task.availabilityState] || task.availabilityState}</Tag>
|
|
||||||
</Space>
|
</Space>
|
||||||
<Text type="secondary" ellipsis title={task.campaignName || task.campaignKey || '-'}>
|
<Text type="secondary" ellipsis title={task.campaignName || task.campaignKey || '-'}>
|
||||||
{task.campaignName || task.campaignKey || '未设置活动批次'}
|
{task.campaignName || task.campaignKey || '未设置活动批次'}
|
||||||
@@ -1421,12 +1452,17 @@ export default function PlatformFulfillmentPage() {
|
|||||||
) : null}
|
) : null}
|
||||||
{task.executionStatus === 'role_ready' ? (
|
{task.executionStatus === 'role_ready' ? (
|
||||||
<Button size="small" type="primary" icon={<CheckCircleOutlined />} onClick={() => void runTaskAction(() => platformFulfillmentApi.confirmBinding(task.id))}>
|
<Button size="small" type="primary" icon={<CheckCircleOutlined />} onClick={() => void runTaskAction(() => platformFulfillmentApi.confirmBinding(task.id))}>
|
||||||
确认绑定
|
代客户确认
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
|
{canManualConfirmBinding(task) && task.executionStatus !== 'role_ready' && task.bindTask?.roleName ? (
|
||||||
|
<Button size="small" type="primary" icon={<CheckCircleOutlined />} onClick={() => void submitOperatorConfirm(task)}>
|
||||||
|
代客户确认
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
{can('platform_fulfillment:use') && canManualConfirmBinding(task) ? (
|
{can('platform_fulfillment:use') && canManualConfirmBinding(task) ? (
|
||||||
<Button size="small" icon={<CheckCircleOutlined />} onClick={() => openManualBinding(task)}>
|
<Button size="small" danger icon={<CheckCircleOutlined />} onClick={() => openManualBinding(task)}>
|
||||||
人工确认绑定
|
强制确认
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
{canResetBinding(task) ? (
|
{canResetBinding(task) ? (
|
||||||
@@ -1474,9 +1510,17 @@ export default function PlatformFulfillmentPage() {
|
|||||||
刷新二维码
|
刷新二维码
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
|
{selected &&
|
||||||
|
selected.executionStatus !== 'role_ready' &&
|
||||||
|
selected.executionStatus !== 'bound' &&
|
||||||
|
(selected.bindingEvidence?.scannedRole || selected.bindTask?.roleName) ? (
|
||||||
|
<Button type="primary" icon={<CheckCircleOutlined />} onClick={() => void submitOperatorConfirm(selected)}>
|
||||||
|
代客户确认
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
{selected && can('platform_fulfillment:use') && canManualConfirmBinding(selected) ? (
|
{selected && can('platform_fulfillment:use') && canManualConfirmBinding(selected) ? (
|
||||||
<Button icon={<CheckCircleOutlined />} onClick={() => openManualBinding(selected)}>
|
<Button danger icon={<CheckCircleOutlined />} onClick={() => openManualBinding(selected)}>
|
||||||
人工确认绑定
|
强制确认
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
{selected.account &&
|
{selected.account &&
|
||||||
@@ -1733,9 +1777,6 @@ export default function PlatformFulfillmentPage() {
|
|||||||
<Descriptions.Item label="销售模式">
|
<Descriptions.Item label="销售模式">
|
||||||
{SALE_MODE_LABELS[selected.saleMode] || selected.saleMode}
|
{SALE_MODE_LABELS[selected.saleMode] || selected.saleMode}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="开放状态">
|
|
||||||
{AVAILABILITY_LABELS[selected.availabilityState] || selected.availabilityState}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="活动批次" span={2}>
|
<Descriptions.Item label="活动批次" span={2}>
|
||||||
{selected.campaignName || selected.campaignKey || '-'}
|
{selected.campaignName || selected.campaignKey || '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
@@ -2240,11 +2281,14 @@ export default function PlatformFulfillmentPage() {
|
|||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
title={`人工确认绑定 ${manualBindTarget ? `#${manualBindTarget.id}` : ''}`}
|
title={`人工强制确认 ${manualBindTarget ? `#${manualBindTarget.id}` : ''}`}
|
||||||
open={Boolean(manualBindTarget)}
|
open={Boolean(manualBindTarget)}
|
||||||
okText="确认绑定"
|
okText="强制绑定"
|
||||||
cancelText="取消"
|
cancelText="取消"
|
||||||
confirmLoading={manualBinding}
|
confirmLoading={manualBinding}
|
||||||
|
okButtonProps={{
|
||||||
|
disabled: manualBindMismatch || !manualBindRole.trim() || manualBindNote.trim().length < 2,
|
||||||
|
}}
|
||||||
onOk={() => void confirmManualBinding()}
|
onOk={() => void confirmManualBinding()}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
setManualBindTarget(null);
|
setManualBindTarget(null);
|
||||||
@@ -2256,9 +2300,17 @@ export default function PlatformFulfillmentPage() {
|
|||||||
<Alert
|
<Alert
|
||||||
type="warning"
|
type="warning"
|
||||||
showIcon
|
showIcon
|
||||||
message="人工确认会直接把订单标记为已绑定"
|
message="强制确认会跳过 actBind 直接把订单标记为已绑定"
|
||||||
description="只在已核实客户游戏角色确实绑定在当前账号上时使用;会停止当前二维码轮询,并记录操作人、角色和备注。"
|
description="只在账号当前角色已经确认绑定到该角色、但缺少本次扫码证据时使用;必须填写依据。普通代确认请用“代客户确认”。"
|
||||||
/>
|
/>
|
||||||
|
{manualBindMismatch ? (
|
||||||
|
<Alert
|
||||||
|
type="error"
|
||||||
|
showIcon
|
||||||
|
message="确认角色与账号当前角色不一致"
|
||||||
|
description="人工确认只能用于账号已经绑定到该角色的场景;换绑必须先完成 actBind 或使用正确账号。"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
<Text type="secondary">
|
<Text type="secondary">
|
||||||
账号当前角色:{manualBindTarget?.bindingEvidence?.accountCurrentRole || '未知'}
|
账号当前角色:{manualBindTarget?.bindingEvidence?.accountCurrentRole || '未知'}
|
||||||
{manualBindTarget?.bindingEvidence?.scannedRole
|
{manualBindTarget?.bindingEvidence?.scannedRole
|
||||||
@@ -2409,196 +2461,271 @@ export default function PlatformFulfillmentPage() {
|
|||||||
<Modal
|
<Modal
|
||||||
open={mappingOpen}
|
open={mappingOpen}
|
||||||
title="斗鱼商品映射管理"
|
title="斗鱼商品映射管理"
|
||||||
width={1120}
|
width={1080}
|
||||||
okText="保存映射"
|
footer={null}
|
||||||
onOk={() => void saveMapping()}
|
onCancel={() => {
|
||||||
onCancel={() => setMappingOpen(false)}
|
setMappingOpen(false);
|
||||||
|
setMappingEditorOpen(false);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Space direction="vertical" size={14} style={{ width: '100%' }}>
|
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
||||||
<Space wrap>
|
<Space wrap style={{ width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Select
|
<Space wrap>
|
||||||
value={mappingFilterMode}
|
<Input.Search
|
||||||
options={[
|
allowClear
|
||||||
{ value: '', label: '全部销售模式' },
|
value={mappingKeyword}
|
||||||
...Object.entries(SALE_MODE_LABELS).map(([value, label]) => ({ value, label })),
|
placeholder="搜索内部 SKU / 商品"
|
||||||
]}
|
style={{ width: 260 }}
|
||||||
onChange={(value) => {
|
onChange={(event) => setMappingKeyword(event.target.value)}
|
||||||
setMappingFilterMode(value);
|
onSearch={(value) => {
|
||||||
void loadMappingRows(mappingSku.trim(), value).catch((error) => message.error(getErrorMessage(error)));
|
setMappingKeyword(value);
|
||||||
}}
|
void loadMappingRows(value).catch((error) => message.error(getErrorMessage(error)));
|
||||||
style={{ width: 160 }}
|
|
||||||
/>
|
|
||||||
<Space>
|
|
||||||
<Text>显示已归档</Text>
|
|
||||||
<Switch
|
|
||||||
checked={mappingIncludeArchived}
|
|
||||||
onChange={(checked) => {
|
|
||||||
setMappingIncludeArchived(checked);
|
|
||||||
void platformFulfillmentApi.listMappings({
|
|
||||||
keyword: mappingSku.trim(),
|
|
||||||
sale_mode: mappingFilterMode || undefined,
|
|
||||||
include_archived: checked,
|
|
||||||
}).then(setMappings).catch((error) => message.error(getErrorMessage(error)));
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<Select
|
||||||
|
value={mappingFilterMode}
|
||||||
|
options={[
|
||||||
|
{ value: '', label: '全部销售模式' },
|
||||||
|
...Object.entries(SALE_MODE_LABELS).map(([value, label]) => ({ value, label })),
|
||||||
|
]}
|
||||||
|
onChange={(value) => {
|
||||||
|
setMappingFilterMode(value);
|
||||||
|
void loadMappingRows(mappingKeyword.trim(), value).catch((error) => message.error(getErrorMessage(error)));
|
||||||
|
}}
|
||||||
|
style={{ width: 150 }}
|
||||||
|
/>
|
||||||
|
<Space size={6}>
|
||||||
|
<Text type="secondary">显示已归档</Text>
|
||||||
|
<Switch
|
||||||
|
checked={mappingIncludeArchived}
|
||||||
|
onChange={(checked) => {
|
||||||
|
setMappingIncludeArchived(checked);
|
||||||
|
void loadMappingRows(mappingKeyword.trim(), mappingFilterMode, checked).catch((error) => message.error(getErrorMessage(error)));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
</Space>
|
||||||
|
<Space>
|
||||||
|
<Button icon={<ReloadOutlined />} onClick={() => void loadMappingRows().catch((error) => message.error(getErrorMessage(error)))}>
|
||||||
|
刷新
|
||||||
|
</Button>
|
||||||
|
<Button type="primary" onClick={openMappingCreate}>
|
||||||
|
新建映射
|
||||||
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
<Button onClick={() => resetMappingForm()}>
|
|
||||||
新建映射
|
|
||||||
</Button>
|
|
||||||
</Space>
|
</Space>
|
||||||
<Space wrap style={{ width: '100%' }}>
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
<Input placeholder="内部 SKU,例如 套装-兔兔白日梦" value={mappingSku} onChange={(event) => setMappingSku(event.target.value)} style={{ width: 260 }} />
|
共 {mappings.length} 条映射;编辑、停用、归档、删除都在“更多”里,不需要横向滚动。
|
||||||
<Input placeholder="活动批次,例如 douyu-2026-11-return" value={mappingCampaignKey} onChange={(event) => setMappingCampaignKey(event.target.value)} style={{ width: 260 }} />
|
</Text>
|
||||||
<Input placeholder="活动名称,例如 11 月返场" value={mappingCampaignName} onChange={(event) => setMappingCampaignName(event.target.value)} style={{ width: 220 }} />
|
<Table<PlatformFulfillmentMapping>
|
||||||
</Space>
|
rowKey="id"
|
||||||
<Space.Compact style={{ width: '100%' }}>
|
size="small"
|
||||||
<Select
|
tableLayout="fixed"
|
||||||
showSearch
|
pagination={{ pageSize: 10, hideOnSinglePage: true, showSizeChanger: false }}
|
||||||
optionFilterProp="label"
|
dataSource={mappings}
|
||||||
loading={mappingGoodsLoading}
|
columns={[
|
||||||
placeholder={mappingGoodsLoading ? '正在加载斗鱼活动商品…' : '选择斗鱼精英宝典商品'}
|
|
||||||
value={mappingGoodsId || undefined}
|
|
||||||
onChange={selectGoods}
|
|
||||||
options={[
|
|
||||||
...goods.map((item) => ({
|
|
||||||
value: item.commodity_id,
|
|
||||||
label: `${item.name || item.commodity_id} · ${item.score ?? '-'} 积分`,
|
|
||||||
})),
|
|
||||||
...(mappingGoodsId && !goods.some((item) => item.commodity_id === mappingGoodsId)
|
|
||||||
? [{
|
|
||||||
value: mappingGoodsId,
|
|
||||||
label: `${mappingGoodsName || mappingGoodsId} · 当前已缓存`,
|
|
||||||
}]
|
|
||||||
: []),
|
|
||||||
]}
|
|
||||||
notFoundContent={mappingGoodsLoading ? null : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无活动商品" />}
|
|
||||||
style={{ flex: 1 }}
|
|
||||||
/>
|
|
||||||
<Button icon={<ReloadOutlined />} loading={mappingGoodsLoading} onClick={() => void reloadMappingGoods()}>
|
|
||||||
刷新商品
|
|
||||||
</Button>
|
|
||||||
</Space.Compact>
|
|
||||||
<Space wrap>
|
|
||||||
<Text>销售模式</Text>
|
|
||||||
<Select
|
|
||||||
value={mappingSaleMode}
|
|
||||||
options={Object.entries(SALE_MODE_LABELS).map(([value, label]) => ({ value, label }))}
|
|
||||||
onChange={setMappingSaleMode}
|
|
||||||
style={{ width: 140 }}
|
|
||||||
/>
|
|
||||||
<Text>所需积分</Text>
|
|
||||||
<InputNumber min={0} value={mappingPoints} onChange={(value) => setMappingPoints(value)} />
|
|
||||||
<Text>启用</Text>
|
|
||||||
<Switch checked={mappingEnabled} onChange={setMappingEnabled} />
|
|
||||||
</Space>
|
|
||||||
<Space wrap>
|
|
||||||
<Text>商品开放时间</Text>
|
|
||||||
<DatePicker
|
|
||||||
showTime
|
|
||||||
value={mappingAvailableFrom}
|
|
||||||
onChange={setMappingAvailableFrom}
|
|
||||||
placeholder="开始时间"
|
|
||||||
/>
|
|
||||||
<Text>至</Text>
|
|
||||||
<DatePicker
|
|
||||||
showTime
|
|
||||||
value={mappingAvailableUntil}
|
|
||||||
onChange={setMappingAvailableUntil}
|
|
||||||
placeholder="结束时间"
|
|
||||||
/>
|
|
||||||
</Space>
|
|
||||||
<Tabs
|
|
||||||
items={[
|
|
||||||
{
|
{
|
||||||
key: 'current',
|
title: '内部 SKU',
|
||||||
label: '当前映射',
|
dataIndex: 'internalSkuKey',
|
||||||
children: (
|
width: 170,
|
||||||
<Table<PlatformFulfillmentMapping>
|
ellipsis: true,
|
||||||
rowKey="id"
|
render: (value: string, row) => (
|
||||||
size="small"
|
<Space direction="vertical" size={0} style={{ maxWidth: '100%' }}>
|
||||||
pagination={false}
|
<Text strong ellipsis style={{ maxWidth: '100%' }}>{value}</Text>
|
||||||
dataSource={mappings}
|
<Text type="secondary" style={{ fontSize: 12 }} ellipsis>
|
||||||
columns={[
|
{row.campaignName || row.campaignKey || '-'}
|
||||||
{ title: '内部 SKU', dataIndex: 'internalSkuKey', width: 150 },
|
</Text>
|
||||||
{
|
</Space>
|
||||||
title: '活动批次',
|
),
|
||||||
key: 'campaign',
|
},
|
||||||
width: 170,
|
{
|
||||||
render: (_: unknown, row) => (
|
title: '商品',
|
||||||
<Space direction="vertical" size={0}>
|
dataIndex: 'goodsName',
|
||||||
<Text>{row.campaignName || row.campaignKey}</Text>
|
width: 250,
|
||||||
<Text type="secondary" style={{ fontSize: 12 }}>{row.campaignKey}</Text>
|
ellipsis: true,
|
||||||
</Space>
|
render: (value: string, row) => (
|
||||||
),
|
<Space direction="vertical" size={0} style={{ maxWidth: '100%' }}>
|
||||||
},
|
<Text ellipsis style={{ maxWidth: '100%' }}>{value || row.commodityId || '-'}</Text>
|
||||||
{ title: '商品', dataIndex: 'goodsName', width: 150 },
|
<Text type="secondary" style={{ fontSize: 12 }} ellipsis>
|
||||||
{ title: '商品 ID', dataIndex: 'commodityId', width: 180 },
|
{row.commodityId}
|
||||||
{
|
</Text>
|
||||||
title: '分类',
|
</Space>
|
||||||
key: 'saleMode',
|
),
|
||||||
width: 130,
|
},
|
||||||
render: (_: unknown, row) => (
|
{
|
||||||
<Space direction="vertical" size={2}>
|
title: '分类',
|
||||||
<Tag color={row.saleMode === 'presale' ? 'gold' : row.saleMode === 'direct' ? 'green' : 'default'}>
|
key: 'saleMode',
|
||||||
{SALE_MODE_LABELS[row.saleMode] || row.saleMode}
|
width: 90,
|
||||||
</Tag>
|
render: (_: unknown, row) => (
|
||||||
<Tag>{AVAILABILITY_LABELS[row.availabilityState] || row.availabilityState}</Tag>
|
<Space direction="vertical" size={2}>
|
||||||
</Space>
|
<Tag color={row.saleMode === 'presale' ? 'gold' : row.saleMode === 'direct' ? 'green' : 'default'}>
|
||||||
),
|
{SALE_MODE_LABELS[row.saleMode] || row.saleMode}
|
||||||
},
|
</Tag>
|
||||||
{ title: '积分', dataIndex: 'requiredPoints', width: 80 },
|
</Space>
|
||||||
{ title: '影响任务', dataIndex: 'affectedTasks', width: 90 },
|
),
|
||||||
{
|
},
|
||||||
title: '状态',
|
{ title: '积分', dataIndex: 'requiredPoints', width: 70 },
|
||||||
dataIndex: 'enabled',
|
{ title: '影响任务', dataIndex: 'affectedTasks', width: 80 },
|
||||||
width: 100,
|
{
|
||||||
render: (value: boolean, row) => (
|
title: '状态',
|
||||||
<Tag color={row.archivedAt ? 'default' : value ? 'green' : 'orange'}>
|
dataIndex: 'enabled',
|
||||||
{row.archivedAt ? '已归档' : value ? '启用' : '停用'}
|
width: 80,
|
||||||
</Tag>
|
render: (value: boolean, row) => (
|
||||||
),
|
<Tag color={row.archivedAt ? 'default' : value ? 'green' : 'orange'}>
|
||||||
},
|
{row.archivedAt ? '已归档' : value ? '启用' : '停用'}
|
||||||
{
|
</Tag>
|
||||||
title: '操作',
|
),
|
||||||
key: 'actions',
|
},
|
||||||
width: 310,
|
{
|
||||||
render: (_: unknown, row) => (
|
title: '操作',
|
||||||
<Space wrap size={4}>
|
key: 'actions',
|
||||||
<Button size="small" disabled={Boolean(row.archivedAt)} onClick={() => editMapping(row)}>
|
width: 250,
|
||||||
编辑
|
render: (_: unknown, row) => (
|
||||||
</Button>
|
<Space size={2} wrap>
|
||||||
{row.archivedAt ? (
|
<Button size="small" disabled={Boolean(row.archivedAt)} onClick={() => editMapping(row)}>
|
||||||
<Button size="small" onClick={() => runMappingAction(row, 'restore')}>
|
编辑
|
||||||
恢复
|
</Button>
|
||||||
</Button>
|
{row.archivedAt ? (
|
||||||
) : (
|
<Button size="small" onClick={() => runMappingAction(row, 'restore')}>
|
||||||
<>
|
恢复
|
||||||
<Button
|
</Button>
|
||||||
size="small"
|
) : (
|
||||||
onClick={() => runMappingAction(row, row.enabled ? 'disable' : 'enable')}
|
<>
|
||||||
>
|
<Button
|
||||||
{row.enabled ? '停用' : '启用'}
|
size="small"
|
||||||
</Button>
|
onClick={() => runMappingAction(row, row.enabled ? 'disable' : 'enable')}
|
||||||
<Button size="small" onClick={() => runMappingAction(row, 'archive')}>
|
>
|
||||||
归档
|
{row.enabled ? '停用' : '启用'}
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
<Button size="small" onClick={() => runMappingAction(row, 'archive')}>
|
||||||
)}
|
归档
|
||||||
<Button size="small" danger onClick={() => removeMapping(row)}>
|
</Button>
|
||||||
删除
|
</>
|
||||||
</Button>
|
)}
|
||||||
</Space>
|
<Button size="small" danger onClick={() => removeMapping(row)}>
|
||||||
),
|
删除
|
||||||
},
|
</Button>
|
||||||
]}
|
</Space>
|
||||||
scroll={{ x: 1300 }}
|
|
||||||
/>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title={mappingEditingId ? '编辑商品映射' : '新建商品映射'}
|
||||||
|
open={mappingEditorOpen}
|
||||||
|
width={620}
|
||||||
|
centered
|
||||||
|
okText="保存映射"
|
||||||
|
cancelText="取消"
|
||||||
|
confirmLoading={mappingSaving}
|
||||||
|
onOk={() => void saveMapping()}
|
||||||
|
onCancel={() => setMappingEditorOpen(false)}
|
||||||
|
>
|
||||||
|
<Space direction="vertical" size={14} style={{ width: '100%' }}>
|
||||||
|
<div>
|
||||||
|
<Text strong>内部 SKU</Text>
|
||||||
|
<Input
|
||||||
|
value={mappingSku}
|
||||||
|
placeholder="例如 套装-兔兔白日梦"
|
||||||
|
onChange={(event) => setMappingSku(event.target.value)}
|
||||||
|
style={{ marginTop: 6 }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Row gutter={12}>
|
||||||
|
<Col span={12}>
|
||||||
|
<Text strong>活动批次</Text>
|
||||||
|
<Input
|
||||||
|
value={mappingCampaignKey}
|
||||||
|
placeholder="douyu-current"
|
||||||
|
onChange={(event) => setMappingCampaignKey(event.target.value)}
|
||||||
|
style={{ marginTop: 6 }}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col span={12}>
|
||||||
|
<Text strong>活动名称</Text>
|
||||||
|
<Input
|
||||||
|
value={mappingCampaignName}
|
||||||
|
placeholder="例如 11 月返场"
|
||||||
|
onChange={(event) => setMappingCampaignName(event.target.value)}
|
||||||
|
style={{ marginTop: 6 }}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<div>
|
||||||
|
<Text strong>斗鱼精英宝典商品</Text>
|
||||||
|
<Space.Compact style={{ width: '100%', marginTop: 6 }}>
|
||||||
|
<Select
|
||||||
|
showSearch
|
||||||
|
optionFilterProp="label"
|
||||||
|
loading={mappingGoodsLoading}
|
||||||
|
placeholder={mappingGoodsLoading ? '正在加载斗鱼活动商品…' : '选择斗鱼精英宝典商品'}
|
||||||
|
value={mappingGoodsId || undefined}
|
||||||
|
onChange={selectGoods}
|
||||||
|
options={[
|
||||||
|
...goods.map((item) => ({
|
||||||
|
value: item.commodity_id,
|
||||||
|
label: `${item.name || item.commodity_id} · ${item.score ?? '-'} 积分`,
|
||||||
|
})),
|
||||||
|
...(mappingGoodsId && !goods.some((item) => item.commodity_id === mappingGoodsId)
|
||||||
|
? [{
|
||||||
|
value: mappingGoodsId,
|
||||||
|
label: `${mappingGoodsName || mappingGoodsId} · 当前已缓存`,
|
||||||
|
}]
|
||||||
|
: []),
|
||||||
|
]}
|
||||||
|
notFoundContent={mappingGoodsLoading ? null : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无活动商品" />}
|
||||||
|
style={{ flex: 1 }}
|
||||||
|
/>
|
||||||
|
<Button icon={<ReloadOutlined />} loading={mappingGoodsLoading} onClick={() => void reloadMappingGoods()}>
|
||||||
|
刷新
|
||||||
|
</Button>
|
||||||
|
</Space.Compact>
|
||||||
|
</div>
|
||||||
|
<Row gutter={12}>
|
||||||
|
<Col span={9}>
|
||||||
|
<Text strong>销售模式</Text>
|
||||||
|
<Select
|
||||||
|
value={mappingSaleMode}
|
||||||
|
options={Object.entries(SALE_MODE_LABELS).map(([value, label]) => ({ value, label }))}
|
||||||
|
onChange={setMappingSaleMode}
|
||||||
|
style={{ width: '100%', marginTop: 6 }}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col span={8}>
|
||||||
|
<Text strong>所需积分</Text>
|
||||||
|
<InputNumber
|
||||||
|
min={0}
|
||||||
|
value={mappingPoints}
|
||||||
|
onChange={(value) => setMappingPoints(value)}
|
||||||
|
style={{ width: '100%', marginTop: 6 }}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col span={7}>
|
||||||
|
<Text strong>启用</Text>
|
||||||
|
<div style={{ marginTop: 6 }}>
|
||||||
|
<Switch checked={mappingEnabled} onChange={setMappingEnabled} />
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<div>
|
||||||
|
<Text strong>商品开放时间</Text>
|
||||||
|
<Space wrap style={{ width: '100%', marginTop: 6 }}>
|
||||||
|
<DatePicker showTime value={mappingAvailableFrom} onChange={setMappingAvailableFrom} placeholder="开始时间" />
|
||||||
|
<Text>至</Text>
|
||||||
|
<DatePicker showTime value={mappingAvailableUntil} onChange={setMappingAvailableUntil} placeholder="结束时间" />
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
<Alert
|
||||||
|
type={mappingEditingId ? 'info' : 'success'}
|
||||||
|
showIcon
|
||||||
|
message={mappingEditingId ? '修改后会同步影响订单选号和兑换资格判断' : '保存后会立即进入商品映射列表'}
|
||||||
|
description="内部 SKU 必须和 order_site 订单商品一致;商品 ID 来自斗鱼精英宝典活动。"
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
</Modal>
|
||||||
</Space>
|
</Space>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user