From 675e0966755f66760918c9f68d9b25a299d303eb Mon Sep 17 00:00:00 2001 From: ywsabc2 Date: Wed, 7 Oct 2026 02:59:48 +0000 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E5=8D=95=E9=A1=B5=EF=BC=9A=E6=92=95?= =?UTF-8?q?=E5=87=AD=E8=AF=81=E6=94=B9=E4=B8=BA=E4=BA=B2=E6=89=8B=E6=92=95?= =?UTF-8?q?=EF=BC=9B=E5=A4=B1=E8=B4=A5=E5=8D=95=E8=83=BD=E9=87=8D=E6=B8=B2?= =?UTF-8?q?=E6=B2=A1=E5=87=BA=E5=9B=BE=E7=9A=84=E6=A8=A1=E6=9D=BF=EF=BC=9B?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=94=B6=E8=B4=A7=E5=90=8E=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=86=8D=E5=85=8D=E8=B4=B9=E9=87=8D=E6=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 撕凭证:按住存根往外拉,拉够才撕下(没拉够弹回);撕下那一刻才发确认收货, 关弹窗 / 先不收货 = 没发生。留「直接撕下」按钮和回车键兜底。 - 重渲弹窗:把应出未出的模板列成「没出图」项(miss_tpls),失败单不再卡在「至少勾一张」; 什么信息都没有的老失败单直接整单重渲。服务器只认本单模板。 - 确认收货后:前端不再给免费重渲按钮,/api/redo 同样拒(直发单不受影响)。 - 状态接口给 files[].tpl、direct、accepted_by_buyer。 - 测试 +4(回执复现 33 条全过;数据库 38、内容后台 86 全过);浏览器实测 24 项全过。 Co-Authored-By: Claude Opus 5.5 --- backend/backend-site/server.py | 21 ++- backend/backend-site/tests/回执复现测试.py | 29 ++++ order/index.html | 150 +++++++++++++++++---- 3 files changed, 168 insertions(+), 32 deletions(-) diff --git a/backend/backend-site/server.py b/backend/backend-site/server.py index 6bc36a2..8db1407 100644 --- a/backend/backend-site/server.py +++ b/backend/backend-site/server.py @@ -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) diff --git a/backend/backend-site/tests/回执复现测试.py b/backend/backend-site/tests/回执复现测试.py index ce35e4e..9dc7090 100644 --- a/backend/backend-site/tests/回执复现测试.py +++ b/backend/backend-site/tests/回执复现测试.py @@ -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_ = [] diff --git a/order/index.html b/order/index.html index c815336..b6d87ee 100644 --- a/order/index.html +++ b/order/index.html @@ -295,6 +295,13 @@ body[data-step="5"] .prog i:nth-child(-n+4){background:var(--acc)} @keyframes stampIn{from{opacity:0;transform:translateY(4px) scale(.96)}to{opacity:.9;transform:none}} .tear-stamp{opacity:0;font-size:11.5px;color:var(--warn,#e8b23a);letter-spacing:.06em;margin-top:8px} .tearwrap.torn ~ .tear-stamp{animation:stampIn .5s .95s var(--ease-out) both} + /* 2026-10-07:存根改成买家亲手撕 —— 能抓、能拖,拉的过程中撕线跟着变亮 */ + .tear-grab{position:relative;z-index:2;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none; + box-shadow:0 0 0 1px rgba(232,178,58,.25) inset} + .tear-grab:hover{border-color:rgba(232,178,58,.55)} + .tear-grab.grabbing{cursor:grabbing;box-shadow:0 10px 26px rgba(0,0,0,.28),0 0 0 1px rgba(232,178,58,.45) inset} + .tear-grab:focus-visible{outline:2px solid var(--acc);outline-offset:2px} + .tearwrap .tear-edge{opacity:calc(.55 + var(--tear-p,0)*.45);transform:scaleY(calc(1 + var(--tear-p,0)*.5))} /* 收货凭证(小票)弹窗 */ .ticket{white-space:pre;overflow:auto;max-width:100%;-webkit-overflow-scrolling:touch;max-height:62vh;font:11.5px/1.5 ui-monospace,Menlo,Consolas,monospace; @@ -1881,12 +1888,26 @@ function redoBtn(j){ } function openRedo(j){ const files=(j.files||[]).filter(f=>!f.is_raw && f.name); - const rows=files.map((f,i)=>'').join('') + + miss.map(k=>'').join(''); openModal('
有问题?免费重渲一次
' +'
' +'上传时你只看到 512 预览,出问题不该你吃亏 —— 这单免费重渲一次' @@ -1894,7 +1915,7 @@ function openRedo(j){ +'
' +'⚠️ 重渲是整单重出(换了皮肤更是全都得重出),不是只重出勾的那几张。' +'下面勾选只是告诉金钻「哪几张有问题」。
' - +(rows||'
这单还没有可勾的图。
') + +(rows||'
这单一张图都没出来,点下面直接整单重渲。
') +((j.skins&&j.skins.length)?('
' +'皮肤传错了?可以顺手换掉:先选是哪张皮肤,再挑新文件(不换就留空)
' +'
' @@ -1989,14 +2010,17 @@ function openRedo(j){ }; $('#redoGo').onclick=async()=>{ const names=[...document.querySelectorAll('.redochk:checked')].map(x=>x.value); - if(!names.length){ $('#redoMsg').innerHTML='至少勾一张'; return; } + const missOn=[...document.querySelectorAll('.redomiss:checked')].map(x=>x.value); + /* 列表里一项都没有(老的失败单,连模板都对不上)→ 整单重出,别卡住 */ + const anyRow=document.querySelector('.redochk,.redomiss'); + if(anyRow && !names.length && !missOn.length){ $('#redoMsg').innerHTML='至少勾一张'; return; } const b=$('#redoGo'); b.disabled=true; b.textContent='提交中…'; try{ const rr=await fetch(API+'/redo',{method:'POST',headers:{'Content-Type':'application/json'}, body:JSON.stringify({oid:S.order, token:S.token, files:names, note:$('#redoNote').value||'', /* 模板真换过才传;没动就不传,省得白跑一次规则校验 */ tpls:([...chosen].join(',')!==curTpls.join(','))?[...chosen]:[], - all:!!(($('#redoAll')||{}).checked), + all:!!(($('#redoAll')||{}).checked) || !anyRow, miss_tpls:missOn, skin:newSkinData||'', skin_id:(($('#redoSkin')||{}).value||''), skin_name:newSkinName||''})}); const jj=await rr.json(); if(!jj.ok) throw new Error(jj.error||'提交失败'); @@ -2012,15 +2036,12 @@ function openRedo(j){ /* 确认收货 = 撕小票(金钻 2026-10-02:要有仪式感 —— 点下确认,把小票那截撕掉) · 小票内容用**真的** /api/receipt(不是摆设) - · 动画和"确认收货"请求**同时**跑,不耽误时间 - · 撕完才关弹窗,画面上真的"撕掉一截" */ + · 2026-10-07(金钻:「动画太快,留给用户可交互撕凭证」):不再自动播 —— + 买家**亲手**按住存根往外拉,拉够了才撕下来;没拉够松手就弹回去。 + 撕下来的那一刻才真正发「确认收货」;没撕就关掉弹窗 = 什么都没发生(按钮恢复)。 + 拖不动的(读屏 / 键盘 / 老设备)用「直接撕下」按钮,或聚焦存根按回车。 */ async function tearAndAccept(btn, oid, token, after){ - const keep=btn.textContent; btn.disabled=true; btn.textContent='确认中…'; - const req=(async()=>{ - const rr=await fetch(API+'/accept',{method:'POST',headers:{'Content-Type':'application/json'}, - body:JSON.stringify({oid:oid, token:token})}); - return rr.json(); - })(); + const keep=btn.textContent; btn.disabled=true; btn.textContent='撕凭证确认收货…'; let txt=''; try{ const r=await fetch(API+'/receipt/'+oid+'?t='+encodeURIComponent(token),{cache:'no-store'}); @@ -2034,20 +2055,88 @@ async function tearAndAccept(btn, oid, token, after){ +'
' + '
'+esc(head)+'
' + '
' - + '
'+esc(stub)+'
' + + '
'+esc(stub)+'
' +'
' +'
' - +'上面这截留在你手里,下面那截(存根)撕走归档。
' - +'
✓ 已归档 · 原图已开放下载
'); - /* 节奏(金钻 2026-10-02:动画太短):入场 0.8s → 撕 1.05s → 收尾,总共约 2.8s - (确认请求同时在跑,动画时间长不影响实际耗时) */ - setTimeout(()=>{ - const w=$('#tearWrap'); if(w) w.classList.add('torn'); - const tip=$('#tearTip'); if(tip) tip.textContent='嘶 —— 存根撕下来了'; - }, 900); + +'按住下面那截存根,往外一撕 —— 撕下来就算确认收货。
' + +'
✓ 已归档 · 原图已开放下载
' + +'
' + +'' + +'
'); + const wrap=$('#tearWrap'), st=$('#tearStub'), tip=$('#tearTip'), card=wrap.querySelector('.tear-card'); + const reduce=matchMedia('(prefers-reduced-motion: reduce)').matches; + const NEED=110; /* 拉多远才撕得下来(px) */ + let done=false, cancelled=false, finish; + const outcome=new Promise(r=>{ finish=r; }); + /* 弹窗被关掉(点遮罩 / 先不收货)而还没撕 → 当没发生 */ + const mo=new MutationObserver(()=>{ + if(!done && !$('#mask').classList.contains('show')){ cancelled=true; finish('cancel'); } + }); + mo.observe($('#mask'),{attributes:true,attributeFilter:['class']}); + $('#tearCancel').onclick=()=>{ closeModal(); }; + + function pose(dx,dy){ + const d=Math.hypot(dx,dy), p=Math.min(1,d/NEED); + const rot=Math.max(-18,Math.min(18, dx*0.07 + Math.max(0,dy)*0.035*(dx<0?-1:1))); + st.style.transform='translate('+(dx*0.62).toFixed(1)+'px,'+(dy*0.82).toFixed(1)+'px) rotate('+rot.toFixed(2)+'deg)'; + if(card) card.style.transform='rotate('+(-p*0.5).toFixed(2)+'deg)'; + wrap.style.setProperty('--tear-p', p.toFixed(3)); + tip.textContent = p<0.15 ? '按住下面那截存根,往外一撕 —— 撕下来就算确认收货。' + : p<0.75 ? '再用点力……' : '松手就撕下来了'; + return p; + } + function tear(dx,dy){ + if(done) return; done=true; + const ang=Math.atan2(Math.max(dy,40), dx||8); + st.style.transition=reduce?'opacity .3s':'transform 1.1s var(--ease-drawer),opacity 1s var(--ease-out)'; + st.style.transform=reduce?'':'translate('+(Math.cos(ang)*260).toFixed(0)+'px,'+(Math.sin(ang)*260).toFixed(0)+'px) ' + +'rotate('+((dx<0?-1:1)*(22+Math.random()*10)).toFixed(1)+'deg)'; + st.style.opacity='0'; + if(card){ card.style.transition='transform .5s var(--ease-out)'; card.style.transform=''; } + wrap.classList.add('torn'); + tip.textContent='嘶 —— 存根撕下来了'; + const b=$('#tearBtns'); if(b) b.style.visibility='hidden'; + finish('tear'); + } + /* 拖:pointer 事件 + capture;没拉够松手 → 弹回 */ + let sx=0, sy=0, dragging=false, lx=0, ly=0; + st.addEventListener('pointerdown',e=>{ + if(done) return; + dragging=true; sx=e.clientX; sy=e.clientY; lx=ly=0; + st.setPointerCapture(e.pointerId); st.style.transition='none'; if(card) card.style.transition='none'; + st.classList.add('grabbing'); e.preventDefault(); + }); + st.addEventListener('pointermove',e=>{ + if(!dragging||done) return; + lx=e.clientX-sx; ly=e.clientY-sy; pose(lx,ly); + }); + const up=()=>{ + if(!dragging) return; dragging=false; st.classList.remove('grabbing'); + if(done) return; + if(Math.hypot(lx,ly)>=NEED){ tear(lx,ly); return; } + st.style.transition='transform .5s cubic-bezier(.3,1.5,.5,1)'; + if(card) card.style.transition='transform .5s var(--ease-out)'; + st.style.transform=''; if(card) card.style.transform=''; + wrap.style.setProperty('--tear-p','0'); + tip.textContent='没撕下来 —— 再用力往外拉一点'; + }; + st.addEventListener('pointerup',up); st.addEventListener('pointercancel',up); + st.addEventListener('keydown',e=>{ if(e.key==='Enter'||e.key===' '){ e.preventDefault(); tear(30,90); } }); + $('#tearNow').onclick=()=>tear(30,90); + + const how=await outcome; + mo.disconnect(); + if(how==='cancel'){ btn.disabled=false; btn.textContent=keep; return; } + /* 撕下来了 → 这时才真的确认收货;动画演完(约 1.6s)再关 */ let jj=null; - try{ jj=await req; }catch(e){ jj={ok:false, error:(e&&e.message)||'网络错误'}; } - await new Promise(r=>setTimeout(r, 2600)); /* 等动画演完再关(一共约 2.8s) */ + const t0=Date.now(); + try{ + const rr=await fetch(API+'/accept',{method:'POST',headers:{'Content-Type':'application/json'}, + body:JSON.stringify({oid:oid, token:token})}); + jj=await rr.json(); + }catch(e){ jj={ok:false, error:(e&&e.message)||'网络错误'}; } + await new Promise(r=>setTimeout(r, Math.max(0, (reduce?600:1700)-(Date.now()-t0)))); closeModal(); if(!jj || !jj.ok){ toast('确认失败:'+((jj&&jj.error)||'未知')); @@ -2846,10 +2935,13 @@ async function checkOrder(){ +'?t='+encodeURIComponent(S.token)+'&dl=1'; }; trow.appendChild(tdl); d.appendChild(trow); - /* 收货后也可能发现不对 —— 重渲按钮两边都给(金钻 2026-10-02) */ - const rrow=document.createElement('div'); rrow.style.cssText='display:flex;gap:8px;margin-top:8px'; - rrow.appendChild(redoBtn(j)); - d.appendChild(rrow); + /* 收货后:买家亲手确认过收货的单不再给免费重渲(2026-10-07:原图都拿走了还能再白出一套, + 会多渲)。直发单没有收货这一步,照旧给。服务器 /api/redo 同样拦着。 */ + if(j.direct && !j.accepted_by_buyer){ + const rrow=document.createElement('div'); rrow.style.cssText='display:flex;gap:8px;margin-top:8px'; + rrow.appendChild(redoBtn(j)); + d.appendChild(rrow); + } } const tip=document.createElement('div'); tip.className='notice'; tip.textContent='成品在服务器只保留 72 小时,请立刻下载并备份到本地/网盘。';