You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.5 KiB
56 lines
2.5 KiB
|
2 days ago
|
# -*- coding: utf-8 -*-
|
||
|
|
"""票 08 重跑前置:归档上一轮意外落库的 demo-selftest-撞码客户。
|
||
|
|
原因:第一轮自测用假信用代码 MA9ABC1234,L3 未命中 67003 → 客户真实落库。
|
||
|
|
若不清理,本轮同名重试会先命中 L2 needConfirm,看不到 67003。
|
||
|
|
走正门 API:workspace page 搜名称 → archive?id=(新客户无商机,67006 不会阻断)。
|
||
|
|
"""
|
||
|
|
import io, sys
|
||
|
|
import requests
|
||
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
||
|
|
|
||
|
|
BASE = 'http://localhost:8080'
|
||
|
|
ADMIN = '739564171091247104'
|
||
|
|
TARGET = 'demo-selftest-撞码客户'
|
||
|
|
|
||
|
|
r = requests.get(f'{BASE}/api/auth/debug/token', params={'userId': ADMIN}, timeout=10)
|
||
|
|
tok = r.json().get('data')
|
||
|
|
tok = tok.get('token') if isinstance(tok, dict) else tok
|
||
|
|
H = {'Authorization': f'Bearer {tok}'}
|
||
|
|
|
||
|
|
found = []
|
||
|
|
for ws in ('pool', 'mine', 'overview'):
|
||
|
|
r = requests.post(f'{BASE}/api/customer/workspace/{ws}/page',
|
||
|
|
data={'current': 1, 'size': 50, 'keyword': TARGET}, headers=H, timeout=15)
|
||
|
|
rows = ((r.json().get('data') or {}).get('content')) or []
|
||
|
|
for c in rows:
|
||
|
|
if TARGET in (c.get('customerName') or ''):
|
||
|
|
found.append((ws, c.get('id'), c.get('customerName'), c.get('customerNo'), c.get('archiveStatus')))
|
||
|
|
if found:
|
||
|
|
break
|
||
|
|
|
||
|
|
if not found:
|
||
|
|
print('未发现脏客户,无需清理')
|
||
|
|
sys.exit(0)
|
||
|
|
|
||
|
|
for ws, cid, name, no, arc in found:
|
||
|
|
print(f'发现: ws={ws} id={cid} {name}({no}) archiveStatus={arc}')
|
||
|
|
if arc == 2:
|
||
|
|
print(' 已是归档态,跳过')
|
||
|
|
continue
|
||
|
|
r = requests.post(f'{BASE}/api/customer/archive', params={'id': cid}, headers=H, timeout=15)
|
||
|
|
if r.json().get('code') == 67004:
|
||
|
|
# 公海客户无 owner,archive 仅销售负责人可执行 → 先 claim 领取成为 owner,再归档
|
||
|
|
r2 = requests.post(f'{BASE}/api/customer/claim', params={'id': cid}, headers=H, timeout=15)
|
||
|
|
print(' claim:', r2.status_code, 'code=', r2.json().get('code'), r2.json().get('message'))
|
||
|
|
r = requests.post(f'{BASE}/api/customer/archive', params={'id': cid}, headers=H, timeout=15)
|
||
|
|
print(' archive:', r.status_code, 'code=', r.json().get('code'), r.json().get('message'))
|
||
|
|
|
||
|
|
# 复核
|
||
|
|
ws = found[0][0]
|
||
|
|
r = requests.post(f'{BASE}/api/customer/workspace/{ws}/page',
|
||
|
|
data={'current': 1, 'size': 50, 'keyword': TARGET}, headers=H, timeout=15)
|
||
|
|
rows = ((r.json().get('data') or {}).get('content')) or []
|
||
|
|
for c in rows:
|
||
|
|
if TARGET in (c.get('customerName') or ''):
|
||
|
|
print('复核:', c.get('customerNo'), 'archiveStatus=', c.get('archiveStatus'))
|