下单页:撕凭证改为亲手撕;失败单能重渲没出图的模板;确认收货后不能再免费重渲

Browse Source
- 撕凭证:按住存根往外拉,拉够才撕下(没拉够弹回);撕下那一刻才发确认收货,
  关弹窗 / 先不收货 = 没发生。留「直接撕下」按钮和回车键兜底。
- 重渲弹窗:把应出未出的模板列成「没出图」项(miss_tpls),失败单不再卡在「至少勾一张」;
  什么信息都没有的老失败单直接整单重渲。服务器只认本单模板。
- 确认收货后:前端不再给免费重渲按钮,/api/redo 同样拒(直发单不受影响)。
- 状态接口给 files[].tpl、direct、accepted_by_buyer。
- 测试 +4(回执复现 33 条全过;数据库 38、内容后台 86 全过);浏览器实测 24 项全过。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yws
2026-10-07 02:59:48 +00:00
co-authored by Claude Opus 5.5
parent bc8402ca67
commit 675e096675
3 changed files with 168 additions and 32 deletions
+18 -3
View File
@@ -2047,6 +2047,7 @@ class H(BaseHTTPRequestHandler):
"name": f.get("name"),
"size": fsz,
"skin": f.get("skin"),
"tpl": f.get("tpl") or "", # 重渲弹窗要知道哪个模板已经出图(2026-10-07)
"is_raw": ("无压缩" in (f.get("name") or "")),
# 收货前:给预览地址;收货后:给原图地址
# ⚠️ 必须带 v=<文件 mtime>:重渲会把同名文件原地覆盖,URL 不变的话
@@ -2103,6 +2104,10 @@ class H(BaseHTTPRequestHandler):
"accepted": accepted,
# 买家自助重渲:用过没有 + 上次选了什么(页面按钮据此置灰)
"redo_used": bool(m.get("redo_used")),
# 直发单没有收货这一步(accepted 恒为真),免费重渲照样给;
# 买家亲手点过「确认收货」的单才关掉重渲 —— 前端靠这个区分(2026-10-07)
"direct": bool(m.get("direct")),
"accepted_by_buyer": bool(m.get("accepted")),
"redo_files": m.get("redo_files") or [],
"amount": amount,
"amount": amount,
@@ -2636,7 +2641,14 @@ class H(BaseHTTPRequestHandler):
return self.err("这一单还没渲完(或正在渲),等它停下来再说")
if m.get("redo_used"):
return self.err("这一单已经用过一次免费重渲了。还不行的话进官方群找金钻,他看着办。")
# ⚠️ 2026-10-07:确认收货 = 买家认可了成品、原图已经放出去了。以前收货后照样能点免费重渲,
# 等于原图拿走了还能再白出一套。直发单(没有收货这一步)不受影响。
if m.get("accepted") and not m.get("direct"):
return self.err("这一单已经确认收货了,免费重渲只能在确认收货之前用。图有问题请进官方群找金钻。")
files = [str(x)[:60] for x in (d.get("files") or [])][:12]
# 没渲出来的模板(渲染失败的那几张根本没有成品文件,勾不了文件名 → 直接报模板 key)
miss = [t for t in (d.get("miss_tpls") or []) if t in TPL_KEYS
and t in (m.get("templates") or [])][:MAX_IMAGES]
note = str(d.get("note") or "").strip()[:200]
# 换皮肤(金钻 2026-10-02:「或者他皮肤填错了重新换」)——
# 传错了很正常,他上传时只看到 512 预览,不该卡在这儿。
@@ -2700,12 +2712,15 @@ class H(BaseHTTPRequestHandler):
for f in (m.get("files") or []):
if (f.get("name") or "") in want and f.get("tpl") and f["tpl"] not in redo_tpls:
redo_tpls.append(f["tpl"])
for t in miss:
if t not in redo_tpls:
redo_tpls.append(t)
if not redo_tpls and files:
# 勾的图找不到模板(老单缺 tpl 字段)→ 退回整单,别让玩家点了没反应
redo_tpls = []
m["redo_tpls"] = redo_tpls
# 没换皮肤、只重渲一部分 → **保留**其它成品(claim 里清了就再也找不回来了)
if files and redo_tpls:
if redo_tpls:
log("免费重渲 %s:只重出 %s" % (oid, "、".join(redo_tpls)))
# 重渲中的那几张先从列表里撤掉(渲染机交新的回来时同名字覆盖)
if files:
@@ -2713,8 +2728,8 @@ class H(BaseHTTPRequestHandler):
m["state"] = "waiting"
m["started"] = m["finished"] = None
m["note"] = "买家申请免费重渲%s:%s" % (
("(只重出 %d 张:%s)" % (len(files), "、".join(files))
if (files and redo_tpls) else "(整单重出)"),
("(只重出:%s)" % "、".join((files or []) + ["%s(上次没出来)" % t for t in miss])
if redo_tpls else "(整单重出)"),
note or "(没写原因)")
with LOCK:
write_meta(oid, m)
@@ -234,6 +234,35 @@ S.write_meta(r2, dict(S.read_meta(r2), state="done"))
st, j, _ = req("POST", "/api/redo", {"oid": r2, "token": t2, "skin": durl(png(seed=9)), "skin_id": "s1", "all": 1})
check("回归:重渲换一张正常皮肤照常可以", st == 200 and j.get("ok"), str(j)[:80])
# 2026-10-07:确认收货后不能再免费重渲(原图都拿走了还能白出一套)
st, j, _ = submit([S.gen_codes(1)[0]], ["stand"])
a_oid, a_tok = j["order"], j["token"]
S.write_meta(a_oid, dict(S.read_meta(a_oid), state="done", accepted=True, accepted_at="2026-10-07T10:00:00"))
st, j, _ = req("POST", "/api/redo", {"oid": a_oid, "token": a_tok, "files": [], "all": 1})
check("洞:确认收货后还能点免费重渲 → 必须拒", not (st == 200 and j.get("ok"))
and (S.read_meta(a_oid) or {}).get("state") == "done" and not (S.read_meta(a_oid) or {}).get("redo_used"),
"server 说:%s" % (j.get("error") if isinstance(j, dict) else j))
st, j, _ = submit([S.gen_codes(1)[0]], ["stand"])
d_oid, d_tok = j["order"], j["token"]
S.write_meta(d_oid, dict(S.read_meta(d_oid), state="done", direct=True))
st, j, _ = req("POST", "/api/redo", {"oid": d_oid, "token": d_tok, "files": [], "all": 1})
check("回归:直发单(没有收货这一步)照常能免费重渲", st == 200 and j.get("ok"), str(j)[:80])
# 2026-10-07:渲染失败的模板没有成品文件 —— 只报模板 key 也要能重渲,而且只重渲没出来的那几个
st, j, _ = submit([S.gen_codes(1, n_fix=2)[0]], ["stand", "wheat"], nTotal=2)
f_oid, f_tok = j["order"], j["token"]
S.write_meta(f_oid, dict(S.read_meta(f_oid), state="failed",
files=[{"name": "站立正反.png", "path": "x.png", "tpl": "stand"}]))
st, j, _ = req("GET", "/api/order/%s?t=%s" % (f_oid, f_tok))
check("状态接口:成品带模板 key、带 direct 标记(重渲弹窗靠它算哪张没出来)",
st == 200 and (j.get("files") or [{}])[0].get("tpl") == "stand" and "direct" in j, str(j)[:120])
st, j, _ = req("POST", "/api/redo", {"oid": f_oid, "token": f_tok, "files": [], "miss_tpls": ["wheat", "boom"]})
mf = S.read_meta(f_oid) or {}
check("修:失败单只勾「没出图」的模板也能重渲,只重出那一个(不认这单以外的模板)",
st == 200 and j.get("ok") and mf.get("state") == "waiting" and mf.get("redo_tpls") == ["wheat"]
and [x.get("name") for x in mf.get("files") or []] == ["站立正反.png"],
"redo_tpls=%s files=%s err=%s" % (mf.get("redo_tpls"), mf.get("files"), j.get("error") if isinstance(j, dict) else j))
# ================================================================== 6. 反馈接口灌盘
ip = new_ip()
codes_ = []