PageSourceSearch

https://nickz.ai/assets/js/index-B8vgi5h_.js

js nickz.ai collected 2026-10-05 14:20:28 UTC 37,578 bytes, 1 lines download raw bytes

1import{u as e,h as t,r as s,j as r}from"./vendor-react-DejgYtBM.js";import{M as n,i,f as a,Y as l,B as d,T as o,a as c,F as p,k as x,x as h,j as m,m as u,l as g,y,X as j,V as f,a1 as v}from"./vendor-semi-D8d7bTtM.js";import{ar as w,u as _,A as b,s as S,w as k,ag as z}from"./index-BeIIFw6E.js";import{C}from"./CardPro-DfDWu9ok.js";import{C as I}from"./CardTable-Cq0lqlnD.js";import{u as T}from"./useIsMobile-D_kfVI0u.js";import{F as $,w as R,X as N,E as O,V as W,aW as D}from"./vendor-icons-EJvJ5X-w.js";import"./vendor-motion-Chfy_MiU.js";const{Text:L}=a,A=e=>{if(null==e||isNaN(Number(e)))return"0.00";const t=Number(e).toFixed(10),s=t.indexOf(".");return-1===s?t+".00":t.substring(0,s+3)},U=()=>{const{t:U}=_(),B=T(),K=e(),F=t(),[P]=s.useState(()=>{const e=F.state?.listFilter||{};return F.state?.listFilter&&window.history.replaceState({},""),e}),[M,E]=s.useState(!1),[X]=s.useState(()=>{try{const e=JSON.parse(localStorage.getItem("user")||"{}");return 11===Number(e.role)}catch{return!1}}),[J,V]=s.useState(!0),[q,H]=s.useState(!1),[Y,G]=s.useState(P.status||""),[Q,Z]=s.useState([]),[ee,te]=s.useState(0),[se,re]=s.useState(P.page||1),[ne,ie]=s.useState(P.pageSize||10),[ae,le]=s.useState(P.invoiceType||""),[de,oe]=s.useState(()=>P.startTs&&P.endTs?[new Date(1e3*P.startTs),new Date(1e3*P.endTs)]:[]),[ce,pe]=s.useState(!1),[xe,he]=s.useState([]),[me,ue]=s.useState(P.keyword||""),[ge,ye]=s.useState(P.searchUserId||""),[je,fe]=s.useState(P.channelId||""),[ve,we]=s.useState([]),[_e,be]=s.useState(!1),[Se,ke]=s.useState([]),[ze,Ce]=s.useState(!1),[Ie,Te]=s.useState(null),[$e,Re]=s.useState(null),[Ne,Oe]=s.useState(!1),[We,De]=s.useState(null),[Le,Ae]=s.useState(!1),[Ue,Be]=s.useState(null),[Ke,Fe]=s.useState(!0),[Pe,Me]=s.useState("list"),[Ee,Xe]=s.useState([]),[Je,Ve]=s.useState(!1),[qe,He]=s.useState([]),[Ye,Ge]=s.useState({}),[Qe,Ze]=s.useState(!1),[et,tt]=s.useState(""),[st,rt]=s.useState(!1),[nt,it]=s.useState(null),[at,lt]=s.useState(!1),dt=async e=>{const t=await b.post("/api/invoice/admin/export-red",{order_nos:e},{responseType:"blob"}),s=new Blob([t.data],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),r=window.URL.createObjectURL(s),n=document.createElement("a");n.href=r;const i=t.headers["content-disposition"];let a=`冲红检测导出_${(new Date).toISOString().slice(0,10)}.xlsx`;if(i){const e=i.match(/filename\*=UTF-8''([^;\s]+)/i);if(e)a=decodeURIComponent(e[1]);else{const e=i.match(/filename="?([^";\s]+)"?/i);e&&(a=decodeURIComponent(e[1]))}}n.download=a,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(r)},ot=()=>{const e={page:se,pageSize:ne,status:Y,invoiceType:ae,keyword:me,searchUserId:ge,channelId:je};return Array.isArray(de)&&2===de.length&&de[0]&&de[1]&&(e.startTs=Math.floor(new Date(de[0]).getTime()/1e3),e.endTs=Math.floor(new Date(de[1]).getTime()/1e3)),e},ct=async(e=1,t={})=>{const s=t.pageSize??ne;try{const r=t.status??Y,n=t.invoiceType??ae,i=t.dateRange??de,a=t.keyword??me,l=t.searchUserId??ge,d=t.channelId??je,o=new URLSearchParams;if(o.set("page",String(e)),o.set("page_size",String(s)),r&&o.set("status",r),n&&o.set("invoice_type",n),a&&o.set("keyword",a),l&&/^\d+$/.test(l)&&o.set("search_user_id",l),d&&o.set("channel_id",String(d)),Array.isArray(i)&&2===i.length&&i[0]&&i[1]){const e=Math.floor(new Date(i[0]).getTime()/1e3),t=Math.floor(new Date(i[1]).getTime()/1e3);e>0&&o.set("start_ts",String(e)),t>0&&o.set("end_ts",String(t))}const c=await b.get(`/api/invoice/admin?${o.toString()}`);c.data.success&&(Z(c.data.data.items||[]),te(c.data.data.total||0),re(c.data.data.page||e),E(!0===c.data.data.can_operate),V(!1!==c.data.data.can_view_detail),H(!0===c.data.data.show_agent_columns),Array.isArray(c.data.data.channel_options)&&c.data.data.channel_options.length>0&&we(c.data.data.channel_options),c.data.data.stat&&Be(c.data.data.stat))}catch(r){S(r.message||U("加载失败"))}};s.useEffect(()=>{ct(P.page||1)},[]);const pt=async()=>{Ve(!0),He([]),Ge({});try{const e=await b.get("/api/invoice/admin/pending-summary-by-channel");e.data.success?Xe(e.data.data?.items||[]):l.error(e.data.message||U("加载失败"))}catch(e){S(e.message||U("加载失败"))}finally{Ve(!1)}};s.useEffect(()=>{"summary"===Pe&&pt()},[Pe]);const xt=e=>{X?l.warning(U("管理员仅可寄送发票")):(Te(e),Re(null),Ce(!0))},ht=async()=>{Oe(!0);try{const e=new FormData;e.append("file",$e);const t=await b.post(`/api/invoice/admin/${Ie.id}/issue`,e,{headers:{"Content-Type":"multipart/form-data"}});t.data.success?(k(U("开票成功")),Ce(!1),Re(null),Te(null),ct(se)):l.error(t.data.message||U("开票失败"))}catch(e){S(e.message||U("开票失败"))}finally{Oe(!1)}},mt=e=>{e.receive_email?n.confirm({title:U("确认寄送"),content:r.jsxs("div",{children:[r.jsx("p",{children:U("将通过邮件发送发票PDF至用户邮箱:")}),r.jsx("p",{style:{fontWeight:"bold",color:"hsl(var(--primary))"},children:e.receive_email}),r.jsxs("p",{style:{color:"#999",fontSize:12,marginTop:8},children:[U("发票抬头"),": ",e.title," | ",U("金额"),": ¥",e.recharge_amount]})]}),onOk:async()=>{De(e.id);try{const t=await b.post(`/api/invoice/admin/${e.id}/send`);t.data.success?(k(U("邮件发送成功")),ct(se)):l.error(t.data.message||U("发送失败"))}catch(t){S(t.message||U("发送失败"))}finally{De(null)}}}):l.error(U("该记录未设置接收邮箱,无法寄送"))},ut=e=>{!e||"pending"!==e.status&&"returned"!==e.status?l.error(U("仅支持删除待开或已退回的记录")):n.confirm({title:U("确认删除"),content:U("确定要删除该发票记录吗?此操作不可逆。"),onOk:async()=>{try{const t=await b.delete(`/api/invoice/admin/${e.id}`);t.data.success?(k(U("删除成功")),ct(se)):l.error(t.data.message||U("删除失败"))}catch(t){S(t.message||U("删除失败"))}}})},gt=[{title:U("ID"),dataIndex:"id"},{title:U("用户 ID"),dataIndex:"user_id"},{title:U("用户名"),dataIndex:"username"},{title:U("发票类型"),dataIndex:"invoice_type",render:e=>U("增值税普通发票")},{title:U("抬头类型"),dataIndex:"invoice_category",render:e=>({enterprise:U("企业"),personal:U("个人")}[e]||U("个人"))},{title:U("开票格式"),dataIndex:"invoice_format",render:e=>{const t=w(e);return r.jsx(i,{color:"XML"===t?"purple":"blue",children:t})}},{title:U("抬头"),dataIndex:"title"},{title:U("金额"),dataIndex:"recharge_amount",render:e=>r.jsxs(L,{style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(String(e)),l.success(U("已复制金额"))},children:["¥",e]})},{title:U("订单数"),dataIndex:"order_nos",render:e=>{try{const t="string"==typeof e?JSON.parse(e||"[]"):e||[],s=Array.isArray(t)?t.length:0;return s?r.jsx(d,{type:"tertiary",theme:"light",size:"small",onClick:()=>{he((Array.isArray(t)?t:[]).map(String)),pe(!0)},children:s}):0}catch(t){return 0}}},{title:U("接收邮箱"),dataIndex:"receive_email"},...q?[{title:U("代理级别"),dataIndex:"agent_level",render:e=>e||"-"},{title:U("上级代理"),dataIndex:"parent_agent",render:e=>e||"-"}]:[],{title:U("支付渠道"),dataIndex:"channel_details",render:(e,t)=>e&&e.length>0?r.jsx(d,{type:"tertiary",theme:"light",size:"small",onClick:()=>{ke(e),be(!0)},children:e.length>1?U("多渠道")+`(${e.length})`:e[0]?.channel_name||"-"}):t.channel_names?r.jsx(L,{children:t.channel_names}):"-"},...J?[{title:U("发票PDF"),dataIndex:"invoice_pdf_url",render:(e,t)=>
1e?r.jsx(d,{type:"tertiary",theme:"light",size:"small",icon:r.jsx($,{size:16}),onClick:async()=>{try{const e=await b.get(`/api/invoice/admin/${t.id}/pdf`,{responseType:"blob"}),s=String(e.headers["content-type"]||"").toLowerCase().includes("xml"),r=new Blob([e.data],{type:s?"application/xml":"application/pdf"}),n=window.URL.createObjectURL(r),i=document.createElement("a");i.href=n,i.download=`${U("发票")}_${t.title}_${t.recharge_amount}${U("元")}.${s?"xml":"pdf"}`,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(n)}catch(e){S(e.message||U("下载发票失败"))}},children:U("下载")}):r.jsx(L,{type:"tertiary",children:"-"})}]:[],{title:U("创建时间"),dataIndex:"created_at",render:e=>e?new Date(1e3*e).toLocaleString():"-"},{title:U("状态"),dataIndex:"status",render:e=>{const t={pending:U("待开"),issued:U("已开"),sent:U("已寄送"),returned:U("已退回"),red_locked:U("开票锁定"),red_flushed:U("已冲红")};return r.jsx(i,{color:{pending:"amber",issued:"blue",sent:"green",returned:"red",red_locked:"purple",red_flushed:"red"}[e]||"grey",size:"small",children:t[e]||e})}},...J?[{title:U("操作"),render:(e,t)=>{const s=()=>K(`/console/InvoiceAdmin/detail/${t.id}`,{state:{record:t,listFilter:ot()}});if(!M)return r.jsx("div",{style:{display:"flex",gap:8},children:r.jsx(d,{onClick:s,children:U("详情")})});if("red_locked"===t.status||"red_flushed"===t.status){const e="red_locked"===t.status?U("开票锁定"):U("已冲红"),a="red_locked"===t.status?"purple":"red";return r.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[r.jsx(d,{onClick:s,children:U("详情")}),r.jsx(i,{color:a,size:"small",children:e}),r.jsx(d,{type:"warning",theme:"light",onClick:()=>{n.confirm({title:U("解除冲红/锁定状态"),content:r.jsxs("div",{children:[r.jsxs("p",{children:[U("当前状态"),":",r.jsx("span",{style:{fontWeight:"bold",color:"hsl(var(--destructive))"},children:e})]}),r.jsx("p",{style:{marginTop:8},children:U("确认要将此发票记录恢复为冲红前的原始状态吗?")}),r.jsx("p",{style:{color:"hsl(var(--warning))",fontSize:12,marginTop:8},children:U("此操作将解除冲红状态,关联订单将恢复为可开票状态。请确认已完成相关财务核对。")})]}),okType:"warning",onOk:async()=>{try{const e=await b.put(`/api/invoice/admin/${t.id}/status`,{status:"restore",force_confirm:!0});if(e.data.success)return k(U("状态已恢复")),void ct(se);if(e.data.need_merge_confirm){const s=e.data.merge_info||{},a=e.data.can_merge,d=s.current_order_nos||[],o=s.original_order_nos||[];return void(a?n.confirm({title:U("是否合并回原发票?"),content:r.jsxs("div",{children:[r.jsxs("p",{children:[U("此记录是从发票")," ",r.jsxs("b",{children:["#",s.original_invoice_id]})," ",U("拆分出来的。")]}),r.jsx("p",{style:{marginTop:8},children:r.jsxs("b",{children:[U("当前记录订单号"),":"]})}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:d.map((e,t)=>r.jsx(i,{size:"small",color:"red",children:e},t))}),r.jsx("p",{style:{marginTop:8},children:r.jsxs("b",{children:[U("原发票订单号"),":"]})}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:o.map((e,t)=>r.jsx(i,{size:"small",color:"green",children:e},t))}),r.jsx("p",{style:{color:"hsl(var(--warning))",fontSize:12,marginTop:12},children:U("选择「确定」将合并回原发票并删除当前记录;选择「取消」将保持独立记录仅恢复状态。")})]}),okText:U("合并回原发票"),cancelText:U("保持独立"),onOk:async()=>{try{const e=await b.put(`/api/invoice/admin/${t.id}/status`,{status:"restore",force_confirm:!0,merge:!0});e.data.success?(k(U("已合并回原发票")),ct(se)):l.error(e.data.message||U("合并失败"))}catch(e){S(e.message)}},onCancel:async()=>{try{const e=await b.put(`/api/invoice/admin/${t.id}/status`,{status:"restore",force_confirm:!0,merge:!1});e.data.success?(k(U("状态已恢复")),ct(se)):l.error(e.data.message||U("操作失败"))}catch(e){S(e.message)}}}):n.info({title:U("无法合并回原发票"),content:r.jsxs("div",{children:[r.jsx("p",{children:s.merge_blocked_reason}),r.jsx("p",{style:{marginTop:8},children:r.jsxs("b",{children:[U("当前记录订单号"),":"]})}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:d.map((e,t)=>r.jsx(i,{size:"small",children:e},t))}),r.jsx("p",{style:{color:"hsl(var(--muted-foreground))",fontSize:12,marginTop:12},children:U("将保持为独立记录并恢复状态。")})]}),okText:U("确定恢复"),onOk:async()=>{try{const e=await b.put(`/api/invoice/admin/${t.id}/status`,{status:"restore",force_confirm:!0,merge:!1});e.data.success?(k(U("状态已恢复")),ct(se)):l.error(e.data.message||U("操作失败"))}catch(e){S(e.message)}}}))}l.error(e.data.message||U("操作失败"))}catch(e){S(e.message||U("操作失败"))}}})},children:U("解除冲红/锁定")})]})}return"pending"===t.status?r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx(d,{onClick:s,children:U("详情")}),!X&&r.jsx(d,{type:"primary",onClick:()=>xt(t),children:U("开票")}),r.jsx(d,{type:"danger",theme:"light",onClick:()=>ut(t),children:U("删除")})]}):"issued"===t.status?r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx(d,{onClick:s,children:U("详情")}),!X&&r.jsx(d,{type:"primary",onClick:()=>xt(t),children:U("重新上传")}),r.jsx(d,{type:"primary",loading:We===t.id,disabled:!!We,onClick:()=>mt(t),children:U("寄送")}),r.jsx(d,{onClick:()=>(async e=>{try{const t=await b.put(`/api/invoice/admin/${e}/status`,{status:"returned"});t.data.success?(k(U("更新成功")),ct(se)):l.error(t.data.message||U("更新失败"))}catch(t){S(t.message||U("更新失败"))}})(t.id),children:U("退回")})]}):"returned"===t.status?r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx(d,{onClick:s,children:U("详情")}),!X&&r.jsx(d,{type:"primary",onClick:()=>xt(t),children:U("重新开票")}),r.jsx(d,{type:"danger",theme:"light",onClick:()=>ut(t),children:U("删除")})]}):"sent"===t.status?r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx(d,{onClick:s,children:U("详情")}),!X&&r.jsx(d,{type:"primary",onClick:()=>xt(t),children:U("重新上传")}),r.jsx(d,{type:"primary",loading:We===t.id,disabled:!!We,onClick:()=>mt(t),children:U("重新寄送")})]}):r.jsx("div",{style:{display:"flex",gap:8},children:r.jsx(d,{onClick:s,children:U("详情")})})}}]:[]],yt=[{title:U("渠道名称"),dataIndex:"channel_name",width:160,ellipsis:!0,render:e=>r.jsx(L,{strong:!0,children:e||"-"})},{title:U("待开票金额"),dataIndex:"pending_amount",width:140,sorter:(e,t)=>(Number(e.pending_amount)||0)-(Number(t.pending_amount)||0),render:e=>r.jsxs(i,{color:"amber",size:"small",children:["¥",A(e)]})},{title:U("订单笔数"),dataIndex:"pending_order_count",width:110,render:e=>r.jsx(L,{type:"secondary",children:e??0})},{title:U("申请条数"),dataIndex:"pending_record_count",width:110,render:e=>r.jsx(L,{type:"secondary",children:e??0})}],jt=[{title:"ID",dataIndex:"id",width:72},{title:U("用户"),dataIndex:"username",width:120,ellipsis:!0},{title:U("抬头"),dataIndex:"title",width:160,ellipsis:!0},{title:U("金额"),dataIndex:"recharge_amount",width:120,render:e=>r.jsxs(L,{children:["¥",A(e)]})},{title:U("抬头类型"),dataIndex:"invoice_category",width:88,render:e=>"personal"===e?U("个人"):"enterprise"===e?U("企业"):e||"—"},{title:U("创建时间"),dataIndex:"created_at",width:168,render:e=>
1e?new Date(1e3*e).toLocaleString():"—"}],ft=(e,t)=>{const s=String(t.channel_id);e?(He(e=>e.includes(s)?e:[...e,s]),(async e=>{const t=String(e);Ge(e=>({...e,[t]:{...e[t]||{},loading:!0,error:null}}));try{const s=new URLSearchParams({status:"pending",channel_id:String(e),page:"1",page_size:String(100)}),r=await b.get(`/api/invoice/admin?${s.toString()}`);if(r.data.success){const e=r.data.data||{},s=e.items||[],n="number"==typeof e.total?e.total:s.length;Ge(e=>({...e,[t]:{loading:!1,loaded:!0,items:s,total:n,error:null}}))}else Ge(e=>({...e,[t]:{loading:!1,loaded:!0,items:[],total:0,error:r.data.message||U("加载失败")}}))}catch(s){Ge(e=>({...e,[t]:{loading:!1,loaded:!0,items:[],total:0,error:s.message||U("加载失败")}}))}})(t.channel_id)):He(e=>e.filter(e=>e!==s))},vt=e=>{const t=String(e.channel_id),s=Ye[t];if(!s||s.loading)return r.jsx("div",{style:{padding:"16px 16px 16px "+(B?"16px":"56px")},children:r.jsx(g,{})});if(s.error)return r.jsx("div",{style:{padding:"12px 16px 16px "+(B?"16px":"56px")},children:r.jsx(L,{type:"danger",children:s.error})});const n=s.items||[],i="number"==typeof s.total?s.total:n.length,a=i>n.length;return r.jsxs("div",{style:{padding:B?"8px 8px 12px 8px":"10px 16px 16px 48px",background:"hsl(var(--foreground) / 0.02)",borderRadius:"var(--radius)"},children:[r.jsx(L,{type:"tertiary",size:"small",style:{display:"block",marginBottom:10},children:U("以下为该渠道待开票明细(仅统计查看,不可操作)")}),B?r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:1},children:n.map(e=>{return r.jsxs("div",{style:{padding:"8px 10px",background:"var(--semi-color-bg-0)",borderRadius:6,marginBottom:4},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:3},children:[r.jsxs(L,{size:"small",type:"tertiary",children:["#",e.id,"  ",e.username," · ",(t=e.invoice_category,"personal"===t?U("个人"):"enterprise"===t?U("企业"):t||"—")]}),r.jsxs(L,{strong:!0,size:"small",children:["¥",A(e.recharge_amount)]})]}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[r.jsx(L,{size:"small",ellipsis:!0,style:{maxWidth:"65%",color:"var(--semi-color-text-1)"},children:e.title||"—"}),r.jsx(L,{size:"small",type:"tertiary",children:e.created_at?new Date(1e3*e.created_at).toLocaleString():"—"})]})]},e.id);var t})}):r.jsx(y,{size:"small",bordered:!0,columns:jt,dataSource:n,pagination:!1,rowKey:"id",scroll:{x:728}}),a?r.jsxs(L,{type:"tertiary",size:"small",style:{display:"block",marginTop:10},children:[U("共")," ",i," ",U("条"),",",U("本页最多展示")," ",100," ",U("条")]}):null]})};return r.jsxs("div",{className:"px-2",children:[r.jsxs(o,{activeKey:Pe,onChange:Me,type:"line",children:[r.jsx(c,{tab:U("发票列表"),itemKey:"list",children:r.jsx(C,{type:"type3",descriptionArea:Ue&&r.jsx("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full",children:r.jsxs(m,{wrap:!0,children:[r.jsxs(i,{color:"blue",size:"default",style:{fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"6px 12px"},className:"!rounded-lg",children:[U("总金额"),": ",Ke?`¥${A(Ue.total_amount)}`:"**"]}),r.jsxs(i,{color:"amber",size:"default",style:{fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"6px 12px"},className:"!rounded-lg",children:[U("待开票"),": ",Ke?`¥${A(Ue.pending_amount)} (${Ue.pending_count||0}${U("笔")})`:"**"]}),r.jsxs(i,{color:"green",size:"default",style:{fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"6px 12px"},className:"!rounded-lg",children:[U("已开票"),": ",Ke?`¥${A((Ue.issued_amount||0)+(Ue.sent_amount||0))}
1 (${(Ue.issued_count||0)+(Ue.sent_count||0)}${U("笔")})`:"**"]}),r.jsxs(i,{color:"red",size:"default",style:{fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"6px 12px"},className:"!rounded-lg",children:[U("已退回"),": ",Ke?`¥${A(Ue.returned_amount)} (${Ue.returned_count||0}${U("笔")})`:"**"]}),Ue.red_locked_count>0&&r.jsxs(i,{color:"purple",size:"default",style:{fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"6px 12px"},className:"!rounded-lg",children:[U("开票锁定"),": ",Ke?`¥${A(Ue.red_locked_amount)} (${Ue.red_locked_count||0}${U("笔")})`:"**"]}),Ue.red_flushed_count>0&&r.jsxs(i,{color:"red",size:"default",style:{fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"6px 12px"},className:"!rounded-lg",children:[U("已冲红"),": ",Ke?`¥${A(Ue.red_flushed_amount)} (${Ue.red_flushed_count||0}${U("笔")})`:"**"]}),r.jsx(d,{icon:Ke?r.jsx(O,{size:16}):r.jsx(W,{size:16}),type:"tertiary",theme:"borderless",size:"small",onClick:()=>Fe(!Ke)})]})}),actionsArea:r.jsx("div",{className:"flex flex-col md:flex-row justify-between items-center gap-2 w-full",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(L,{type:"tertiary",style:{fontSize:13,whiteSpace:"nowrap"},children:U("关键词")}),r.jsx(p,{value:me,onChange:ue,placeholder:U("搜索用户名或企业名"),style:{width:200},onEnterPress:()=>ct(1)})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(L,{type:"tertiary",style:{fontSize:13,whiteSpace:"nowrap"},children:U("用户 ID")}),r.jsx(p,{value:ge,onChange:e=>ye(String(e||"").replace(/[^\d]/g,"")),placeholder:U("用户 ID"),style:{width:100},onEnterPress:()=>ct(1)})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(L,{type:"tertiary",style:{fontSize:13,whiteSpace:"nowrap"},children:U("状态")}),r.jsxs(x,{value:Y,onChange:G,placeholder:U("全部"),style:{width:130},children:[r.jsx(x.Option,{value:"",children:U("全部")}),r.jsx(x.Option,{value:"pending",children:U("待开")}),r.jsx(x.Option,{value:"issued",children:U("已开")}),r.jsx(x.Option,{value:"sent",children:U("已寄送")}),r.jsx(x.Option,{value:"returned",children:U("已退回")}),r.jsx(x.Option,{value:"red_locked",children:U("开票锁定")}),r.jsx(x.Option,{value:"red_flushed",children:U("已冲红")})]})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(L,{type:"tertiary",style:{fontSize:13,whiteSpace:"nowrap"},children:U("类型")}),r.jsxs(x,{value:ae,onChange:le,placeholder:U("全部类型"),style:{width:130},children:[r.jsx(x.Option,{value:"",children:U("全部类型")}),r.jsx(x.Option,{value:"normal",children:U("普通发票")})]})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(L,{type:"tertiary",style:{fontSize:13,whiteSpace:"nowrap"},children:U("渠道")}),r.jsxs(x,{value:je,onChange:fe,placeholder:U("全部渠道"),style:{width:130},children:[r.jsx(x.Option,{value:"",children:U("全部渠道")}),ve.map(e=>r.jsx(x.Option,{value:String(e.id),children:e.name},e.id))]})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(L,{type:"tertiary",style:{fontSize:13,whiteSpace:"nowrap"},children:U("时间")}),r.jsx(h,{type:"dateTimeRange",value:de,onChange:oe,placeholder:[U("开始时间"),U("结束时间")],style:{width:B?"100%":300}})]}),r.jsx(d,{type:"primary",onClick:()=>ct(1),children:U("查询")}),r.jsx(d,{onClick:()=>{ue(""),ye(""),G(""),le(""),fe(""),oe([]),ct(1,{keyword:"",searchUserId:"",status:"",invoiceType:"",channelId:"",dateRange:[]})},children:U("重置")}),M&&r.jsxs(r.Fragment,{children:[r.jsx(d,{icon:r.jsx(R,{size:16}),loading:Le,onClick:async()=>{Ae(!0);try{const e=new URLSearchParams;if(Y&&e.set("status",Y),ae&&e.set("invoice_type",ae),me&&e.set("keyword",me),ge&&/^\d+$/.test(ge)&&e.set("search_user_id",ge),je&&e.set("channel_id",String(je)),Array.isArray(de)&&2===de.length&&de[0]&&de[1]){const t=Math.floor(new Date(de[0]).getTime()/1e3),s=Math.floor(new Date(de[1]).getTime()/1e3);t>0&&e.set("start_ts",String(t)),s>0&&e.set("end_ts",String(s))}const t=await b.get(`/api/invoice/admin/export?${e.toString()}`,{responseType:"blob"}),s=new Blob([t.data],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),r=window.URL.createObjectURL(s),n=document.createElement("a");n.href=r;const i=t.headers["content-disposition"];let a=`开票记录导出_${(new Date).toISOString().slice(0,10)}.xlsx`;if(i){const e=i.match(/filename\*=UTF-8''([^;\s]+)/i);if(e)a=decodeURIComponent(e[1]);else{const e=i.match(/filename="?([^";\s]+)"?/i);e&&(a=decodeURIComponent(e[1]))}}n.download=a,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(r),k(U("导出成功"))}catch(e){S(e.message||U("导出失败"))}finally{Ae(!1)}},children:U("导出")}),r.jsx(d,{icon:r.jsx(N,{size:16}),type:"warning",theme:"light",onClick:()=>{Ze(!0),it(null),tt("")},children:U("冲红检测")}),r.jsx(d,{theme:"light",type:"tertiary",onClick:()=>K("/console/InvoiceAdmin/logs"),children:U("操作日志")})]})]})}),paginationArea:z({currentPage:se,pageSize:ne,total:ee,onPageChange:e=>ct(e),onPageSizeChange:e=>{ie(e),ct(1,{pageSize:e})},isMobile:B,t:U}),children:r.jsx(I,{columns:gt,dataSource:Q,hidePagination:!0,rowKey:"id",size:"small"})})}),M&&r.jsx(c,{tab:U("渠道待开票汇总"),itemKey:"summary",children:r.jsxs(u,{bordered:!0,shadows:"hover",style:{borderRadius:12,overflow:"hidden"},bodyStyle:{padding:"16px 20px 20px"},children:[r.jsxs("div",{style:{marginBottom:14,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[r.jsx(d,{type:"primary",theme:"solid",onClick:pt,loading:Je,children:U("刷新")}),r.jsx(a.Text,{type:"tertiary",size:"small",children:U("仅统计状态为「待开票」的记录;点击行展开查看该渠道下的发票申请(只读)。")})]}),r.jsx(g,{spinning:Je,children:B?r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[Ee.map(e=>{const t=String(e.channel_id),s=qe.includes(t);return r.jsxs("div",{style:{border:"1px solid var(--semi-color-border)",borderRadius:8,overflow:"hidden"},children:[r.jsxs("div",{onClick:()=>ft(!s,e),style:{padding:"10px 12px",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",background:s?"hsl(var(--foreground) / 0.03)":"var(--semi-color-bg-0)"},children:[r.jsx(L,{strong:!0,children:e.channel_name||"-"}),r.jsx(L,{type:"tertiary",size:"small",children:U(s?"收起":"展开")}
1)]}),r.jsxs("div",{style:{padding:"6px 12px 10px",display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[r.jsxs(i,{color:"amber",size:"small",children:["¥",A(e.pending_amount)]}),r.jsxs(L,{type:"secondary",size:"small",children:[e.pending_order_count??0," ",U("笔")]}),r.jsx(L,{type:"tertiary",size:"small",children:"·"}),r.jsxs(L,{type:"secondary",size:"small",children:[e.pending_record_count??0," ",U("条申请")]})]}),s&&r.jsx("div",{style:{borderTop:"1px solid var(--semi-color-border)"},children:vt(e)})]},t)}),0===Ee.length&&!Je&&r.jsx(L,{type:"tertiary",style:{textAlign:"center",padding:"24px 0",display:"block"},children:U("暂无数据")})]}):r.jsx(y,{size:"small",bordered:!0,columns:yt,dataSource:Ee,pagination:!1,rowKey:e=>String(e.channel_id),scroll:{x:"max-content"},expandRowByClick:!0,expandedRowRender:vt,expandedRowKeys:qe,onExpand:ft})})]})})]}),r.jsx(n,{title:U("订单号列表"),visible:ce,onCancel:()=>pe(!1),footer:null,children:Array.isArray(xe)&&xe.length?r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,padding:"20px 0"},children:xe.map((e,t)=>r.jsx(i,{size:"default",style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(String(e)),l.success(U("已复制订单号"))},children:String(e)},t))}):U("暂无订单")}),r.jsx(n,{title:U("支付渠道详情"),visible:_e,onCancel:()=>be(!1),footer:null,width:700,children:Array.isArray(Se)&&Se.length>0?r.jsxs("div",{style:{padding:"10px 0"},children:[r.jsx(j,{defaultActiveKey:Se.map((e,t)=>String(t)),children:Se.map((e,t)=>r.jsx(j.Panel,{header:r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%"},children:[r.jsx(i,{color:"blue",size:"small",children:e.channel_name||`${U("渠道")}${e.channel_id}`}),r.jsxs("span",{style:{color:"#666"},children:[e.count||0," ",U("笔")," / ¥",A(e.amount)]})]}),itemKey:String(t),children:e.order_details&&e.order_details.length>0?r.jsx(y,{dataSource:e.order_details,columns:[{title:U("订单号"),dataIndex:"order_no",render:e=>r.jsx(i,{size:"default",style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(e),l.success(U("已复制订单号"))},children:e})},{title:U("金额"),dataIndex:"amount",render:e=>r.jsxs(L,{style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(A(e)),l.success(U("已复制金额"))},children:["¥",A(e)]})}],pagination:!1,size:"small",rowKey:"order_no",style:{marginTop:8}}):r.jsxs(r.Fragment,{children:[r.jsxs(f,{row:!0,children:[r.jsxs(f.Item,{itemKey:U("订单数量"),children:[e.count||0," ",U("笔")]}),r.jsxs(f.Item,{itemKey:U("订单金额"),children:["¥",A(e.amount)]})]}),e.order_nos&&e.order_nos.length>0&&r.jsxs("div",{style:{marginTop:12},children:[r.jsxs(L,{strong:!0,style:{display:"block",marginBottom:8},children:[U("订单号列表"),":"]}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e.order_nos.map((e,t)=>r.jsx(i,{size:"default",style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(e),l.success(U("已复制订单号"))},children:e},t))})]})]})},String(t)))}),Se.length>1&&r.jsxs("div",{style:{marginTop:16,padding:"12px",background:"#f5f5f5",borderRadius:6},children:[r.jsxs(L,{strong:!0,children:[U("汇总"),":"]}),r.jsxs(L,{style:{marginLeft:16},children:[U("共")," ",Se.reduce((e,t)=>e+(t.count||0),0)," ",U("笔")," / ¥",A(Se.reduce((e,t)=>e+(t.amount||0),0))]})]})]}):r.jsx(L,{type:"tertiary",children:U("暂无渠道信息")})}),r.jsx(n,{title:U("开票 - 上传发票文件"),visible:ze,onCancel:()=>{Ce(!1),Re(null),Te(null)},onOk:()=>{X?l.warning(U("管理员仅可寄送发票")):$e?(({record:e,file:t,t:s,onConfirm:r})=>{const i=w(e?.invoice_format),a=w((e=>String(e?.name||"").toLowerCase().endsWith(".xml")?"xml":"pdf")(t));i!==a?n.confirm({title:s("开票格式与用户申请不一致"),content:s("用户申请的是 {{requested}} 格式,当前上传的是 {{uploaded}} 格式。确认继续开票?",{requested:i,uploaded:a}),okText:s("继续开票"),cancelText:s("返回修改"),onOk:r}):r()})({record:Ie,file:$e,t:U,onConfirm:ht}):l.error(U("请先上传发票文件"))},confirmLoading:Ne,okText:U("确认开票"),cancelText:U("取消"),width:500,children:Ie&&r.jsxs("div",{style:{padding:"10px 0"},children:[r.jsxs(f,{row:!0,style:{marginBottom:16},children:[r.jsx(f.Item,{itemKey:U("发票抬头"),children:Ie.title}),r.jsxs(f.Item,{itemKey:U("金额"),children:["¥",Ie.recharge_amount]}),r.jsxs(f.Item,{itemKey:U("用户"),children:[Ie.username," (ID: ",Ie.user_id,")"]}),r.jsx(f.Item,{itemKey:U("接收邮箱"),children:Ie.receive_email||"-"}),r.jsx(f.Item,{itemKey:U("用户申请格式"),children:r.jsx(i,{color:"XML"===w(Ie.invoice_format)?"purple":"blue",children:w(Ie.invoice_format)})})]}),r.jsx("div",{style:{border:"2px dashed hsl(var(--border))",borderRadius:8,padding:24,textAlign:"center",background:$e?"hsl(var(--success) / 0.12)":"hsl(var(--foreground) / 0.02)",cursor:"pointer",transition:"all 0.3s"},children:$e?r.jsxs("div",{children:[r.jsx($,{size:24,style:{color:"hsl(var(--success))"}}),r.jsx("p",{style:{marginTop:8,fontWeight:"bold"},children:$e.name}),r.jsxs("p",{style:{color:"#999",fontSize:12},children:[($e.size/1024).toFixed(1)," KB"]}
1),r.jsx(d,{size:"small",type:"danger",theme:"light",style:{marginTop:8},onClick:e=>{e.stopPropagation(),Re(null)},children:U("移除")})]}):r.jsxs("label",{style:{cursor:"pointer",display:"block"},children:[r.jsx(D,{size:24,style:{color:"hsl(var(--muted-foreground))"}}),r.jsx("p",{style:{marginTop:8,color:"hsl(var(--muted-foreground))"},children:U("点击上传发票文件")}),r.jsx("p",{style:{color:"#999",fontSize:12},children:U("支持PDF或XML格式,最大20MB")}),r.jsx("input",{type:"file",accept:".pdf,application/pdf,.xml,application/xml,text/xml",style:{display:"none"},onChange:e=>{const t=e.target.files?.[0];if(t){const e=t.name.toLowerCase();if(!e.endsWith(".pdf")&&!e.endsWith(".xml"))return void l.error(U("仅支持上传PDF或XML格式文件"));if(t.size>20971520)return void l.error(U("文件大小不能超过20MB"));Re(t)}e.target.value=""}})]})})]})}),r.jsx(n,{title:U("冲红检测"),visible:Qe,onCancel:()=>{Ze(!1),it(null),tt("")},footer:null,width:800,style:{maxHeight:"80vh"},children:r.jsxs("div",{style:{padding:"10px 0"},children:[r.jsxs("div",{style:{marginBottom:16},children:[r.jsx(L,{style:{display:"block",marginBottom:8,color:"hsl(var(--muted-foreground))",fontSize:13},children:U("请输入需要检测的订单号,多个订单号用逗号、换行或空格分隔")}),r.jsx(v,{value:et,onChange:tt,placeholder:U("输入订单号,多个用逗号、换行或空格分隔"),style:{width:"100%"},autosize:{minRows:3,maxRows:8}}),r.jsxs("div",{style:{marginTop:12,display:"flex",gap:8},children:[r.jsx(d,{type:"warning",theme:"solid",loading:st,onClick:()=>{const e=et.trim();if(!e)return void l.error(U("请输入订单号"));const t=e.split(/[,,\n\r\s]+/).map(e=>e.trim()).filter(Boolean);0!==t.length?n.confirm({title:U("确认冲红锁定"),content:r.jsxs("div",{children:[r.jsx("p",{children:U("即将对以下订单号执行冲红锁定:")}),r.jsxs("p",{style:{fontWeight:"bold",color:"hsl(var(--destructive))"},children:[U("共")," ",t.length," ",U("个订单号")]}),r.jsx("p",{style:{color:"#999",fontSize:12,marginTop:8},children:U("锁定后这些订单号将无法再开票(财务和用户均不可操作),此操作不可撤销。")})]}),okType:"danger",onOk:async()=>{rt(!0);try{const e=await b.post("/api/invoice/admin/check-red",{order_nos:t});if(e.data.success){const t=e.data.data;it(t),k(U("冲红锁定完成")),ct(se),t.duplicated_orders&&t.duplicated_orders.length>0&&(await dt(t.duplicated_orders),k(U("已开票数据已导出")))}else l.error(e.data.message||U("检测失败"))}catch(e){S(e.message||U("检测失败"))}finally{rt(!1)}}}):l.error(U("请输入至少一个有效的订单号"))},icon:r.jsx(N,{size:16}),children:U("开始检测")}),nt&&nt.duplicated_count>0&&r.jsx(d,{icon:r.jsx(R,{size:16}),loading:at,onClick:async()=>{if(nt&&nt.duplicated_orders&&0!==nt.duplicated_orders.length){lt(!0);try{await dt(nt.duplicated_orders),k(U("导出成功"))}catch(e){S(e.message||U("导出失败"))}finally{lt(!1)}}else l.error(U("没有可导出的已开票订单"))},type:"primary",children:U("导出已开票数据")})]})]}),nt&&r.jsxs("div",{children:[r.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16,flexWrap:"wrap"},children:[r.jsxs(i,{color:"blue",size:"default",style:{fontWeight:500,padding:"6px 12px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},className:"!rounded-lg",children:[U("总输入"),": ",nt.total_input," ",U("个")]}),r.jsxs(i,{color:"red",size:"default",style:{fontWeight:500,padding:"6px 12px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},className:"!rounded-lg",children:[U("已开票"),": ",nt.duplicated_count," ",U("个")]}),r.jsxs(i,{color:"purple",size:"default",style:{fontWeight:500,padding:"6px 12px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},className:"!rounded-lg",children:[U("已锁定待开发票"),": ",nt.locked_invoice_count||0," ",U("条")]}),r.jsxs(i,{color:"grey",size:"default",style:{fontWeight:500,padding:"6px 12px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},className:"!rounded-lg",children:[U("未开票"),": ",nt.new_count," ",U("个")]}),nt.split_invoice_count>0&&r.jsxs(i,{color:"cyan",size:"default",style:{fontWeight:500,padding:"6px 12px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},className:"!rounded-lg",children:[U("拆分发票"),": ",nt.split_invoice_count," ",U("条")]})]}),r.jsxs("div",{style:{marginBottom:16,padding:"10px 14px",background:"hsl(var(--warning) / 0.12)",borderRadius:8,fontSize:13},children:[U("所有输入的订单号已被冲红锁定,用户和财务均无法再对这些订单开票。"),nt.split_invoice_count>0&&r.jsx("span",{style:{display:"block",marginTop:4},children:U("其中 {{count}} 条合并开票记录已自动拆分,被冲红的订单号已独立分离,不影响同一发票内其他订单。",{count:nt.split_invoice_count})})]}),nt.duplicated_orders&&nt.duplicated_orders.length>0&&r.jsxs("div",{style:{marginBottom:16},children:[r.jsxs(L,{strong:!0,style:{display:"block",marginBottom:8,color:"hsl(var(--destructive))"},children:[U("已开票订单(已冲红)"),":"]}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:nt.duplicated_orders.map((e,t)=>r.jsx(i,{color:"red",size:"default",style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(e),l.success(U("已复制订单号"))},children:e},t))})]}
1),nt.new_orders&&nt.new_orders.length>0&&r.jsxs("div",{style:{marginBottom:16},children:[r.jsxs(L,{strong:!0,style:{display:"block",marginBottom:8,color:"hsl(var(--foreground) / 0.08)"},children:[U("未开票订单(已锁定)"),":"]}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:nt.new_orders.map((e,t)=>r.jsx(i,{color:"purple",size:"default",style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(e),l.success(U("已复制订单号"))},children:e},t))})]}),nt.invoice_records&&nt.invoice_records.length>0&&r.jsxs("div",{children:[r.jsxs(L,{strong:!0,style:{display:"block",marginBottom:8},children:[U("关联的已开票记录")," (",nt.invoice_records.length," ",U("条"),"):"]}),r.jsx(y,{dataSource:nt.invoice_records,columns:[{title:U("ID"),dataIndex:"id",width:70},{title:U("用户"),dataIndex:"username",width:100},{title:U("抬头"),dataIndex:"title",width:150,ellipsis:!0},{title:U("金额"),dataIndex:"recharge_amount",width:100,render:e=>r.jsxs(L,{style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(String(e)),l.success(U("已复制金额"))},children:["¥",e]})},{title:U("状态"),dataIndex:"status",width:100,render:e=>{const t={pending:U("待开"),issued:U("已开"),sent:U("已寄送"),returned:U("已退回"),red_locked:U("开票锁定"),red_flushed:U("已冲红")};return r.jsx(i,{color:{pending:"amber",issued:"blue",sent:"green",returned:"red",red_locked:"purple",red_flushed:"red"}[e]||"grey",size:"small",children:t[e]||e})}},{title:U("订单数"),dataIndex:"order_nos",width:80,render:e=>{try{const t="string"==typeof e?JSON.parse(e||"[]"):e||[];return Array.isArray(t)?t.length:0}catch{return 0}}},{title:U("创建时间"),dataIndex:"created_at",width:160,render:e=>e?new Date(1e3*e).toLocaleString():"-"}],pagination:!1,size:"small",rowKey:"id",scroll:{y:300}})]})]})]})})]})};export{U as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.