2 lines
33 KiB
JavaScript
2 lines
33 KiB
JavaScript
import{j as e,b as X,r as a}from"./react-vendor-C_od1ZSF.js";import{f as Z}from"./dateTime-DDi7rqpW.js";import{U as re,I as ie,X as H,J as ce,R as K,N as oe,O as ee,m as se,E as de,F as xe,V as me,y as ue,h as he,g as ge,o as pe}from"./icons-vendor-DwxdQTKt.js";import{g as U,o as be,c as ye,b as le,a as Y,p as fe,d as ne}from"./index-KV7tSL6x.js";const ve=[{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:{},i=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:i.map(Ne)}},Ne=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||"")}},we=s=>(s==null?void 0:s.results.filter(_e))||[],_e=s=>!s.success,ke=(s,t)=>s!==null&&!t,Ce=s=>{if(!s)return"请选择订单文件";const t=s.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(t)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},T=(s,t)=>s===t,Se=(s,t)=>s instanceof Error&&s.message?s.message:t,Ee=({filter:s,onFilterChange:t,accountFilter:i,onAccountFilterChange:u,accounts:b,accountName:m,searchText:h,onSearchChange:N})=>{const g=l=>t(l.currentTarget.dataset.status||"all"),f=l=>u(l.target.value),y=l=>N(l.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:ve.map(l=>e.jsx("button",{"data-status":l.key,onClick:g,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${s===l.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:l.label},l.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(re,{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:i,onChange:f,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:"全部账号"}),b.map(l=>e.jsx("option",{value:l.id,children:m(l.id)},l.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:h,onChange:y,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Oe=s=>{const t=m=>{var h;s.setImportFile(((h=m.target.files)==null?void 0:h[0])||null)},i=()=>s.closeImportModal(),u=()=>void s.handleImportOrders(),b=()=>void s.handleRetryImport();return s.showImportModal?X.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:i,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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(ce,{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:b,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:we(s.importResult).map((m,h)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:m.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:m.message||"导入失败"})]},`${m.order_id}-${h}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:i,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},Me=180,te=5e3,Ie=async s=>U("/api/v1/accounts/details",void 0,s),Fe=async(s,t)=>U("/api/v1/items",void 0,t),Re=s=>{const t=String(s||"");return t==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(t)?t:"unknown"},De=async(s,t,i=1,u=20,b,m)=>{const h={page:i,page_size:u};s&&(h.cookie_id=s),t&&t!=="all"&&(h.status=t),b!=null&&b.trim()&&(h.search=b.trim());const N=await U("/api/v1/orders",h,m),g=be(N,["data","result"])||{},y=(Array.isArray(g.orders)?g.orders:ye(g.data,["data","orders","items"])).map(l=>({...l,id:l.id||l.order_id,status:Re(l.status||l.order_status),quantity:Number(l.quantity||1)}));return{success:!0,data:y,total:g.total||y.length,page:g.page||i,page_size:g.page_size||u,total_pages:g.total_pages||1}},$e=async(s,t)=>fe(`/api/v1/orders/${s}`,t),Ae=async s=>ne(`/api/v1/orders/${s}`),Le=async(s,t,i)=>{const u=new FormData;s&&u.append("cookie_id",s),t&&u.append("status",t);const b=await le("/api/v1/orders/refresh",u,i),m=Me,h=500;let N=0;try{for(;N<m;){const f=await U(`/api/v1/orders/refresh/${b.job_id}`,void 0,i);if(f.status==="succeeded"&&f.result)return f.result;if(f.status==="failed"||f.status==="cancelled")throw new Error(f.error_message||"订单刷新任务失败");const y=h;await new Promise((l,n)=>{const S=()=>{globalThis.clearTimeout(R),n(new Error("请求已取消"))},R=globalThis.setTimeout(()=>{var k;(k=i==null?void 0:i.signal)==null||k.removeEventListener("abort",S),l()},y);i!=null&&i.signal&&(i.signal.aborted?S():i.signal.addEventListener("abort",S,{once:!0}))}),N+=1}}finally{}const g=await Pe(b.job_id);if(g.status==="succeeded"&&g.result)return g.result;throw g.status==="failed"?new Error(g.error_message||"订单刷新任务失败"):new Error("订单刷新任务等待超时,已请求取消")},Pe=async s=>{try{await Te(s,{timeoutMs:te})}catch{}return U(`/api/v1/orders/refresh/${s}`,void 0,{timeoutMs:te})},Te=async(s,t)=>ne(`/api/v1/orders/refresh/${s}`,void 0,t),qe=async s=>Y(`/api/v1/orders/${s}/refresh`),ze=async(s,t)=>Y("/api/v1/orders/manual-ship",{order_ids:s,ship_mode:t}),Be=async(s,t)=>s instanceof FormData?le("/api/v1/orders/import",s,t):Y("/api/v1/orders/import",s,t),Je=(s={pageSize:20})=>{const[t,i]=a.useState([]),[u,b]=a.useState([]),[m,h]=a.useState([]),[N,g]=a.useState("all"),[f,y]=a.useState(""),[l,n]=a.useState(""),[S,R]=a.useState(""),[k,E]=a.useState(1),[_,L]=a.useState(1),[I,c]=a.useState(!1),w=a.useRef(0),v=a.useRef(null),F=a.useRef(null),$=a.useCallback(async()=>{var j;const d=++w.current;(j=v.current)==null||j.abort();const x=new AbortController;v.current=x,c(!0);try{const O=await De(f||void 0,N,k,s.pageSize,S,{signal:x.signal});if(!T(d,w.current))return;i(O.data),L(O.total_pages)}catch(O){T(d,w.current)&&!x.signal.aborted&&console.error("加载订单失败:",O)}finally{T(d,w.current)&&c(!1)}},[f,S,N,s.pageSize,k]);a.useEffect(()=>{const d=window.setTimeout(()=>{E(1),R(l.trim())},300);return(()=>window.clearTimeout(d))},[l]),a.useEffect(()=>($(),(()=>{var d;w.current+=1,(d=v.current)==null||d.abort()})),[$]),a.useEffect(()=>{var x;const d=new AbortController;return(x=F.current)==null||x.abort(),F.current=d,Promise.all([Ie({signal:d.signal}),Fe(void 0,{signal:d.signal})]).then(([j,O])=>{d.signal.aborted||(h(j),b(O))}).catch(j=>{d.signal.aborted||console.error("加载订单辅助数据失败:",j)}),(()=>d.abort())},[]);const C=a.useMemo(()=>new Map(m.map(d=>[d.id,d])),[m]),D=a.useMemo(()=>{const d={};return u.forEach(x=>{x.item_id&&(d[`${x.cookie_id}:${x.item_id}`]=x.item_title||x.item_id)}),d},[u]),J=a.useCallback(d=>{const x=C.get(d),j=(x==null?void 0:x.remark)||(x==null?void 0:x.nickname);return j?`${j} · ${d.slice(0,6)}`:`账号 ${d.slice(0,8)}`},[C]),G=a.useCallback(d=>{const x=C.get(d);return(x==null?void 0:x.remark)||(x==null?void 0:x.nickname)||"未命名账号"},[C]),q=a.useCallback((d,x,j)=>{if(j!=null&&j.trim())return j;const O=D[`${d}:${x}`];if(O)return O;const M=u.find(z=>{if(!j||!z.item_title)return!1;const B=j.toLowerCase(),P=z.item_title.toLowerCase();return P.includes(B)||B.includes(P)});return(M==null?void 0:M.item_title)||"未知商品"},[D,u]);return{orders:t,items:u,accounts:m,filter:N,setFilter:g,accountFilter:f,setAccountFilter:y,searchText:l,setSearchText:n,page:k,setPage:E,totalPages:_,loading:I,loadOrders:$,accountName:J,accountNickname:G,getItemNameById:q}},Ge=s=>{const[t,i]=a.useState(!1),[u,b]=a.useState(null),[m,h]=a.useState(null),[N,g]=a.useState(!1),[f,y]=a.useState(""),l=a.useRef(0),n=a.useRef(null);a.useEffect(()=>(()=>{var _;l.current+=1,(_=n.current)==null||_.abort()}),[]);const S=a.useCallback(()=>{b(null),h(null),y(""),i(!0)},[]),R=a.useCallback(()=>{var _;l.current+=1,(_=n.current)==null||_.abort(),g(!1),i(!1),b(null),h(null),y("")},[]),k=a.useCallback(async()=>{var w;if(!ke(u,N))return;const _=u;if(!_)return;const L=Ce(_);if(L){y(L);return}const I=++l.current;(w=n.current)==null||w.abort();const c=new AbortController;n.current=c,g(!0),h(null),y("");try{const v=new FormData;v.append("file",_);const F=je(await Be(v,{signal:c.signal}));if(!T(I,l.current))return;h(F),b(null),await s(),F.failed_count===0&&T(I,l.current)&&(alert(`订单导入成功,共 ${F.success_count} 条`),i(!1),h(null))}catch(v){T(I,l.current)&&!c.signal.aborted&&y(Se(v,"导入失败,请检查文件格式"))}finally{T(I,l.current)&&g(!1)}},[u,N,s]),E=a.useCallback(async()=>{await k()},[k]);return{showImportModal:t,importFile:u,setImportFile:b,importResult:m,importing:N,importError:f,openImportModal:S,closeImportModal:R,handleImportOrders:k,handleRetryImport:E}},W=(s,t)=>s instanceof Error?s.message:t,Ue=({orders:s,page:t,accountFilter:i,filter:u,setPage:b,loadOrders:m})=>{const[h,N]=a.useState(!1),[g,f]=a.useState(null),[y,l]=a.useState(!1),[n,S]=a.useState(null),[R,k]=a.useState(!1),[E,_]=a.useState(""),[L,I]=a.useState(!1),[c,w]=a.useState(null),[v,F]=a.useState(null),[$,C]=a.useState(null),D=a.useRef(0),J=a.useCallback(async()=>{const o=++D.current;try{const p=await Le(i||void 0,u);if(o!==D.current||(await m(),o!==D.current))return;p.message&&alert(p.message)}catch(p){if(o!==D.current)return;console.error("同步订单失败:",p),alert(W(p,"同步失败,请重试"))}},[i,u,m]),G=a.useCallback(o=>{_(o),w(null),k(!0)},[]),q=a.useCallback(async o=>{var p;I(!0),w(null);try{const A=(p=(await ze([E],o)).results)==null?void 0:p[0];A!=null&&A.success?(w({success:!0,message:A.message}),m()):w({success:!1,message:(A==null?void 0:A.message)||"发货失败"})}catch(Q){w({success:!1,message:W(Q,"请求失败")})}finally{I(!1)}},[m,E]),d=a.useCallback(o=>{f(o),N(!0)},[]),x=a.useCallback(o=>{S({...o}),l(!0)},[]),j=a.useCallback(o=>{S(p=>p&&{...p,...o})},[]),O=a.useCallback(async()=>{if(n!=null&&n.order_id)try{const o={};n.status!==void 0&&(o.order_status=n.status),n.buyer_id!==void 0&&(o.buyer_id=n.buyer_id),n.amount!==void 0&&(o.amount=n.amount),n.receiver_name!==void 0&&(o.receiver_name=n.receiver_name),n.receiver_phone!==void 0&&(o.receiver_phone=n.receiver_phone),n.receiver_address!==void 0&&(o.receiver_address=n.receiver_address),n.item_id!==void 0&&(o.item_id=n.item_id),n.quantity!==void 0&&(o.quantity=n.quantity),n.item_title!==void 0&&(o.item_title=n.item_title),await $e(n.order_id,o),l(!1),S(null),await m()}catch(o){console.error("更新订单失败:",o),alert("更新失败,请重试")}},[n,m]),M=a.useCallback(async o=>{F(o);try{const p=await qe(o);p.success?await m():alert(p.message||"同步失败")}catch(p){console.error("同步订单失败:",p),alert(W(p,"同步失败,请重试"))}finally{F(null)}},[m]),z=a.useCallback(async o=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){C(o);try{await Ae(o),s.length===1&&t>1?b(p=>p-1):await m()}catch(p){console.error("删除订单失败:",p),alert(W(p,"删除失败,请重试")),await m()}finally{C(null)}}},[m,s.length,t,b]),B=a.useCallback(()=>N(!1),[]),P=a.useCallback(()=>l(!1),[]),V=a.useCallback(()=>{k(!1),w(null)},[]);return{showDetailModal:h,selectedOrder:g,showEditModal:y,editingOrder:n,showShipModal:R,shipOrderId:E,shipLoading:L,shipResult:c,syncingOrderId:v,deletingOrderId:$,handleSync:J,handleShip:G,executeShip:q,handleViewDetail:d,handleEdit:x,handleSaveEdit:O,updateEditingOrder:j,handleSyncSingle:M,handleDelete:z,closeDetailModal:B,closeEditModal:P,closeShipModal:V}},ae=({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"},i={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:i[s]||s})},He=()=>{const s=Je(),t=Ge(s.loadOrders),{orders:i,accounts:u,filter:b,setFilter:m,accountFilter:h,setAccountFilter:N,searchText:g,setSearchText:f,page:y,setPage:l,totalPages:n,loading:S,loadOrders:R,accountName:k,accountNickname:E,getItemNameById:_}=s,L=Ue({orders:i,page:y,accountFilter:h,filter:b,setPage:l,loadOrders:R}),{showDetailModal:I,selectedOrder:c,showEditModal:w,editingOrder:v,showShipModal:F,shipLoading:$,shipResult:C,syncingOrderId:D,deletingOrderId:J,handleSync:G,handleShip:q,executeShip:d,handleViewDetail:x,handleEdit:j,handleSaveEdit:O,updateEditingOrder:M,handleSyncSingle:z,handleDelete:B,closeDetailModal:P,closeEditModal:V,closeShipModal:o}=L,p=r=>{m(r),l(1),f("")},Q=r=>{N(r),l(1)},A=r=>{f(r),l(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:R,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(K,{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(oe,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:G,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(ee,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsx(Ee,{filter:b,onFilterChange:p,accountFilter:h,onAccountFilterChange:Q,accounts:u,accountName:k,searchText:g,onSearchChange:A}),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:i.map(r=>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:r.item_image?e.jsx("img",{src:r.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(se,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:_(r.cookie_id,r.item_id,r.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(r.cookie_id),children:[e.jsx(re,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:E(r.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",r.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",r.quantity," • ",Z(r.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:r.buyer_id}),r.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:r.receiver_name})]}),r.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:r.receiver_phone})]}),r.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:r.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:r.amount?`¥${r.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(ae,{status:r.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[r.status==="pending_ship"&&e.jsx("button",{onClick:(()=>q(r.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=${r.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:(()=>x(r)),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:(()=>j(r)),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:(()=>z(r.order_id)),disabled:D===r.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(K,{className:`w-4 h-4 ${D===r.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:(()=>B(r.order_id)),disabled:J===r.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"})})]})]},r.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:["第 ",y," 页 / 共 ",n," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:y<=1,onClick:(()=>l(r=>r-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:y>=n,onClick:(()=>l(r=>r+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(ge,{className:"w-5 h-5"})})]})]})]}),I&&c&&X.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:P,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:c.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(c.cookie_id),children:E(c.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(ae,{status:c.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:c.amount?`¥${c.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:c.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:Z(c.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:[c.item_image&&e.jsx("img",{src:c.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:_(c.cookie_id,c.item_id,c.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",c.item_id]}),c.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",c.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:c.buyer_id})]}),c.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:c.receiver_name})]}),c.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:c.receiver_phone})]}),c.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:c.receiver_address})]})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:P,className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),c.status==="pending_ship"&&e.jsx("button",{onClick:(()=>{P(),q(c.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(Oe,{...t}),F&&X.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:o,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:$,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(ee,{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:$,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(se,{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:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),$&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(K,{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:o,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&&v&&X.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:V,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:v.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:v.status,onChange:(r=>M({status:r.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:v.buyer_id,onChange:(r=>M({buyer_id:r.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:v.amount,onChange:(r=>M({amount:r.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:v.receiver_name||"",onChange:(r=>M({receiver_name:r.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:v.receiver_phone||"",onChange:(r=>M({receiver_phone:r.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:v.receiver_address||"",onChange:(r=>M({receiver_address:r.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:v.item_title||"",onChange:(r=>M({item_title:r.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:V,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(pe,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})};export{He as default};
|