2 lines
34 KiB
JavaScript
2 lines
34 KiB
JavaScript
import{j as e,b as H,a as r}from"./react-vendor-l-BBvuKH.js";import{f as ee}from"./dateTime-DDi7rqpW.js";import{U as ne,I as ie,X as K,J as oe,R as Y,N as ce,O as se,m as te,E as de,F as xe,V as me,y as ue,h as he,g as pe,o as ge}from"./icons-vendor-CIGXYOCp.js";import{r as M,c as I}from"./index-DawJY7_a.js";import{o as be,c as ye}from"./contract-COFcZjyb.js";import"./vendor-cRYyTeIw.js";const fe=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],je=s=>{const t=typeof s=="object"&&s!==null?s:{},a=Array.isArray(t.results)?t.results:[];return{total:Number(t.total||0),success_count:Number(t.success_count||0),failed_count:Number(t.failed_count||0),results:a.map(ve)}},ve=s=>{const t=typeof s=="object"&&s!==null?s:{};return{order_id:String(t.order_id||"unknown"),success:t.success===!0,message:String(t.message||"")}},Ne=s=>(s==null?void 0:s.results.filter(we))||[],we=s=>!s.success,_e=(s,t)=>s!==null&&!t,ke=s=>{if(!s)return"请选择订单文件";const t=s.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(t)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},z=(s,t)=>s===t,Ce=(s,t)=>s instanceof Error&&s.message?s.message:t,Se=({filter:s,onFilterChange:t,accountFilter:a,onAccountFilterChange:u,accounts:p,accountName:x,searchText:g,onSearchChange:N})=>{const j=i=>t(i.currentTarget.dataset.status||"all"),h=i=>u(i.target.value),v=i=>N(i.target.value);return e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-surface-muted",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:fe.map(i=>e.jsx("button",{"data-status":i.key,onClick:j,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${s===i.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:i.label},i.key))}),e.jsxs("div",{className:"flex w-full md:w-auto flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ne,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:a,onChange:h,className:"ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm",children:[e.jsx("option",{value:"",children:"全部账号"}),p.map(i=>e.jsx("option",{value:i.id,children:x(i.id)},i.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(ie,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-brand transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:g,onChange:v,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Ee=s=>{const t=x=>{var g;s.setImportFile(((g=x.target.files)==null?void 0:g[0])||null)},a=()=>s.closeImportModal(),u=()=>void s.handleImportOrders(),p=()=>void s.handleRetryImport();return s.showImportModal?H.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:a,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(K,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"选择Excel文件"}),e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv,.json",onChange:t,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持 .xlsx、.csv、.tsv、.json 格式"})]}),s.importFile&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:s.importFile.name})]})}),s.importError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-100 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:s.importError}),e.jsx("button",{type:"button",onClick:p,disabled:s.importing||!s.importFile,className:"font-bold whitespace-nowrap",children:"重试"})]}),s.importResult&&s.importResult.failed_count>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3 text-sm font-bold text-amber-800",children:["导入完成:成功 ",s.importResult.success_count," 条,失败 ",s.importResult.failed_count," 条"]}),e.jsx("div",{className:"max-h-64 overflow-y-auto rounded-xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"订单ID"}),e.jsx("th",{className:"px-3 py-2",children:"失败原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:Ne(s.importResult).map((x,g)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:x.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:x.message||"导入失败"})]},`${x.order_id}-${g}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:a,className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"取消"}),e.jsx("button",{onClick:u,disabled:!s.importFile||s.importing,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:s.importing?"正在导入…":"导入订单"})]})})]})}),document.body):null},Oe=180,ae=5e3,Re=async s=>(await M(a=>I.GET("/api/v1/accounts/details",{signal:a}),s)).map(a=>({id:a.id,enabled:a.enabled,auto_confirm:a.auto_confirm,remark:a.remark,pause_duration:a.pause_duration,paused_until:a.paused_until,paused:a.paused,username:a.username,show_browser:a.show_browser,nickname:a.nickname,avatar_url:a.avatar_url,profile_error:a.profile_error})),Me=async(s,t)=>M(a=>I.GET("/api/v1/items",{params:{query:{cookie_id:s}},signal:a}),t),re=s=>{const t=String(s||"");return t==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(t)?t:"unknown"},Ie=async(s,t,a=1,u=20,p,x)=>{const g={page:a,page_size:u};s&&(g.cookie_id=s),t&&t!=="all"&&(g.status=t),p!=null&&p.trim()&&(g.search=p.trim());const j=await M(n=>I.GET("/api/v1/orders",{params:{query:g},signal:n}),x),h=be(j,["data","result"])||{},i=(Array.isArray(h.orders)?h.orders:ye(h.data,["data","orders","items"])).map(n=>({...n,id:n.order_id,order_status:re(n.order_status),status:re(n.status||n.order_status),quantity:Number(n.quantity||1)}));return{success:!0,data:i,total:h.total||i.length,page:h.page||a,page_size:h.page_size||u,total_pages:h.total_pages||1}},Fe=async(s,t)=>M(a=>I.PUT("/api/v1/orders/{order_id}",{params:{path:{order_id:s}},body:t,signal:a})),De=async s=>M(t=>I.DELETE("/api/v1/orders/{order_id}",{params:{path:{order_id:s}},signal:t})),Te=async(s,t,a)=>{const u=new FormData;s&&u.append("cookie_id",s),t&&u.append("status",t);const p=await M(h=>I.POST("/api/v1/orders/refresh",{body:u,signal:h}),a),x=Oe,g=500;let N=0;try{for(;N<x;){const h=await M(i=>I.GET("/api/v1/orders/refresh/{job_id}",{params:{path:{job_id:p.job_id}},signal:i}),a);if(h.status==="succeeded"&&h.result)return h.result;if(h.status==="failed"||h.status==="cancelled")throw new Error(h.error_message||"订单刷新任务失败");const v=g;await new Promise((i,n)=>{const S=()=>{globalThis.clearTimeout(T),n(new Error("请求已取消"))},T=globalThis.setTimeout(()=>{var k;(k=a==null?void 0:a.signal)==null||k.removeEventListener("abort",S),i()},v);a!=null&&a.signal&&(a.signal.aborted?S():a.signal.addEventListener("abort",S,{once:!0}))}),N+=1}}finally{}const j=await Ae(p.job_id);if(j.status==="succeeded"&&j.result)return j.result;throw j.status==="failed"?new Error(j.error_message||"订单刷新任务失败"):new Error("订单刷新任务等待超时,已请求取消")},Ae=async s=>{try{await Pe(s,{timeoutMs:ae})}catch{}return M(t=>I.GET("/api/v1/orders/refresh/{job_id}",{params:{path:{job_id:s}},signal:t}),{timeoutMs:ae})},Pe=async(s,t)=>M(a=>I.DELETE("/api/v1/orders/refresh/{job_id}",{params:{path:{job_id:s}},signal:a}),t),Le=async s=>M(t=>I.POST("/api/v1/orders/{order_id}/refresh",{params:{path:{order_id:s}},signal:t})),$e=async(s,t)=>{const a=await M(u=>I.POST("/api/v1/orders/manual-ship",{body:{order_ids:s,ship_mode:t},signal:u}));return Z(a)},qe=async(s,t)=>{if(s instanceof FormData){const p=await M(x=>I.POST("/api/v1/orders/import",{body:s,signal:x}),t);return Z(p)}const u=await M(p=>I.POST("/api/v1/orders/import",{body:s,signal:p}),t);return Z(u)},Z=s=>({partial_failure:s.partial_failure,message:s.message,total:s.total,success_count:s.success_count,failed_count:s.failed_count,results:(s.results||[]).map(t=>({...t,status:t.status==="failed"||t.status==="succeeded"||t.status==="reconciliation_required"?t.status:void 0}))}),ze=(s={pageSize:20})=>{const[t,a]=r.useState([]),[u,p]=r.useState([]),[x,g]=r.useState([]),[N,j]=r.useState("all"),[h,v]=r.useState(""),[i,n]=r.useState(""),[S,T]=r.useState(""),[k,E]=r.useState(1),[_,$]=r.useState(1),[F,o]=r.useState(!1),w=r.useRef(0),y=r.useRef(null),D=r.useRef(null),P=r.useCallback(async()=>{var f;const d=++w.current;(f=y.current)==null||f.abort();const m=new AbortController;y.current=m,o(!0);try{const O=await Ie(h||void 0,N,k,s.pageSize,S,{signal:m.signal});if(!z(d,w.current))return;a(O.data),$(O.total_pages)}catch(O){z(d,w.current)&&!m.signal.aborted&&console.error("加载订单失败:",O)}finally{z(d,w.current)&&o(!1)}},[h,S,N,s.pageSize,k]);r.useEffect(()=>{const d=window.setTimeout(()=>{E(1),T(i.trim())},300);return(()=>window.clearTimeout(d))},[i]),r.useEffect(()=>(P(),(()=>{var d;w.current+=1,(d=y.current)==null||d.abort()})),[P]),r.useEffect(()=>{var m;const d=new AbortController;return(m=D.current)==null||m.abort(),D.current=d,Promise.all([Re({signal:d.signal}),Me(void 0,{signal:d.signal})]).then(([f,O])=>{d.signal.aborted||(g(f),p(O))}).catch(f=>{d.signal.aborted||console.error("加载订单辅助数据失败:",f)}),(()=>d.abort())},[]);const C=r.useMemo(()=>new Map(x.map(d=>[d.id,d])),[x]),A=r.useMemo(()=>{const d={};return u.forEach(m=>{m.item_id&&(d[`${m.cookie_id}:${m.item_id}`]=m.item_title||m.item_id)}),d},[u]),U=r.useCallback(d=>{const m=C.get(d),f=(m==null?void 0:m.remark)||(m==null?void 0:m.nickname);return f?`${f} · ${d.slice(0,6)}`:`账号 ${d.slice(0,8)}`},[C]),V=r.useCallback(d=>{const m=C.get(d);return(m==null?void 0:m.remark)||(m==null?void 0:m.nickname)||"未命名账号"},[C]),G=r.useCallback((d,m,f)=>{if(f!=null&&f.trim())return f;const O=A[`${d}:${m}`];if(O)return O;const R=u.find(B=>{if(!f||!B.item_title)return!1;const J=f.toLowerCase(),q=B.item_title.toLowerCase();return q.includes(J)||J.includes(q)});return(R==null?void 0:R.item_title)||"未知商品"},[A,u]);return{orders:t,items:u,accounts:x,filter:N,setFilter:j,accountFilter:h,setAccountFilter:v,searchText:i,setSearchText:n,page:k,setPage:E,totalPages:_,loading:F,loadOrders:P,accountName:U,accountNickname:V,getItemNameById:G}},Ge=s=>{const[t,a]=r.useState(!1),[u,p]=r.useState(null),[x,g]=r.useState(null),[N,j]=r.useState(!1),[h,v]=r.useState(""),i=r.useRef(0),n=r.useRef(null);r.useEffect(()=>(()=>{var _;i.current+=1,(_=n.current)==null||_.abort()}),[]);const S=r.useCallback(()=>{p(null),g(null),v(""),a(!0)},[]),T=r.useCallback(()=>{var _;i.current+=1,(_=n.current)==null||_.abort(),j(!1),a(!1),p(null),g(null),v("")},[]),k=r.useCallback(async()=>{var w;if(!_e(u,N))return;const _=u;if(!_)return;const $=ke(_);if($){v($);return}const F=++i.current;(w=n.current)==null||w.abort();const o=new AbortController;n.current=o,j(!0),g(null),v("");try{const y=new FormData;y.append("file",_);const D=je(await qe(y,{signal:o.signal}));if(!z(F,i.current))return;g(D),p(null),await s(),D.failed_count===0&&z(F,i.current)&&(alert(`订单导入成功,共 ${D.success_count} 条`),a(!1),g(null))}catch(y){z(F,i.current)&&!o.signal.aborted&&v(Ce(y,"导入失败,请检查文件格式"))}finally{z(F,i.current)&&j(!1)}},[u,N,s]),E=r.useCallback(async()=>{await k()},[k]);return{showImportModal:t,importFile:u,setImportFile:p,importResult:x,importing:N,importError:h,openImportModal:S,closeImportModal:T,handleImportOrders:k,handleRetryImport:E}},X=(s,t)=>s instanceof Error?s.message:t,Be=({orders:s,page:t,accountFilter:a,filter:u,setPage:p,loadOrders:x})=>{const[g,N]=r.useState(!1),[j,h]=r.useState(null),[v,i]=r.useState(!1),[n,S]=r.useState(null),[T,k]=r.useState(!1),[E,_]=r.useState(""),[$,F]=r.useState(!1),[o,w]=r.useState(null),[y,D]=r.useState(null),[P,C]=r.useState(null),A=r.useRef(0),U=r.useCallback(async()=>{const c=++A.current;try{const b=await Te(a||void 0,u);if(c!==A.current||(await x(),c!==A.current))return;b.message&&alert(b.message)}catch(b){if(c!==A.current)return;console.error("同步订单失败:",b),alert(X(b,"同步失败,请重试"))}},[a,u,x]),V=r.useCallback(c=>{_(c),w(null),k(!0)},[]),G=r.useCallback(async c=>{var b;F(!0),w(null);try{const L=(b=(await $e([E],c)).results)==null?void 0:b[0];L!=null&&L.success?(w({success:!0,message:L.message}),x()):w({success:!1,message:(L==null?void 0:L.message)||"发货失败"})}catch(W){w({success:!1,message:X(W,"请求失败")})}finally{F(!1)}},[x,E]),d=r.useCallback(c=>{h(c),N(!0)},[]),m=r.useCallback(c=>{S({...c}),i(!0)},[]),f=r.useCallback(c=>{S(b=>b&&{...b,...c})},[]),O=r.useCallback(async()=>{if(n!=null&&n.order_id)try{const c={};n.status!==void 0&&(c.order_status=n.status),n.buyer_id!==void 0&&(c.buyer_id=n.buyer_id),n.amount!==void 0&&(c.amount=n.amount),n.receiver_name!==void 0&&(c.receiver_name=n.receiver_name),n.receiver_phone!==void 0&&(c.receiver_phone=n.receiver_phone),n.receiver_address!==void 0&&(c.receiver_address=n.receiver_address),n.item_id!==void 0&&(c.item_id=n.item_id),n.quantity!==void 0&&(c.quantity=n.quantity),n.item_title!==void 0&&(c.item_title=n.item_title),await Fe(n.order_id,c),i(!1),S(null),await x()}catch(c){console.error("更新订单失败:",c),alert("更新失败,请重试")}},[n,x]),R=r.useCallback(async c=>{D(c);try{const b=await Le(c);b.success?await x():alert(b.message||"同步失败")}catch(b){console.error("同步订单失败:",b),alert(X(b,"同步失败,请重试"))}finally{D(null)}},[x]),B=r.useCallback(async c=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){C(c);try{await De(c),s.length===1&&t>1?p(b=>b-1):await x()}catch(b){console.error("删除订单失败:",b),alert(X(b,"删除失败,请重试")),await x()}finally{C(null)}}},[x,s.length,t,p]),J=r.useCallback(()=>N(!1),[]),q=r.useCallback(()=>i(!1),[]),Q=r.useCallback(()=>{k(!1),w(null)},[]);return{showDetailModal:g,selectedOrder:j,showEditModal:v,editingOrder:n,showShipModal:T,shipOrderId:E,shipLoading:$,shipResult:o,syncingOrderId:y,deletingOrderId:P,handleSync:U,handleShip:V,executeShip:G,handleViewDetail:d,handleEdit:m,handleSaveEdit:O,updateEditingOrder:f,handleSyncSingle:R,handleDelete:B,closeDetailModal:J,closeEditModal:q,closeShipModal:Q}},le=({status:s})=>{const t={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},a={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[s]||t.cancelled}`,children:a[s]||s})},He=()=>{const s=ze(),t=Ge(s.loadOrders),{orders:a,accounts:u,filter:p,setFilter:x,accountFilter:g,setAccountFilter:N,searchText:j,setSearchText:h,page:v,setPage:i,totalPages:n,loading:S,loadOrders:T,accountName:k,accountNickname:E,getItemNameById:_}=s,$=Be({orders:a,page:v,accountFilter:g,filter:p,setPage:i,loadOrders:T}),{showDetailModal:F,selectedOrder:o,showEditModal:w,editingOrder:y,showShipModal:D,shipLoading:P,shipResult:C,syncingOrderId:A,deletingOrderId:U,handleSync:V,handleShip:G,executeShip:d,handleViewDetail:m,handleEdit:f,handleSaveEdit:O,updateEditingOrder:R,handleSyncSingle:B,handleDelete:J,closeDetailModal:q,closeEditModal:Q,closeShipModal:c}=$,b=l=>{x(l),i(1),h("")},W=l=>{N(l),i(1)},L=l=>{h(l),i(1)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"订单中心"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"查看所有闲鱼交易记录与状态。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:T,className:"p-3 rounded-2xl bg-white border border-gray-100 text-gray-600 hover:bg-gray-50 hover:text-black transition-colors shadow-sm",children:e.jsx(Y,{className:`w-5 h-5 ${S?"animate-spin":""}`})}),e.jsxs("button",{onClick:t.openImportModal,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors text-sm flex items-center gap-2 shadow-lg",children:[e.jsx(ce,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:V,className:"ios-btn-primary px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 text-sm flex items-center gap-2",children:[e.jsx(se,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsx(Se,{filter:p,onFilterChange:b,accountFilter:g,onAccountFilterChange:W,accounts:u,accountName:k,searchText:j,onSearchChange:L}),e.jsx("div",{className:"overflow-x-auto min-h-[400px]",children:e.jsxs("table",{className:"w-full text-left border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-5",style:{width:"28%"},children:"订单信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"26%"},children:"买家信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"11%"},children:"实付金额"}),e.jsx("th",{className:"px-6 py-5",style:{width:"13%"},children:"当前状态"}),e.jsx("th",{className:"px-6 py-5 text-right",style:{width:"22%"},children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:a.map(l=>e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:l.item_image?e.jsx("img",{src:l.item_image,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(te,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:_(l.cookie_id,l.item_id,l.item_title)}),e.jsxs("div",{className:"mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:E(l.cookie_id),children:[e.jsx(ne,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:E(l.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",l.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",l.quantity," • ",ee(l.created_at)]})]})]})}),e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"text-xs text-gray-500",children:"买家ID"}),e.jsx("div",{className:"text-sm font-bold text-gray-800",children:l.buyer_id}),l.receiver_name&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货人"}),e.jsx("div",{className:"text-xs text-gray-600",children:l.receiver_name})]}),l.receiver_phone&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"联系电话"}),e.jsx("div",{className:"text-xs text-gray-600 font-mono",children:l.receiver_phone})]}),l.receiver_address&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货地址"}),e.jsx("div",{className:"text-xs text-gray-600 line-clamp-1",children:l.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:l.amount?`¥${l.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(le,{status:l.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[l.status==="pending_ship"&&e.jsx("button",{onClick:(()=>G(l.order_id)),className:"mr-2 text-white bg-black hover:bg-gray-800 shadow-lg shadow-gray-200 text-xs font-bold px-3 py-2 rounded-xl transition-all active:scale-95",children:"立即发货"}),e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${l.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"mr-2 inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(de,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>m(l)),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(xe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>f(l)),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(me,{className:"w-4 h-4"})}),e.jsx("button",{onClick:(()=>B(l.order_id)),disabled:A===l.order_id,className:"mr-2 text-gray-400 hover:text-green-600 p-2 rounded-xl hover:bg-green-50 transition-colors disabled:opacity-50",title:"同步订单",children:e.jsx(Y,{className:`w-4 h-4 ${A===l.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:(()=>J(l.order_id)),disabled:U===l.order_id,className:"text-gray-400 hover:text-red-500 p-2 rounded-xl hover:bg-red-50 transition-colors disabled:opacity-50",title:"删除订单",children:e.jsx(ue,{className:"w-4 h-4"})})]})]},l.id))})]})}),e.jsxs("div",{className:"p-4 border-t border-gray-50 flex items-center justify-between bg-white",children:[e.jsxs("div",{className:"text-sm text-gray-500 font-medium pl-2",children:["第 ",v," 页 / 共 ",n," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:v<=1,onClick:(()=>i(l=>l-1)),"aria-label":"上一页",className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(he,{className:"w-5 h-5"})}),e.jsx("button",{disabled:v>=n,onClick:(()=>i(l=>l+1)),"aria-label":"下一页",className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(pe,{className:"w-5 h-5"})})]})]})]}),F&&o&&H.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"订单详情"}),e.jsx("button",{onClick:q,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(K,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"订单信息"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"订单号"}),e.jsx("div",{className:"font-mono text-sm font-bold text-gray-900",children:o.order_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"所属账号"}),e.jsx("div",{className:"truncate whitespace-nowrap text-sm font-bold text-blue-700",title:E(o.cookie_id),children:E(o.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(le,{status:o.status})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"实付金额"}),e.jsx("div",{className:"text-lg font-extrabold text-gray-900",children:o.amount?`¥${o.amount}`:"待获取"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"数量"}),e.jsx("div",{className:"font-bold text-gray-900",children:o.quantity})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"创建时间"}),e.jsx("div",{className:"text-sm font-medium text-gray-700",children:ee(o.created_at)})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"商品信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl flex items-center gap-4",children:[o.item_image&&e.jsx("img",{src:o.item_image,alt:"",className:"w-20 h-20 rounded-xl object-cover border border-gray-200"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-bold text-gray-900 mb-1",children:_(o.cookie_id,o.item_id,o.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",o.item_id]}),o.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",o.item_price]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"买家信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"买家ID"}),e.jsx("div",{className:"font-bold text-gray-900",children:o.buyer_id})]}),o.receiver_name&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货人"}),e.jsx("div",{className:"font-medium text-gray-700",children:o.receiver_name})]}),o.receiver_phone&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"联系电话"}),e.jsx("div",{className:"font-mono text-sm text-gray-700",children:o.receiver_phone})]}),o.receiver_address&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货地址"}),e.jsx("div",{className:"text-sm text-gray-700",children:o.receiver_address})]})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:q,className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),o.status==="pending_ship"&&e.jsx("button",{onClick:(()=>{q(),G(o.order_id)}),className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200",children:"立即发货"})]})})]})}),document.body),e.jsx(Ee,{...t}),D&&H.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"480px"},children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"立即发货"}),e.jsx("button",{onClick:c,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(K,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"请选择发货方式:"}),e.jsx("button",{onClick:(()=>d("status_only")),disabled:P,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-gray-400 hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(se,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"仅修改闲鱼发货状态"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:'不实际扣除或发送卡券,仅在闲鱼平台将订单标记为"已发货"。 适用于已经给客户发过货、只是忘记在闲鱼修改状态的情况。'})]})]})}),e.jsx("button",{onClick:(()=>d("full_delivery")),disabled:P,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-brand hover:bg-blue-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(te,{className:"w-5 h-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"完整发货(匹配卡券并发送)"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),P&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(Y,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),C&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${C.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[C.success?"✓ ":"✗ ",C.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:c,className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:C!=null&&C.success?"完成":"取消"})})]})}),document.body),w&&y&&H.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑订单"}),e.jsx("button",{onClick:Q,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(K,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单号"}),e.jsx("input",{type:"text",value:y.order_id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单状态"}),e.jsxs("select",{value:y.status,onChange:(l=>R({status:l.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"processing",children:"处理中"}),e.jsx("option",{value:"pending_ship",children:"待发货"}),e.jsx("option",{value:"shipped",children:"已发货"}),e.jsx("option",{value:"completed",children:"已完成"}),e.jsx("option",{value:"cancelled",children:"已取消"}),e.jsx("option",{value:"refunding",children:"退款中"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"买家ID"}),e.jsx("input",{type:"text",value:y.buyer_id,onChange:(l=>R({buyer_id:l.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"实付金额"}),e.jsx("input",{type:"number",value:y.amount,onChange:(l=>R({amount:l.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货人"}),e.jsx("input",{type:"text",value:y.receiver_name||"",onChange:(l=>R({receiver_name:l.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"联系电话"}),e.jsx("input",{type:"text",value:y.receiver_phone||"",onChange:(l=>R({receiver_phone:l.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货地址"}),e.jsx("textarea",{value:y.receiver_address||"",onChange:(l=>R({receiver_address:l.target.value})),rows:2,className:"w-full ios-input px-4 py-3 rounded-xl resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"商品标题"}),e.jsx("input",{type:"text",value:y.item_title||"",onChange:(l=>R({item_title:l.target.value})),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:Q,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:O,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ge,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})};export{He as default};
|